What's new
What's new

G code, what kind of math do you need to know?

Higgins909

Aluminum
Joined
Nov 19, 2018
Sorry if this should have gone in the General sub forum. I usually think my posts can go in either...

Now I know manual coding G code isn't so popular anymore, but I intend to start there. Do you even have to be mathematically smart to do stuff in CAD/CAM? I remember when I first started working a mill guy told me that he had to relearn geometry or something. Recently another guy told me that your had to solve a bunch of math problems or something with your resume to get a job, in a machine shop.

At this point I only know how to make a lathe do a 45 deg chamfer and that's it. If it was a 60deg, I wouldn't know how. What kind of math do I need to be familiar with. What are common problems to be solved, to write a program?

Thanks,
Higgins909
 
Even doing 2 axis lathe parts you will need to know trig which includes calculating angles of various degrees, blending angles to radii, and blending partial radii to each other.
 
The little acorn fell to the ground and after a while said "Gee-I'm-a-Tree".
You don't need deep but you will need things like "Some Old Hags Can't Afford Husbands Til Old Age".:)
Mostly it's the tangent (and inverse) button on the calculator. Rise over run.
Sometimes sine but not so much.

If you need to write a program with a radius tool following a profile with many angles and radii without using any comp it gets messy but few people can do this and most just cheat it in.

You need to "get" the X-Y-Z coordinate system in space and know this like the back of your hand.
Then the most easy and basic trig concepts. Usually rise over run or how convert a angle into these two numbers.
Bob
 
The more you know, the easier it is.

You have to be able to assign a numerical value to every end point on your tool path. If you don't know much, you stick with straight lines. You can draw them out on paper and measure the coordinates. 10x (or more) as necessary. You won't be calculating tangent points for lines at angles, or blend radii, or higher level stuff. Its doable, but a few point take enough time to write an entire program. That stuff is for cad programs.
 
I've used trig alot hand coding. I learned it as SOH CAH TOA. Sine = Opposite side/Hypotenuse, Cosine = Adjacent side/Hypotenuse and Tangent = Opposite/Adjacent. This has to do with finding angles or lengths of sides of Right Triangles (one of the three angles is 90 degrees). Geometry is helpful too. These days I just pull out my phone and look stuff I need up on google....
 
.....If you need to write a program with a radius tool following a profile with many angles and radii without using any comp it gets messy but few people can do this and most just cheat it in......

Anyone that was programming CNCs before the mid 80s did the math regularly and did profiles with out comp all the time. All in a days work before easy access to CAM.

I've seen folks do it, but never understood the lure of the "cheating it in" method as it takes more time than just doing the math.

For the OP...

In addition to learning right angle trig as has been mentioned, you should read up on geometric propositions and geometric constructions. These are essentially the "laws" of geometry that you must use to accurately break down a profile into elements that are then solved with mathematics and trigonometry.

When you start looking at all this it will probably jog loose some memories of things some boring teacher was rambling on about back when you were in middle school.
 
Math is important. If you are afraid of math, then machining may not be for you. It is an integral part of everything a machinist does. CNC programming is based on coordinate systems and trigonometry. You don’t need to be an expert in non-linear math, but you do need a good foundation in the basics.
 
I don't do any Math that I didn't learn in Middle school. With the exception of Pythagorean Theorem, but that's only because I was thinking about other things then, and I'm a slow learner. I'm sure other people learned it in Middle school.

You are not solving anything--at all. The Formulas have already been worked out. So actually the question should be; "What formulas do I need to remember, and know by heart?"

R
 
All of it that you can comprehend.

Side bar......I always love when I hear someone say ...."I never have used geometry, algebra or trig.....It was a complete waste of time".

What goes through my head when I hear that..."huh...even with computers I still use all of those on a regular basis, whether it ias just the thought process involved or actual calculations......I guess you dont really need those running the cash register. I wonder if you could make change without the cash register"?
 
Anyone that was programming CNCs before the mid 80s did the math regularly and did profiles with out comp all the time.

That was me. I now use some trig software I bought almost 30 years ago for $35. I wonder how long it would take me to blend a couple radii the old school way. I haven't done it in so long I probably would take forever to remember how.
 
Have any of you seen what they "teach" in school these days ?

Certainly not skills needed to get a job.
 
......I always love when I hear someone say ...."I never have used geometry, algebra or trig.....It was a complete waste of time".....

That's funny! Reminds me of when I was building my shop some 30 years ago. I hired the concrete foundation work out. Just in BS'ing with the guy setting up the forms I asked him if he used geometry or trig to check and adjust the square of the forms. His answer was pretty close to the quote above. Then he proceeds to tell me how if you just measure up 6 feet on one side and 8 feet on another side then measure the diagonal you should get 10 feet and you then shift the forms until you get 10 feet. Then you know the forms are squared up. Magic! :)
 
There's nothing to hand coding G-code that involves anything above high school math unless you want to get creative, and unless you're a highly qualified professional at that certain type of job you're never expected to get creative.

The only three formulae you need are:

Sin(angle)=opposing side thru hypotenuse
Cos=adjacent thru hypotenuse
Tan=opposing thru adjacent

But if you really want to enjoy your work and start to understand it, you need to _understand_ these things beyond clicking a number into a calculator and hit "sin". Or if we talk 70 years ago, look at "sin 43") and go checking a table.

I'm not the best at these things by far but...

Most people think you're a programmer when you can take a technical drawing and throw out coordinates. That's what makes dumb people at work say things like "uh, anyone can code." And they're right in a sense until they encounter that job when that's not enough and then they are truly lost, yet unable to admit they're incompetent.

CAM software is hard at work enabling them but unfortunately most of what it does is generate dumb code that they can´t read.
 
Side bar......I always love when I hear someone say ...."I never have used geometry, algebra or trig.....It was a complete waste of time".

What goes through my head when I hear that..."huh...even with computers I still use all of those on a regular basis, whether it ias just the thought process involved or actual calculations......I guess you dont really need those running the cash register. I wonder if you could make change without the cash register"?
Interesting. I never made it past basic math in highschool (add, subtract and long division) and barely passed those classes. And yet my machine shop is doing well. I don't even know if my employees know math beyond the basics, because we don't need it. I'll be sure to let them know they're doing it wrong when I hand out their next $2,000 bonus at the end of the month.
 
Last edited:
Interesting. I never made it past basic math in highschool (add, subtract and long division) and barely passed those classes. And yet my machine shop is doing well. I don't even know if my employees know math beyond the basics, because we don't need it. I'll be sure to let them know they're doing it wrong when I hand out their next $2,000 bonus at the end of the month.
And, this seems to be the truth. You don't need more than basic math to be a successful worker or manager. Yet the original post stated he wanted to "learn manual G-code." And if you want to do that and make anything meaningful beyond following a simple 2D contour you need math.

Probably he didn't want anything more tho, dunno.
 
Interesting. I never made it past basic math in highschool (add, subtract and long division) and barely passed those classes. And yet my machine shop is doing well. I don't even know if my employees know math beyond the basics, because we don't need it. I'll be sure to let them know they're doing it wrong when I hand out their next $2,000 bonus at the end of the month.


Awesome!!!

I was thinking when I started reading this thread "I'm pretty good at (basic) math, but I don't have ANY trig memorized, and I would probably need a few minutes for something beyond basic algebra" but it does not hinder me one bit in this trade. Now I would say understanding Gcode and what the machine is doing is far better than being some math whiz.

"Do you even have to be mathematically smart to do stuff in CAD/CAM?"

I don't think so. You need to be 'smart' to design fixtures and tooling. You need to be smart to apply 'fea' to your contraptions. You need to be 'smart' to understand how constraints work in a given software... etc (maybe substitute smart with learned/understood-stand).

In Mastercam I can click in any field that is looking for a value and do a number of things like - distance between 2 points, z value, x value, etc so I don't even have to necessarily know ahead of time what the distance I am looking for is (if that makes sense). I can also type in things like .150-.01 and it will do the math (ya I know that is an easy one Lol). I can also type in "20mm" and it will plug in .7874 for me (programming in inches).
 
All of it that you can comprehend.

Side bar......I always love when I hear someone say ...."I never have used geometry, algebra or trig.....It was a complete waste of time".

What goes through my head when I hear that..."huh...even with computers I still use all of those on a regular basis, whether it ias just the thought process involved or actual calculations......I guess you dont really need those running the cash register. I wonder if you could make change without the cash register"?

Saturday Morning Breakfast Cereal - Why I Couldn't Be a Math Teacher
 
Interesting. I never made it past basic math in highschool (add, subtract and long division) and barely passed those classes. And yet my machine shop is doing well.....

That is because there are tools (CAD/CAM) available to get you past the math barrier. Fortunately for all of us there are folks out there that get and dig advanced math so they can make the tools we use.

The OP is looking to develop his ability to calculate toolpaths without CAM. He will need to learn some geometry and trigonometry to do that.
 








 
Back
Top