9 Lines of code are all you need to get started. But they're also what you need to really understand, if you're planning on being a knowledgeable CNC programmer. In this Tip of the Day, Mark shows us where to START and where to go after we've got those first 9 lines under our belts.
Mark mentions other videos that are related to the material in this video. Here are the links to those videos: Set Work Offsets Manually: • How to: Set a work offset with an edge fin... Set Work Offsets with Probe: • Set Work Offsets in Seconds – Haas Automat... Set Tool and Work Z Offsets: • How to: Set Tool Length and Work Offsets –... Set Tool Offsets with Probe: • Tool Offsets Explained – Haas Automation T... Complete Part Setup: • Make a Part From Start to Finish; Mark's G...
Don’t miss any TIP-OF-THE-DAY videos. Click here http://ow.ly/s28l30mTiUo to join our email list!
If you enjoyed this video, please hit the like button and share it with a friend who’ll find it helpful . . . and thanks!
Hello and welcome to this Haas tip of the day. So we want to program a CNC mill. So you pull
out the manual and you start reading. That is a lot of code. Now those aren't really our manuals,
this guy is. But still there are enough codes in here to choke a horse. So where do we start?
Inside this envelope are the top secret nine lines of code that every CNC programmer knows.
The nine lines of code that you need to fully understand before you write your first program.
So stick around as we look inside. Everything for me begins with my setup sheets. So check
this out. I've got a block loaded up. Now if you're tightening up those tools by hand...
You have been preparing to be a CNC programmer your entire life. You might just not know it.
Our moms, our teachers, and even the cookie monster started off teaching us how to count cookies
before we could ride a bike. And by kindergarten or first grade we took those numbers
and laid them across a number line from zero to ten. But all on a single axis. And by fifth grade
they added another axis. And we started plotting pairs in both an x and a y in a single quadrant.
And then by sixth grade our minds were blown when they started adding in negative values. Negative
numbers. We now had both positive and negative x values. Positive and negative y values. And we
were taught to plot coordinate pairs in all four quadrants. It started to look like a CNC machine.
In fact just about half of our sixth grade math class was basically an intro to CNC programming
class. Now with these templates they've made things incredibly easy for us. All the lines
that are connected are called a shape. Shape one. Shape two. Shape three. And they gave us
very specific instructions. We can plot each point on the axes and connect them in order.
Do not connect the shapes to each other. This makes sense. We grab our pen or pencil. We're
going to draw the shape. When done we pull our pen off the paper. Move to the next shape. Come
back down the paper. Continue with that second contour. Now these templates are everywhere on
the internet. You can find tons of them just by googling graphing coordinate pairs. Or you can
create your own. So having mastered the art of middle school graphing of coordinate pairs we can
prepare to move from from this to machining on actual machines. But we need some codes.
Tyler the envelope please. Ah perfect. These are what I think are the nine most basic lines of
code that every CMC programmer knows. Before you can program this you need to understand what each
and every one of these lines does. This is where we start. Now don't worry about writing all this
down. We'll link to this document in the description of the video. Now these look like pretty simple
codes. You probably already know them if you're already a programmer. But the bonus content that
you'll download is kind of an expanded version. It'll have these basic nine lines of code for
in the bonus content we'll add the nine lines for lathe. And we'll also give you what to study next
the more advanced codes. Because just about every part that you will ever program can be made using
just the codes on this sheet. A really really good resource. We've boiled down that entire manual
into a single page for you. Now right in the middle of these nine lines of code
is a little section that's labeled dot to dot xyz locations. Now these are simply the dot to dot
points that we've all been graphing since sixth grade or earlier. If you put together enough
shapes you've got a CNC program. You can engrave, you can face, you can machine the primer of a part
just by drawing it on graphing paper then dropping in those xyz locations right here in the middle of
this program. Now this is not a how-to video it's just showing you which codes you need to study
first kind of video. But we'll give you a quick definition of each of these right now.
This code is bookended by percent signs both at the top and the bottom of the program. Our legacy
controls require this and the new ones can get away without it. But it's always a good idea just
to throw them in. Now on our very first line we have our o number that is an o not a zero
followed by a unique number that serves as our program identifier. The text behind right after
our o number is in parentheses. Text in parentheses is typically ignored by the program
it's just a comment that we leave for the operator. Next line we've got our m6 t1.
This is our command to put tool number one in the spindle. The next line is m3 s7500. Now that line
commands our spindle on and off in much the same way that we would command our cordless drill to
work. An m3 is like pressing the forward button it makes our spindle turn clockwise. If we press
the reverse button that's like commanding an m4 on our spindle it makes the the spindle turn
counterclockwise or anti-clockwise. And the s7500 commands 7500 revolutions per minute. That's just
how fast the spindle will move. Now we're not going to go too far in depth on any of these codes
we're just giving an overview here. The real benefit of this whole video is just showing you
which codes you gotta know. G54 is a particular work offset that this part uses. It references
the G54 row on our work offset page. Now we've made whole videos on this so be sure to check out
the links. G0, G90, G17 these codes are part of what we call our safe startup line. The G0 commands
a rapid move. It's used to go fast not for cutting. G90 commands absolute mode which just
means that all of our x y and z moves are referenced off a single zero point the same way
there was a zero reference point at the center of our graphing paper. G17 is our plane selection
which lets a control know we are drawing machining in the x y plane. Here we have our x y starting
position. Now it's where our tool will go first like the first x y position of our first shape
that we drew on graphing paper. G43 H1. Now these codes work together to let the machine know where
our tool is in relationship to our machine and our part in the z-axis along the z. Now we usually use
H1 if we're using tool one. Now they typically match. H1 references the row one on the tool
offset page. We've also got a z move on this line. This is the very first z move of the program. You
never ever ever ever want to command a z move unless you've commanded a G43 H something H that
matches your tool number beforehand. Otherwise the control is not going to where where that tool is
in space. Now we've made entire videos on this so check them out. Check out the links in the
description. M8 turns on our coolant. M9 would turn it off. And now we come to our first feed
move. G1 z minus. Now G1 just means that we want to machine in a line just like our dot to dots.
This G1 feed move always requires an F feed rate which is in inches per minute or millimeters per
minute by default on your machine. And we're back to dot to dot. Dot to dot is where we enter in all
of our x y locations. The things that we want to draw. The shapes. But between each shape we've got
to have a z move to get us back up and off of the part. So again G1 is for machining feeding from
point to point. G0 is for raffeting from from spot to spot between shapes between cuts. And when
we're all done we wrap it up G0 off of our part in the z and then we end the program with an M30.
If you are an operator and you want to machine. You want to program. Start here. Learn these codes
first. If you're a student and you want to get ahead in your g-code programming class
start here. Now once you've created your code you'll want to check it. We can run this in a
graphics on the machine. Press the graphics button. Set your offsets. Let it run. But I'm going to show
you our desktop mill right now. Now this desktop mill typically runs a tiny end mill to machine
out parts but we have a pen attachment in it right now which allows us to proof out our programs and
to practice our code writing. It's just perfect for this type of testing. Well that is it for this tip
of the day pretty much. Remember start here. You got to learn all these codes. Well before you go
be sure to hit the like button and be sure to download the bonus content that we link to in
the description. Not only do we have all these mill codes these basic mill codes we also have
those same basic nine lines of code for your lathe. Don't want to miss that. Basic mill. Basic lathe.
Next we've got all the advanced codes for you. Things that you need to learn next and if there
was a next next it would be find yourself a modern cam system. So much easier. Learn the g-code
and then move on to a cam system. Well truly thank you for letting us be a part of your success
and for watching this Haas tip of the day. Everything for me begins with my setup sheet.
So check this out. I've got a block loaded up. Now if you're tightening up those tools by hand