3D printer - Editing G-Code | G-Code Tutor | Skillshare

3D printer - Editing G-Code

G-Code Tutor, Engineering Artist

3D printer - Editing G-Code

G-Code Tutor, Engineering Artist

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
15 Lessons (1h 11m)
    • 1. Introduction

    • 2. Overview

    • 3. GCodes v Mcodes

    • 4. Cartesian Coordinate System

    • 5. G0 and G1 movement

    • 6. G28 Return to home position

    • 7. Absolute and incremental programming

    • 8. Metric and imperial measurement units

    • 9. G02 and G03 printing arcs

    • 10. G4 Dwell command

    • 11. Plane Selection

    • 12. M Codes used on a 3D printer

    • 13. Other codes

    • 14. Editing a program part 1

    • 15. Editing a program part 2

  • --
  • 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.





About This Class

Being an expert with your 3D printer means understanding the programming language of 3D printers.

Having a good understanding of the modelling and slicer software is a great start, but having knowledge of the actual program produced by this software makes editing and problem solving easy.

3D printers read a language called G-Code, this is the same geometric programming language that is used by industrial CNC machines.

Good news! it's not hard to learn, in fact with my tutorial you will be able to read and edit your G-Code files in less than 2 hours!

Meet Your Teacher

Teacher Profile Image

G-Code Tutor

Engineering Artist


Hello, I'm Marc.

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

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
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.



1. Introduction: So what is G code on? Why, if it's important tonight, even for free D printer owners? Well, the G in G code stands for geometric programming language. This means that we use the G coat toe program shapes with inside a machine, and the machine control G code was first invented to control CNC milling machines. And since he lives now, I teach how to program these big, large industrial machines for the last 20 years on. The code is very similar to what freely princes output from their slice of programs. So making Freedy models in the slice of programs to Prince on your printer is a skill set that everyone needs her own. Freedy princess. But sometimes things might go wrong. The machine made my not heat up. For example, it might go to a wrong position and have a full understanding of how we solve these problems. A general knowledge of G code is required. Without it, we won't know whether there's something from with a printer. Well, it's something wrong with the program. So over this course of lessons are going to teach you how to read and write the Geico for your free D printer to give you a complete understanding of how your machine works and help to control it. 2. Overview: Before we get stuck in having a look at what each G code and M CO does, we're gonna have a quick overview. Look off a program. It doesn't matter what software you use to generate your G code. In this case, I'm using slicer and have generated the Geico program for the famous part Binchy to see the G code printed out like this. It looks a bit daunting at first, but not to worry is quite simple when we break it down. No, it doesn't matter what software were used to generate RG codes. What does matter is that you select the correct printer from the settings so the machine can read the G codes correctly. Geico is pretty much the same and universal across all machines, but each machine has a favorite way of reading it. So I've printed it out here for the rep wrap type of printer. So let's have a general look at this program to see what's going on. The first line tells us it was generated by slicer on our date and time very starts. That line is a semi colon. Now the semi colon means we're adding an operator's note This is so human, you can read it and understand what is going on. This note is purely for you, so you can understand what each Geico to encode means. See, the programme explains itself as we read it, so you don't need to reference back to m coating Geico chiefs to understand what is going on. Most of the time, this would depend on the system you use to print out your program. Slicer is really good for this. It does explain everything in the program as we read for it. So the lines that start with a semi colon is not read by the machine. They're designed purely for human to read it, notes written within the program like this are known as operators knows they can also be included with inside brackets, and it gives the same effect. Selous section here is called the Header. This is where the information goes. That's house the operator, how the program will run. So here we know what our parameters are for the extrusion. The infill parameters on the solid fill on top in Phil. Now, operators notes are great, but sometimes the software we used to generate the G coat doesn't at one, but here we have m 107 So I have to refer to my sheet off. What encodes mean toe? Understand what this line of code does? So m 107 turns to find off. It's probably not needed in this section of the program, but it's just make sure the fan is not running before we start our cycle. Now, our next M coat that machine turns on is RM 1 90 Alice sets the temperature off our beds. Within each line of code, we use an s value to define what the code does. So in this case s 65 sets up bed temperature to 65 degrees now s coming whole range of things, depending on what M code we use and there will be covered in debt. A different parts off this course in a similar sort of way. We can also set our temperature of our nozzle, but using the same kind of system. So m 104 it's the M code to set are not all temperature. And as you can see by I s value, we set it at 205 degrees Celsius. Now G 28 tells a machine to go back to its home position, which is normally where it goes to when the program has finished. Now this could be followed with X zero y 00 I will explain more about this later in the course where it would have its own section devoted to G 28. This is useful to know when you wish to explain or splits programs to run separately so we can put a G 28 at the end of our section of program when we want the program to stop there so we can stop for the evening. I run a different program the next day to continue from where we left off. Now G one is our movement command. This is the G cage you'll see most common throughout the entire program. G one tells a machine to move from point A to point B and the amount to move, so this slowing housing machine to move said five millimeters upwards. We know it's upwards because it's plus about you. If it was a minus value, it would move downwards towards the bet, so your praises note here, says Lifton nozzle, Because that's what's going on. It's lifting the nozzle five millimeters in our average direction and it's using a feed rate off five meters per minute. Now how do I know that well F is our feed right value. This tells a machine how fast to move when using a G one command. Now 5000 is in millimeters, so 5000 millimeters is the same as five meters. Feed rate is often explains in millimeters per minutes, not in meters per minute. That's what we have a value of 5000. Now I m 109 is quite a clever encode. This tells the machines wait until the temperature off the bed has reached 205 degrees. The 205 degrees again is defined by our value s so m 109 s, 205 tells machine toe weight into our temperature off our beds. It's up to where we wish it to be. This is followed by a semi colon, wherein operators notice so we can understand at a glance what the M 09 does now. Before we start at in any measurements to our program, we use G 21 to tell the machine that we're using millimeters on not inches. If we were going to set the machine to read in inches, we would use G Code G 20 for more information on this look at the lesson on G 20 and G 21 metric or imperial systems. Now keep 90 is a more difficult one to understand. So it's best to look at her whole section on G 90 and G 91. A rough explanation is that G 90 uses an absolute coordinate system, which takes all measurements from one point on the components called a datum. And Jeanne, 91 tells a machine to move a certain distance from where the cutter is at that point in time. But like I said, there is a whole lesson on that subject so across that bridge, and discuss it in depth later in the course and in much the same way the machine reads G 90 toe, Understand? To use the absolute coordinate system. When MoveOn in X y and zed directions, we used M 82 toe tell the machine we're using the absolute system for when we're extremely the gene 92 command issues to set the start position, which is the origin off one or more of the axes. In this case, we're setting our extrude ahead 20 Here we have our first movement line using a G one command. That said, Dimension brings our nozzle half a millimeter off the bed of the table. This is a human that her data position is zero on the bed of the table. The F value is a feed rate of 7800 millimeters per minute, or 7.8 meters per minute. On this line, we retract our filaments in are extremely by two millimeters, using the feed rate of 2400 millimeters per minute. While we do this here, we can see our first exit boy positions. Now X is the axis that runs from left to right across your free D printing beds on the Y axis runs from front to back. I will go into a lot more depth on this on the lesson cut Asian coordinate system, and it's next block of code of highlighted will span for the rest of the program, or at least the majority of the program. This could be hundreds of thousands of lines long. Now we don't really need to worry ourselves about this section because this is what we rely on Spicer to generate for us. This is how the actual model is printed on our printer on every movement that it makes to do. So I'll just scan over it quickly on the first line, just give you a rough idea off we. Each part means the G one G code for a straight line movement. X and Y are positional, so that's how we know where the machine will go to from the position the nozzle is already act F is our feed right? That's how fast it will move and e is the extraction rate off our filaments. We can add semi Coghlan's. It's had a gap in the program to break things up and make it easier for a human to read. I have added thes two semi colons here just to demonstrate that this program will be hundreds of thousands of lines long between the last block of G codes on the next section of program that I'm about to explain. These next few lines of program will be at the very end of the program. This is important snow when we come to spine in programs, joining them or splitting them into two and 107 turns off our fan en 104 sets the temperature off our nozzle so in s value of zero will turn off our nuttall so it start cooling down. G 28 x zero will send the machine home in the X axes Only. This will put the machine back to its start position just along the X axes. And finally, M 84 disables are stepping motors. This means we can now move the axis freely by hand if we wish to. Now we've come to the end of an overview of the different sections of program on the different things we might come across. But this is just a general overview. The rest of the course will give an in depth look over how each part works, how each section works of each other and how coordinate system works. How the machine works out where it needs to go and everything you need to know about reading and writing. A G code program for Afridi. Princess 3. GCodes v Mcodes: load. The language we are using is called G code. It could just have easily been called M code, as we used em, coz just as much decodes. Now the thing with them codes is like they could be different, depending on your machine. They're a miscellaneous function that's can change dependent on the machine makers, the phone where maker or any combination in between. This makes it difficult for me to teach about em codes as theme code I give in. The lessons might not be the same as the ones in your machine, so it's always good to refer back to your own manual to find out the proper M Co. To use for your printer. This problem is not just related to three D printers or machines that use the language of G code. To control him is the same. And quite often in a factory environment, I'll be operating free or four different machines at roughly the same time with different M codes that is used as you can imagine, this could get quite confusing, so the meaning behind this is that the G in G code stands for geometric. It's a geometric programming language on the M and M code stands for a couple of things. It depends who you ask. I personally have always referred to M code as a miscellaneous code. This is because it changes depending on which machine you're operating. But a lot of CNC programmers call em code machine code. I find this a bit confusing because in my understanding, machine code is zeros and one format that is used to program processes at the very core level. But I still don't know what is the official meaning of this. In my research I've done for this course, I have come up with life, but me personally on the people of works around has always referred to it as a miscellaneous code in industry, off memorized over 90 different G codes. But luckily enough for free D printers, there's only a handful that is used, and this is a list of the ones that were used in this course. Andi throughout pretty printing in general. On the resources section of this lesson, you can download a pdf file off these G codes on em coats. From out this course, I will go into detail on each G code and how it works and also explain a few relative M codes that is needed when we're splitting programs or editing. I'm not gonna go too deep into the M codes because, as I said, it may change depends on your machine. So the codes that I give may be different if your particular printer this is important to bear in mind. The G coats and encodes that are using this course are based upon the marlin phone wear on the red proper princes. I've done this because it seems to be the most common kind used at this moment in time. But depending on your printer and phone wear makeup, well, it depends on what M codes are used. 4. Cartesian Coordinate System: in this lesson, we're going to take a look. Let's help. The printer understands how to move and how it reads the program for positions. The system the free D printer uses is known as occultation Coordinate system. If you've ever potted graphs at school, you'll probably be familiar with the way this works. Let's have a look how the printer understands this. The three D printer has free main axes as X y and Zed. The extra leader is 1/4 axes, but it's known as an auxiliary axis. Act separately from the other free when viewing the printer from the front, the axis and that travels left to right, is known as the X Axes. The axes that moves the printer forwards and backwards is known as the Y axes, and up and down is known as a set axis. An easy way to remember the difference between the X and Y axes is the letter boy looks like an arrow pointing towards you, which is the way the axes runs. Now for the printer to know which way to travel upon these axes, we give it a plus or a minus value. This diagram shows which direction the plus and minus run within the said axes minus always means you're coming towards the bench or the table off the machine X minus, and why minus brings it over to the bottom left hand corner. This is the same system that is used on all CNC machinery, whether it's free D printers or a large industrial CNC mill emission, the principle is the same, and there's one more piece of information that the machine will need to know to understand how to move in a free the environment using this system. And that is where the data position lies. Now the datum is represented by this symbol. This is universally recognized symbol of a datum that you will find on any machine that uses the Cartesian coordinate system and often seen on engineering drawings. Free D printers tend to standardize the position of the datum, and that is in the bottom left hand corner off the table. The datum is the machines X zero y zero said 20 position. So when the so when the nose was in this position, that would be the measurements. That machine would read zero y zero, said Syria, with the datum in the bottom left corner. That means any time we moved the nozzle away towards the back of the machine, it would be moving in a plus dimension along the Y axis, the same as if it moves right from the datum. It would be in a plus position of the X axes. So if we were to Nicholas as a graph format, this is how the machine would look from above, using that data position as a zero point with a cross section of the graph. So any movement to the right or above the data position would be a plus dimension. So since our data position, it sets on the bottom left hand corner off our Freedy Princess beds we would be working in this quarter ends off the graph. So all dimensions from the data position would be plus to cover the table are looking at this graph. The table would be the yellow box. Hello. It seems to be standardised these days that the data position is on the bottom left hand corner. Occasionally, a certain slow sir may print the datum in a different position. So we still have talked for an understanding of how this works. If the datum is not where you would expect it to be, say let's have a look at what would happen if the datum is at the top right hand corner instead of the bottom left of our machine. Our graph structure would now look like this with the yellow box represents the table of the machine and the datum is our machine zero points. So all dimensions running from the datum would be minus are not plus as well, even backwards and x two a minus value on down boy. So let's have a look how we would program a simple square using occultation coordinate system most typical way we will express our dimensions is using X first them Why I love the machine will read it in any order. This is just a standardized way that mathematicians writes the function X y If we were to plot our first points on this graph at X one y one my little by plus numbers, our first point would look like this. We are one unit plus off the data position and why on one unit plus from the data position in X, so it would be in the postive quartering off a graph. Now, after data musician was in the bottom left hand corner, we would always stay in the positive quadrant of the graph. But I'm gonna mix things up a little bit to give you a better understanding of how data positions work. I'm putting my data position in the centre off the free D printer. In theory, datum positions can be anywhere we wish them to be that can even be floating above the job or deep underneath the machine table. It's a theoretical position where old mentions run from. So if we wanted to plot a position below are datum here in the second quarter means it would look like this. This is plus free units in the X dimension. But because we've crossed our line and gone below the datum r Y position is minus two. When we plots are Fed points were now Internet in slip, awesome left quadrants. So this means both our X axes and R Y axis and now minus because we're below and left off our data position. So now I've added my fourth and final plots off this graph in the Y axis. We're now insult plus area. So why is plus free? And our X axes is minus 2.5 because we're still left off the data into the minus side. Now that we have plotted the shape we wish to print onto a graph, let's have a look at how we would program this. Using correct coordinates of Fast Point would be X one y one. This is because in the plus direction, off both the X and the Y axes. Now what the units are at this point doesn't matter. It could be millimeters. It could be inches. It could be feet or meters if we were freely prints in the house. So I'm just gonna refer to the units are genus are not as millimeters or inches. A second point would be X free was still in the plus direction of the X. So we don't need to add a plus sign free automatically assumes it's a positive number because we were blow the y axis zero point. Why is minus two on our third position were left off the datum on the X axis. So this is still in tow. R minus sides now. So our exes, minus 2.5. Where is were also below the data on the Y axis. So we're entering into the minus territory of the Y axis. So this is minus 1.5 now, without pregnant, I've no added the G one or feed rate two lines as we've gone by. This is just so makes it easier to read more were plotting a graph. But under normal programming situation, the beginning of this line would have G one for a feed rates move, followed by an effort value for the speed of our feet. Let's have a look at our fourth and final points off our graph. We're plus off the data position on the Y axis. So why is now free 0.0? And we're still minus along the X axes. So I'm exact sees here, reads at minus 2.5. Then we can return back to our start position, so complete our shape. So if you call up our original program of our bench E that we looked at during the interview, we can see from the highlighted areas the X and Y dimensions. This is how the machine understands it, because in the machine's brain, it sees our graph as its plotting our shape. Now the F value is our feed rate. It doesn't need to be repeated each line. Once the feed rate is set, the machine will keep reading that feed right until it receives a different feed. Right. And the E on this line is our ex treating amounts, which will be discussed later in this course. So that's how the Cartesian coordinate system works. And this is the only system used by Freedy princes. There is a different system called the polar coordinates system. Now the polar coordinates system is different because we need to give it on an angle on 11th Raval in an X y and Zed position of each plots. Say to me, a definite little five millimeters in the plus direction on X, we would say ex five millimeters at 90 degrees. But lucky for us, Freedy princes very rarely use this system, so it's not something you would probably come across. This is more the CNC programming on larger industrial machines. So now that you have an understanding of how the X y and Zed positional system works within Afridi printer, we could move on to the rest of the lessons where I'll be teaching you how to understand the rest of the program. 5. G0 and G1 movement : when we looked at our overview we come across are very large sex on the program made up between the code G one and G zero. Let's have a closer look at what laced decodes do and how they work now. The G code programming language was first invented to control large industrial scene see machines such a CNC lathes and CNC milling machines. With these machines, it was usually called G one are not just G one, but in recent years it's been short into G one on most machines, where that free D printer or a CNC milling machine can understand the G code G one as well as G 01 So the official name for a G one command is linear movement commands with a feed rates. When we add a G one command, we also have to add a feed right to tell the machine. Help fast to move. So in this demonstration of this line here, G one house, the machine we're using a linear move, a straight line move X moves the nozzle 100 millimeters tele left. We know it's left because it's a minus number on our feed rate. It's seven meters per minute defined at 7000 millimeters. Now this is what we use when we're extrude enough elements I might actually making our parts. But when we're not extremely in on, we wish to move as fast as possible. From point A to point B, we would use a G zero command. Now this works in much the same way. The only difference is we don't need to add a feed rate with an F value so G zero removed in machine on the fastest possible way to the position of X minus 100 millimeters. We don't need to feed right cause machine is already operating at its top speed. The majority off the program will be programmed using G one and G zero commands the G one. You'll see a lot more. Almost every line off the program when you consider it could be hundreds of thousands of lines. Long will be using DJ one command Now. Freedy princes differ from CNC machines, and that's we also haven't e value on this line. Now the e value is the extrusion rate off the filament is how fast the filament is coming out of the nozzle because we're using software to generate RG code. Sometimes it doesn't generate it in the best fashion. On the second line highlighted here, you can see our E body is 2.0 really just e 2.0 with teller machine. Exactly the same thing. Sometimes in this case slicer or whatever software were using to generate the G Kate May over generates. That's not a problem. The machine can still read it. The only difference it makes is a mix of file size larger. And that concludes this lesson on Houston G one and G zero to move on those around the machine bed. 6. G28 Return to home position: we're going to talk a little bit about the correct use of the G code G 28. Let's decode sends the print nozzle back to its home position, or it starts position. Now. This is where things might get a little bit complicated. The machine actually has two separate datum positions, one that we used to program from on one that the machine calls its home position. So in effect, G 28 sends a machine back to its home position, which the machine thinks is X zero y zero said so. But because we've been programming from our data position, this is the position we use. That's how measurements come from for the components that were printing. The reason I'm discussing the two different data is that play here will be a parent as we move on through this lesson. If we just use G 28 nothing house on that line of code, the machine will always return back to its home position or it starts position. No extra information needs to be added, but if we just wanted send it back on one axes, we can add the axes to this line of coat so low. For all intents and purposes, we'd probably only use just G 28 to send all three axes back to its home position. If we type G 28 x zero, it will send suggesting X axes back to its home position, leaving the set and Y axes in the same position it waas when it was last printing. We can also do this with the y axes, always that axes. So quite often we might need to use this just a recorded, said axes back to its start position whilst leaving the X and boy in the same position as it was printed. So it's do that. We would just add G 28 0 to recall our said axes back to its start position and that one axes only. So to recap, if our data position that we're programming from and all the measurements for our program for our Freedy model is coming from the data on the bottom left hand side, such as shown in this picture, G 28 might not necessarily take the print nozzle back to this position. There may be another datum at play where the machine uses as its rest position or its home position by calling up G 28. The machine goes into this mode off, looking for its own data position and other data position that we use when we're programming. This could be in the center of the machine beds, all the back rights corner or anywhere that the machine is previously set up within the parameters. So a low have gone deep into the theory of what G 28 actually means from the machines perspective. From our perspective, all we really need to know it's at the code. G 28 sends a machine back to its home position, or we can decide to move it in one axes only, or even two axes by adding X zero y zero or zero till its line of coat. 7. Absolute and incremental programming: in this section, we're going to take a look at the difference between absolutes programming on incremental programming Now in the free D printer world, it's often referred to as relative and not incremental, so this could also be called absolute and relative programming. But in the CNC world of programming industrial machines, the word incremento is used. And since I'm a CNC instructor, I'm going to be calling. It's incremental and not relative, right? So let's have a look and see what the differences are and how it affects our programs. As we can see on the screen. There's two different decodes. We need to change machine between absolute or incremental programming. The G 90 tells machine that when the absolute mode and we used 18 91 for incremental. So what is the difference between absolutely incremental? Let's have a look that all machines annual programmes have a date in position. This is our reference points that the machine takes at 00 as in ex zero boy zero, said Sarah. This is used for our programs, so old dimensions run from our data position. So in absolute programming, I've put my datum in the bottom left hand corner which is pretty standard for free D printers. Hello. The data position can be anywhere we like. If the data was on the right hand side of this components, all our dimensions to move in X towards the left would be minus. For more information on this, look back at my lesson on the Cartesian coordinate system on how this works. So in this example are datum has on the bottom left hand corner. This means that all our dimensions going above and to the rights of the datum will be a plus number in X and y. So to move are not all 80 millimeters to the right we would use x 80. This moves are not all 18 millimeters in the plus direction from the datum. So a typical program to make this move would be g one x 80 because it takes all the dimensions from the datum. Remember, the datum is X zero on the next line of code. We wish to move our nozzle another 20 millimeters to the right so our program would now read G one x one hundreds. The position of Nautile is always taken from the data position. So now are not always 100 millimeters to the right of our datum, so our program would read X 100 and that is the absolute coordinate system that uses G 90 to turn. This function on the 90 is usually found at beginning of the program before any dimensional moves are made. So let's have a look how that same move would be programmed if we use in the G 91 incremental mode or relative mode, we're starting our Nautile off in the same place on the bottom left hand corner. Now to move 18 millimeters to the right. It would still be x 80 because it's 18 millimeters from the last position off the nozzle. But because we're in Gene and he won incremental mode, a machine Nell takes on not a position as the data position. So where are North was sitting at the moment? It would read X zero y zero and to move on Nautile an extra 20 millimeters to the right. From that position, we would now just tell the machine to move X 20. Where is an absolute mode. The command is X 100. This is because our datum has shifted to the last position off the nozzle. So the move is relative to where, you know. So is this is by incremental is also known as relative position in. If we were to move on Nautile back to previous location from here we would program in X minus 20 because the North Pole position is now zero Samonas 20 would move it back 20 millimeters to the left of the components. If we're in absolute, we would have programmed this at X 80 because it's 18 millimeters plus from the data position set to buy the machine. Now let's have a look at our program that we first spoke about during the overview. This is our program off the Behnke that was generated by slicer. Now, as you can see that I've highlighted we add the gene 90 order G 91 right at the beginning off the program before any dimensional moves are made. This is something machine knows is an absolute or incremental before we start reading the program. Now, this coordinate system where we're using absolute or incremental, applies to the X Y and Zed positions. Our ex trita is set separately From this we told the extra odor to use M 82 or M 80 free for absolute or relative in our example program. We're using absolute for our extruded as well. So we use every 82 to turn on the absolute positioning system for the extruded moves. If we were using Incremental, this would be M 80 free on this line that I've highlighted. Where are extruded moves? Two millimeters in the minus direction. This is why, when we're programming using Absolute for the extra leader, we will often see the commands G 92 0 This tells our printer that the points the EC Streeter is that is now nine as zero. We would see this quite a lot in a program that uses the absolute coordinate system. If we were using relative positioning or incremental, the printer would always be at zero point at each line of the program, so we would just tell the printer to extrude the exact amount we need for the next line. For this reason, it's quite common to see the machines set to the absolute coordinate system. But the extruded set to the relative system 8. Metric and imperial measurement units: using G code, we could tell the machine to switch between imperial units or metric units, dependent on what our requirements are in my industry. Off programming, industrial machines using G codes. I worked for the aerospace industry. This means sometimes I might be making parts for, say, Boeing that works mostly in imperial units and another part of the day I might be making parts for Airbus, which is based in Europe. So I need to switch between these two quite often. I, uh, not sure how that slides ended up here. So moving on the two G codes, we need to switch between these two modes off. The coordinate system is G 20 which tells Machine we're using the Imperial Measurement System on G 21 which is the metric units system. Now. If we look back to the program that was generated by slicer that we looked at during the overview section, we can see that before any coordinates or measurements are made within the components. We called G 21 to set the machine. So the millimeters unit system, no extra information needs to be added here just G 21 on its own line to change this to the imperial system, we would have used G 20. It's a simple is that, But I don't like simple. Let's make things more complicated. As Afridi Prince Verona, you might need to convert between metric and imperial. Often you might have a drawing that's an imperial that you wish to program for metric or vice versa. So it's important to remember that one inch equals 25.4 millimeters. No, no in this makes the equation easy to change between millimeters and inches. So say, for example, we had 1.5 inches that we wanted to convert into millimeters. Because one inch equals 25.4 millimeters, we simply times this by 25.4. So 1.5 inches times 25.4 will give us 38.1 millimeters. And that is how we quickly contract between the two. It's always handy to have a calculated nearby how to convert the other way. From a metric two inches, we simply divide by 25.4 instead of multiply. So if we had 38 points one millimeters on, we divided that by 25.4, this will give you value and inches so it converts between metric and imperial units. We just need to remember 25.4. We multiply it to convert inches into metric on. We divide it to convert to metric to imperial or inches. 9. G02 and G03 printing arcs: so we now know how to print administrates line. What about if we wish to print an arc or a radius? It's two different ways we can do that. Let's take a look. The G code for a clockwise arc is G two. The four form way of rightness is G 02 You're free D printer will understand both methods. G two is probably what you will see in the program as printed out from slicer or whatever stuff where you use to produce your G code program. So in this example, we're going to program its head millimeter radius at the ends of a straight line move. Now you may notice that my diagram off the printing nozzle is actually a 1,000,000 cutter in this example. That's because it's exactly the same process as we use. When using a CNC milling machine or a CNC router, we're going to be using two separate lines of code. Two prints are Ageas, so we start by turning the machine. That's how Regis is in a clockwise direction that we use G two or G O. T. Now, since our radius is at the end of a straight line move, we give the distance off that straight line. Move. Phyllis. I'm using Boy 50. This tells machine we're moving 50 millimeters towards the back off the machine. We'll also take some notable to the start point of our radius. Then we tell it the our value, which is the value of our rages. 10 millimeters defines a 10 mill radius. G two machine McCarten. Clockwise on 10 millimeters is a direction off our ages. Now Follow me on this line. We have our feed Right now. This feed rates. It's particularly low number in this example because this is based off a CNC milling machine program, so it probably be looking at a feed rate between 2000 and 6000 millimeters per minute because we told the machine we wish to use G two prints are radius. We now have to define a linear straight line move to tell the machine that were coming off in a straight line, and the rage is's not continuing. So we switch over to G one. So long G one x 50 moves are print Nosal 50 millimeters in the plus direction, away from the radius. Now it's printer radius in the opposite direction in an anti clockwise direction or counterclockwise. It's exactly the same. We just use G free instead of G two. Our X dimension is a minus figure here because we're moving to the left off our X. We're human. Our data position. It's the position off the cutter. This makes it easy to understand the coordinates I'm using during this explanation. Now some slice of programs may produce this G code in a slightly different fashion. The center points off the radius can be defined instead of giving the size of the radius. So that's looking Slatter little bit more and explain how this works. We have free axes are X y and Zed axes. Police will have auxiliary axes references, which are I, J and K. They mean the same thing, but sometimes the G code would be printed using I, J and K instead of X y and Zed. If it's not the position off the print nozzle but a reference position, let me explain, as we approach outrageous removed the print, Nigel. So why 40 along the Y axis to bring out to the start position off the right here? We also add a feed rate on an extrusion, right? We're precious Using g A. One are straight line Maeve. Now it's time to add RG to command Saleh machine that we're cutting clockwise radius. Our x and Y positions are the endpoint off the radius. This is important. Now we add our I and J values. Now all eyes are X axes and this is incremental or relative to the position off the prince nozzle. So I 10 millimeters would tell the machine that the center point of our radius is 10 millimeters along the X axes in a plus direction. The J value is our Y axes on because our print nozzle is already parallel to our radius. Centerpoint, RJ value zero. This is because we don't need to go up or down in the Y axis to be in the center point off the radius. We don't need to add on our value less machine already knows the end point off the radius on the center point. That's all it needs to know to calculate a perfect arc. Now, finally, we move away from my radius in a straight line move for that, we use G one in this case we're moving 50 millimeters in our plus direction are actual program. Here is an absolute so x 50 50 millimeters from our data position. But don't forget when we use a ny NJ values the machine takes them as relative positions from where the print knows always. There's more about this in my absolute and incremental section off this course. No, if we're using G free, let's go into an anti clockwise direction. Let's see how this would look same as before. We approached our start position off our radius using wife 40 millimeters on a straight line. Move using G one with the feed rate, I'm probably on extraction rate G A. Free is our anti clockwise direction, so we list the end points of the radius, which is 10 millimeters to the left in X, so our X value is minus 10. This is because the radius is 10 millimeters, so the distance between the center of the prince nozzle on the center off the end points of the radius is 10 millimeters. Why? Value is also this endpoints. But in the boy axes now, because the center points off our ages is to the left off our print nozzle. The only value is a minus figure. Remember, the I value is the distance from the center point off the radius from the print nozzle in the X axes. So since we're going left, its A minus figure now R J value. It's a y axes since our sense of points of our radius is level with the center points of our print. Nosal, this is zero. Remember, I NJ values are always taken incrementally. We don't have to set the machine into incremental motiveless toe happen. The machine will always take I j and K values in an incremental fashion. I would also like to note at this point, the K value is the same thing, but in a set direction which is really used on Freedy princes. But sometimes you may come across it, so it's good to mention it now since this example is based in center point of our prince nozzle as the datum, When they're moving to the left of the datum, we become a minus figure. This is why X is minus. If our data position was far over to the left, this number would just be less than the exposition we started that this is a Shuman were using the absolute coordinate system. So to finish off this radius G one X minus 50 moves are print Nosal away from the radius in a straight line. Now I'm not suggesting that we start toe program are free D printers line by line, but using these kind of values. But at least this way, when you see it in the program, you'll recognize what's going on on. This will make editing spice in on joining programs a lot easier, as you will have a full understanding of how the machine reads the program on what happens during each line. So that's the two different ways Radius is are produced using the G code programming language. 10. G4 Dwell command: at any point we compose are free D printer to stop it from Princeton. To do this, we use the simple commands G four. This is our dwell command. We also need to give it one more piece of information, and this is how many seconds the machine will dwell for. This value is given in milliseconds on. We use a value off P to the fineness. So P 5000 means we're going to dwell for five seconds because its value is in milliseconds . If we wish to machines pools for seven seconds, this value would be P 7000 7000. Now this could be used for a lot of different things. We might be waiting for the eight extruded to heat up the beds, heat up, etcetera, so we can use this to control when the prince of stops and how long it stops. For while we're waiting for other things to happen, pull it into a more visual example. We can bring our printing noted down Teoh position. Then we use G four p 5000 to pause the print for five seconds at this point, and the machine will carry on with the rest of the program and its cycle 11. Plane Selection: some three D printers I've seen used plain selection. Hello. It's like young common. I'm going to go over it so we have a little understanding of how this works. On a free axes machine such as Afridi printer, we have free separate planes. These are defined by G 17 G 18 and G 19 G coats. The easiest way to describe these planes is by using this diagram. G 17 is the usual plane that we work in. This is the beds off the machine using the X and Y coordinates. Now for us to cut a radius using G two or G free on this plane, it's automatically G 17. We don't have to tell the machine to go into this mode. It's a shames. This is the mode that were normally printing in, but some princes capable of programming and arc in an incentive direction. This means the Ark comes away from the table. The machines that do this, we use G 18 for the X and said Plain and Jean 19 for the wine set. If none of these G codes have been activated within the program, the princess will assume G 17 is the one that is active. So when we produce radius is on arcs using G two and G free, it would look like this G 17 plane sits on the bed, so it's flat on the table. The G 18 plane would look like this. This is for printing. Radius is on arcs coming on the side of the machine. I'm putting the machine in sludgy 19 plane. It would look like this. It's a mirror image off the G 18 plane. If you find your machine uses G 17 G 18 and G 19 within the Geico program from the slicer, please let me know in the comments, and I would have more information to the section. 12. M Codes used on a 3D printer: in this lesson, we're going to look at the different M codes and how they affect our program. Now the G coast em coz used in this course are based on the Marlin phone. Where on the riprap princes. Now that very is the same. The encode may be different on different firmware and print a set ups. Hello, Thean codes I'm going to go over now tend to be pretty standard across the full range of firmware and printers. Now, this is a common problem with them coats being different on each machine. The G code language in general, used in industry has the same problem as different machines. May need different M codes for different functions. Hello, that does tend to be a standard set of them codes that is the same on all machines. M coat above the number 100 for example, in 100 tow em on thousands. They tend to be used by the machine manufacturers to do different things, depending on the weight machines set up on the needs off the machine. So I've often programmed the CNC milling machine in the morning that uses totally different M coats to the mill. That's how programs in the afternoon. So it's advisable. Let's have a print out off the codes specific to your machine when editing a program so you can use it for reference. So let's have a look at the most common M codes that we use. M zero. This is the most common encode in the world. It is used on every machine, and it always means the same thing. It means to stop the machine. It could be used at the end of the program to tell the machine that the job is complete or confused halfway through. If we need to check something, maybe pulls the program this it behaves similar to M one in the world. Afridi Printing FM coats do the same thing. Normally, M one is an optional stop. Where is the operator has the option to stop the machine at that point by pressing a button on the controls. This is used less and less in three D printing. At the end of the program, we often disabled stepper motors. This is done by using the M Coat M 84. Once the stepper motors are disengaged on disabled, we can and move the axes around by hands if we wish to. This is name code that we use quite a lot. This sets the extruded target temperature. So using M 104 it's how we tell the machine what temperature to set Extremely too. We define the temperature by using an s value. So s 205 will set the temperature to 205 degrees Celsius. We have a lot of control over each feature of our printer just within the program. So N 106 consent the speed off our fan again. We do this using an s value. So using this example M 106 s 255 sets the fan to 100%. Where s equals 0% on s 255 It's 100%. And if we turned out fine on you may wish to turn it off. At some points flat, we use em. 107 machines may also use em 106 s zero To turn the fan off. This just reduces the revs per minute to zero, since it takes a while for intruder to reach the required temperature. If we used the encode m 109 weaken. Tell it to wait until a target temperature is reached. And, like theology, M code that we've discussed so far weaken Set that target temperature by using an s Fadi, in this case, I'm heating the extrude er up to 205 degrees Celsius on the machine will wait until that temperatures reach before it carries on reading the rest of the program. The heated bed target temperature it sets by using the M coat M 1 40 and actually probably guessed we define this temperature. But using an s value A list him code works conjunction with our next M code and 1 90 This waits for heated bed to reach his temperature before it starts reading the rest of the program. Now, if we haven't defined are better temperature yet. We can do so on this line as well. So the line em 1 90 s 70. This will set the table temperature to 70 degrees Celsius. I never wait until that temperature has been reached. If we've already previously set our temperature off the bed, we don't need tired of the S value onto this line. Now there is many, many L AM codes that may be different for each machine, but these ones are the general controls off your free D printer. As I said that it began in this lesson, it's always wise to have a print outs off the M codes that work in conjunction of your princess because they did vary between different makes models and found where. 13. Other codes: Now we've covered G codes on em codes, and we've had a look at the different axes on how they move. Now there's a few other commands and letters we may see with inside the program. I want to go over them, have the next few minutes so we can discuss what they will do when we see an E value inside a longer program. This refers to the amount of filaments that is extruded during that movement. A typical line would look like this. You have G one which are linear movements. Distance our X and Y positions are our coordinate system off where the machine is moving to . Then we have our e value. Ari value in this case is extruding 4.9 millimeters off filaments during this move. And this is followed by our feet, right? We're moving at 1.8 meters per minute or 1800 millimeters per minute. Sometimes we might see a line that looks a little bit like this. I minus value on our e number tells a machine to reverse the extraction by two millimeters . This is used to problem are nozzle I feed right also needs to be given here because we're using G one, which needs a feed rates command. If a feed rate is still alive from the line above, it will read that if no feed rate is given often we will see Jean 92 e. Zero. When we see this line, it's simply reset the data position off the filament, so it's house machine. The current place in the filament should be read it e zero. This is normally used it for programming in absolute, because if we using relative programming or incremental, the position will always be zero. When we see an F value on the end of a line that normally starts with G one, G two or G free, this refers to the feed. Right now this is in millimeters per minute, so a typical line would look like G one that no 0.5 millimeters f 7800. Now the F 7800 will be millimeters per minute. We can also say it's 7.8 meters per minute. Now a team number is if we used the machine of more than one extreme. This comes from CNC milling machines, and since he lives with a T stands for talk number. And just to make things a little confusing in the world of fraidy printing, T zero is the first extrude ahead where his t two would be your fed extreme. And finally we have our s value. Now it s value. Come in a range of things. It's normally just the value that we can set for a particular M coat. For example, when we use em 109 the machine will wait for the extra leader to reach its amateur off 205 degrees C. We set the Celsius by using anus fatty and and when a full set the target temperature, this isn't just use for temperature control s value coming whatever value we wish to set that particular M code at 14. Editing a program part 1: Let's have a look, taken a single program and splitting it into two separate programs that we run at different times. So his up and she pregnant. If we just scroll down to the very bottom we can see, it's over 100,000 lines long. It's absolutely massive program, so we don't want to be Warren too much about the content of this. We're looking for an area where we can safely split the program into two so I could find a middle section. So we're looking at around 60,000 lines in or so now we want to be looking for it, said Move. So what we can do that is pressure control, F in no pad plus plus or any Windows software. I just hope, said, then finds next and highlights Older said movements within our program. Somebody conferred, said movement around about Line 60,000. Here we have a perfect one. What happens here is Theis treated lifts up at the end off the princess cycle above, so we know the X treaters lifted away from the job at this point, so it's a good place to split it. We're just gonna add a few lines of code that could be found at the very end of our program . So the stuff of Jean 92 e zero, this resets the origin of our extra. Now we want to turn our fan off, so, flats, we use em 107 Now we're gonna want to turn our extreme her off. So using the M code M 104 on we set at 20 degree C by using an s value. Now we want to send our shoot of actual home position. That's just a simple G 28 command. It sends our studio home. Now you wish to disable the majors in turn, everything cough. So M 84 turns off are stepping motors. That's all the lines of code that we need to add at the end of the program to safely finish the program. The trick is, is making sure it's in the right place. So look for a said movement and then once see, excluder is away from the material. We can then safely return home. So we covered quite a lot of program that lets go over it and have a recap RG 92 command obsessed in the extreme t zero since our reference to our extruded. So it now knows it's on the zero position G 28 command. This sends are extremely back to our home position. Off the printer. The M 107 turns off her fan on the M 10 for s zero turns off her temperature. So m one therefore sets are temperature on the value. S zero turns it off, then finally m 84 turns off. All are stepping maters in. The next lesson demonstrates how we can take our second half of the program and add the beginning information to it so it can run safely at a separate time. 15. Editing a program part 2: in this lesson, we're gonna have a look at our second half of our Benji program and see what information we need to add to the beginning to be out to make it safely run as its own program. The first thing we need to do it sets our beds temperature. We do that by using the M code M 1 90 Now we set our temperature using it s value some setting up bed to 65 degrees C. Next, I'm going to set our extruded temperature. The encode M 10 full defines some of our extruded on we set temperature using the nest value. So in this instance, I'm setting it to 205 degrees. We want to make sure the head of our printer is at its reference point or its home position . So you some t 28 weaken sends the head to its home position. Want a lift? Our nautile up five millimeters from that position. So G one is our linear movement. We set out said distance, but used instead five. This move has had five millimeters and then we give it to feed, right, so it knows how fast to move its less position. I never fought with stop printing. We want to make sure our extruded is at the right temperature. So given the command M 109 on the value that we set are extremely to this would tell the machine toe wait until the extreme is reached. His temperature before it carries on reading the rest of the program set to our metric units. We use the Geico to G 21. If we were working in inches, this would be G 20 sound machine working. The absolute coordinate system used g 90 if we use in relative or incremental would be jean 91. And to set our extruded to the same absolute corner system used M 82 two sets, a reference point for Extreme Give it a point of origin. Eugene 92 e zero. Now we wish to move our prince head to the start position of the first layer of our prints . So we need to find what said value to give its here. We find this value by looking through the end of our first section of this program. The last set moves that we made, we can see it happen. So before we split the program, this was the position where the slow sir wanted start printing on the set axes. So we know this is the right hope to start off a new program. So we're just going to start that value here after the G one linear movement command on. We need to define a feed, right? We have a couple of lines left over from the old program that we don't really need. We don't want the extractor to start extruding on. We certainly don't need to. Zero. It's afterwards because we've just Syria. It's on the line above using gene engine duty free so we can safely remove these two lines of coat. Now the first line of code adobe printing that comes directly after our said move. So let's just have a recap over what we did here. First, we set the temperature of our bed using the M code M 1 90 on. We set it to 65 degrees within s value. Then we set our extrude is temperature. By using M 104 on, we set it to 205 degrees C. Then we sent the prints head back to its home position just in case that moved during the note. Whenever the prince was last used to G 28 cents a prince head back to it 00 position or its reference position. Well, then lifting nose go up by five millimeters using it said movement G one is Alinea. Move. We raised a said five millimeters upwards and we gave it to feed rates off five meters per minute to do this. Now, since we sets our extreme temperature, we now wish to machines. Wait until that temperatures reached before we start printing. So M 109 tells machine to wait until the extreme has reached a temperature off 205 degree C for 205 degrees is defined by the S for you. We then set our measurement units two millimeters using G 21 g 20 would be our imperial units. The absolute coordinate system was selected using Gene 90. Where is incremental or as it's also known as relative would be 18 91. We also set our extrude er to absolute coordinate system as well. For this we use M 82 and then we set the Origin Rx trita using Gene 92. One of the most important things we need to do is make sure, said Hope is correct. Now we bring down the print nozzle so hard to find, said Hives, and we know what this said. Hope is because it's the last set move on the previous program that we split.