G-code snippets for pause/resume - filament not extruded after resume

I asked about this on the Prusa forums but got no replies so I'm also trying here:

I am trying to use octoprint's "@pause" dummy gcode. In PrusaSlicer I use the "custom g-code" at-layer feature to insert @pause. That does pause the print, and I can resume it through octoprint's web UI.

With just the @pause command, the problem is that the hot nozzle stays in place and melts whatever area of the print it's at.

So now I am trying to add two G-code snippets in octoprint's "after pause" and "after resume" scripts. I found a starting point in octoprint's docs here:

https://docs.octoprint.org/en/master/features/gcode_scripts.html#more-nifty-pause-and-resume

Using those, the behavior is improved, the nozzle moves away from the print and to a location that lets me access the print area to insert things.

However I have two remaining problems:

1.) When the printer pauses and the nozzle moves up, it leaves behind a vertical strand of melted filament. I have to cut that off with a side-cutter. I thought the retraction for the E axis would prevent that.

2.) More importantly, when the print resumes, it seems that no filament is extruded. It just goes through the motions but no more filament is built up.

I previously (before using octoprint) used a manual filament change event instead of pause, and I did not have either of these issues, so I know the printer is capable of cleanly pausing and resuming the print, given the right g-code.

I tried various changes to the snippet, for example I tried to add a few mm more extrusion at resume than retraction at the pause (with a dwell and manual cleanup of the resulting gunk at the nozzle after the extrusion) to make sure the filament is really at the tip of the nozzle.

I tried to capture the issues in a video (sorry for the quality):

You can hopefully see that no filament is extruded when it resumes. Ignore the fact that it's a bit messy because I didn't clean the nozzle this time and cut off the extra vertical strand, I did that in other attempts and it made no difference. The main problem is that the nozzle doesn't seem to be extruding filament after the resume.

I wonder if anybody has experience with this and can help me come up with some g-code that does the right thing.

In this case, a picture is NOT worth a thousand words.

Rather than make us guess (most likely incorrectly), please provide the gcode snippets you are using and a sample gcode file that contains the pause (something simple like a 2x2x2mm cube with a pause at Z=1mm). Enable the OctoPrint serial.log, print the above file, and provide the log here.

1 Like

Thanks Brad, following this suggestion I created a test model, 0.8m high, sliced to four 0.2mm layers in PrusaSlicer. The @pause occurs between layers 2 and 3 (i.e. at 0.4mm).

Attached here is the gcode file I loaded into Octoprint as well as the log files.

For this test, I reverted the pause/resume gcode snippets back to the ones from the documentation:

https://docs.octoprint.org/en/master/features/gcode_scripts.html#more-nifty-pause-and-resume

serial.log (163.2 KB) octoprint.log (13.7 KB) pause test_0.2mm_PLA_MINI_2m.gcode (37.4 KB)

As I suspected, the gcode produced by the slicer uses M83 ; extruder relative mode and the pause and resume snippets contain:

; absolute E
M82

which leaves the extruder in the wrong mode when the object gcode resumes. Remove the M82 commands from the snippets and things should work better.

Thanks again Brad, very interesting. I removed them and did a quick test, unfortunately the result was the same. I'll keep experimenting a bit more like I did initially, but this time with the M82 instructions removed.

Just curious if you found a solution to this @liyanage? I have the exact same problem. Thanks so much.

Ok. I changed M82 to M83, and while it doesn't quite make sense in my head, it seems to work after a few tests. I know that switches it to relative E but I don't quite understand how it works. I'll update this if anything changes on my end.

Absolute vs. Relative is fairly easy to understand with coordinates. Move to X=100, Y=100 absolute is a fixed location on the bed. Move X=100, y=100 relative says move 100 units in X and 100 units in Y.

The same applies to the extruder. If the extruder has extruded 100mm of filament, E110 in absolute mode says extrude 10mm more. E10 in relative mode would do the same.

Some slicers use absolute E and some use relative E (and some have an option to do either). G-code snippets for pause and resume almost always use relative movements, but you have to know what mode the slicer is using so you can restore that mode when you are done.

Unfortunately, Marlin doesn't have a command to save the current mode nor does it have a command to restore a saved mode so you have to know what the slicer is using.

2 Likes

I was reading in another thread that some older printers don't like relative ... not the case with me as I'm using a Prusa i3 MkII... a lot of the code you'll find on the interwebs will lean towards absolute for general compatibility. So maybe that one wee change really did the trick. I'm in the middle of a long print now...about to split my office, so I'll pause and manually turn off the heaters and fan before I go. We'll see if she works on the morrow. Thanks!

I believe (but would have to verify) that PrusaSlicer uses relative E. You could check by opening the gcode file, if the E number is not increasing then it is relative. Scroll all the way to the bottom of the print, if the E numbers are still low it is definitely relative.

Indeed, it is relative. I was able to print my 14 hour print with a break in-between. It wasn't perfect, but the issues had nothing to do with the above problem. The second session was just a wee bit off from the day before (admittedly my studio went from very warm to very cool overnight, which I think may be the culprit.). That may be another thread one day haha.

Thanks so much for your help.

The temperature changes probably caused some things to expand/contract, and change shape slightly. That's just physics, not sure there's a lot you can do there.

1 Like

Yeah, I figured that as well. If I was printing in PLA I would have been more apt to just let it go all night... for some reason (even though I know it's probably not a big difference) since I was printing a little hotter using PETG... I didn't feel comfortable letting it go all night in the office with me two blocks away... :slight_smile:

1 Like

When looking up the different gcode-commands i found out, that some printers interpret G90 and G91 as relative/absolute settings for both XYZ and E (see here). This is why my Prusa MINI+ kept not extruding after resuming.

This is the code that works fine for me:

GCODE after pausing:

{% if pause_position.x is not none %}
; relative XYZE
G91
M83

; retract filament, move Z slightly upwards
G1 E-30 F10000
G1 Z+30 F4500

; absolute XYZE, switch E back to relative
G90
M83

; fan off
M107

; move to a safe rest position, adjust as necessary
G1 Y180 X90
{% endif %}

GCODE before resuming:

{% if pause_position.x is not none %}
; relative extruder
M83

; prime nozzle
G1 E20 F4500
G1 E28 F100

; absolute XYZE, switch E back to relative
G90
M83

; fan on
M106 S255

; reset E
G92 E{{ pause_position.e }}

; move back to pause position XYZ
G1 X{{ pause_position.x }} Y{{ pause_position.y }} Z{{ pause_position.z }} F4500

; reset to feed rate before pause if available
{% if pause_position.f is not none %}G1 F{{ pause_position.f }}{% endif %}
{% endif %}

I made it so the printer moves to the very back of the bed and starts extruding a little bit before reaching back to the print. It leaves a filament snake behind that you can easily pull of from the back while printing. But this seems to be the only way to resume the print with a perfect extrusion (no thinner filament extrusion).

How do you APPLY the GCODE after pausing?

  • I tried pasting it into the Octoprint Terminal, but that didn't work.
  • I tried looking for a spot in PrusaSlicer (Printer Settings) to paste the Gcode. But there isn't a spot to pasted code related to pausing.

My environment:

  • Prusa MK3S+
  • PrusaSlicer
  • Octoprint

Thanks!

They go OctoPrint settings -> GCODE Scripts

Perfect. Thank you very much!