Power Loss Shutdown and Power Loss Recovery
Important Notes
1. Function Concepts and Processes
-
Power Loss Shutdown
- Concept: Upon detecting an abnormal power loss, the system does not save the current printing state and directly executes a safe shutdown.
- Recovery Process: After power is restored, the device will automatically reboot and stand by. The previous print job is aborted, and you need to manually start a new print.
-
Power Loss Recovery
- Concept: Upon detecting an abnormal power loss, the system immediately saves the current print progress (e.g., position, layer height) before shutting down.
- Recovery Process: After power is restored, user confirmation is typically required for the device to resume and complete the unfinished print from the point of interruption.
2. Core Rules
- Power Loss Shutdown and Power Loss Recovery are mutually exclusive functions and cannot be enabled simultaneously.
- If the Power Loss Shutdown function is enabled, the Power Loss Recovery function will automatically become inactive.
3. How to Choose
- Choose "Power Loss Shutdown": If you prioritize electrical safety, or want the device to automatically start up and stand by after power restoration without resuming interrupted prints, enable this function.
- Choose "Power Loss Recovery": If you frequently perform long-duration, critical print jobs and wish to resume printing from the interruption point after a power loss, enable this function.
Configuration
- Power Loss Shutdown
- Power Loss Recovery
Configure Power Failure Shutdown
Note
- Method to configure power failure shutdown
-
Enter the device's IP address in the browser address bar, for example:
http://192.168.6.179 -
Access the configuration page
- Open the device IP address in the browser, for example:
http://192.168.1.2/ - In Fluidd, uncheck the option ->
Filter hidden files and foldersas shown in the left image below. - In Mainsail, check the option ->
Show hidden filesas shown in the right image below.
Loading...Loading...- You should now see the
.flyos-configfolder. Enter this folder and locate thesys-config.conffile. - The
sys-config.conffile is a symbolic link to theconfig.txtconfiguration file in the removable disk namedFlyOS-Conf.
Loading...- Open the
sys-config.conffile and locate the two configurationsshutdown_pin_stateandshutdown_pin=, and modify them to match the configurations below: - Please note that
shutdown_pin=noneneeds to be deleted or preceded by a#symbol.
- Open the device IP address in the browser, for example:
shutdown_pin_state=1
shutdown_pin=PI4
- Then
Save->Closeand restart the system.
Loading...
Disable Power Failure Shutdown
Note
- The power failure shutdown function needs to be disabled, otherwise the power failure resume printing function cannot be used.
- The power failure resume printing function includes an automatic shutdown feature after saving progress.
- Please ensure that no other power supply is connected to the host computer, otherwise it will not be able to power on.
-
Enter the device's IP address in the browser's address bar, for example:
http://192.168.6.179 -
Access the configuration page
- Open the device IP address in the browser, for example:
http://192.168.1.2/ - In Fluidd, uncheck -> "Filter hidden files and folders" as shown on the left in the image below.
- In Mainsail, check -> "Show hidden files" as shown on the right in the image below.
Loading...Loading...- You will now see the
.flyos-configfolder. Inside this folder is thesys-config.conffile. - The
sys-config.conffile is a symbolic link to theconfig.txtconfiguration file in the removable diskFlyOS-Conf.
Loading...- Open the
sys-config.conffile and locate the configurationsshutdown_pin_stateandshutdown_pin=. - Add a
#at the beginning of these configuration lines. - Then click
Save->Closeand restart the device.
Loading... - Open the device IP address in the browser, for example:
plr.cfg Configuration File
- In the printer configuration page, locate the
plr.cfgfile. - Clear its contents, then paste the configuration below into it.
- The configuration file content is as follows:
[mcu host]
serial: /tmp/klipper_host_mcu
[power_loss_resume]
power_pin: host:gpiochip1/gpio8
is_shutdown: True # Whether to perform shutdown operation, enabled by default
paused_recover_z: -2.0 # If paused during shutdown, Z-axis movement distance when resuming print, default is no movement
start_gcode:
# G-code executed before resuming print
# All parameters saved before power loss can be accessed via {PLR}
# Use M118 {PLR} to output all available parameters
# M118 {PLR}
M118 Starting resume print: {PLR.print_stats.filename}
M118 Interruption position: X:[{PLR.POS_X}] Y:[{PLR.POS_Y}] Z:[{PLR.POS_Z}] E:[{PLR.POS_E}]
# Restore all heater temperatures
{% for name, heater in PLR.heaters.items() %}
{% if heater.target > 0 %}
M118 Setting heater [{heater.name}] target temperature: {heater.target}
SET_HEATER_TEMPERATURE HEATER="{heater.name}" TARGET={heater.target}
{% endif %}
{% endfor %}
# Wait for extruder temperature
{% if PLR.toolhead.extruder in PLR.heaters and PLR.heaters[PLR.toolhead.extruder].target > 0 %}
{% set extruder = PLR.heaters[PLR.toolhead.extruder] %}
M118 Waiting for [{extruder.name}] to reach target temperature: {extruder.target}
TEMPERATURE_WAIT SENSOR="{extruder.name}" MINIMUM={extruder.target-5} MAXIMUM={extruder.target+5}
{% endif %}
G91 ; Relative coordinates
G1 Z2 F100 ; Raise Z, prepare for X, Y homing
G90 ; Absolute coordinates
G28 X Y ; Home XY
M83 ; Relative extrusion
# G1 E0.5 F400 ; Extrude a little
layer_count: 2 # Execute layer_change_gcode after resuming the specified number of layers
layer_change_gcode:
# G-code to execute after resuming {layer_count} layers
M118 Restoring print speed
M106 S{PLR.fan_speed} ; Turn on part cooling fan
M220 S{PLR.move_speed_percent} ; Set requested speed percentage
M221 S{PLR.extrude_speed_percent} ; Set requested extrusion speed percentage
shutdown_gcode:
# G-code executed before shutdown
M118 Low power voltage, shutting down
# M112 ; Emergency stop
-
After saving the above configuration file
-
Open the
printer.cfgfile and add the following content at the very beginning:
[include plr.cfg] -
Click Save and Restart in the upper right corner.
-
At this point, the Klipper power loss recovery function has been configured.
About [homing_override] Explanation
Note
- Note: If you use
[homing_override], do not arbitrarily set the homing position within[homing_override]. We are not responsible for failures in power loss recovery caused by this. - Configuration instructions for
[homing_override]are provided below.
- Explanation
[force_move]: Enables the force move function, allowing forced movement to a specified position.[force_move]replaces theset_position_zfunction in[homing_override]. Not following this configuration may lead to power loss recovery failure.- The
[homing_override]configuration below is designed to correctly home the Z-axis during power loss recovery.
[force_move]
enable_force_move: true
[homing_override]
axes: z
gcode:
{% set max_x = printer.configfile.config["stepper_x"]["position_max"]|float %}
{% set max_y = printer.configfile.config["stepper_y"]["position_max"]|float %}
{% if 'z' not in printer.toolhead.homed_axes %}
SET_KINEMATIC_POSITION Z=0
G90
G0 Z5 F600
{% endif %}
{% set home_all = 'X' not in params and 'Y' not in params and 'Z' not in params %}
{% if home_all or 'X' in params %}
G28 X
{% endif %}
{% if home_all or 'Y' in params %}
G28 Y
{% endif %}
{% if home_all or 'Z' in params %}
G0 X{max_x / 2} Y{max_y / 2} F3600
G28 Z
G1 Z10 F2000
{% endif %}
- About Lifting Explanation
- This configuration executes actions only when the Z-axis is not homed. It does not affect normal usage.
{% if 'z' not in printer.toolhead.homed_axes %}
SET_KINEMATIC_POSITION Z=0
G90
G0 Z5 F600
{% endif %}
- This configuration executes actions only when the Z-axis is not homed. It does not affect normal usage.
About the Configuration of [gcode_macro _CLIENT_VARIABLE]
- When your configuration includes the
[gcode_macro _CLIENT_VARIABLE]macro and sets the following variables: - Reference
[gcode_macro _CLIENT_VARIABLE]
variable_use_custom_pos: True # Enable custom position
variable_custom_park_dz: 5 # Set custom parking height offset
- You must adjust the
paused_recover_zparameter value in the [power_loss_resume] module accordingly, making its sign opposite to the offset value above.
Configuration Correspondence
| Macro Variable | Pause/Resume Module Parameter | Correspondence |
|---|---|---|
variable_custom_park_dz: 5 | paused_recover_z: -5 | Opposite signs, same value |
variable_custom_park_dz: -3 | paused_recover_z: 3 | Opposite signs, same value |
Example Configuration
[gcode_macro _CLIENT_VARIABLE]
variable_use_custom_pos: True
variable_custom_park_dz: 5
[power_loss_resume]
paused_recover_z: -5
Important: Not maintaining this correspondence may lead to incorrect Z-axis height calculation during power loss recovery or pause/resume, affecting printing.
Testing
Step 1 Test: Simulate Power Loss via Emergency Stop
- Start printing any file. During the print, click the Emergency Stop button to simulate a power loss situation.
- Click Firmware Restart again, wait for
Klipperto reconnect and return to normal. - Observe if a pop-up prompt appears on the web interface. If it does, it indicates the power loss recovery function is working normally.
- You can further test real power loss scenarios later to verify the reliability of the function.
Step 2 Test: Real Power Loss Simulation and Function Verification
- Test Preparation: After the system boots normally and connects to
Klipper, first confirm the status of the indicator light near the host computer. Typically, anLEDwill keep blinking while the system is running. This indicator is the key light to observe in the following steps. - While the device is running normally and connected to
Klipper, directly disconnect the power to simulate a real power loss scenario. - Immediately check if the indicator light near the host computer completely turns off within 5 seconds.
- If it turns off: It indicates the power-off shutdown function is normal. Please proceed with the following steps.
- If it does not turn off: It means the automatic shutdown function did not activate. This is usually due to errors in related configurations (such as
kppmwiring or configuration). Focus on checking and troubleshooting.
- Wait at least
5seconds, then restore power. Observe ifKlippercan automatically reconnect and resume normal operation. (Saving data and shutting down requires3-5seconds.) - Check the web interface.
- If a pop-up prompt appears: It indicates the power loss recovery function has been successfully activated and is running normally.
- If there is no prompt: It indicates the power loss recovery function did not start as expected. Please systematically check the related configurations based on the above observations.
Loading...