G & M Code: CNC Lathe Programming by Hand - Vlog #91

Neo Structure
3 followers
5 Video Views·Dec 12, 2024
CNC Machining is what we do. We are Experts and on this channel we are bringing our knowledge and experience to YOU. Want more? Learn CAD, CAM & CNC Machining through our FREE TITANS of CNC: Academy.
What's up everyone this is Tyson at Titans of CNC. Today I'm going to walk you through how to hand
program on a lathe. Before we get started I'd like to invite you to subscribe to our channel.
We've got plenty more videos coming. Like this video and feel free to leave comments we'll get
to you if you have any questions. So on our YouTube channel my dad has a really good video
on how to program on a mill. If you haven't seen it already check it out. Following his video I
thought it'd be a good idea to show you guys how to hand program on a lathe. We'll do a simple face
and turning cycle. It's a really basic cycle but I'll walk you through step by step. I'm actually
running a job on this machine. It's out of a plastic called Peak. I don't want to break this
machine down so we're just going to program right in here. I'm going to make sure that it doesn't
get in the way of the job. The speeds and feeds for this material you can use on plastics or aluminum
whichever one you want. Let's get started. I'm going to walk you through this. So the first thing
I'm going to do is I'm going to make a fresh program. We're going to go to edit F1 to bring up
the menu. I'm going to push write until I get to the program menu and we're going to hit create new
program. It's asking me right now to enter the program o code. If you've seen my dad's video you
know that we have to give our program a five digit number after the o code. So I'm just going to give
it a little generic one two three four five. So o one two three four five and then we're going to
hit enter. I got my new program made. First thing I'm going to do is I'm going to actually name my
program. Give it something so that it shows up on this list here. Anything that isn't a G or an M
code you have to put in parentheses so it doesn't get mixed in with the actual program. So I'm going
to hit parentheses and I'm just going to type in the name of my program. So I'll just do face and
turn end of parentheses and then I'm going to hit insert. Adds that in and get my cursor to the end
of the block here. I'm going to hit the end of block button a few times. Hit insert. It gives me
some space so everything's not bunched up together. So usually at the top of my program I like to
leave some comments for whoever's running this machine. I'll put stuff like the company name.
I'll put those all in parentheses. I'll put things like what company this job is for.
For the next line I like to type in setup information. Things that the operator of the
program can reference at the top of the program. So I'm going to type in my material size. We're
going to go 1.375 peak. That's the name of the material I'm running. It's a type of plastic.
End of parentheses. End of block and then I'm going to hit insert and there we go. I also like to put
my initials here along with the date and that way whoever's running this machine knows who
programmed it or if it's been edited. If someone's edited my program they put their initials there
and they put an updated date and that way there's no question that we're running the most recent
program. Once I've got all my info there I'll give the program a couple of end blocks here
and give myself some more space and then we're going to start the actual program from this point.
So we're going to start off with a basic program. It's just going to face down the front of the part
and it's just going to do one pass across the OD. Doesn't seem like it's a whole lot but it's a
basic program. You can of course add on to it and make more passes but I'm just going to show you
one face pass, one turn pass and just the little things at the beginning and the end of the program
you need and you can get started hand programming. The first thing I'm going to do is I'm going to
give it an end number here with the number of my tool. All this end number is is a marker so that
when I need to find a certain tool in the program I just search for it. N1 brings me to tool 1.
N2 will bring me to tool 2 and that way I'm not spending a lot of time trying to find a certain
tool. So N1 and then in parentheses right after the end I'm going to give it my tool name. So this
tool I'm going to go 0156 radius OD rougher in parentheses and I'm going to put an end block here.
We're going to insert that so you can see I put an index number here that just tells the operator
what tool number this is. It's not actually part of the program and then I have a tool label there
so you can easily find your first tool and what it does. Next thing we're going to do our first tool
T101 tool 1 offset 1. I'm going to put an end of line block we're going to hit insert.
This is going to tell the machine to index to tool 1 and use the first offset on that tool.
Now we're going to do our first g-code. If you've seen my dad's video he explains
g-codes and m-codes. Usually your g-codes are all movement or offset based settings. G0 is rapid,
G1 is feeding and then usually your m-codes are all optional or machine settings. Things like
turning on the coolant, bringing up the part catcher, unclamping the chuck those will be m-codes.
So I'll type in our first g-code we're going to go G54 end of line block insert. Usually I use G54
for the main work offset. Usually I'll use G55 if I'm flipping around the part and using a different
starting Z and then sometimes for setups or cutting jaws I might use G59 just because that's
an offset that's way out of the way and has nothing to do with my current setup. But for all the main
things and probably for 90% of the time you'll be using G54. The next line we're putting in G18.
This is selecting my X and Z coordinate system. I usually specify it on this machine because this
is a live tooling machine. Sometimes it uses different coordinates like X and Y so I usually
tell my tools on this machine but it might be a good idea to have on other machines. So I'm doing
G18 end of line block, we'll hit insert. Now it's using X and Z and I'll put in one more G line here
G99 and that's going to tell the machine to use inches per revolution. Again it's a live tooling
machine sometimes I switch around to inches per minute so just to make sure that this program
doesn't get mixed up with any other tools or whatnot that I've got going on in here. I'll tell
it use that work offset, use these coordinates and use inches per revolution. And now it matches up
with the rest of my lathe programs. I'm going to put the next line of code here. We're going to go G97,
S2500 and M3. So G97 that's going to spin the spindle to whatever RPM I tell in the S number
here. So it's going to spin it at 2500 RPM and M3 is what direction the spindle is spinning. So M3
is clockwise, M4 would be counterclockwise. With how this machine is set up and using right-handed
tools you're going to be using M3 most of the time. So I'm going to start that, hit insert.
We've got our spindle spinning. I'm going to make our first move in the program.
G0 that's your rapid move. I'm going to bring it down to X and I'm going to bring it down
in front of the part and a little bit above the part. So I'm going to go 100 thousandths bigger
than what the diameter of this material is. So we're going to go X 1 inch 475. It's going to be
a rough face cut. So I'm going to go Z 0.005. So X 1.475, 100 thousandths above 1 inch 375,
which is our diameter size. And then Z 0.005 that's going to bring this tool
five thousandths away from Z0 which would be the finish Z. I'm going to add our end of block here
and we're going to hit insert. In a normal program I'd also add an M8 to the end of this line here
and that would start my coolant. But because we're filming this and I know that this is a
plastic part that can handle not having coolant, I'm going to leave that out. I've got our tool
rapid to position. So the next line I'm going to add is a G50 and this is a spindle limit. What
this line tells it is that the RPM can't go past this number that I'm going to specify as an S
number here. So I'm going to say S 3600 and hit end of line block here. The next line of code I'm
going to add is a G96, which is surface footage per minute. When you go down to center line using
SFM your machine speeds up. So I need to set a limit there so that the machine doesn't go crazy
when it's going down to the center. So that said, next line we're going to do is G96. We're setting
our machine to SFM. I'm going to set it to 1000 SFM and I'm going to hit end of line block here.
You might be wondering why I'm putting a G96 when I've already got a G97 earlier in my program.
It's because I like to get my machine spinning at a close speed to what that G96 number would
be when it's at this position. Because if I set it early in the program it's just going to be
spinning really slow because that tool is away from center line. So I'll usually give it a close
speed to what it'll be as if it was in position. Set that to G97 and then when my tool is in
position right before it's ready to cut I'll give it the G96 number. And then there's a 1000 SFM.
It'll be nothing in plastic. It'll work fine in aluminum too. Now that we have our tool in position
spindle is spinning where we want it. We'll do our very first feed number. We're going to type
in G01. It's going to be a feed command. We're going to go to X negative point zero three one
and then I'm going to give it a feed command and I'm going to type in our inches per revolution
that I want to run our feed rate at. So I'm going to go feed rate of 12 thousandths. End of line
and we're going to hit insert. So we got our face pass. You might be wondering why I'm not
programming to X zero because I'm going straight down. I'm actually going a little bit further to
X negative point 31 thousandths. The reason for that is because my tool if you look at my setup
here it's got a 15 thousandths radius. If I just went to X zero because of that radius it wouldn't
quite be on the center of the part. I actually have to go down a little bit and compensate for
the radius. So a good rule is when you want to face to your center of your part go down twice as
much as what your radius is. So double that number and give it a negative version of that as your X
here and that'll take it straight to center line. So we face the center line. Now I'm going to back
the tool off a hundred thou. When you have an OD that you're cutting negative moves will always
cut into the part and positive moves will back off the part. I did our face pass. I want this tool to
back off the part. So now I'm going to go in Z and I want to back this tool off a hundred thou.
So I'm going to go positive Z one hundred and five thousandths. End of line block insert.
So it went to Z five thousandths fed down the front of the part. Now it's feeding off of the
part a hundred thou so it's going to Z 105 and now that it's away from the part I'm going to get the
tool into position to turn across the OD of the part now. So I know I'm away from the part now we're
going to go G zero a rapid move and I'm going to bring the X to whatever X I want to do my first
cut at. So because I'm going to give this part a 25 thousandths radius this starting X number is
going to be a little bit tricky. So I need to give this machine the starting position of my radius in
X. If you have a radius you have a starting point here and then you have your actual radius arc and
it's turning straight across the rest of the OD. So to find that starting point you take your finish
OD size for your radius. So in this case it's going to be 1.25 and that's the diameter that
the radius ends up being after it's made and then I'm going to subtract it by what my radius is
plus the radius of the tool. I have a 15 thousandths and six tenths radius on my tool. I'm going to add
that to the 25 thousandths radius that I want to make. You're going to put together 25 thousandths
and 15 and six tenths that's going to give you 0.0406 and then I'm going to subtract it so 1.25
and then because this is a diameter we're going to subtract it one more time so minus 0.0406
equals X 1.1688 end of line block insert. If that seems a little bit confusing it might make more
sense in the next couple lines I'm going to add here but just know if I add the radius that I want
to make plus the radius of my tool if I add that two times to this number it'll give me 1.25.
So now I've got my pre-starting point for the radius we're going to feed into the part now in Z
and match up to where we face the part so we're going to go G 0 1 feed command I'm going to put
Z positive 0.005 and that matches up with the Z that we had earlier when we faced down for the
front of the part and I'm going to put end of line block. I don't need to put a feed rate on this line
because I have a feed rate earlier in the program so as long as my feed rate hasn't changed I don't
need to keep telling my G 1's feed rates so I can insert my line here and we have our Z movement to
the front of our part. So now we're going to actually put the radius into the part we're going
to put a G 3 a G 3 on an OD tool that's usually going to give you an OD radius you use a G 2 for
an ID radius we're going to put the finish X diameter for our radius so X 1.25 then we're
going to put our Z move so how far the radius is going in Z so I'm going to put a Z negative
so Z minus point and then I brought this number up earlier we're going to see it on the next move
that I'm going to make but I'm going to take the radius what radius size I want to make so I want
plus the corner radius of my tool 0.0156 that gives you 0.0406 but then I'm going to subtract
from this number the five thousandths that I'm leaving on the part because this is a rough part
and the number I'm going to put into my Z here is going to be 0.0356 and it's a negative Z
right after the Z I'm also going to give it an R and that's going to actually be my radius number
here and same thing for the R it's going to be radius plus the tool radius so in this R
we're going to put 0.0406 that's our tool radius plus the radius that I want to make
so a 0.025 radius end of line insert so you can see that R number is the same as the Z move because
it's at the front of the radius we just added five thousandths to it because we were off the
part five thousandths and there we go we swung a 0.025 radius on the front of the part the very
next line we want to feed across the top of the part now it's very important to put a G1 after
your G3 because you're no longer in radius mode sometimes it's easy to forget to put a G1 after
this radius move and it'll give you alarm saying you can't do that because you're trying to make
another radius so we're going to put a G1 and we're going to feed across the part now in Z
so we're going to go Z minus 1.1 I'm going to feed across the part an inch and one hundred
thousandths end of line block again we're using the same feed so we don't have to put another
feed rate and insert there we go we turned across the part the program is pretty much done at this
point so now I want to back off the part and get my tool a safe distance away before I home it
I'm actually going to give it the same X number that I started the program off in I'm not going
to put a G1 because we're still feeding using the previous feed motion I'm just going to put an X
1.475 this is going to feed up to one inch 475 bigger than my starting diameter away from the
material put an end of line block and hit insert now that it's away from there I'm going to bring
it a safe distance away in Z we're going to go G0 we're going to rapid Z positive one hundred
thousandths end of line block this is bringing my tool to the front of the part away from all
my turn surfaces and now that I know my tool is away from my part and away from my chuck
I'm going to start homing it out we're going to go G28 that's your home command return to your
and I'm going to go U0 point W0 point end of line block so G28 we're homing the machine
U0 that's telling the machine to home the machine in X the U corresponds with X
same thing with W we're homing the machine in Z going to Z0 so this is going to take the tool
and it's going to go all the way to the back of the machine to what my machine says when it homes
out the machine and now the very last thing I'm going to put an M30 at the end of the program
and that tells the machine that the program's ended and to reset the cursor and bring it to
the start of the program and there we go we got a full program a simple face pass we did a little
corner break at the start of the program and we turned across the OD of the part let's run the
program in graphics and we'll actually cut the material here so there we go I walked you through
how to hand program this is going to be the first of many videos on different examples of how to
hand program so hopefully I'll be able to walk you through things like making drill passes tapping
cycles ID passes if there's something you want to see programmed or want to learn how to program
feel free to leave a comment and maybe we can make that happen so thanks for watching and see you next
time
