Delay after fan or motor power on, before issuing steps

Sorry, I forgot I had a couple additional calls in another config file. In addition to the macros above, I also have:

[gcode_macro G28]
rename_existing: G2801
gcode:
    {% if (printer["gcode_macro SET_PSU"].value)|int == 0 %}
        SET_PSU VALUE=1
    {% endif %}
    G2801 {rawparams}

[gcode_macro TOGGLE_LIGHT]
variable_value: 0
gcode:
    {% set power = params.VALUE|default((not printer['output_pin caselight'].value))|int %}
    {% if (printer["gcode_macro SET_PSU"].value)|int == 0 %}
        SET_PSU VALUE=1
    {% endif %}
    SET_PIN PIN=caselight VALUE={power}
    SET_GCODE_VARIABLE MACRO=TOGGLE_LIGHT VARIABLE=value VALUE={power}

Plus my PRINT_START macro and a FILAMENT_UNLOAD macro contain:

    {% if (printer["gcode_macro SET_PSU"].value)|int == 0 %}
        SET_PSU VALUE=1
    {% endif %}

I also have this in my moonraker.cfg:

[power Printer]
type: klipper_device
object_name: gcode_macro SET_PSU
#off_when_shutdown: False
initial_state: on
locked_while_printing: True

G28 is my only motors-related override for power checking, the logic being that I do not make use of manual steppers, so on my setup, if the printer isn’t homed, Klipper will refuse to execute moves anyway. Homing the printer will turn the PSU on and it will stay on until the idle timeout, so I can safely assume that if the printer is homed, the PSU is on.

I’ll note that this configuration doesn’t check to make sure the PSU is on before extruding filament, but I never do that manually in normal operation anyway. If I have to do it for some reason, I have to remember to turn on the PSU or else I get an error.

1 Like