You might have noticed the start and end gcode options there are in the various slicers/gcode generators, but are those gcodes any good?
Here I will share the gcodes I use for every print I do with Slic3r.
M106 S0 ; Make sure fan is stopped
M104 S0 ;Cancel the M104 set by Slic3r
M140 S[bed_temperature] ;Start heating the bed up
G00 X-200 F10000
G00 Y-200 F10000
G28 X Y; home x and y
G28 Z; home z
M84 ;Disable all steppers
M84 S30 ;Set stepper timeout to 30 seconds
M190 S[bed_temperature] ;Set bed temperature and wait
As you can see, I start by turning the hotend off with M104, I do this because Slic3r puts it in before the start gcode, in which I heat the bed up. The bed can easily take 15 minutes to reach 110c, and some even report it to take around 30 minutes, and I don’t want my hotend to be at 240 degrees c while the bed is heating up… But the first ting after turning the hotend off again, I turn the heated bed on, because I will need to get that up to the right temperature before I can start printing. After that I move X Y and X to -200. The reason for -200 is that my printer can do about 200x200x115mm, and I want it to get to the end stop switch fairly fast, but without going full speed at it, so that’s why I use F10000. When all axis are resting at the homing switch, I do a G28 to make them all home properly, followed by lifting the hot-end 3mm over the bed. I then use M84 to disable all steppers, because there can be some time before they are going to move again. Right after disabling the steppers, I set a 30 second timeout, just in case something happens during the print, or if I stop it and forget to disabling after doing so.
The printer is now more or less ready to print, except the bed has only got a few degrees up, so I use M190 to set the temperature for the heated bed, but this time it will wait for the bed to reach that temperature.
After reaching the 100c set with M190, I set a new temperature at 110c, but this time I allow it to continue, because it can already start printing with the bed at 100c, and because Slic3r inserts an M109 which sets the temperature on the hot-end, and waits for it to get there too. By the time my hot-end reaches the set temperature, the heated bed is up to 105-107 degrees, which is just fine for my printer to print ABS on.
Everything is now ready, and the printer will start printing.
As you might have noticed, there are no code here which sets the temperature for the hotend, this is because Slic3r sets the temperature with M109 right after the start gcode.
In the end of the generated gcode, this gcode will be inserted.
M140 S0 ;Turn heated bed off
M104 S0 ;Turn nozzle heat off
G91 ;Make coordinates relative
G0 Z2 E-2 ;Move up 2mm and retract extuder 2mm at 400mm/min
G90 ;Use absolute coordinates again
G00 X100 Y200 F10000 ;Go to dump area
M84 ;Disable steppers so they dont get hot during idling...
M84 S0 ;Cancel the timeout set by the start gcode
The first thing I want to do here, is to turn the heaters off.
After that I want be sure the hot-end is free of the part, so I use G91 to switch to relative coordinates, which means it will move the set amount, and not to the absolute position. While lifting I also retract the filament 2mm from the hot-end so it wont leak out while it is cooling down.
When this is done I switch back to absolute coordinates and moves the printer to X100 Y200, so the bed is as close to me as possible.
Only thing left to do is to switch the steppers off again, and cancel the timeout that was set in the start gcode.
But why do all this, when many do it manually?
The reason for that is that I am lazy, and in my head this is a machine that can help me make my life easier. All I want to do, is to design the part, run it through a program that generates the gcode, load that gcode into my host software, and then press PRINT. And this is all I do. I don’t have to prime the hot-end before printing, I don’t have to home anything, all I do, is to hit print, and I can then go do something else, and when I get back, there will be a finished part on the print bed, and the printer will be ready for the next thing my mind can come up with.
I hope this inspired you to make your printer easier to use, and makes you do less work for each thing you print! 🙂