3d Printers G-Code Explored and Explained with Examples

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
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 let's 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 let's 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-axis 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 extruders 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-axis 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-axis 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 octoprint 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 corners 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
Info
Channel: Make With Tech (MakeWithTech)
Views: 61,576
Rating: undefined out of 5
Keywords: 3d printer gcode, mattercontrol, g code 3d printer, gcode, open-source, opensource, Simplify3D, How, G-code, it, works, How does it work, 3Dprinting, 3Dprinter, 3DP, 3D, slicing, slicer, slic3r, 3D-Printing, 3D-printer, 3D printing (innovation), 3Dprint, Screen, 3d printer g code, astroprint, gcode 3d printer, g code for 3d printer, 3d printer code, g code 3d printing, cura, ender 5, monoprice mini delta, prusa ik mk3, 3d print, 3d-printer, how to 3d printer, how do 3d printers work, prusa
Id: cJlre1lEdcQ
Channel Id: undefined
Length: 22min 18sec (1338 seconds)
Published: Sun Nov 03 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.