Stampanti 3D

Klipper Power Loss Recovery – 3D print resume



We are working on gcode/bash macros to be able to recover an interrupted 3D print with Klipper after a request of FIRMWARE_RESTART.
Power Loss Recovery macros will reprint the last unfinished layer.
At the moment it is still not possible, like Marlin, to recover the print at the right position where the interruption occurred,
because you would need to keep track of every single command in the gcode file.

A Gcode interrupted after Z=1.5



At the start of printing, many variables will be saved in a save_variables.cfg file
such as the filename and the variable that will be used to check if printing has been interrupted.
Another macro saves some variables during printing, such as layer height and extruder temperature.

It is also possible to save other variables as the last temperature of the bed, but I have excluded this for reasons which I will explain below **.

After the interruption these variables will be resumed in order to regenerate the Gcode file:
the nozzle will be heated to make it detach from the piece: it may have stuck to the cooled print;
then a +1mm movement will be performed on Z
with a SET_KINEMATIC_POSITION Z=0, G91 and G1 Z1 command;
then the homing starts on all the axes which I perform with optical endstops
which are able to guarantee good precision on the repositioning of the printhead and the bed.


Then it will be restored the Extrude printing temp and the last Fan Speed before the interruption.
The Extruder will be set to the filament position with G92 Exxx (SET_POSITION Extruder).

Finally the macro complete the plr.gcode file resuming the original your_file.gcode
from the Z height in which the printing was interrupted.



If you cannot perform a Z homing due to the piece on the plate and the endstops positioned on the upper side of the bed,
and if you have a bed that does not fall down due to gravity with the print interrupted, you can perform a
SET_KINEMATIC_POSITION Z=X where X is you last uncomplete layer in “mm”.
You can also perform a manual positioning in Z with a PAUSE, a relative movement of Z and a manual SET_KINEMATIC_POSITION Z=X.
This command is a “fake” Z homing by setting the current position of the bed to your value.

There are some things to optimize yet, like a purge just before the resuming
so you can reprint the interrupted layer without gaps in the extrusion
due to filament leaking during the operations above.

INSTALL MACROS AND SCRIPTS

Download from my >> Github.com/Travis90x <<
the plr.cfg file and put it in your /home/pi/printer_data/config/ folder
download plr_z.sh in /home/pi/printer_data/config/scripts/
with putty:
chmod +x /home/pi/printer_data/config/scripts/plr.sh

In your Slicer add the macro SAVE_LAST_FILE in the last row of start gcode, but before the purge line.
in the first row of the end gcode add the macro CLEAR_LAST_FILE
Otherwhise you can use personalized Klipper macros recalled by the slicer in the start or end gcode.

At every layer add gcode macro: LOG_Z
In Cura slicer: Add Post processing script -> “Insert at layer Change” and insert “After”, G-code: LOG_Z
ALERT: at the moment this macro can works only if you set the slicer without Z_hop and without Lift Head or similar,
because these functions could change the position in Z just before the layer change.

In printer.cfg or other included .cfg you need:
[save_variables]
filename: ~/save_variables.cfg

With Kiauh install Gcode Shell Command from the Advanced Menu.
sudo apt-get install git -y
git clone https://github.com/th33xitus/kiauh.git
./kiauh/kiauh.sh





If you want set a bed temp with the temperature found after the FIRMWARE_RESTART, use the macro:
SET_BED_TEMP_TO_SENSOR in your Klipper macro Start_Print.
This macro is integrated in plr.cfg.
** After the interrupt, if the bed has cooled down and you heat it again to the previous printing temperature,
this may cause warping of some materials such as ABS or ASA.

en_GBEnglish (UK)