Top 10 useful G-Code commands for 3D Printing

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
your 3D printer is dumb I'm sorry but it's true these incredible machines are actually quite basic in that they only follow the commands that we give them they can't think for themselves at least not for now what are these commands called and how can you use them to level up your 3D printing experience well G-Code is one of the oldest programming languages around and this video I'm going to talk about 10 G-Code commands that you really need to know to level up your 3D printing game let's get started how's it going guys Angus here from making smooth so as I mentioned these machines can't think for themselves they can only follow commands that we give them and these days we use slices to convert our 3D geometry into commands that these machines can follow to reproduce our object but what is G-Code what does it look like and how do you understand it now here I have a G-Code file to print out a cube that was sliced in pressure slicer now you send this file to the printer through the micro SD card and then the printer will follow these commands line by line to reproduce your object if you're just looking at this for the first time it may seem daunting and Incredibly confusing and I totally get it I'm not very good at programming but G-Code is actually fundamentally quite simple in that you just need to know what commands you're looking for and then you can actually start to understand what's going on in this file and as I mentioned previously G-Code is actually one of the oldest programming languages around it was created in the 1950s we might be thinking well Angus 3D printers wanted around the 1950s well that's right because G-Code wasn't created for 3D printers specifically it was created originally as a CNC programming language which is computer numerical control the coded numbers which you see here are fed into an electronic device which we call an electronic director the electronic director in turn generates electrical signals which operates Servo mechanisms which in turn controls the Machine Tool so with CNC you can use computers to control machines and this could be a CNC milling machine a CNC lathe a laser cutter or a 3D printer so you can see how G-Code slotted perfectly into the 3D printing ecosystem as it was being developed without G-Code these machines won't do anything they will just sit there idly but if you give them commands that it recognizes it will carry out those commands with the unit that the command dictates and then move on to the next line the next line through the whole file to carry out the operation so if that sounds pretty cool to you might be wondering well how do I send G-Code commands to my 3D printer I don't want to just make custom G-Code files and load them in like a 3D printing file that's too tedious and it absolutely is which is why we can tether 3D printers to our computer or you can send G her commands over Wireless if you're lucky enough to have octoprint or something like Clipper enabled but in this video we're going to keep it basic I'm going to show you how to connect over serial to a 3D printer like this Ender 3 over the USB connection so to do that we need a bit of software called repetio This is repetia now it's not the only software that can connect to a 3D printer over a Serial but it's very old very well established and free so easy to get and it works very well when controlling machines like the sender 3. so to connect over serial you need two things you need the com Port which is the port that it's connected to on the computer so it can figure out what to connect to and you need the board rate which is the transfer speed between the control board and the computer they need to be correct otherwise it won't understand what to connect to and to configure those you go to config and printer settings now figuring out the the com Port is usually pretty easy unless you have lots of things connected over serial to your computer um this is com3 It's the only one that's popping up then board rate figuring that out is a little bit more complicated because it's not usually advertised clearly anywhere you can try searching your 3D printer make and then board rate on Google or something to find out what it is but generally if it's a and a three-ish machine then you want to go with one one five two hundred that's a good starting point if that doesn't work you can try either way above it or below it see what connects but this works fine for my end of three I'm sure it's gonna work fine for yours as well then you click apply and then we're done with that we can actually connect to the machine it's connected up right now it's not powered up you notice that the screen's on but it's actually not powered on that's because it's getting 5 volt power from the computer's USB port to power the control board but obviously you're not gonna be able to 3D print with that now I don't know if this is recommended I usually have the power on while it's connected uh just make sure that it's not trying to drain power from the USB port I don't think that's possible but uh for the purpose of the video because the fans are very loud on this printer I'm just going to have it off for now I'm just going to connect and then you'll see as it connects you'll do a few handshakey things down the bottom here and we are connected so this machine is now connected and you can see it's connected because every second the 3D print is actually feeding back to the computer over serial the state of the hotend and bed temperatures alrighty so we can go over to manual control here and we can start typing out G-Code now there is actually a wonderful interface here to control things directly but you might not have that so for the purpose of this video we're talking about G-Code commands that I recommend you need to know another one by far is g28 homing when you initially turn on these 3D printers they do not know where they are in space these step Motors that they use do not have the ability to remember their positions so what you need to do is home them to a zero position before you can do anything else so this is what it looks like you put in g28 hit enter and then the machine will home itself to all axes but let's just say you don't want to home all axes at once or you can actually specifically home individual axes by simply adding the axi you want to home after g28 so for example we can do g28 x0 now we'll just home our x-axis or if you want to add g28 y 0 that'll harm just y or g28 Z 0 as well g28 is at the basis of all movement when it comes to G-Code commands for your 3D printer so that's why there's no place like g28 next up G1 now G1 is your bog standard movement command G1 is by far the most used command you'll come across when you look at a G-Code file for 3D printing you can see that it's used so much in the file and that's because the machine is moving constantly and every time it moves from one point to another it needs a G1 command G1 is a linear move so what that means is if you're starting at zero because we homed remember zero zero zero on all axes if you decide to send G1 X 100 you'll move linearly to x 100 and from here we could send G1 Y100 and then finally we could send G1 Zed 100 and will move the Gantry up 100 millimeters to be in that position so we are now at 100 100 100 from the origin but what if we entered them all at once so that's home again and then enter G1 X100 Y100 Z100 so what you'll notice is it will linearly move to that new coordinate that's why G1 is a linear movement this is handy because it's the shortest distance it's like as the crow flies from one coordinate to another but this can be an issue imagine you have a file on the build plate and you want to move above it but it's going to move from the bottom uh homing Point diagonally up to whether where it is above the file it might Collide which is why you might have G1 X100 and then move across and that's why I often in start an NG code you'll see G1 movements done in sequence to move the nozzle up out of the way so it doesn't collide with prints before it does anything else and G1 is also really handy if your machine doesn't have a guided bed level routine you can actually disable step Motors and move it around manually if you want to be really precise you can home and then simply enter your movement commands using the G1 command to have powered movements so you know that that Z distance is never moving and get a perfect result every time but of course you can also use the G1 command to move of the extruder as well so let's try that now let's go G1 E100 oh you look at that down there cold Extrusion prevented now that's normally what you'd want because you don't want to try to force filament into an extruder that's not heated up because that's not going to work let's say you're diagnosing something or you're building a printer or you're trying to set your e-steps but it's dangerous to heat up an extruder when you don't really need to so this next command is one that even if you're expensive 3D printing I'm always guarantee you haven't used m302 the M command m302 allows you to enable or disable cold Extrusion prevention so to use it you type in m302 and you set its state so P0 is called Extrusion prevention on which means it won't let you extrude till you heat up to a certain say temperature but m302 P1 will actually disable it which means you can extrude at any temperature even room temperature it doesn't care anymore and it's really good if you're doing some mods or playing around with your e-steps you don't want to worry about heating up your extruder unnecessarily because as that can be dangerous just make sure you turn it back on afterwards now when I discuss G1 I mentioned that it's a linear movement between coordinates what's really important is once you've homed your 3D printer it's running in what's called absolute mode so for example if you move from zero to 100 in the Z Direction then you enter G1 Z100 again it's not going to move at all it's not going to move 100 up I'm not going to move 100 down it's going to stay there to move it again you actually need to give it a whole new coordinate like move it back down to zero and move it up to z200 and by default this applies to the extruder as well which initially I'll be honest confused the heck out of me setting G-Code commands to it and it catches a lot of people off so when you send G1 E100 it'll move 100 millimeters of filament but if you enter the same command again it won't move so of course there's commands to help us overcome that as well and we have two options number one is to reset the extruded position so it thinks it's back at zero using g92 let's say you've moved 100 millimeters of filament and you want to reset it again to zero you just enter g92 e0 and machine will say okay we'll extrude is it zero again so you can do another G1 E100 and we'll just continue on like that or the other option is to set your extruder to relative mode using the M command M83 by doing this it no longer cares if it was at zero or not it will just move forward 100 then move for another 100 back 100 doesn't care this is how I see most 3D printers and slicers handle their extrusions with the rest of the printer in absolute mode but both approaches are valid knowing the command g92 e0 is really handy if you want to just manually send filament or figure out how to figure out your e-steps because it helps you reset back to zero without any faffing about but let's just say you do want to set a different steps per millimeter number for your extruder or XYZ axes multitude you would use M92 so this command lets you set the steps per millimeter if you're running default millimeter units you can configure for inches but I don't really see people doing that so the default is steps per millimeter and using the M92 command you can set your new steps a millimeter and the Machine will take that in and understand it to perform an e-step calibration you mark a reference point between the filament and extruder and then enter G1 E100 to extrude 100 millimeters of filament you can then set your new steps per millimeter number by entering M92 e new steps and hitting enter once you're done be sure to save to eprom with the M500 command all the changes won't be there next time you power up a 3D printer alternatively in repetio you can actually change and save the settings by going to config firmware eprom configuration and changing them here so for example here the e-steps are 93 let's say I wanted to make it 100 that's not correct but for the purpose of the video whatever and I say okay and you can see what that's done in the log here down the bottom that it saved all the commands that were in that list to the 3D printer and if I turn this 3D printer off and then back on these are preserved let's just say you do need to heat up your 3D printer well of course there are commands for that as well but it's really important to note that there's two types of commands one your 3D printer will wait till it reaches the desired temperature before proceeding and two where it will just start heating to that temperature but keep going now it really depends when you'd want to use these for example in your start G-Code if you want to start heating up your extrudux it takes a while to heat up before it starts doing the Homing sequence and everything then you'd use m104 it doesn't matter that it's going to take a while to heat up because by the time it is heated up it's already gone through its movement and you start printing so you save a little bit of time but if you absolutely have to start at that temperature and the machine's not that thing about in the meantime then you absolutely should use M109 where it'll wait till it hits that temperature to start printing and again this is really important for beds as well so beds have their own versions of these commands which is m140 and m190 so again same idea m140 will start heating to a temperature but not weight and m190 will wait till it hits that temperature so for when you're printing stuff like AVS you need that print bed to be at temperature before it starts that first layer otherwise it's probably going to warp up and fail which case you need to make sure it will actually wait to hit that temperature which is why you start G-Code you might want to use that again most slices will do this sort of thing now but it's really important to have this under your tool belt to diagnose things if you want to figure out what's actually going on in your G-Code and how you can change it to your liking using start and NG code scripts and now for the last of the useful G-Code commands I want to talk about is m303 which is PID tuning so PID is essentially figuring out the best profile to run the hotend and bed heaters at to hit temperatures quickly and maintain them evenly without getting weird oscillations where it overshoots and then undershoots and it gets these weird oscillations in temperature which can be really bad PID tuning is trying to smooth that out and figure out the best values to get the heating as as accurately as possible that's as far as I understand PID but that's really is as far as you don't need to understand it as well so to use the command all you have to do is just enter m303 and then let it run its course it takes a little while to heat up and then slowly cool down and it will spit out the p i n d value use which you can just enter into the eprom and then save it and then use them in future prints and while that 3D print is calibrating its PID values let's talk about this video sponsor micro center micro center is your One Stop Shop for all things Tech and they have a huge range of products for makers Micro Center has been sponsoring the channel for a very long time now and they sent across some of their roles of Inland PLA and this silk two-tone pla is gorgeous I printed this off on the end of three and it came out beautifully I just love how it shifts almost like a hologram in the light as you look at it and they have a huge range of different colors to choose from but the number one complaint I hear is that you guys don't have a Micro Center near you well microsetter is opening a brand new store in Indianapolis Indiana on July the 20th which is really exciting with everything they have on offer you could build an entire maker space with just one stop to Micro Center and if you want to pick a random 3 Pro for only 99 bucks then there's a link to the coupon in the description below but do keep in mind it's for new customers in store only now back to the video let's finish up with two G-Code commands that are just fun to use they're not really practical in any way but they're good to know we'll start with m300 M 300 will make the 3D printer beep now you can actually change this that if you get Type M 300 and then p uh let's say 100 it's a little bit if you do m300 P10 it's a really short bip and that little bit may be familiar to any of you have a pressure 3D printer because that's how it's doing that sound so this command is essentially just to turn the Beeper on and off there is also an S command which can change its frequency but it doesn't seem to do anything with the uh Ender 3 so like you know s 200 P 100 it seems to be the same frequency might work in other 3D printers but you can enter this into your G-Code command if you want to make the 3D printer beep at you for example if you wanted to beep halfway through the print to remind you that it's still running you can just enter it in and it'll do it um no problem then finally one more command that's a lot of fun to use is m017 so m double one seven foreign text on your LCD and again you can use this to set halfway through the print you can say okay I'm halfway done or hey don't forget this you know you can put a shopping list in there you can tell it to subscribe to your channel and of course you can combine it with beeping or any other G-Code command because again these are used in combination to make a very very powerful programming language that these 3D printers need to run again they're dumb they're really cool but they're essentially computer controlled hot glue guns they can't think for themselves and they need these commands to work so that's why I reckon it's worth just having a little dive and getting to understand what some of these commands mean and then if you're interested in fine-tuning and troubleshooting your 3D printer connect it to serial and have a play for yourself and of course let me know in the comments below which one you think is the most useful or if there's one that I've missed out that you think oh Angus why didn't you you didn't talk about that one please let me know in the comments below because of course I'm always learning as well because here I'm making smoothies my aim to empower creativity through technology and I look forward to seeing you again very shortly here on Maker's Muse catch you guys bye
Info
Channel: Maker's Muse
Views: 86,559
Rating: undefined out of 5
Keywords: 3d, printing
Id: ePT8iM1ibNs
Channel Id: undefined
Length: 17min 5sec (1025 seconds)
Published: Tue Mar 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.