[Solved] Issue with Pause / Resume gcode scripts

What is the problem? Pause works just fine (code below), but upon resume, the print head moves back into position and then the extruder pumps out a bunch of mat'l for no reason.

It's almost like the printer is trying to "undo" the G1 E-80 F1000 move on its own. By the way, my printer is a Delta (SeeMeCNC RoStock v2). Octoprint 1.4.0 running on OctoPi 0.17.0

What did you already try to solve it? I removed all 'resume' gcode.

Here is the custom gcode script in the 'after print job is paused'

G91 ; Relative movement
G1 Z5 ; Move head away vertically
G1 E-6 F1000; Retraction move, take away filament pressure
G90 ; Absolute position ON
G1 Y-100 ; Move to front position
G91; Relative movement
G1 E-80 F1000; retract filament into bowden for easier swap
G90; Absolute position ON

Here is the 'Before print job is resumed' (Nothing)

Terminal commands just prior to the pause event

Send: N2879 G1 X10.817 Y5.078 E266.01017*102
Recv: ok
Send: N2880 G1 X10.423 Y5.844 E266.0645*92
Changing monitoring state from "Printing" to "Pausing"
Recv: ok
Send: N2881 G1 X9.964 Y6.595 E266.12003*94
Recv: ok
Send: N2882 G1 X9.466 Y7.293 E266.17411*80
Recv: ok
Send: N2883 M400*22
Recv: ok
Send: N2884 M114*17
Recv: ok
Recv: ok
Recv: X:9.47 Y:7.29 Z:2.900 E:266.1688
Send: N2885 M105*16
Recv: ok
Send: N2886 G91*37
Recv: T:205.36 /205 B:59.75 /60 B@:106 @:91
Recv: ok
Send: N2887 G1 Z5*82
Recv: ok
Send: N2888 G1 E-6 F1000*11
Recv: ok
Send: N2889 G90*43
Recv: ok
Send: N2890 G1 Y-100*126
Recv: ok
Send: N2891 G91*35
Recv: ok
Send: N2892 G1 E-80 F1500*59
Recv: ok
Send: N2893 G90*32
Recv: ok
Changing monitoring state from "Pausing" to "Paused"
Recv: wait
Recv: wait
Recv: wait
Recv: wait

Terminal command after resume

Recv: wait
Recv: wait
Changing monitoring state from "Paused" to "Resuming"
Changing monitoring state from "Resuming" to "Printing"
Send: N6781 G0 F3600 X-2.776 Y8.536 Z6.6*6
Recv: ok
Send: N6782 G1 F600 Z5.6*20
Recv: ok
Send: N6783 G1 F2700 E553.84918*53
Recv: ok
Send: N6784 G1 X-1.972 Y9.34 E553.92091*65
Recv: ok
Send: N6785 G0 F3600 X-1.972 Y10.047*101
Recv: ok
Send: N6786 G1 F2700 X-3.953 Y8.067 E554.09759*16
Recv: ok
Send: N6787 G1 X-4.041 Y7.979*59
Recv: ok
Send: N6788 G1 F2700 E551.09759*50
Recv: ok
Send: N6789 G1 F600 Z6.6*28
Recv: ok
Send: N6790 G0 F3600 X1.837 Y-8.581 Z6.6*3
Recv: ok
Send: N6791 M106 S255*92
Recv: ok
Recv: Fanspeed:255
Send: N6792 G0 X1.837 Y-8.581 Z6.9*109
Recv: ok
Send: N6793 G1 F600 Z5.9*27
Recv: ok
Send: N6794 G1 F2700 E554.09759*58
Recv: ok
Send: N6795 G1 F835.5 X2.56 Y-8.392 E554.14473*1
Recv: ok
Send: N6796 G1 X3.275 Y-8.141 E554.19253*118
Recv: ok

octoprint.log (32.6 KB)

I guess you need to learn about absolute versus absolute mode for the stepper motors. Note how you've retracted 80mm of filament but I'm guessing that for the extruder you're still in the absolute mode. So you've added negative 80 to the extruder's audit. Then when you start up the job again it likely spits out 80mm worth of filament before continuing, right?

In your pause script, you might try sandwiching that retraction command with these two:
Set extruder to relative mode
Set extruder to absolute mode

Note that in the descriptions of Marlin's G90 and G91 there's an exception for E if M82 or M83 have been used. My guess is that your start gcode has a M82 in it.

You are changing the extruder "position" in the pause script so you must compensate for that in the resume script. If this pause and resume is to change the filament, then you probably want to set the E position manually (G92 E). Take a look at https://docs.octoprint.org/en/master/features/gcode_scripts.html for variables and examples to accomplish this.

An alternative would be to use the M600 (and M603) commands if your firmware supports them.

Excellent info. Thank you both. I'm going to dig in and try some of these solutions right now.

b-morgan, Your link helped the most and your description was spot on. Both replies helped me understand what is really happening with the positioning and gcode statements (still a greenie-novice for sure).

The gcode link actually had some good examples of pause/resume and storing/recalling the last position of the XYZ & the Extruder. This was what I wound up with in the 'Before print job is resumed' script area:

M82 ; Absolute the Extruder
G90 ; absolute the xyz
; Reset extruder
G92 E{{ pause_position.e }}
; Relocate to the xyz
G1 X{{ pause_position.x }} Y{{ pause_position.y }} Z{{ pause_position.z }} F4500

Now I can print multi-color objects... Like this test cone.. Thank you so much...