Resume print from specific layer after failed print

Printer Model: Ender 3 v2
MCU / Printerboard: Creality 4.2.2

It finally happened, printer stopped extruding at layer 17 (clogged nozzle), it’s a big print that ocuppies most of the bed so I want to continue from there and it won’t go anywhere, it’s well glued. You may say “but layer 17 is nothing, just start over”, no, thanks, I want to learn because I’ve been smashing my head for the past hour with no success.

So, this is the print Imgur: The magic of the Internet, I went with the “cut the gcode from the layer” approach but…

First attempt, Klipper shouted at me that it needed to home, ok, hopefully the bed was still available and it was able to home XYZ, I just had to touch the safe home position a bit). Then there was max_extrude_only_distance which I had to modify as per Klipper instructions.

After a lot of failed attempts (and manually shutting down the printer) now it was max_extrude_cross_section which I needed to modify because I still don’t know, I modified it and when I “started pritining”, but no // Klipper state: Shutdown.

This is the start of the modified gcode.

;FLAVOR:Marlin
;TIME:24225
;Filament used: 26.0152m
;Layer height: 0.2
;MINX:12.777
;MINY:2.655
;MINZ:0.28
;MAXX:207.223
;MAXY:214.18
;MAXZ:29.28
;Generated with Cura_SteamEngine 5.4.0
M82 ;absolute extrusion mode
; Ender 3 Custom Start G-code
G92 E0 ; Reset Extruder
G28 ; Home all axes

;MESH:NONMESH
G0 F600 X193.716 Y204.122 Z3.88
G0 F15000 X75.238 Y22.025
;TIME_ELAPSED:12338.121982
;LAYER:18

...

I searched google with “klipper resume failed print” and similar and there was nothing which helped, how come such a basic thing isn’t covered anywhere? I know Klipper is more advanced and stuff but this same crap with Marlin was just that, cut the gcode and send it, boom, done (no, I’m not going back to Marlin).

Any clues? Thanks.

There was no power loss, as I said the nozzle clogged, so the printer went on with it’s thing until I realized half an hour later that it wasn’t extruding but still moving.

This is the same mechanism, and Klipper does not support it.

Resuming from a failed print like you describe is possible, but it is difficult. Even after going through the difficult steps of resuming, the resulting print is likely to have low quality. The filament adhesion between old and new layers is likely to suffer notably due to thermal effects resulting from the time gap between those layers.

If one wants to try it (or just wants to understand how it can be done) I can outline the process as I understand it. Note that I’ve never attempted this myself, so I can’t provide in-depth guidance.

As I understand it:

  1. The first step is to make sure Klipper is back up and running and that Klipper knows the toolhead position. If Klipper never lost power or never went into a shutdown state, then Klipper will already know its position and nothing needs to be done. If Klipper did turn off the steppers, then if rehoming is possible, then homing the printer is likely the best way to make sure Klipper knows its position (rehoming is often only possible on a machine that homes to Z max). If homing is not possible, but one knows the actual toolhead position with great accuracy, then one can manually turn on all the stepper motors using SET_STEPPER_ENABLE commands (see the documentation) and then issue a SET_KINEMATIC_POSITION command with the known toolhead position (see the documentation and be sure [force_move] is enabled in the printer.cfg file).
    Note that if the stepper motors were disabled, then the act of enabling them is likely to cause them to “jump to the nearest full step position”. This means, that in practice, even if one thinks the toolhead hasn’t moved since a “shutdown event”, just enabling the stepper motors will cause the toolhead to change position (typically by about 0.200mm).
    Note that using SET_KINEMATIC_POSITION on a position that one “guesses” is likely to cause chaos. (For example, the toolhead ramming into the frame, ramming into the print, or on delta-style printers, moving in seemingly completely random directions.)
  2. It’s necessary to identify where in the g-code file that the failure occurred, and remove all the g-code leading up to that point. This is quite difficult, but there are guides online describing how one can attempt this.
  3. The g-code state needs to be reconstructed at the start of that new g-code file. The “g-code state” is very confusing and arcane - g-code was never designed for “resuming” like this. For example, one needs to determine if the g-code was in absolute or relative mode and set that state (G90, G91, M82, M83). One also needs to determine and set any kinematic g-code offsets (G92, but this is rare) and one needs to determine the extruder offset (common). Many g-code files use “absolute extrusion offsets” and, if so, one must calculate and program a new extruder offset (G92 E???) so that the following “absolute extrusions” in the reconstructed g-code file match with the current extruder position (as understood by the restarted Klipper).
  4. It’s necessary to re-enable heaters. It’s necessary to move the toolhead to the resume position (G1) that corresponds with the reconstructed g-code file (if the toolhead is not already at that position). One can then, ideally, start the print of that reconstructed g-code file.

From your description above, it sounds like you did not correctly “reconstruct the extruder position”. The “max extrude distance” errors was Klipper informing you that the new print commands were non-sensical. Overriding the error check would not have improved things - the appropriate fix would have been to calculate a correct extruder offset and set it via G92 E???.

Cheers,
-Kevin

Kevin, I appreciate the great write-up, here is another thread which everyone may find useful on resuming failed prints with Klipper: https://klipper.discourse.group/t/how-to-resume-fix-failed-print/8687

I think the most troublesome issue that everyone runs into when their print fails, is that it is NOT possible to rehome the Z axis. Typically X and Y are not an issue, but rehoming Z with a print on the bed is not at all possible with larger prints. And some Klipper printers don’t support doing “G28 XY” and then manually moving the hotend to the proper Z value. For example, if you call “G28 XY” on my Elegoo Neptune 4 Pro it just does a full “G28”, and the printer will not allow you to lower the Z axis more than 6mm from the starting point.

After reviewing what you wrote here:

If homing is not possible, but one knows the actual toolhead position with great accuracy, then one can manually turn on all the stepper motors using SET_STEPPER_ENABLE commands (see the documentation) and then issue a SET_KINEMATIC_POSITION command with the known toolhead position (see the documentation and be sure [force_move] is enabled in the printer.cfg file).

If we can force the printer to do all of this manually, why is it not possible for Klipper to automate logging the last known layer number when the print was "cancelled / otherwise interrupted, and then just restart the print from that layer using the same configuration settings laid out by the Gcode in the first place? Rehoming all axis and these other tedious setup steps shouldn’t be neccessary. It should be as simple as “Caution: Your print failed at layer 217 out of 884! Would you like to restart this print from layer 217?” Then you hit “Confirm” or “Cancel” and you are on your way.

I can’t find the reference to this right now but I thought the off-print z offset stop switch (like used with the Voron) was meant to deal with this situation:

Now, you need to move the Z-stop offset switch to somewhere away from the board so that the toolhead won’t come into contact with the model (ie no part of the toolhead overhangs the heated bed) but this should do what you’re looking for (along with a bit of macro help).

Hi!
I’ve made a writeup of my resume path which is tested on my modified Ender5. Might help next time.
You can reach it here.

1 Like

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