Transcript:
Either szura of the Dr Racks channel. If you want to communicate effectively in a foreign country. I happen to live in the United States. If I go to France on, I want to be able to communicate fully with folks in France. I need to speak French. Germany, German Israel, Hebrew Saudi Arabia Arabic. So likewise, if I want to be really good at using a 3d printer, I need to understand something about the language of 3d printers, the language that’s used to communicate between a computer and a 3d printer. That language is called g-code and stay tuned today and we’re going to learn something new. We’re gonna learn about G code that will help you initially install new printers into a slicer. The program that’s used to convert between a three-dimensional object and an object ready to be printed. It’ll help you fine-tune your prints. It’ll help you understand better. The parameters in a slicer, so stay tuned, lets. Learn something together. [MUSIC] G-code geometric code is not at all new it was developed in the 1950s at MIT and it was developed for use with numeric controlled machines. Numeric controlled machines are machines where some type of automation is used to control a manufacturing machine. Initially, you would put instructions on a printed card, a punched card that would go into the machine with the instructions and they switch to magnetic tapes. Nowadays, most numeric control machines are actually computer numeric controlled machines because they’re controlled by computers. A 3d printer is a form of a numeric control machine and it uses g-code or geometric code, a variation very similar to the original. G code developed in the 1950s One of the nice things about the G code that’s used by most FDM style 3d printers is its human readable. It’s not in binary bits and bytes. It’s in text. It’s something you can read and learn to understand, and today we’re going to learn how to understand the variation of G code that was created for Reprap 3d printers. Those are the style of FDM 3d printers that most of us use at home and many of us use in the office lets. Look at this picture together as a bit of background. In this picture, you’ll see a three-dimensional object on the left that three-dimensional optic is created by a computer-aided design program. You could use something as simple as Tinkercad. You could use fusion 360 you could use much more sophisticated programs, but you create a three-dimensional object. 3d printers can actually print three-dimensional objects, 3d printers are really very simple machines. They print a layer at a time, it’s almost like printing on a piece of paper and putting a new piece of paper in and putting another layer, except they stack those pieces of paper those layers, one on top of the other to create a three-dimensional object. So you need to take your three-dimensional shape and you need to convert it into a series of layers. That function is done by a slicer and the format used by many. Fdm style, 3d printers, filament based 3d printers is g-code. So on the left, you see a 3-dimensional object in the middle, you have a slicer, creating individual layers and on the right. You’ll see that your printer is just drawing lines and shapes a layer at a time now to understand g-code. We also need to go back to a bit of geometry and remember that a three-dimensional printer has an X access, a y-axis and the Z-axis. Now the starting point could be in the very center in this case. This is a monoprice. Delta mini printer now. I’m not really a big fan of the Delta Mini. I don’t think it’s very reliable or easy to use printer. It’s very, very inexpensive, but it’s a blast to watch, so we’re gonna use it today from some examples just because it’s fun to watch in the case of this printer, the origin or the 0 0 0 point 0 0 0 is in the center on many. Fdm style, Cartesian style, 3d printers. The origin is the bottom left corner, so when you’re telling the printer to go to position 1 on the X-axis 1 on the Y-axis and 1 on the Z-axis. You need to know relative to the origin. OK, let’s get on the screen now and take a look at some actual g-code. The first command g28 is a command that says to the printer. Move the print nozzle to the origin to 0 0 0 The second command g1 says. Move to X Location 10 Why Location 0 Z Location 0 so that’s basically going to draw a line That’s 10 over on the X-axis and 0 on the Y-axis so right along the x-axis, it’s going to move 10 positions over at the Z-axis. It’s not going to move up at all, and it’s going to do it. At 300 millimeters per minute, so f 300 means move at 300 millimeters per minute and over that distance, it’s going to extrude point 0 4 millimeters of filament, So you’ve just seen all of the magic of G code. You’re at a given point, you tell the printer to move to another point and extrude some plastic. If you extrude more prep plastic, your line is going to be thicker and wider. If you extrude less plastic, your line will potentially be thinner. You’re going to do that over and over again, then you’re going to move up your z-axi’s. So for the next line matter, it may be instead of Z 0 You’re gonna be at Z 0.20 now? I want to actually correct something I said here. The first layer is really not extruded at 0 because there’d be no place for the filament to go. So if you have a point 2 O layer height that first layer will start at Point 2 O. Now, let’s look at the various classes of commands. Here’s some simple commands, G 0 and G 1 or commands to make a movement to move the printhead, ZG0 says. Move there as fast as you can. G 1 says that you should move there linearly. G 1 is optimized for precision G. 0 Depending on your firmware is optimized for speed in many FDM printers, There’s no difference between is G 0 and a G 1 most of the G code I see, produced from Slicers, uses a g1 for everything g29 and we’re gonna show you how that works in a minute says to your printer. If you have an auto bed Leveling system probe the bed, calculate the height at each position on the bed, g28 says. Move to the home position, zero zero zero, or, in some cases X and Y 0 0 but Z, wherever you’re currently at, there are N commands and commands really talk to the firmware versus the printer, so m117 says put a message on the LCD. If there’s an LCD in the printer, G 90 91 and 92 are used to set the printer into either absolute tower relative mode and then set an initial position a starting point so as an example, relative mode says. When I give you a movement, add that amount of movement to the current position, absolute mode says that go to this point in this for three-dimensional space, depending on your slicer and your printer. You could be using either. Slicers originally only generally supported one or the other many slicers support. Both today M5o 3 in General, The m500 series of Commands 500 501 502 503 They control the defaults. The parameter stored in your printer and then the M 104 and the m4 140 commands are examples of commands that control the temperature of the extruder, the hot end and the temperature of the print bed. Okay, now let’s look at some g code together and walk through it to get an idea. This is G co that sent over you printer by the slicer before reprint and this is typical of the types of things that are done. So the end sent 117 command at the beginning puts a message on the LCD panel. Then it resets the extruder’s distance to zero so that the printer all future print commands will be relative that to that zero. It hones all the axes. It resets the extruder again. That’s sort of redundant, and then it’s going to move the z-axi’s up a little bit at 3,000 millimeters per minute now. Why is it going to do that? Well, it’s gonna move the printhead around in order to prime the nozzle priming. The nozzle is where you extrude some filament away from your print so that you can make sure it’s flowing smoothly and we don’t want to scratch to the print bed. We’re removing a nozzle around, so g1 says, move the nozzle to one millimeter above the print bet, and then the next g1 says go basically to the origin that would be just a little bit off the bottom right hand corner if you’re on a Cartesian printer and this was for a Cartesian printer and then move to Y 20 and a height of three tenths of a millimeter above the print bed, and that’s the start position for a line, then you’ll see on the next g1 command. There’s an e 15 that says extrude 15 millimeters of filament, so the next move is going to move the Y. The printhead along the Y axis another 80 millimeters from 20 to 100 also 0.3 millimeters above the printhead that would be like a point 3 millimeter layer height, extruding 15 millimeters of filament. That’s gonna draw a line, so that’s what’s called the waste line or the index line and it’s used to make sure once again the filament is moving. We move a little bit over. We draw a second line. Then we reset the extruder to zero. So the slicer has a starting point. We move the z-axi’s up a little bit and we’re ready for our print now. If you really want to learn about g-code, the best way is to connect a printer, either over Wi-Fi or directly to your computer and send it some commands to see what happens. So we’re going to show you both ways first. I mean, I have this printer plugged into a USB port on this computer, and I’m going to run. A program called manner control. By matter. Hackers matter controls a very nice terminal interface. It has one limitation. I’m going to point out, which is why I’m going to use another program for our examples. So let me switch here to matter control. I’m already connected to this printer, and if we go to our terminal panel here, you’ll see these numbers scrolling up the screen. Well, by default matter control is sending a message to the printer. AG code and the G code. It’s sending we can actually look at that, so we can say show us that is an. Em 105 See the EM 105 s here. It’s sending an EM 105 that says to the printer about once a second, tell me the temperature of the extruder and the bed, and how many extruders you have on this printer. Well, we’re gonna turn off seeing the temperature requests, and we’re going to scroll down a little bit and we can see that we have the ability here to enter command, so I’m going to enter An M 503 and 503 is a command that says to the printer. Tell me what your stored values are. I’m gonna say sent now because this is continuing to scroll. I have to actually sort of freeze. This it’s a little tricky to do here. You have to get to the spot you want and then we’ll see that. I sent the 5:03 command and then here are the results that came back from the printer. Now this is connected to a Delta printer, so the origin is in the middle and so there are some special values because it’s a delta printer because of the scrolling temperature, and there might be a way that I haven’t found out how to turn that off on matter control. We’re going to actually connect this printer a different way. We’re going to connect it to an Octa print box. Octoprint is a program that runs on a Raspberry. Pi can run another computers. Also, this is running on a Raspberry. Pi, that’s about a $60 computer with the case in the power supply, maybe $65 Then it’s a really easy way to add. Wi-fi it to any printer. So I’m going to take and disconnect the printer here. I’m actually gonna turn it off for a moment here. I’m going to connect my octoprin’t box to this printer, and now we will power it back on. I’ll close this window and I’m going to go to my active print window and say connect. So now we’re connected to this printer. / Octopus, print and octoprint also has a terminal window and we can see here in the terminal window that are connected to the monoprice printer mono prices printer. This particular printer is made by a company called Maya Yan, which you can see here in the firmware connection. There’s a very nice feature here to suppress temperature messages, and that’ll make it much easier to see things. So if we did the M 503 command again and we did a send, we’ll see here all our values and we can easily scroll through and take a look at those. Now let’s actually make this printer move. We’re gonna start with a G 28 command. A G 28 command will home the printer on this printer. It will move it to sort of this. Center top position. Isn’t this fun to watch this printer? So we just did that If there had been a g28 command on an SD card that was loaded into the printer and we said print, that’s exactly what would happen now. We’re gonna send the command to the printer to check If the print bed is level on this printer, It doesn’t a very interesting way. You might be able to hear these clicks. It actually causes the printhead to touch the print bed and trigger a micro switch, so it knows the distance where it hits in multiple places on the printer, so the command for that is g29 and then you do with this printer have to tell it what the standard height differences – between the response of the switch and the actual printhead. I’m gonna tell its point. 0 4 millimeters. So let’s go ahead and watch this. Do the auto bed level. So it’s going to go down. Go over to the corner’s 3 locations. I believe I remember and it’s going to check those three locations. So when you see your printer, do an auto bed level check at the beginning of a print. That’s because your g-code file has a g29 command in it and we can see here. Here are the offsets for the three positions from those tests because in each position it showed us what the offsets were. Now, let’s say we want to move to a particular position. Well, first, we’re going to do a G 90 that says, put this printer in absolute mode, so I can tell it exactly where to go, and we see here that that completed correctly. Then I can say G 1 Move the printer to X 0 y 10 at a speed of three thousand millimeters per minute. Let’s go now, it didn’t move it down at all. That’s because I didn’t give it A Z height. I can say set the Z height to Z 0.2 Oh, so point two millimeters above the printbed because I’d be using a point, Two millimeter print layer height And now we’re already that if I go ahead and do a Z one and let’s now move it to Y 100 same X position, and I’ll set an e zero point one. Oh, that would say now. Draw a line from where it’s currently out at to the Y 100 position, extruding 0.10 millimeters of filament. Now there’s no filament loaded in this printer, but there’s not a filament sensor on this printer here, so it’s not going to know it. This command will still work fine. Whoops, what happened there well? This printer only has 120 millimeter print bed, and so it started in the middle. So I only had 60 to go. I moved it too far. Okay, powered cycle. The printer, ivory leveled the print bed. I reef honed it to the center and now we’re gonna try that command again and this time I won’t drive the printhead off the surface, so we’re gonna do a g1 Y 20 this time, we’ll make it. Y 30 extruding 0.5 millimeters of filament. And that’s exactly how would work so theoretically. You could sit here at the computer, and you could draw things on your 3d printer. It’s very much like turtle graphic, and in fact, that might be an interesting way to teach children a bit of geometry. Well, folks. I hope you learned something today. I did don’t try to send the printhead further than your print bed. Fortunately, there’s a very inexpensive printer. It didn’t break anyways, but you can do damage if you’re not careful and more importantly. I hope you learned a little bit about G code. What it is how it’s used to control the printer. And now when you look in your slicer and you see the G code before a print and the G code after a print, you can interpret it yourself. If you want to learn more about G code, just go into Google and type G code, and you’ll see lots of sources for it. If you type Marlin G code, you’ll see the G code for most consumer grade home based 3d printers. Thanks again. Please give me a thumbs up. If you found this interesting useful. Share this video with everyone, You know, recommend it to folks and subscribe to the Channel. Don’t forget to hit the bell, so learn about new videos as they’re published and leave me comments so we can continue to learn things together.