Program a CNC Milling machine using G-Code | G-Code Tutor | Skillshare

Program a CNC Milling machine using G-Code

G-Code Tutor, Engineering Artist

Program a CNC Milling machine using G-Code

G-Code Tutor, Engineering Artist

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
6 Lessons (29m)
    • 1. Introduction

      1:40
    • 2. The basics

      5:37
    • 3. Writing the header information

      3:49
    • 4. Setting the datum position

      3:19
    • 5. Understanding working planes

      6:01
    • 6. Machining a profile

      8:44
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

81

Students

--

Projects

About This Class

This class teaches you how to program a CNC Mill using the FANUC GCode language

I explain the core concepts and many ways to approach writing programs for CNC.

  • GCODES and MCODES
  • Best practices
  • Step by step programming explanation
  • An in-depth look at G17, G18 & G19 plane selection
  • Dealing with datum shifts
  • Floating datums
  • Obstacle avoidance using G98 & G99
  • and much, much more!

At first, these impressive machines look daunting to learn to program. By breaking down each operation line by line, command by command they are not as complex as they seem.

I explain each GCode that is used, every part of a cycle that is written and each movement that is made.

Meet Your Teacher

Teacher Profile Image

G-Code Tutor

Engineering Artist

Teacher

Hello, I'm Marc.

I have studied engineering and portrait art for over 26 years. A strange mixture indeed.

See full profile

Related Skills

Technology CNC Data Science

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction : Hi, My name's Mark. Welcome to Chico Cheetah in this series of lessons against teach you how to program a CNC milling machine using a panic decode. Once we've covered the basics and then move on teaching about different cycles, we use a G 81 journey. It cycles G 83 penetrating cycles happened and even boring a large diamond hole. We also make apart so you can see how these things work. Railroad environment. In this course I cover how to program a CNC machine from all the sides was available to us to heli coil 1,000,000 program in different parts and shapes and profiles. Harry Geico, Cheetah teach how to program CNC machines So it's easy to follow and quick to understand. 2. The basics: just in case you haven't done my course, that foundation for CNC programming, in which case go and get it. I'm going to run over the basic G codes, M codes and different concepts that are used for out this course. This is G 00 the most basic of G codes. We use its rapid Travis around the machine when we're not cutting for that's, we just need to give the G code on the positional dimensions. Geo one acts similar. The only difference is we need to define the feed rate. Do you know one is used for cutting material in a straight line? It's a machine of radius is and arcs. We would use G A to D A. To cuts in a clockwise direction. For this, we have to stay to the end points of the radius on to find a feed rate. The our value is the size, the radius that we wish to cut. If we move my cutter to the start position of the radius, we can define the center point by using I and J values. I is a value of the X axis to the center point of the radius and Jay is a sense point on the Y axis. These are both taken incrementally from the last position of the cutter. This technique makes machining compound radius is and blends possible machine in a counterclockwise motion. We use G a free instead, g 02 everything. House remains the same in the safety line. I had the Geico to G 90. Now G 90 tells a machine we're using absolute coordinate system. This means we have a fixed date, um, on the components on all dimensions run from that date. Um, within the program G 91. It's an incremental measuring system. This means all the dimensions tanking from the last known position of the cutter. There's two more G codes that I need to mention G 20 and G 21 G 20 puts machine into the Imperial units. Measuring system on G 21 puts the machine into the metric system at the beginning of the extraction of program. You'll likely see this in my programs. Let's go over it so you know what it all means. And one I used as a search function we used to use in numbers on every single line in the old days. Now we just use them occasionally so we can search on the machine easily. Teach separates hole. If we type in one and the down arrow on the control, the family control system will search for N one so we can find out all easily. The t 01 I one means to one offsets one and in brackets we Canavan operators notes that machine doesn't read. This is purely for the operator. Below this, we will put in m 06 to do an automated tool change To put it all from the carousel into the spindle on s 500 set suspended speed of the machine. We would normally follow this with an M o free to turn on the cutter. Now we have cut a compensation cut. A compensation is how the machine knows the radius of the tool. This is so we can program to the shape of the components on the drawing on the machine automatically offsets to cutter by the radius amount. So he cuts the profile at the right size. G 41 turns on a cutter compensation by offsetting a tool to write to the material and G 42 offsets it to the left. The G coach D 40 cancels Cut a compensation. Different machines have different ways of defining what we use for radius for cutter compensation. The more modern machines would have, a tool table on the information sits within their you might find other machines, such as desktop routers have a value after the G 41 or G 42 G code. This tells the machine the diameter of the tool and how much to offset it by. And finally, here is a list of em codes that I use Join this tutorial and 00 stops the machine. This cannot be overridden in Bali. Operator. There's many reasons why we reduce M 00 within the program. It could be for inspection purposes or maybe to check if the cutter is damaged. M 01 is the option Stop option. This allows the operator to stop the machine at this point, if he wishes were using the button on the controls to turn to spend along in a clockwise direction, we would use M o free and to tend to spend long in a counterclockwise direction. M 04 Every five times has been doing off. It's a performing automated tool change almost six is used and turn a coolant on. We used M 08 and then turn accordance off M 09 m. Fatty tells machine that the program has finished and it will rewind it back to the start. This lesson was intended to be a recap of the basic functions of a CNC machine. For more information on this, look into my course, the foundations of CNC programming. This explains these concepts in great detail. 3. Writing the header information : before we get into the Complicate stuff, I'm just gonna go over the head s so we know how to lay our program. Different companies may request you do it in a certain way, but this is why ANA me lay out the header. The percentage sign is a handshake signal between the N. C. On the machine controls. If you're programming on the machine, you don't need to add this at the beginning of the program, we start our program off with a program number, so we give it a four digit code. In this case, I'm calling it 0001 After that, we had the program description and brackets. It's in brackets, so the machine does not read it. This is purely and operates his night. This is where I would nobody put the program number to draw with number on any information that we need to relate this program to depart still have in brackets. So it's not right. His notes only. I had my name on and the date so we know the last time this program has written or edited. It also helps toe adds what machine the program was originally programmed for this way, if it ends up on the wrong machine, we don't have any accidents. I like to separate each part by using the end of block command. This gives a space. It just makes it easier for the operator to read. So it's not a jumbled mess of brackets. I like to add subheadings. So here's a subheading tooling. I'm about to list what tools we're using in front of each tool that we use, I am told number on the offsets number, defined by T 011 and then description of what little is the end one. At the beginning, I use for a search function. In the old days, we used to list every line of code with a different end number like this. If any of you have programs that expect rooms back in the early eighties, you're probably familiar with listing each line with a number. It's not really done in this day and age, and it's not needed in CNC machines anymore unless you're using a machine that's about 30 years old. But it doesn't mean the numbers don't have a use anymore. We can use them for search numbers and also for subroutines. I'll go over the subroutines later in the course, but for now, the n one in the beginning of the line t 0101 50 mil en mil. It's amusing for a search function, so I can type in n once the controls push it down Arrow, and we'll search where n. One is in the program. Before our tool change. I will put em one in the program so we can find out all on a block of code quickly and easily. This makes education a breeze and also makes it easier to rerun a tool without happens to search for the code, looking for the right place to start under that line, I like to add more tolling information. This is a code for the holder, like the tool sits in, and I would also add the tip number so we have the right greater tips for material that we're using. Then I just repeat that process for each tool that we use. Join our program for setting tools such as sense drills and drills. We don't need that much information with a sense of drill. We simply needs the size, so I put B s too, so we know which side Central used. It might also be useful to list whether it's carbide or high speed. Still, as you can see her tool for with offset forwards of five millimeters drill and about today it's tin coated. So I know which to get from stores. And finally of added the M six tap. I've kept the end number the same as a tool. Numbers all the way through. This just makes it easier to search for. So we noticed always until five. So we know the search function would be in five. Oh, just one more thing. At the end of the program, we have Emma 30. This M code is used to warn the program back to start. 4. Setting the datum position: before we can start programming, we need to find our datum on. We need to tell machine where it is. In this case, I put on the bottom left hand corner off the component on on the surface of the component, and we don't need to just stop it. One datum. We can use lots. We can use G 54 G 55 G 56 to 57 to 58 G 59. And if that's not enough, we can use G 51.1 to 51.2 g 55.2 exceptions. So we have pretty much an unlimited amount of data means we can use. This is ideal. If we're making the same components multiple times at the same block material, we only need to program it once than at the datum shift so we can program the same parts in a different place off the material within the machine controls. We can tell the machine where we wish her date needs to be. In the grand scheme of things. This is only done using a touch probe or by touching on the tour to position we wish and then hitting measure. That's a little bit beyond the scope of this course, because I don't have a machine intro hand that's called upon it. We simply use G 54. Tell the machine which data were using or G 55 40 56 etcetera. But there's also another way of setting the datum if it's the same place every time. For example, you always have the same voice sets up in the machine, or a fixture is always loaded in exactly the same position. We can set the datum in the machine. Using a code G 10. We use the Geico G 10 to put information into the data musician. For example, we can tell the machine the X Y and Zed coordinates off the G 54 datum just by using one block of coat So G 10 sets the work shift datum value. Next piece of information we need to tell the G 10 is to give it an hour to body this house . It was setting the standard work offsets now R p value house. It's which datum were put in this value into. For example, here we got P one, which is G 54 will be used in G 54 for the rest of this course for our main datum. So we would have P one in this position to tell these quarters to go into the datum of G 54 . If we use p zero or we don't add a P value at all, it would automatically go to the last datum that was used. Finally, we have our X y and zed coordinates. This is the position of the datum in relation to the machine datum. It's okay. We don't need to actually measure this. As I mentioned just now, we used to measure function on the machine controls to set this position for us. Then we just copied a position into this line of code. So let's have a look how we would write it in the program. First, we would have G 10 an hour to tell it without sitting offsets. P one tells its we using the G 54 offsets and then we tell it that offset is the X 15 Wife 30 and said zero. And that is how we set the datum automatically using a line of program on the G 10 G code 5. Understanding working planes: in this lesson, I want to talk about cutting on different planes on a CNC milling machine. For lots, we used G 17 G 18 and G 19 G codes. This diagram makes it easier to visualize where each plane is. RG 17 plane that is our usual cutting plane on the X and Y axes. This is the plane that the machine defaults to. If we don't enter a G 17 g 18 orgy, 19 G code into the programme, the machine automatically assumes we're in G 17 mode. The G 18 plane is used when the cutting arcs on the X and said axes on the G 19 plane form . A cutter knocks on the white and said a typical line of program would look a bit like this . Houston one, These G codes taking the first line as an example, the G 17 house machine. What plane we're cutting on the G 02 is our clockwise move. Ex employees positional moves are is our radius on a feed right at the end to change between different planes. We simply add the different relative G code at the beginning of the line. So the machine, always a Shames were in G 17 mode. Unless we states otherwise. If we are programming were multiple planes, it's best to states the G 17 g code at beginning the section of program. Normally somewhere after a tool change. This is to stop the machine from accidentally cutting in the wrong plane. If we jump into the program to re cuts with a certain toe, a typical safety line after a tool change would look like this. G 90 tells machine we're using the absolute system de 54 resets out datum G 21,000 Machine room metric on G 17 tells machine what plane were using. Let's have a look each plane in relation to which way the G 02 or geo freak man works. Remember, G 02 is our clockwise interpretation of cutting an arc NGO free its counterclockwise. This is a graphical representation of the G 17 plane. The G 18 plane would look like this on the G 19 plane. These last three slides are available for download underneath this lesson, so let's have a look. A sample program of how we use this in real life practice. For this example, I'll start with the T 17 plane. We start off of anyone. Our search number until one with offsets one and operators nights of 10 millimeter end mill m 06 is our tool change. Commend. This will give us an automated tool change if the machine is capable. Next, we have a blocker code which I referred to as our safety line. G 90 tells machine that were used in the absolute measuring system. G 54 calls are datum on G 21 tells machine we're using metric G 17 can also be added to the slowing to tell the machine that the rest of the block program will be used in the G 17 plane. RS Value sets a spindle speed of 2000 r p m and M o free turns a cutter on in a clockwise direction and we now believe our country into position using the rapid command of G 00 g 40 Free turns on our cutter compensation said 10. Bring to cut it down to 10 millimeters off the face of the material on emirate turns on our coolant using a dear one feed right to command. Now bring ours there down 30 millimeters past the face of material of a feed rate of 50 millimeters per minute. Now we get soggy. 17 line. I think a G 17 before radial move tells machine which plane we wish to cut the radius in. If we were cutting on reality planes, we would at G 18 or G 19 in place of RG 17 here. So she's 17. Selects a plane g o to select SAR clockwise radial motion. Exxon Boy. Oppositional movements are is our size off our radius. And finally, efforts are feed rates. Since our component has no dimensions, I won't bother going over each line of our dimensional moves. The machine already knows we're in G 17 mode. Love Staci again on this line followed Bellagio free counterclockwise move to bring the cutter back in the obviously direction to cut the radius. Using G 00 a rapid away from material 10 millimeters above the face of the parts and using M 09 to turn off the Coghlan's G 50 free tells the machine we wish to use. The machine dates him ex wines. AIDS takes it back to the machine. Zero point on m 05 turns off the cutter G 40 turns off her cutter compensation on em. 30 tells the machine the program is finished and to rewind back. So start so the same part, using the G 18 plane would look like this. It's almost exactly the same program. Apart from the line where we use our G 02 to cut our radius, we use a G 18 command before hands to tell the machine which plane we're cutting in. You notice. After we've cut this plane, I'll go back into the G 17 mode on the line below before we start the rest of our milling. If this G 17 wasn't there, the machine would probably alarm out. Worst case scenario, it would think it's on a different plane and cut in the wrong direction. But in my experience, the machine normally alarms out. And that concludes our discussion about planes on the mill emission 6. Machining a profile: now I'm guns program. It's simple parts. This is so you can see how I lay out a program as I code it, and I'll go over each line separately so you can see exactly what's going on on the encodes and decodes that I use. The first thing we need to do is decide where we're going to put our datum so we can set the work shift in the program. Since the dimensions seems to be coming from the bottom left hand corner, this seems like a good place to place it. The first line is our tour. Cool line. It's what we tell the machine. What tool on what offset we're going to be using. So I start off with search number N one, then followed by T 0101 that defines to one on offsets. One. The 15 millimetre end mill in brackets is not racist. Note. So your pretty nose, which talk we're running This is not read by the machine. The most six, its automated tool Change em coat. This tells a machine to take the cutter from the right position in the carousel and place it's in spindle. Here is a G 10 line. It should be slightly familiar with us By now. RG 10 tells machine that we wish to set the dates in position. This is used if the billet of material was always loaded in the same position each time insulin wishing if we have a standard vice that's fitted or a picture that's always loaded in the exactly same position, Al two tells machine we're going to set the date. Um, P one is a code we used to put the following information into G 54 Offset. This is called upon every time we called up G 54. We live in the program. Our chief 54 position will be our data position. Well, the Dimension Smith companions would be measured for my data position. So a datum is X zero y zero. I'm taking the top face of the components as zero, the dimensions on X y and zed on this line telling machine the distance from the machine datum to our work shift Datum here is our safety block. I place this after every tool change in case anything changes so we can start the program from any tool without having to re read the beginning header off the program se gi 90 house machine we used in the absolute coordinate system. Do you? 54 tells a machine which dates and we're using G 21,000 machine were used in the metric measuring system, and G 17 defines our plane that we're cutting on to set the revs per minute of art all use s 2000 that sets its 2000 rpm. Am I free turns on the cutter to rotate in a clockwise direction if we filled out the tool table correctly. Inside the machine controls and G 42 were the correct amount of offset. So our tool for cutter compensation We have added a tour radius of 7.5 millimeters in the tour table to make a 15 millimetre cutter cut at the right sites. So G 42 turns on our cutter compensation to offset the cutter to the left or the components . Now, ever think it's set up? We can move our cutter to start position that we wish to cut. We do this by using the G 800 rapid travel move and we take it to eggs. Zero boy, zero which removes to our datum that we set with off G 54 on RG 10 offsets earlier. I like to move to cut it down and set on a separate line when we're under a G O rapid command. This is so I can visually make sure that the cutter is moving safely inside the machine. I'm missing any clamps or vices that may be on the table, so the final movement, while in rapid is bringing the set down on the M 08 times on the coolant. Now it's time to start cutting our geo one command plunges. I cut it into material by 10 millimeters, decimated by those dead skin minus 10 dimension. The second tutorial. Amusing feed rates of 50 millimeters per minute, defined by the F value this can change greatly depends on your material size of cutter type of cutter rigidity of the machine size of the machine. Exception with the geo one linear feed rate command, still active from the line above, are now move to cut a 40 millimeters up into the first corner of our taper with a feed rate 100 millimeters per minute. Now, because draftsman of really lazy people. They didn't add to the dimension for the end of the tape it for us. So we need to work it out by using some simple geometry. Maths. Let's look at how we do that. Then, if we need calculates, I've added to have a question mark. We know our angle is 30 degrees. We know the opposite length is 80 millimeters minus 40 millimeters, which is 40 millimeters. So we need to draw a right angle triangle that looks like this to work out The bottom line for the triangle needs Teoh A little bit of trigonometry for that, we need to know which trigonometry equation to use. Luckily for us, I've included this table as a handout underneath this lesson. So which equation do we need to use? Well, we know ankle A and we know the length small way, and we need to find out the length of small B. So the best equation for us to use his B equals small a ko tang ankle? A. So that starts with that equation on our triangle. We can change that equation around by using linear transposition for more information on how to do this, keep an eye open for my course machine shop maths. So he starts our equation with question. Mark equals them for a divided by the tangent of Anger Away, which translates to 40 millimeters divided by the tangent off 30 degrees. So using the scientific calculator on punching in 10 30 we can conclude status equals 0.577 Free move Reference to arch economic equation We don't take our 40 millimeters and divide it by not 400.577 free and articles 69.282 And this is a limp we are looking for for our triangle. Now we can add that to our drawing and finish off up right in our program. So now we know I x dimension We can enter into the program for about why 80. This is the wide dimension from the datum to the top of our profile. Now we move our cutter to the beginning of our radius using X 120. Now we can machine are radius using the geo to command the G A two commanders are clockwise radial movement. The X and Y positions is the end point of our radius on our to find society. Radius in this case is 20 millimeters. Isolate the feed right down to 50 millimeters per minute to reduce chatter as we're cutting this ark. Now tell the machine that we wish to cut in a straight line. Phyllis, we use our geo one linear move Command are y dimension is the end point where we wish to move to in this case right down on the bottom of the material where the dates and lies and of increased to feed right back 200 millimeters per minute here are taking our Carter 20 millimeters past the start point to give us a nice clean edge. Now we need to do is bring are cut away from the components. For that I used G 00 the rapid trouble commands. I'll bring the set up 10 millimeters above the face of the component on our turn a coolant off with m 09 Now tell the cutter to go back to our machine data position, which is also our talk change position. The G 50 free sets a datum back to the machine datum away from our work shift datum that we defined with G 54. Now we can give the dimensions x zero y zero instead, zero on the machine takes them from a G 50 free datum m 05 House A cutter to stop irritating G 40 cancels our cutter compensation. Andi m 01 is optional. Stop. So if the operator wishes to stop the machine at this point and measure the components, he simply has to push the optional stop button on the controls. And that is how I write a basic a 1,000,000 program. We will use this information later in the course when I started out in different cycles and more advanced techniques.