G & M Code - Titan Teaches Manual Programming on a CNC Machine.

Numerical Control Machine Ch5
1 follower
1 Video View·Oct 18, 2024
Titan teaches you how to program a CNC Machine right at the control using G & M codes.
Hey, what's up everybody?
This is Titan from Titans of CNC, and in this video, I'm going to teach you how to manually
program with G and M code at the control.
So I figured to teach G and M code, one of the best ways to do this is to actually write
a program and then explain what I'm doing so you can see how the codes react to each
other.
Also, I figured I'd pick a project that was familiar.
So right here, I have the Titan 1M from our academy, and we have three different prints
that take you through the stages.
So the first print shows you the outside profile of the block that you have to machine.
The second print shows you the 1032 threads inside the part, and the third one shows the
pockets and shows the part complete.
So let's actually profile the part with a half inch end mill and come back and actually
chamfer, drill, and tap the 1032 threads.
One thing I'll also say is G and M codes, what are they?
G codes actually create action.
It makes the machines move.
M codes usually turn things on or off.
So to turn on the spindle, you'd hit M3, spindle turns on.
Turn on the coin, M8, shut off the program, M30, stop a sub, M99, and on and on.
So G codes create movement, M codes turn things off and turn things on.
So now the first step in programming is to actually create a program.
To create the program, I'm going to hit list program.
I'm going to hit O, all programs start with the letter O, so I'm going to hit O.
I'm going to look up and see the different programs in there and pick a number that's
not being used, and I'll pick 300.
I'm simply going to hit enter, and boom, there it is.
From that point, I hit memory, boom, it sets over here.
I hit edit, I'm able to toggle around and actually create my program.
So the first thing I'm going to do is create some space.
This end of block key right here is genius.
So I like just kind of hitting it, boom, boom, creating some space, getting away from the
top.
This is where I can write instructions, X, Y, 0 is upper left, Z, 0 is top, move in,
do this, do that.
These are the tools that all be right up there in my header.
Now, to program these different tool paths, I'm going to actually use four different tools,
and I'm going to pull those tools off of the building blocks tool list.
It's a standardized tool list of 16 tools that allows you to make all of the building
blocks.
So the first tool is tool number two.
It's a half inch end mill, and we're going to use that half inch end mill to actually
profile around this part right here.
All right, so now let's actually write this program.
So the first thing we're going to do is we're going to hit M6, go grab a tool.
Let's do tool one, and then I'm going to hit end of block, enter, M6, T1.
You see the zero?
If you hit M6, the machine will automatically put the zero in.
You don't have to hit M06.
Just hit M6, T1, end of block, enter, or just enter, and the zero will automatically appear.
So this is telling the machine to go get tool number one, which is our half inch end mill.
Next thing we're going to do is we're going to go to location.
So we're going to say X, Y, zero is in the upper left, so right up in this corner right
here.
All right, so now that we have our tool, we're going to actually go in, we're going to say
G0, rapid movement, move as fast as you can with no feed rate.
Let's get to position.
Then we're going to hit G90.
It's just a safety code that I like because some people go into G91 and you cancel G91,
which is incremental, with a G90.
And since a G91 can be dangerous, I just like having a G90 at the start of my tool just
to be safe.
I'm going to hit G54.
That's our fixture offset for that particular part.
I'm going to go X, negative 0.5, Y, 0.25, and then I'm going to turn on my spindle.
Turning on the spindle is M3, and then S with the amount of RPMs for how fast you want to
actually run that spindle.
So I'm going to hit M3, speed, 4, 0, 0, 0, and then watch.
I'm just going to press enter, boom, it's up there with my end of block.
So now that we're in location, what do we do next?
Let's turn on the coolant while the machine is still up here so that if there's chips
in the line, they have a chance to flush out.
So once the tool engages the material, you'll be blasting that coolant.
So I'm going to turn on M8, coolant on, enter, all right?
Now the machine is reacting off of its home positions, but I want it to react off of the
height offsets that we got when we zeroed off our tools.
So how do we do that?
G43, go read height offset, H1 for tool 1, height 1, H1, and then Z point 1, and then
enter, boom.
So all of a sudden it reads the offset, now it knows where the material is, and then it
drops down 100,000 shy of that surface.
Now I just like creating a little bit of space, so I'm going to create a little space, pop
in an end of block right there.
So when we're above, we can rapid G0, we can move around, we're not going to hit anything.
But now we're going to actually submerge, we're going to drop down and engage the material.
So I'm going to go from a G0 to a G1, a G1 is a linear movement with a feed rate.
So my part is 750 thick, so I'm going to drop to Z negative 760.
So I'm going to hit G1, Z negative point 760, feed 50, enter, and I'm down.
Next thing I'm going to do is shoot across the back surface of the part.
So my X, Y, zero is in the upper left, I'm at X negative 0.5, I'm at 250 off the part
because it's center of the tool.
So the tool is a half an inch, so half of the tool is 0.250, and that's why I have 0.250
right there.
Now as I actually wrap it across here, I got to remember there is a radius corner and it's
10,000.
So what I want to do is, I actually want to run all the way across that back end and then
stop 10,000 shy from the end of the part.
So the part is 4 inches, once we're in G1, if the next line is G1 also, you do not have
to repeat it.
So all I'm going to do is go to location, so I'm going to hit X 3.99, I'm going to leave
my feed rate alone, and I'm just going to hit enter.
Now we're going to make that radius, right?
So it's 10,000, so you're always thinking center of the tool.
So since the tool is 250 and it's going around the radius and the center of the radius is
10,000 in, we combine the two and we come up with 0.260.
So now we're actually going to radius around it, so the code is going to change.
So the radius around it, since we're going clockwise, the code will be a G2, counterclockwise
would be a G3.
So I'm going to hit G2, I'm going to X 4.25, and that's where I'm going to end.
I'm going to end at the bottom of the radius, so I'm going to hit Y negative 0.01, and then
I'm going to hit R 0.26, I'm going to hit enter, and boom, there you go.
And now basically I went across the back, I took that corner, I made the radius, and
now I'm just going to repeat the process looking at the dimensions on the print.
So now I got to drop down, this is 1.9, and I'm going to stay 10,000 shy, so I'm going
to drop down in Y to 1.890.
So back to G1, Y negative 1.89, enter, same thing.
Now I'm coming around the bottom end, so I'm going to go G2, X 3.99, 10,000 shy, now I'm
on the bottom, and then Y negative 2.15, which is the 1.9 plus the 0.250, and then a radius
of 0.26, boom.
So now I've taken that turn on the bottom.
Now I go back to X0 over here, so I'm going to go G1, X 0.01, boom, I'm right there.
I'm going to take the corner down here, do the same G2, coming around that end, ending
at 1.890, so I go G2, X negative 0.250, and then Y negative 1.89 with a radius of 0.26,
enter.
Now I got to go back to home, back to X, Y, 0.
So I'm going to come over here, I'm going to shoot up by just hitting G1, Y negative
0.01, enter, and now I'm right here.
Why do I not move the X?
Because the X is already in position, so if I just move the Y and the X is in position,
the Y is just going to move up and the X is going to stay exactly the same.
That's why you see me only changing the Y.
So now let's take the turn up here, and then I'm going to ramp off it so we don't leave
a line, and then I'm going to bring the tool up.
So G2, X 0.01, Y 0.25, radius 0.260, enter, boom.
Now I'm at the top.
The top, if my Y was at 250, I'd be right on that surface.
So I'm actually going to ramp off it.
So I'm going to actually move over an X, but I'm going to lift my Y off the surface so
it just gradually ramps off the material so we don't leave a line.
So I'm going to go G1, X 0.25, Y 0.25, it would be 0.25, but I'm going to go a little
bit extra.
So 0.27, I'm going to hit end of block, boom, it's right there.
Then I'm going to hit end of block one more time, G0, Z 0.1, end of block, enter, boom.
There you go.
So that's tool one, dropping down over here, walking around the park, doing all the radiuses,
coming over here, ramping off, and then lifting up to Z 0.1.
So what am I going to do next?
Go get the next tool.
So this is actually going to be pretty easy.
So we're going to use a can cycle and we're going to use three tools from the building
blocks tool list.
So we're going to start with the quarter inch chamfer, tool number 15, then we're going
to go to the 177 drill, which is the proper drill size for a roll tap for a 10-32 thread.
And then we're going to finish it off with a 10-32 tap, and then I'm going to show you
a trick to make it quick and simple and precise.
So the tools are standardized, but I'm actually going to change the order.
So we're going to go tool one, tool two, tool three, tool four, all right?
So tool two is the chamfer mill where we're spotting where the drill is actually going
to drill for that tap.
So let's go grab tool number two.
So M6T2, boom.
So let's go to location.
The first hole we'll do is at 0.150 and 0.150.
So I'm going to go G0, G90, G54, X0.15, Y0.15, M3, spindle, we'll say 7,000, end of block.
And we go to location.
Rapid movement, absolute positioning to the G54 fixture, to my X and Y location, to M3,
turn the spindle on to 7,000 RPMs.
Let's turn the coolant on.
Let's go grab our tool height offset, G43, H2, Z0.1, end of block, boom.
All right?
So now I'm going to show you something different than milling.
This is a can cycle for a drill program.
So we're going to go G81, drill with no peck, right?
Just come down, boom, all right?
G98, when you raise back up, when the tool raises back up, it would go to our initial
plane, which would be on the G43 line.
If I had a G99, it would go to our rapid plane.
In this case, they're pretty much both the same because we went Z0.1.
So next one is R, which is our rapid plane, boom, boom.
Then we're going to go depth.
So it's a 90 degree included angle.
So if I go 100,000 deep, that means it makes that diameter twice as big.
So that would be 200.
For a 1032 thread, we're actually going to build a chamfer that's about 0.205.
So I'm going to go negative 0.1025, and then I'm going to hit feed rate.
I'm going to hit 20 point, and I'm going to hit end of block, and there you go.
So now you have your drill program.
When you raise back up, go to your rapid plane, R1 is your rapid plane, Z negative 1025 is
how deep we're going, and we're feeding at 20 point, which is 20 inches per minute.
The cool thing about rapid is if you were in a pocket and you were way down here, you
could actually, instead of raising all the way up, you could keep your R down and actually
stay down and be like boom, boom, boom, boom, and then raise it up before you hit the wall.
But that's advanced programming.
Right now you want to stay above Z and not mess with it.
So we're going to walk right around here.
So we're going to go X 1.15, Y negative 0.3, boom.
That's our next location.
It can cycle is modal.
That means that you can go location to location to location.
It'll keep drilling the exact drilled hole, the G81 at that depth until you cancel it.
And when you cancel it, that would be a G80, and I'll show you.
So hole location is right there.
So we're going to go next.
The third hole is two point and then Y negative 1.216, boom.
I'm going to hit end the block, boom.
I'm going to go back up here.
I'm going to say X 2.85, Y negative 0.3, boom.
I'm going to hit X 3.85, Y negative 0.15.
That's that one.
I'm going to boom.
I'm going to drop down.
My X is going to stay the same.
So I'm just going to hit Y negative 1.75 and hit enter.
Now I'm going over here.
So I'm at X 0.15, I'm going to enter.
Now I have all my drilled holes right here, boom, boom, boom, boom.
There's 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7.
That all looks good.
So now I'm going to end it with a G80.
So right here, I'm going to say G80, cancel, can cycle, boom.
It's canceled.
All right, and then now that's done.
Now here's the trick.
So I just gave you a drill program and I have three different tools that are doing similar
can cycles, right?
The drill program is a can cycle and I have three tools that are doing basically the same
thing with the same motion, okay?
So watch, I'm just going to come down here right above where I want to start and I'm
just going to copy it and I'm going to paste it two times because most of the information
is going to stay the same.
So I'm going to hit F2, I'm going to scroll down, boom.
I'm going to hit it one, again, and again.
Now I have three of them right here, okay?
And now I simply have to change my T's and my H's.
You always want to make sure that your T and your H are exactly the same, otherwise
you can crash this machine.
So this one is now going to be, this one's going to be tool three, I'm going to hit that
guy, I'm going to hit H3, H3, I'm going to hit that guy, I'm going to look at it.
Now we're drilling, right?
So let's change the RPMs a little bit.
I'm going to go 5,000, hit that bad boy right there.
We're using a Kenamental drill, so you can actually go three times diameter, so it's
a pretty awesome drill.
Just to be safe, because I'm teaching GNM code, I'm actually going to stay a little
bit shy.
So what I'm talking about is this, G1 is one movement drilling straight down and coming
out.
G83 is a drill movement with a peck.
So as you come down, you can say go 100,000, 200,000, 300,000, so you can break that chip
and get the chip out.
So we're going to hit G83, and now I'm going to leave everything the same, but I'm going
to add a Q, and the Q is the size of the peck.
So boom, boom, boom.
So we're going to do a Q of Q.050, just for safety.
This Kenamental drill can kill it, but I just want to be safe, all right?
And we're just going to insert this guy.
Now T3, H3, always double checking, boom, boom, G83, boom, boom.
But how deep am I going to go?
So I come over here, it says 380, so I'm going to go 580, so I'll go Z negative .58.
So I go deep now, and it's going to peck 50,000ths at a time.
So now I come down here, I hit T4, right there.
I'm going to hit 1,000, because now we're tapping, okay?
So tool four is a 1032 roll tap, okay?
We got cooling in the machines, the roll taps like the heat.
I'm going to run it at 1,000 RPMs.
I'm going to leave everything the same, but I'm going to change this to the tapping cycle,
and that's a G84.
So we're going to go G84, boom.
We do not want it to hit the bottom, so I'm going to say 100,000ths shy from the bottom.
So I'm going to say Z negative .48, which is 100,000ths shy of the depth that the drill
went down, boom.
And over here, I'm going to put the exact feed rate.
When you're tapping, there's a calculation.
It has to be perfect.
So this is feed 3, 1.25, because I'm 1,000 RPMs, and I have 32 threads per inch on that thread.
So I hit that guy right there.
I said I needed my H and my T to be identical.
T4, H2, so let's go H4, boom, and we are perfect.
So now we have tool 1, tool 2, tool 3, tool 4, all dialed.
Now we just have to finish it up, right?
So it's thinking about my height offset for tool 4 right now, okay?
But I want to send it back home.
So all I'm going to do is hit G0, rapid movement.
The height offset, the G43 line, let's cancel that.
That's a G49, boom, G49, all right?
And then G90, G90, absolute positioning.
Z0, I'm going to hit enter.
That basically cancels the height offset.
Now the machine's reading its home position.
You say Z0, it just goes home, which is top of the movement, okay?
Now there's two ways to home the machine.
You can do a G28 or a G53.
I'm actually going to use a G53 because it allows me to put an X movement
and position my table where I want it.
So if I wanted my table moved so I could actually open the doors
and have a vice at a specific spot, I can actually change my X
so the table moves perfectly into position.
So I'm going to say G53, X negative 30 inches, Y0, enter.
And then I'm just going to hit M30, shut it down, end of program, boom.
And that's your program right there, all right?
Now, did it work?
I don't know, like we were going pretty fast.
So how do we actually double check it, okay?
We're in here.
We're going to hit setting graph one time.
Just hit the start button.
Boom, it goes around, goes around, goes around.
Oh man, it looks good, all right?
So what if I can't really see what's going on, okay?
One thing that I can do is I can actually hit F2 right here.
That'll zoom it and then I can just basically come down
and I can actually page.
So see that little square right there?
That represents the entire block right here.
So I'm going to come up.
I'm going to come over.
I'm going to look at my part.
I'm going to actually just see if I can get a little bit closer.
See that?
Then I'm going to hit enter.
Then if I do it again, oh, I can see every single radius, every single radius.
Boom, boom, boom, boom, boom, boom, boom.
So I'm looking at my part.
I'm looking at the outside.
Boom, boom, boom.
I can see right here where it came up and actually tapered off.
I can see drilled hole, drilled hole, drilled hole,
drilled hole, drilled hole, drilled hole, drilled hole.
It looks good and now I have confidence to go to the next level.
So now I just have to take my tools, offset them about six inches off the part
and then I'm going to dry run the entire program
to make sure that all the tools function perfectly.
I'm going to drop my feed rates, my rapid
and double check everything to just proof it all out.
Once I've had success, we can engage the material.
We can make a part.
Boom.
