nallath/PostProcessingPlugin

PauseAtHeight: E instructions after pause

Opened this issue · 7 comments

Hi,

I don't understand something. I use the PauseAtHeight plugin very often. Here is a sample of what it generates:

G1 F2100 E94.54111
G0 F2400 X154.614 Y82.071
G0 X152.988 Y81.313
G0 X151.244 Y80.741
G0 X149.274 Y80.371
G0 X116.957 Y75.362
G0 X114.566 Y75.211
G0 X113.119 Y75.263
G0 X110.771 Y75.561
G0 X109.369 Y75.885
G0 X107.123 Y76.62
G0 X104.922 Y77.65
G0 X103.746 Y78.347
G0 X94.384 Y85.158
G0 X90.7 Y86.864
G0 X83.301 Y84.582
G0 X81.941 Y84.321
G0 X80.562 Y84.235
G0 X79.184 Y84.321
G0 X72.221 Y85.181
G0 X72.158 Y85.104
;TIME_ELAPSED:57957.372119
;TYPE:CUSTOM
;added code by post processing
;script: PauseAtHeight.py
;current z: 51.580000 
M83
G1 E-30.000000 F1500.000000
G1 Z52.580000 F300
G1 X190.000000 Y190.000000 F9000
M84 E0
M104 S0; standby temperature
M0 ;Do the actual pause
M109 S260; resume temperature
G1 E30.000000 F1500.000000
G1 E100.000000 F199.998000
G1 Z52.580000 F300
G1 X72.158000 Y85.104000 F9000
G1 F9000
M82
G92 E94.541110
;LAYER:166
G0 X72.158 Y85.104 Z51.28
M204 S1000
M205 X10 Y10
;TYPE:WALL-INNER
G1 F900 E6.79673
G1 F600 X72.823 Y84.588 E6.83235
G1 X73.497 Y84.13 E6.86684
G1 X74.226 Y83.7 E6.90266

As you can see before the pause the extruder is set to position 94.54111. During the pause, extruder is set to relative mode, does some stuff, and then reset to absolute mode. Previous position is then restored (G92 E94.541110).

But then, the extruder is set to odd values:

;TYPE:WALL-INNER
G1 F900 E6.79673

It seems after the pause the absolute values are reset.

I'm asking this question as an introduction for a bigger problem: after the pause and after the printhead moves back into position, some material is retracted. I observed that for all my prints. The amount of material retracted varies. I've been chasing this bug for some time now.

The part that the PauseAtHeight script inserted only goes up to the ;LAYER:166 bit though.

It seems like it's working all right for me. Here's a sample of what I get:

G1 X116.3 Y116.3 E454.50718
G0 F7200 X116.1 Y116.3
G0 X115.625 Y115.728
G0 X107.514 Y107.514
;TIME_ELAPSED:375.445383
;TYPE:CUSTOM
;added code by post processing
;script: PauseAtHeight.py
;current z: 5.270000 
;current height: 5.000000 
M83
G1 Z6.270000 F300
G1 X190.000000 Y190.000000 F9000
G1 Z15 F300
M84 E0
M104 S0; standby temperature
M0 ;Do the actual pause
M109 S0; resume temperature
G1 Z6.270000 F300
G1 X107.514000 Y107.514000 F9000
G1 F9000
M82
G92 E454.507180
;LAYER:50
G0 X107.514 Y107.514 Z5.27
;TYPE:FILL
G1 F2418.8 X115.484 Y115.484 E454.90168

@Ghostkeeper Well, it seems all right for me as well, but what I see in real life is different.

The head moves back in position when I resume (right x, y, z), retracts a piece of filament, then start printing.

Also I noted a few things in your Gcode:

G1 Z6.270000 F300
G1 X190.000000 Y190.000000 F9000
G1 Z15 F300

You have two Z movements before pausing, I have one, but that's probably because we don't have the same version of the plugin.

You also didn't put any retraction/extrusion. I retract 30 mm when I pause, and extrude 100 mm before resuming the print.

Also, did you try this Gcode ? Do you see a retraction when the head moves back in position ?

Ah, I think I'm onto something. First, discard my first post. I had a custom version of the pauseAtHeight plugin.

I recently updated to Cura 3, and installed the pauseAtHeight plugin from the master branch of this repo. We should have the same version of the plugin.

Here is a piece of G-code with a pause. Also, I forgot to mention in my first post that I redo one layer after the pause. Very sloppy first post, sorry...

G1 F900 X134.139 Y112.077 E1237.62229
M204 S5000
M205 X30 Y30
G0 F2400 X133.889 Y112.244
G1 F2100 E1229.62229
G0 F2400 X124.83 Y107.697
G0 X121.362 Y107.697
G0 X114.424 Y102.522
G0 X113.678 Y102.27
G0 X101.021 Y98.818
G0 X100.329 Y97.799
G0 X99.534 Y96.862
G0 X98.639 Y96.015
G0 X97.66 Y95.27
G0 X96.605 Y94.636
G0 X95.488 Y94.119
G0 X94.322 Y93.727
G0 X78.934 Y90.239
G0 X78.87 Y90.163
;TIME_ELAPSED:16104.462263
;TYPE:CUSTOM
;added code by post processing
;script: PauseAtHeight.py
;current z: 12.580000 
;current height: 11.050000 
M83
G1 E-30.000000 F1500.000000
G1 Z13.580000 F300
G1 X190.000000 Y190.000000 F9000
G1 Z15 F300
M84 E0
M104 S0; standby temperature
M0 ;Do the actual pause
M109 S260; resume temperature
G1 E30.000000 F1500.000000
G1 E100.000000 F199.998000
G1 E-30.000000 F1500.000000
G1 Z13.580000 F300
G1 X78.870000 Y90.163000 F9000
G1 E30.000000 F1500.000000
G1 F9000
M82
G92 E1229.622290
;LAYER:36
G0 X78.87 Y90.163 Z12.28
M204 S1000
M205 X10 Y10
;TYPE:WALL-INNER
G1 F900 E1090.99439
G1 F600 X80.515 Y88.905 E1091.07619
G1 X82.265 Y87.842 E1091.15707
G1 X84.141 Y86.966 E1091.23886
G1 X86.091 Y86.299 E1091.32027
G1 X88.102 Y85.846 E1091.4017
G1 X90.145 Y85.613 E1091.48293
G1 X92.21 Y85.601 E1091.5645

So in the G-code, I have layer 36, a pause (inserted by the plugin), and layer 36 again (inserted by the plugin).

As you can see, after the pause the plugin set the extruder to absolute mode (M82) and then set the extruder position to 1229.622290 (G92 E1229.622290), which should be the extruder position at the end of layer 36. But then, layer 36 is inserted again, but the position of the extruder is not updated (G1 F900 E1090.99439), it's the same as it was at the beginning of layer 36 the first time. But layer 36 was printed already once.

All this results in what I described previously: when I resume my print, the head moves back into position, retracts (actually the extruder's position is set to a value inferior to what it should be), and then prints again.

Does it make sense ? Am I clear ?

Also, I think there is another bug: the last extruder position before the pause is E1237.62229, but the plugin only restores to G92 E1229.622290

Also, I think there is another bug: the last extruder position before the pause is E1237.62229, but the plugin only restores to G92 E1229.622290

Actually the last extruder position before the pause is E1229.62229 (the fifth line of your quote), so that seems to be correct.

But I see what you mean. It looks like the "Redo Layers" functionality simply copies over the g-code from previous layers without paying attention to the position of the extruder. We should include some trickery with G92 there.

Actually the last extruder position before the pause is E1229.62229 (the fifth line of your quote), so that seems to be correct.

Oh ! I did see that one. Ok cool then, this is fine.

We should include some trickery with G92 there.

What do you think the best way to go is ? I can make a PR. I see in the code of PauseAtHeight.py that we have access to each layer of the gcode:

        for layer in data:

So we can probably increment all the E values of the layers after the pause. It might be resource intensive to do that though, but not sure.

EDIT:
Nah, actually I got what you meant. We just need to G92 at the E value of the beginning of the layer being re-done.

Made a PR: #59

I'll try it when I can at work, but I don't see why it wouldn't work. What do you think @Ghostkeeper ?

I can confirm this fix works in real life. My print resumed, the extruder was in the right position, and the "redo layers: 1" effectively reprinted tha layer before the pause.