Dears, allow me to ask for help because I’m unable to solve this by myself.
The problem is quite clear. The command RESTORE_GCODE_STATE does restore the the Z position.
If you look in my configuration I want to use it for the filament runout and there is a M600 macro and it is pretty straightforward:
[gcode_macro M600]
gcode:
{% set X = params.X|default(10)|float %}
{% set Y = params.Y|default(10)|float %}
{% set Z = params.Z|default(10)|float %}
SAVE_GCODE_STATE NAME=M600_state
PAUSE
G91
G1 E-0.8 F2700
G1 Z{Z}
G90
G1 X{X} Y{Y} F3000
G91
G1 E-20 F1000
RESTORE_GCODE_STATE NAME=M600_state
But it does never restore the Z position. It just restores the X and Y position.
I’m using octoprint by the way. And it just shows correctly the pause and continue status.
But I have tested running the RESTORE_GCODE_STATE from the terminal with the same results.
Another minor problem, but maybe related is that if I do extrude from octoprint (for the filament change) then it restores the position at snail pace, in a very very slow way, and again without restoring the Z position.
What can be causing this problem. I cannot find anything related on the web.
If you want to restore the XYZ state then you must use the MOVE=1 parameter - for example, RESTORE_GCODE_STATE NAME=M600_state MOVE=1. See: G-Codes - Klipper documentation .
Thanks for your answer but I already tested the MOVE=1 and it changes nothing. Besides all the examples I find to implement M600 do not include the parameter. For instance:
In my case it is already restoring X and Y. Even without the parameter. By the way, the MOVE_SPEED doesn’t work either.
EDIT:
Apologies, I think I did something wrong when testing this. This is the latest code:
[filament_switch_sensor e0_sensor]
pause_on_runout: True
runout_gcode:
M600; pause macro
switch_pin:^PC2
[pause_resume]
[gcode_macro M600]
gcode:
{% set X = params.X|default(10)|float %}
{% set Y = params.Y|default(10)|float %}
{% set Z = params.Z|default(10)|float %}
SAVE_GCODE_STATE NAME=M600_state
PAUSE
G91
G1 E-0.8 F2700
G1 Z{Z}
G90
G1 X{X} Y{Y} F3000
G91
G1 E-20 F1000
RESTORE_GCODE_STATE NAME=M600_state MOVE=1 MOVE_SPEED=1000
Now it retrieves the correct position but it does it before I unpause the print from octoprint. So it moves away from the print, then returns to the same position and then pauses the print.
Therefore the problem is on the runout routine itself.
Yay, I finally found the problem. TLDR It is because the the resume button in octorprint does not send the command RESUME, and it does leaves the system in an inconsistent status.
Here is the long version:
First I went back to the original code because it was working for everyone:
[filament_switch_sensor e0_sensor]
pause_on_runout: True
runout_gcode:
M600; pause macro
switch_pin:^PC2
######################################################################
# Filament Change
######################################################################
# M600: Filament Change. This macro will pause the printer, move the
# tool to the change position, and retract the filament 50mm. Adjust
# the retraction settings for your own extruder. After filament has
# been changed, the print can be resumed from its previous position
# with the "RESUME" gcode.
[pause_resume]
[gcode_macro M600]
gcode:
{% set X = params.X|default(50)|float %}
{% set Y = params.Y|default(0)|float %}
{% set Z = params.Z|default(10)|float %}
SAVE_GCODE_STATE NAME=M600_state
PAUSE
G91
G1 E-.8 F2700
G1 Z{Z}
G90
G1 X{X} Y{Y} F3000
G91
G1 E-50 F1000
RESTORE_GCODE_STATE NAME=M600_state
Then I started a print and:
1 Trigger the filament sensor.
2 The tool parks as expected.
(optional) I force a extrusion to simulate the load of the filament.
3 Run the RESUME command from terminal.
4 Print resumes and position (including Z) is restored
I can repeat this process as many times as I want and it does work consistently.
Without stopping the print I try to resume from octoprint.
1 Trigger the filament sensor.
2 The tool parks as expected.
3 Click on the resume button in octoprint.
4 Print resumes, restores X and Y but not Z.
Without cancelling the print I try again.
1 Trigger the filament sensor.
2 The tool parks but without pausing it restores de X and Y position (not Z) and continues printing.
I repeat the process and is always the same. The filament sensor does not pauses the print anymore.
Even worse. If I cancel the print and try a new one it behaves the same way. I need to restart the system.