Ending GCode for Cura

I have spent the last few days fumbling my way around Cura, and setting up an OctoPi. I noticed that when a print finished with OctoPi that the ending sequence differed from printing in Snapmaker. When you print with the Snapmaker software Z access lifts up a bit and then the build plate moved towards the front of the machine allowing for easier access to the print without the need to use the “Jog” function. When a print finishes with Cura/OctoPi the head Just moves back to along the “X” axis to the start position, then the build plate moves along the “Y” axis back away from the user.

GCode as it appears at the end of a print in Snapmaker
;End GCode begin
M104 S0 ;extruder heater off
M140 S0 ;heated bed heater off (if you have it)
G90 ;absolute positioning
G92 E0
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z20 E-1 F{speed_travel} ;move Z up a bit and retract filament even more
G1 X0 F3000 ;move X to min endstops, so the head is out of the way
G1 Y125 F3000 ;so the head is out of the way and Plate is moved forward
M84 ;steppers off
;End GCode end
M104 S0
;End of Gcode

GCode as it appears Snapmaker Manual for Cura settings
M104 S0
M140 S0
;Retract the filament
G92 E1
G1 E-1 F300
G28 X0 Y0
M84
M82 ;absolute extrusion mode
M104 S0
;End of Gcode

As I am just learning to read GCode I can’t see any reason why this wouldn’t work for the end code in Cura/OctoPi. So my question is if I replace the end code will it cause any problems, namely cause damage to the printer?

1 Like

To give you a short answer, YES! Well, maybe…

I’ll explain.
Snapmaker3D outputs an end code that is related to the height of your model. I know from the code you posted that it was taken from a model that is 10mm in height. Snapmaker3D will alter the end code to always clear your model by 10mm in Z, thus the line

If you use this in Cura AND your model is no more than 20mm tall, you will be fine. If you use this end code with a 30mm tall model you will melt your way into your nicely finished model and put a fair amount of stress on your Snapmaker at the same time.

I prefer to move the Z axis to the top of the travel. I also omit the M84 code to turn the steppers off. Leaving the motors on should prevent the dreaded Z axis drop. I have had success so far with this but I can’t speak to any potential unforeseen repercussions. I will post my end code below so that you can try it and see if it works for you.

M104 S0 ;extruder heater off
M140 S0 ;heated bed heater off (if you have it)
G90 ;absolute positioning
G92 E0 ;set extruder to zero
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z125 F3000 ;move Z all the way up
G1 X0 Y125 F3000 ;move X to min endstops, table forward

Here is an alternative that will mimic the Snapmaker3D end code

M104 S0 ;extruder heater off
M140 S0 ;heated bed heater off (if you have it)
G90 ;absolute positioning
G92 E0 ;set extruder to zero
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G92 Z0 ;set Z to zero
G1 Z10 F{speed_travel} ;move Z 10mm from top of print
G1 X0 F3000 ;move X to min endstops, so the head is out of the way
G1 Y125 F3000 ;so the head is out of the way and Plate is moved forward

Finally, this PDF is very useful RepRap Cheat Sheet

4 Likes

Thank you, that makes a lot of sense. Also, thank you for the link to the PDF, I was going through the write-up that All3DP had on their website, but it wasn’t as complete as this PDF. I am going to go home tonight and give your code a try. Thank you again.

I also added a link to their GCODE Wiki in the SnapLinks page.

1 Like
1 Like

And will that work ok if the print is almost as tall at the z-axis travel?
That’s the tricky part.

1 Like

start g-code:
G28 ;Home
G0 X-4 Y-1 F6000
G0 Z0
G92 E0
G1 F200 E20
G92 E0

end g-code:
M104 S0 ;extruder heater off
M140 S0 ;heated bed heater off
G90 ;absolute positioning
G92 E0 ;set extruder to zero
G1 E-1 F300 ;retract the filament a bit
G0 Z125 ;move Z all the way up
G0 X0 Y125 ;move X to min endstops, table forward
G0 Z115 ;10mm from the top becose of reference start sequence
M84

I copied what one of the snapmaker staff put for their Cura gcode end into OctoPrint and I always come back to the print head resting on the print. Kinda annoying.

Try changing the end of the script to:

G91 ; relative positioning
G1 Z10 ; move Z up a bit
G90 ; absolute positioning
G1 X0 F3000 ; move X to min endstops so the head is out of the way
G1 Y125 F3000 ; so the head is out of the way and Plate is moved forward
M84 ; disable motors

Man, I am about to loose my mind with Cura…

I keep putting all the settings in for my filaments and profile settings and it either crashes or does and update and doesn’t keep any settings. So unbelievably frustrating.

The last crash brought me back to having to setup a new printer.

Anyone else have these frustrations?

2 years later but still very relevant. I just came home to a broken 16 hour print because the head didn’t move up far enough. That cheat sheet should be a sticky here somewhere.