Commands continue to be executed after pause

Basic Information:

Printer Model: Delta kossel custom
MCU / Printerboard: MKS Robin nano V3.1
Host / SBC: Raspberry pi 3B
klippy.log

klippy.log (52.4 KB)

Describe your issue:

I’m new to klipper, I’m setting up a macro to change the filament manually on a bowden delta printer. This macro parks the effector, unloads the filament and pauses printing, then when it resumes it should load the filament and continue printing.

the problem is that several commands are executed after the pause. and the real pause is performed later.

the machine performs the pause parking, but does not stop until a few commands later.

i tried putting M400 before and after the pause, i tried G4 after the pause, i tried adding a move command after the pause. always performs the same movements after the pause.

am i doing something wrong? Is this the normal operation of the pause?

I would like the “PAUSE_LOAD_FILAMENT” macro ando other commands to run after the resume and not during the pause procedure.

Forgive my poor English, if you don’t understand I’ll try to explain it better. If anyone can help me I will be very grateful.

[gcode_macro PAUSE_FILAMENT_CHANGE]
gcode:
    {% set X = params.X|default(0)|float %}
    {% set Y = params.Y|default(0)|float %}
    {% set Z = params.Z|default(260)|float %}
    {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(190)|float %}
    SAVE_GCODE_STATE NAME=pause_state
    SET_LED LED=LEDs WHITE=1		# Open leds
    G1 F3000.0 E-3
    G91
    G0 F9000 Z1
    G90
    G0 F12000 X0 Y-110 	            # park the nozzle
    G91
    G0 F9000 Z15		            # too close to bed--move to at least 15mm
    PAUSE_UNLOAD_FILAMENT
    M104 S100		                # standby temperature
    G90
    M83
    M117 Canvi de filament
    # M400                          # Test without effect
    PAUSE                           # theoretical pause
    # M400                          # Test without effect
    # G4 P10000                     # Test without effect
    # G0 Z259 F9000                 # Test without effect
    M109 S{EXTRUDER_TEMP}     		# resume temperature
    PAUSE_LOAD_FILAMENT
    G1 F3000.0 E-3
    # REAL PAUSE in all the different tests
    G0 X0 Y0 F24000
    RESTORE_GCODE_STATE NAME=pause_state
    G1 F3000.0 E3
    SET_LED LED=LEDs WHITE=0		# Close leds
    M117

[gcode_macro PAUSE_UNLOAD_FILAMENT]
gcode:
    M83
    G1 F200
    G1 E3 F200
    G4 P4000
    G1 E15 F1400
    G1 E-25 F7200
    G4 P1000
    G1 E-640 F7200

[gcode_macro PAUSE_LOAD_FILAMENT]
gcode:
    M83
    G1 E580 F7200
    G1 E30 F1000
    G1 E30 F500
    G4 P4000
    G1 E20 F1000
    G4 P4000
    G1 E20 F1000
    G4 P4000
    G1 E20 F1000
    G4 P2000

[gcode_macro PAUSE_END]
gcode:
    G0 Z260 F9000
    # M400                          # Test without effect

[gcode_macro _CLIENT_VARIABLE]
variable_use_custom_pos   : True # use custom park coordinates for x,y [True/False]
variable_custom_park_x    : 0.0   # custom x position; value must be within your defined min and max of X
variable_custom_park_y    : 0.0   # custom y position; value must be within your defined min and max of Y
variable_custom_park_dz   : 0.0   # custom dz value; the value in mm to lift the nozzle when move to park position
variable_retract          : 3.0   # the value to retract while PAUSE
variable_cancel_retract   : 5.0   # the value to retract while CANCEL_PRINT
variable_speed_retract    : 50.0  # retract speed in mm/s
variable_unretract        : 3.0   # the value to unretract while RESUME
variable_speed_unretract  : 50.0  # unretract speed in mm/s
variable_speed_hop        : 50.0  # z move speed in mm/s
variable_speed_move       : 100.0 # move speed in mm/s
variable_park_at_cancel   : True # allow to move the toolhead to park while execute CANCEL_PRINT [True/False]
variable_park_at_cancel_x : 0  # different park position during CANCEL_PRINT [None/Position as Float]; park_at_cancel must be True
variable_park_at_cancel_y : 0  # different park position during CANCEL_PRINT [None/Position as Float]; park_at_cancel must be True
variable_idle_timeout     : 3600  # 1H
variable_user_pause_macro : "PAUSE_END"    # Everything inside the "" will be executed after the klipper base pause (PAUSE_BASE) function
#variable_user_resume_macro: ""    # Everything inside the "" will be executed before the klipper base resume (RESUME_BASE) function
variable_user_cancel_macro: "CANCEL_PRINT_END"    # Everything inside the "" will be executed before the klipper base cancel (CANCEL_PRINT_BASE) function
gcode:

Finally I was able to fix the problem by splitting the macro into two parts, the first that ends with the PAUSE command, and the second with the rest of the commands that go AFTER the PAUSE command.

This way the PAUSE is executed at the desired time without other commands being executed during the pause procedure

[gcode_macro PAUSE_FILAMENT_CHANGE]
gcode:
    {% set X = params.X|default(0)|float %}
    {% set Y = params.Y|default(0)|float %}
    {% set Z = params.Z|default(260)|float %}
    SAVE_GCODE_STATE NAME=pause_state
    SET_PIN PIN=CaseLight VALUE=1	# Encendre leds
    G1 F3000.0 E-3		            # Retracció negativa de 3 mm a 50 mm/s
    G91                             # coordenades relatives
    G0 F9000 Z1		                # move up a millimeter to get out of the way
    G90                             # coordenades absolutes
    G0 F12000 X0 Y-110 	            # park the nozzle
    G91                             # coordenades relatives
    G0 F9000 Z15		            # too close to bed--move to at least 15mm
    PAUSE_UNLOAD_FILAMENT
    M104 S180		                # standby temperature
    G90                             # Use absolute coordinates
    M83			                    # Extrusor en mode relatiu
    M117 Canvi de filament
    PAUSE

[gcode_macro RESUME_FILAMENT_CHANGE]
gcode:
    {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(190)|float %}
    M109 S{EXTRUDER_TEMP}     		# resume temperature
    PAUSE_LOAD_FILAMENT
    G1 F3000.0 E-3		            # retraccio negativa de 3mm a 50 mm/s
    G0 X0 Y0 F24000
    RESTORE_GCODE_STATE NAME=pause_state
    G1 F3000.0 E3		            # Retracció positiva de 3mm a 50 mm/s
    SET_PIN PIN=CaseLight VALUE=0	# Apagar leds
    M117

From the slicer I call the two macros one after the other.

PAUSE_FILAMENT_CHANGE
RESUME_FILAMENT_CHANGE EXTRUDER_TEMP=[nozzle_temperature]

Anyway, I still don’t understand the order and preference of the commands inside the macros, if someone knows how klipper is programmed and can explain it to me, it would be appreciated.

Thanks

In a nutshell, PAUSE tells the printer to pause once the current command is finished executing. When you put it in a macro, the entire macro is the current command, so the pause doesn’t begin until the macro is finished, regardless of where in the macro it is called. Your solution is exactly how you deal with the situation.

I understand how it works, thanks for the explanation, now I know how it goes and I won’t go crazy if the commands are out of order along with the pause command.

Thank you very much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.