9 Lines of Code Every CNC Machinist Needs To Know! - Haas Automation Tip of the Day

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
- Hello and welcome to this Haas Tip of the Day. So we wanna program a CNC mill, so you pull out the manual (books hitting table) (people groaning) (accordion music) 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! (horse neigh) 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. (upbeat music) Everything from me begins with my setup key. So check this out, I've got a block loaded up here. 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 'em across a number line from zero to 10, 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. 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, (folk music) we're gonna 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. (alarm noise) (people cheering) So having mastered the art of middle school graphing of coordinate pairs, we can prepare to move from this to machining on actual machines, but we need some codes. Tyler, the envelope, please. (laughs) Perfect. These are, what I think, are the nine most basic lines of code that every CNC 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 mill. 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 every program can be made using just the codes on this sheet. A really, really good resource. We've boiled down that entire manual (books hitting table) (people groaning) (singing) 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 a primer of a part just by drawing it on graphing paper then dropping 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 book-ended 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 M06 T1. This is our command to put tool number one in the spindle. The next line is M03 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 M03 is like pressing the forward button. It makes our spindle turn clockwise. If we press the reverse button, that's like commanding an M04 on our spindle. It makes the spindle turn counterclockwise or anticlockwise. And the S7500 commands 7,500 revolutions per minute. That's just how fast the spindle will move. Now, we're not gonna 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. G00, G90, G17. These codes are part of what we call our safe startup line. The G00 commands a rapid move. It's used to go fast, not for cutting. G90 commands absolute mode, which just means that all of our XYZ 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 XY plane. Here, we have our XY starting position. Now, it's where our tool will go first. Like the first XY position of our first shape that we drew on graphing paper. G43 H01. 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 H01 if we're using tool one. They typically match. H01 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 wanna command a Z move unless you've commanded a G43 H something, H that matches your tool number, beforehand. Otherwise, the control's not gonna 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. M08 turns on our coolant. M09 would turn it off. And now we come to our first feed move. G01 Z minus. G01 just means that we wanna machine in a line. Just like our dot-to-dots. This G01 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 XY locations. The things that we wanna draw. The shapes. But between each shape, we've gotta have a Z move to get us back up and off of the part. So again, G01 is for machining, feeding from point to point. G00 is for rapiding from spot to spot, between shapes, between cuts. When we're all done, we wrap it up G00, 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 wanna program, start here. Learn these codes first. If you're a student and you wanna get ahead in your G-code programming class, start here. Once you've created your code, you'll wanna check it. We can run this in graphics on the machine. Press the graphics button, set your offsets, let it run, but I'm gonna 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 gotta 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. You don't wanna 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 onto a CAM system. Truly, thank you for letting us be a part of your success and for watching this Haas Tip of the Day. (upbeat music) Everything for me begins with my setup key. So check this out, I've got a block loaded up here. Now, if you're tightening up those tools by hand.
Info
Channel: Haas Automation, Inc.
Views: 275,299
Rating: 4.9520411 out of 5
Keywords: CNC machine tools, CNC machining, Gene Haas, Haas Automation, Haas CNC, CNC, Haas, haascnc, machining, manufacturing, cnc machines, cnc mill, milling machine, cnc machine, cnc milling machine, machine tools, lathes, cnc machining, rotary table, cnc machinery, cnc machine tool, boring bar, cnc machining center, cnc cutting machine, haas tip of the day 9 lines, 9 lines of code every cnc machinist needs to know, haas mark terryberry, mark terryberry tip of the day
Id: hJM8pnUazpk
Channel Id: undefined
Length: 11min 3sec (663 seconds)
Published: Thu Jan 30 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.