Power Loss Shutdown and Power Loss Resume
1. Feature Concepts and Workflow
-
Power Loss Shutdown
- Concept: Upon detecting an abnormal power loss, the system does not save the current print state and directly performs a safe shutdown.
- Recovery Workflow: After power is restored, the device will automatically restart and enter standby mode. The previous print job has been aborted, and you will need to manually start a new print.
-
Power Loss Resume
- Concept: Upon detecting an abnormal power loss, the system will immediately save the current print progress (such as position, layer height), and then shut down.
- Recovery Workflow: After power is restored, typically requiring user confirmation, the device can resume the unfinished print from the point of power loss.
2. Core Rules
- Power Loss Shutdown and Power Loss Resume are mutually exclusive features and cannot be enabled simultaneously.
- If the Power Loss Shutdown feature is enabled, the Power Loss Resume feature will automatically become inactive.
3. How to Choose
- Choose "Power Loss Shutdown": If you prioritize electrical safety, or prefer the device to automatically start and enter standby mode after power is restored without needing to resume an interrupted print, enable this feature.
- Choose "Power Loss Resume": If you frequently run long-duration print jobs that cannot afford failure, and wish to resume printing from the interruption point after a power loss, enable this feature.
Wiring
Before starting, completely turn off the printer and disconnect the power supply. Do not plug or unplug wiring harnesses, organize interface cable sequences, or touch terminals while the system is powered on.
- The following instructions apply to the Power Loss Shutdown and Power Loss Resume functions of the FLY-Pi.
- When connecting other devices via USB, a finished USB power isolator or a finished USB cable containing only data lines must be used to prevent backfeeding 5V power between the two ends. Do not cut or modify cables yourself.
- Power must be supplied using the dedicated KPPM module. Do not use other power supply methods.
- If the 5V connection between the host and client board cannot be disconnected, the mainboard must be fully powered off before restarting; otherwise, it may fail to boot properly.
- FLY-Pi 5V Wiring
- FLY-Pi USB Wiring
- FLY-Pi 5V Wiring
Loading...
- FLY-Pi USB Wiring
Loading...
Configuration
- Power Loss Shutdown
- Power Loss Resume
Configure Power-Off on Power Loss
- Method for configuring power-off on power loss
-
Enter the device's IP address in the browser's address bar, for example:
http://192.168.6.179 -
Enter the configuration page
- Open the device IP address in the browser, for example:
http://192.168.1.2/ - For fluidd, as shown on the left in the figure below,
uncheck->Filter hidden files and folders. - For mainsail, as shown on the right in the figure below,
check->Show hidden files.
Loading...Loading...- At this point, you can see the
.flyos-configfolder. Entering this folder will reveal thesys-config.conffile. - The
sys-config.conffile is a symbolic link to theconfig.txtconfiguration file on the removable diskFlyOS-Conf.
Loading...- Open the
sys-config.conffile, find theshutdown_pin_stateandshutdown_pin=configurations, and modify them as shown below. - Please note that
shutdown_pin=noneneeds to be deleted or preceded with a#.
- Open the device IP address in the browser, for example:
shutdown_pin_state=1
shutdown_pin=PA21
- Then
Save->Closeand restart the system
Disable Power-Off Shutdown
- Before using print resume after power loss, ensure that Klipper has started properly and can control the printer.
- The power-off shutdown feature must be disabled; otherwise, print resume after power loss will not take effect.
- After disabling power-off shutdown, the device will remain powered. Please ensure that the host machine does not have any other independent power supply connected; otherwise, the device will still not be able to shut down after a power outage.
-
Enter the device's IP address in the browser's address bar, for example:
http://192.168.6.179 -
Enter the configuration page
- Open the device's IP address in the browser, for example:
http://192.168.1.2/ - In fluidd, as shown in the left image below:
Uncheck->Filter hidden files and folders. - In mainsail, as shown in the right image below:
Check->Show hidden files.
Loading...Loading...- At this point, you can see the
.flyos-configfolder. Enter this folder and you will find 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 two configurations:shutdown_pin_stateandshutdown_pin=. - Add
#at the beginning of these two configurations. - Then
Save->Close, and restart the device.
Loading... - Open the device's IP address in the browser, for example:
plr.cfg Configuration File
- In the printer configuration page, locate the
plr.cfgfile. - Clear all existing content, then paste the configuration below.
- The configuration file content is as follows:
- The power_pin must use the host GPIO or a pin recommended by the product, and cannot use a pin from the slave (MCU/toolboard).
[mcu host]
serial: /tmp/klipper_host_mcu
[power_loss_resume]
power_pin: host:gpiochip1/gpio21
is_shutdown: True # Whether to execute shutdown operation, enabled by default
paused_recover_z: -2.0 # If paused during shutdown, Z movement distance when resuming print, default no movement
start_gcode:
# Gcode to execute before starting resume printing
# All parameters saved before power loss can be accessed via {PLR}
# Use M118 {PLR} to output all available parameters
# M118 {PLR}
M118 Starting resume printing: {PLR.print_stats.filename}
M118 Interrupted 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 %}
M83 ; Relative extrusion
G1 E-2 F1000 ; Retract
G91 ; Relative coordinates
G1 Z2 F100 ; Lift Z, prepare for X,Y homing
G90 ; Absolute coordinates
G28 X Y ; Home X Y
resume_gcode:
# Gcode to execute after moving to target position, before starting formal printing
M83 ; Relative extrusion
G1 E4 F800 ; Extrude 4mm filament, compensate for oozing
layer_count: 2 # Execute layer_change_gcode after printing specified layers during resume
layer_change_gcode:
# Gcode to execute after {layer_count} layers of resume printing
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:
# Gcode to execute before shutdown
M118 Power voltage low, shutting down
# M112 ; Emergency stop
-
After saving the configuration file above
-
Open the
printer.cfgfile, and add the following at the very beginning:[include plr.cfg] -
Click "Save & Restart" in the top right corner.
-
This completes the configuration of the Klipper power loss resume function.
About [homing_override]
- If
[homing_override]is used, do not arbitrarily set the homing position within[homing_override]. Failure to do so may result in print resume failure and no responsibility will be accepted. - Configuration instructions for
[homing_override]are provided below.
- Explanation
[force_move]: Enables the forced move function, allowing forced movement to a specified position when not homed.[force_move]replaces theset_position_zfunction in[homing_override]. Failure to configure this way may lead to print resume failure.- The
[homing_override]configuration below is intended to correctly home the Z-axis during print resume.
[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 Lift Explanation
- This configuration only executes when the Z-axis is not homed and does not affect normal usage.
{% if 'z' not in printer.toolhead.homed_axes %}SET_KINEMATIC_POSITION Z=0G90G0 Z5 F600{% endif %}
- This configuration only executes when the Z-axis is not homed and does not affect normal usage.
About Configuration for [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 park height offset
- You must accordingly adjust the
paused_recover_zparameter in the [power_loss_resume] module, making it opposite in sign to the offset value above.
Configuration Correspondence
| Macro Variable | Pause/Resume Module Parameter | Correspondence |
|---|---|---|
variable_custom_park_dz: 5 | paused_recover_z: -5 | Opposite sign, same value |
variable_custom_park_dz: -3 | paused_recover_z: 3 | Opposite sign, 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: Failure to maintain this correspondence may lead to incorrect Z-axis height calculation during print resume or pause recovery, affecting the print.
Testing
First Step Test: Simulating Power Loss via Emergency Stop
- Start printing any file. During the print, click the Emergency Stop button to simulate a power loss scenario.
- Click Firmware Restart again and wait for
Klipperto reconnect and return to normal. - Check if a popup notification appears on the web interface. If it appears, the print resume function is working correctly.
- Subsequently, you can further test with an actual power loss to verify the function's reliability.
Second Step Test: Actual Power Loss Simulation and Function Verification
- Test Preparation: After the system starts normally and connects to
Klipper, first confirm the status of the indicator light next to the host computer. Usually, anLEDwill blink when the system is running. This indicator light is the key one to observe in subsequent 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 next to the host computer turns off completely within 5 seconds.
- If it turns off: The power-off shutdown function is normal. Please proceed with the subsequent steps.
- If it does not turn off: The automatic shutdown function is not working. This is usually due to incorrect related configurations (such as
kppmwiring or settings), which need to be carefully checked and troubleshot.
- Wait at least
5seconds, then reconnect the power. Observe ifKlipperautomatically reconnects and returns to normal operation. (Saving data and shutting down takes3-5seconds). - Check the web interface
- If a popup notification appears: The print resume function has been successfully activated and is operating normally.
- If there is no notification: The print resume function did not start as expected. Please systematically check the relevant configurations based on the above observations.