Octoprint GCODE script for job cancellation sidekick 747

So I either setup octoprint wrong–and that is a real possibility–or it is potentially dangerous for new users. I paused a print job, lifted the nozzel 10 mm, moved the bed home, and then after inspecting my print, cancelled a print job via octoprint.

It dropped the hot nozel on the black bed holder on the left corner my bed. Fortunately it didn’t seem to do any damage this time other than melt part of the holder, but next time I can see the potential of damage.

I think I need to update my GCODE script for “After print job is cancelled” in octoprint. Write now it is:

; disable motors
M84

;disable all heaters
{% snippet 'disable_hotends' %}
{% snippet 'disable_bed' %}
;disable fan
M106 S0

My script for “After print job is paused” is empty.

Where would I find out what gcodes to send in these two scenerios (pausing, cancellation, resuming, etc.

And / or is this something I can have cura do for me automatically? (Note, however, I am thinking about switching from Cura because it is not quite doing some of the things I need it to do…so maybe octoprint settings would be better?)

Currently, in cura for my printer I have the following start code:


; Script based on an original created by tjjfvi (https://github.com/tjjfvi)
; An up-to-date version of the tjjfvi's original script can be found
; here:  https://csi.t6.fyi/
; Note - This script will not work in Cura V4.2 and above!
; max_feedrate_z_override = {max_feedrate_z_override}
; retraction_amount = {retraction_amount}
; retraction_hop = {retraction_hop}
; retraction_hop_enabled = {retraction_hop_enabled}
; retraction_prime_speed = {retraction_prime_speed}
; retraction_retract_speed = {retraction_retract_speed}
; retraction_speed = {retraction_speed}
; speed_travel = {speed_travel}
; retraction_enable = {retraction_enable}
; layer_height = {layer_height}
; smooth_spiralized_contours = {smooth_spiralized_contours}


;This G-Code has been generated specifically for the LulzBot Sidekick with a Universal Tool Head
G90 			            ; absolute coordinate
M82     	            	; set extruder to absolute mode
G92 E0     					; set extruder position to 0
M117 Heating...         	; progress indicator message on LCD
M109 R{material_soften_temperature} ; soften filament before homing Z
G28 ; Home all axis
G1 E-15 F100 ; retract filament
M140 S{material_bed_temperature_layer_0}     	; start bed heating up
M104 S{material_probe_temperature}     	        ; start extruder heating to probe temp
M190 S{material_bed_temperature_layer_0}     	; wait for bed to reach printing temp
G29     					; start auto leveling
G0 X0 Y0 F5000
M109 R{material_print_temperature_layer_0}     	; wait for extruder to reach initial printing temp
M117 SideKick Printing...   ; progress indicator message on LCD
G1 Z2 E0 F75 ; prime tiny bit of filament into the nozzle

Does anybody know where I can find, or can they share their octoprint Gcode scripts for the sidekick 747 with the M175 V2 head?

Okay, poking around cura some more (Lulzbot edition) I noticed a partially hiden “End Gcode” script:

;This G-Code has been generated specifically for the LulzBot Sidekick with a Universal Tool Head
M400                                      ; wait for moves to finish
M140 S{material_part_removal_temperature} ; start bed cooling
M104 S0                                   ; disable hotend
M107                                      ; disable fans
G92 E5                                    ; set extruder to 5mm for retract on print end
M117 Cooling please wait                  ; progress indicator message on LCD
G1 Y-10 Z251.3 E0 F3000                ; move to cooling position
G1 E5                                     ; re-prime extruder
M190 R{material_part_removal_temperature} ; wait for bed to cool down to removal temp
G27                            ; present finished print
M140 S{material_keep_part_removal_temperature_t}; keep temperature or cool down
M77					                      ; End GLCD Print Timer
G90                                       ; absolute positioning
M18 X E				                  	  ; turn off x and e axis
M117 Print Complete.                      ; print complete message

I wonder if this would be okay for the print cancellation gcode script in octoprint?

You can see the start and end code for any Lulzbot printer you have set up in Cura LE by going to Settings/Printer/Manage Printers, and clicking the “Machine Settings” button.

I know very little about Octoprint, but you can probably almost cut and paste it into octoprint, but you’ll have to do something with those variables that appear between curly braces like “{material_part_removal_temperature}.”

1 Like

Thanks, I happened to just notice that coincidentally. However there is no pause or cancel code. I wonder how I can get that out of the gLCD controller to put it into octoprint. When I pause or cancel when not using octoprint, using the gLCD, I don’t think I had this problem.

The gLCD is just a display for what the controller is doing. If you wanted to see exactly what happens when you pick pause or cancel from the gLCD you’d have to dive into the Marlin firmware source code for the menu structure.

1 Like

Interesting…I would have guessed the gLCD sends gcodes…I’ll keep poking around then.

@cdsmith
Okay, I am going through the firmware. I had thought the gLCD was just another host…but based on what you say, and some of the code, it looks like marlin firmware controls the gLCD too?

If that is the case, I still don’t see anything about canceling a print job. I see code for canceling an object but that looks it is for scenerios when you are printing multiple objects, one of them fails, and you want to keep going.

Do you have any additional clues?

I also see M25 for pausing an SD print, but nothing that is letting me know what I should include in my after print job in cancelled? The following–the last time I tried it, resulted in a hot end dropping straight down while it was still hot.

image

Okay, I found this code (which I have not tested):

G91; Set to Relative position
G1 E-6 F300; retract the filament a bit before lifting the nozzle
G0 Z50; move z axis up 50
G1 Y150 F5000; move part out for inspection

from this post dated about 4 years ago Octoprint Filament Runout Sensor - #16 by eobie

I’m not sure why the mix of G0 and G1 commands after reading this: Linear Move | Marlin Firmware

Which says “Keep using G0 for non-print moves. It makes G-code more adaptable to lasers, engravers, etc.” maybe it is a don’t care in the context of octoprint?

Ah, I found similar code at the end of an output gcode…I’m now starting to think (out loud here) that I could use this:

;This G-Code has been generated specifically for the LulzBot Sidekick with a Universal Tool Head
M400                                      ; wait for moves to finish
M140 S60.0 ; start bed cooling
M104 S0                                   ; disable hotend
M107                                      ; disable fans
G92 E5                                    ; set extruder to 5mm for retract on print end
M117 Cooling please wait                  ; progress indicator message on LCD
G1 Y-10 Z251.3 E0 F3000                ; move to cooling position
G1 E5                                     ; re-prime extruder
M190 R60.0 ; wait for bed to cool down to removal temp
G27                            ; present finished print
M140 S60.0; keep temperature or cool down
M77					                      ; End GLCD Print Timer
G90                                       ; absolute positioning
M18 X E				                  	  ; turn off x and e axis
;M117 Print Complete.                      ; print complete message
M117 Print Cancelled.                      ; print complete message
M82 ;absolute extrusion mode
M104 S0 ; not sure why this is necessary again, but it doesn't seem like it would hurt anything

Thanks @cdsmith, I think I will test it out tomorrow…

I was looking through the firmware a bit last night trying to figure out how the menu structure works and I got lost real fast. I know I’ve looked at that code before but I don’t remember how it worked.

The key with the Sidekick is that it doesn’t have lead screws or geared Z motors, or a z-brake like the Mini 2, so there is nothing to hold up the Z axis if the Z motors lose power.

There’s two things that are done about that. The abort code can move the Z axis all the way to the top of travel and the magnets in the top should hold the Z axis from falling. Or your abort code can move the Z axis up and disable all but the Z motors, and leave the Z motors on with a small amount of current to support the Z axis. I think that line that says “;move to cooling position” is meant to move the Z axis up to the magnets.

The difference between using G0 and G1 is that G0 is used for movements that aren’t extruding, so the printer can move faster between points and not worry about accuracy of the movement, other than hitting the end point. This can make prints faster if your printer supports the difference because it will know the G0 moves don’t need to be slow and accurate but the G1 moves do need to be accurate. I don’t know if Lulzbot printers actually handle G0 and G1 differently.

I think you are on the right track with using that block of end code.

1 Like

This seems to work, other than some anomolies with the messages…

; This G-Code was adapted from gcode generated by Cura
; specifically for the LulzBot Sidekick with a Universal Tool Head
M117 Cancelled via octoprint, cooling please wait   ; progress indicator message on LCD
; However, the above message only presents briefly...then reverts to 
; "Printing...".  Even so, the script seems to work and the print is ultimately cancelled
; in a manner that seems safe after a couple of tests
M140 S60.0                                          ; start bed cooling
M104 S0                                             ; disable hotend
M107                                                ; disable fans
G92 E5                                              ; set extruder to 5mm for retract on print end
G1 Y-10 Z251.3 E0 F3000                             ; move to cooling position
G1 E5                                               ; re-prime extruder
M190 R60.0                                          ; wait for bed to cool down to removal temp
G27                                                 ; present finished print
M140 S60.0                                          ; keep temperature or cool down
G90                                                 ; absolute positioning
M18 X E                                             ; turn off x and e axis
M77                                                 ; Stop GLCD Print job Timer
M117 Print Cancelled.  Safe to remove               ; print complete message
M82 ;absolute extrusion mode
M104 S0 ; disable hotend (again?)
M106 S0 ; disable fan

EDITED to move the final M117 after M77