prusa3d / Prusa-Firmware

Firmware for Original Prusa i3 3D printer by PrusaResearch
GNU General Public License v3.0
2.02k stars 1.05k forks source link

[3.5.0] M601 results in an infinite pause/resume loop #1378

Closed TheHammockGuy closed 4 years ago

TheHammockGuy commented 5 years ago

A bug was introduced in the 3.5.0 firmware release related to the M601 gcode command when printing from an SD card. When this command is executed it is taking the print's current location on the sd card and rolling backwards equal to the length of data in the command buffer and planner. This results in a new location to be used upon resume. This new location is immediately before the M601 command. This results in the long pause operation being called again after resuming from a long pause.

Also, M601 now implicitly pauses as part of the command, where before you would need to use an M1 command to wait for user input before using the M602 resume command.

The bug appears to come from this commit: https://github.com/prusa3d/Prusa-Firmware/commit/1585dc66b0f96c63dd65b57644326180761ef3c5

The issue resides in Marilin_main.cpp in the function "stop_and_save_print_to_ram"

I have made a workaround, but this should really have a more proper fix: https://github.com/TheHammockGuy/Prusa-Firmware/commit/867efed04353a11877742bba19288d3d5bfad35a

Current Behavior: M601 Turns off nozzle heat, moves to a holding location, and triggers an implicit pause. User selects Resume from LCD menu and it re-executes the above M601 command resulting in a loop

Expected(previous) behavior: M601 Turns off nozzle heat, moves to a holding location, and then continues executing gcode to allow for M1 to wait for user input M602 to reposition back to original location, reheat, and continue printing

Behavior with my workaround: M601 Turns off nozzle heat, moves to a holding location, triggers an implicit pause and sets a flag to ignore further M601 commands until after M602 is called User selects Resume from the LCD menu and it skips the above M601 due to the flag setting M602 Resets the flag allowing M601 to be executed again in the future

TheHammockGuy commented 5 years ago

I have also created a pull request in case you want to use my workaround until a better fix can be scheduled:

Pull request https://github.com/prusa3d/Prusa-Firmware/pull/1379

PavelSindler commented 5 years ago

Thank you for reporting this bug.

thenickdude commented 5 years ago

~Looks like this got fixed in 3.5.1 by 16e5fb50ddc72a294c7eb173622d0ec2961210cc~

kubiani commented 5 years ago

Looks like this got fixed in 3.5.1 by 16e5fb5

I'm still seeing this issue. Currently running v3.5.1-1778 on a Mk2.5. I normally print via USB from an attached OctoPi but I've also confirmed the infinite loop behavior still occurs via an SD print.

The only apparent difference with the USB print is it seems like it doesn't respect the new "wait for user input" as part of M601 command; on the USB print it tries to auto resume whereas the SD print requires me to select "resume print" from the menu.

UPDATE: Looks like that fix wasn't applied to the 2.5 branch which would explain why it's still an issue for me.

Grismo commented 5 years ago

The specific code in marlin_main.cpp which shall cure the issue is at least not there in the source code for version 3.5.1. So I would assume that it might be a problem for MK3 as well.

Grismo commented 5 years ago

The M601 bug seems still to be there, although maybe in another form. I just tested M601 in a small test. When M601 is called, printer moves to pause position, hotend is switched of, heatbed is still on. LCD shows message "print paused". But how to resume the print? If I remember correctly there has been a menu item like "resume print" when M601 caused an endless repetition. An combination of M601 followed by M1 doesn't work as well. So now we are caught in an endless pause instead of an endless pause loop. By the way - I tested it on an MK2.5 with MMU2 with FW 3.6.0. Oh - forgot to mention that the M601 was followed by a M602 in the SD-file. And I tried M601, M1, M602. Or did I something wrong?

thenickdude commented 5 years ago

Confirmed that M601 still doesn't work in 3.7.1-RC1 for the MK3S. M601 results in the print pausing, and "print paused" is displayed on the screen. Selecting Resume Print from the menu results in the printhead returning to the print surface, and making one quick lateral movement, then the print pauses again and the head is retracted - an infinite loop that can't be escaped from.

McSlow commented 5 years ago

Doesn't work with 3.7.1 released version. Still infinite pause loop. Current workaround is either a bunch of commands (containing M1, some movements, turning on steppers) which produces bad results for the following layers) or M600, which moves the bed behind the extruder ( not ideal to insert parts) and unnessecarily reloads filament causing some minor issues.

F0x06 commented 5 years ago

Still not fixed since 3 Dec 2018 ? This ruined one of my prints, issue still present on 3.7.2...

F0x06 commented 5 years ago

@TheHammockGuy Thanks for the "dirty" fix, patched my v3.7.1 with the same logic, works perfectly until a better fix from Prusa 👍

TheHammockGuy commented 5 years ago

It may be helpful if people still experiencing this but post the couple lines of gcode before and after your use of M601 to be sure of the exact conditions that you are using to reproduce the bug. Even if commit 16e5fb5 fixed the infinite loop issue, the behavior and use of M601 would still have changed slightly.

As in my original post, you would previously have needed to do:

M601 to initiate pause M1 to wait for user input M602 to resume print

With the change to the behavior of M601 you no longer need to follow up with M1 and M602. It would be good to confirm that the people still experiencing issues are using only M601 and not following up with M1 and M602.

This data may help Prusa engineers release a less hacky fix sooner.

F0x06 commented 5 years ago

It may be helpful if people still experiencing this but post the couple lines of gcode before and after your use of M601 to be sure of the exact conditions that you are using to reproduce the bug. Even if commit 16e5fb5 fixed the infinite loop issue, the behavior and use of M601 would still have changed slightly.

As in my original post, you would previously have needed to do:

M601 to initiate pause M1 to wait for user input M602 to resume print

With the change to the behavior of M601 you no longer need to follow up with M1 and M602. It would be good to confirm that the people still experiencing issues are using only M601 and not following up with M1 and M602.

This data may help Prusa engineers release a less hacky fix sooner.

I was printing a glasses stand, with some pennies insert at layer 2.6

.....
G1 X109.081 Y79.797 E0.19944
G1 X109.473 Y79.864 E0.01343
G1 X110.593 Y80.169 E0.03931
G1 X111.679 Y80.581 E0.03931
G1 X112.720 Y81.096 E0.03931
G1 X113.706 Y81.708 E0.03931
G1 X114.660 Y82.443 E0.04075
G1 X119.864 Y77.239 E0.24912
G1 X121.462 Y77.414 E0.05441
G1 X123.230 Y77.530 E0.05997
G1 X125.001 Y77.568 E0.05997
G1 X126.773 Y77.530 E0.05997
G1 X127.870 Y77.458 E0.03721
G1 X117.931 Y87.396 E0.47574
M204 S1000
M601
;BEFORE_LAYER_CHANGE
;2.6

G1 E-0.04000 F1800.00000
G1 F5760
G1 X118.746 Y86.581 E-0.34200
G1 E-0.01800 F1800.00000
G1 Z2.800 F7200.000
;AFTER_LAYER_CHANGE
;2.6
G1 X99.589 Y68.539
G1 Z2.600
G1 E0.40000 F1800.00000
M204 S800
G1 F4800
G1 X100.053 Y68.539 E0.01573
......

The printer paused correctly and parked, then i selected "Resume" from LCD, printer heated-up again, resumed the print, then instantly paused and parked again when the nozzle touched the part, tried 3 times and same behavior.

TheHammockGuy commented 5 years ago

@PavelSindler @XPila The issue seems to be that the stop_and_save_print_to_ram function which is called by lcd_pause_print uses sdpos_atomic to determine the current position on the SD card for saving print progress. The variable sdpos_atomic is not impacted by the cmdqueue_pop_front function in the commit that was intended to fix this bug. So even though that pop command is being executed the pause function is still using the same SD card position to resume the print as it was before the pop was requested.

robscar commented 4 years ago

still seeing the exact same issue in 3.8.1. Any chance to fix this?

kenour commented 4 years ago

Oh it's not just me! I've been trying to add a pause at a specific layer to pour epoxy resin into my print, but it gets stuck in a loop. I've been using PrusaSlicer and would go to the layer I wanted, use the GUI to insert a filament change, then just change the M600 for M601. But it wouldn't restart after the pause.

Filament change works, but I really want a long pause as I need the extruder to bugger off out the way and the model to be moved forward to pour the resin in.

wavexx commented 4 years ago

See PR #2274

Mito57 commented 4 years ago

This bug has not been fixed. I just tried the new "add pause" feature in the last Prusa slicer and it caused the continuous loop. I had to stop the print and insert a different code manually into the gcode.
I used this: https://forum.prusaprinters.org/forum/original-prusa-i3-mk2-s-others-archive/pause-print-in-gcode/#post-125748 Although not as good as the M601 should be, it works. Hopefully, now with the addition of the feature in the slicer, more people will try to use the feature and this will be addressed.

wavexx commented 4 years ago

Are you printing via usb or via SD?

Mito57 commented 4 years ago

Via SD

On Mon, Dec 23, 2019 at 11:16 AM wavexx notifications@github.com wrote:

Are you printing via usb or via SD?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/prusa3d/Prusa-Firmware/issues/1378?email_source=notifications&email_token=AODDQ6II22QTQRU5P6KHZ6DQ2DW7ZA5CNFSM4GH6KSDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHRRPAY#issuecomment-568530819, or unsubscribe https://github.com/notifications/unsubscribe-auth/AODDQ6N3KEUDKECN54TA5KLQ2DW7ZANCNFSM4GH6KSDA .

wavexx commented 4 years ago

There are still some PRs which deal with pause/resume issues (#2352, #2353) that got discovered later which are not yet contained in an official release, and also a few other ones that still need merging (#2368, #2382 and #2383) to cover some remaining issues.

With these PRs merged I can use M601 correctly both from the SD and via USB (just tested with a small test cube and with the new "add pause"/M601 added by slic3r).

I could build a test firmware if you're willing to help testing it :) (in this case, please say which model do you have).

Mito57 commented 4 years ago

I have never done any firmware modification or compiling but I can definitely test if if you do it. My printer is a MK3S and I'm running the 3.8.1-2869 firmware.

On Mon, Dec 23, 2019 at 12:50 PM wavexx notifications@github.com wrote:

There are still some PRs which deal with pause/resume issues (#2352 https://github.com/prusa3d/Prusa-Firmware/pull/2352, #2353 https://github.com/prusa3d/Prusa-Firmware/pull/2353) that got discovered later which are not yet contained in an official release, and also a few other ones that still need merging (#2368 https://github.com/prusa3d/Prusa-Firmware/pull/2368, #2382 https://github.com/prusa3d/Prusa-Firmware/pull/2382 and #2383 https://github.com/prusa3d/Prusa-Firmware/pull/2383) to cover some remaining issues.

With these PRs merged I can use M601 correctly both from the SD and via USB (just tested with a small test cube and with the new "add pause"/M601 added by slic3r).

I could build a test firmware if you're willing to help testing it :) (in this case, please say which model do you have).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/prusa3d/Prusa-Firmware/issues/1378?email_source=notifications&email_token=AODDQ6MATNN4DUG4SYUPRYDQ2ECBBA5CNFSM4GH6KSDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHRWS6Q#issuecomment-568551802, or unsubscribe https://github.com/notifications/unsubscribe-auth/AODDQ6IYPV3ZHBHSVQZLLZ3Q2ECBBANCNFSM4GH6KSDA .

pavelchuchma commented 4 years ago

The issue reproduced using prusa3d_fw_3_8_1_MK3. Printing from SD card. I tried to resume ~5 times, no success. Successfully resumed after unload and load the filament. Attaching my model. bok01-zaklad_0.15mm_PETG_MK3_59m.zip

Mito57 commented 4 years ago

That's exactly what happened to me but I did not think on unloading/loading filament, but then the workaround would be to insert a color change instead of a pause. A little more work but it will stop and resume the print successfully. I've done it before the context menu was added to the slicer. Prusa should just fix the bug in the firmware or remove the option in the context menu. I used the option to insert this gcode (using the context menu) and it worked just fine.

G1 X10.000 Y200.000 E0; parking position M1; user stop M105; return to current temp

pavelchuchma commented 4 years ago

I believe that "Průšovi kluci šikovní" will fix this forgotten, simply reproducible, bug very soon :-)

wavexx commented 4 years ago

I prepared two builds for those that would like to test the pause/resume functions.

These build on top of the current master 955c88cf688a0456868304b5c1fc4ab34a9abddf and additionally include PRs #2382 #2383 #2394 #2393 #2390 #2368 #2395 in single-language (English only).

This is unofficial/testing stuff, so you know the risks. I tried all combinations I could think of (M601 via USB or SD, M600, change of filament (again M600) but via tune during a pause triggered via M601) but I'd love if somebody could give it more testing.

Mito57 commented 4 years ago

I tested the pause function with this firmware and appears to be working fine now. I used the "insert pause" from the Prusa slicer beta using the context menu.

I'm not really sure how it's supposed to work though. I had to go to the "resume print" option on the printer's menu to keep going. I thought that is should have displayed a custom message and only pressing the button was needed to resume?

On Thu, Jan 2, 2020 at 11:49 AM wavexx notifications@github.com wrote:

I prepared two builds for those that would like to test the pause/resume functions.

These build on top of the current master 955c88c https://github.com/prusa3d/Prusa-Firmware/commit/955c88cf688a0456868304b5c1fc4ab34a9abddf and additionally include PRs #2382 https://github.com/prusa3d/Prusa-Firmware/pull/2382 #2383 https://github.com/prusa3d/Prusa-Firmware/pull/2383 #2394 https://github.com/prusa3d/Prusa-Firmware/pull/2394 #2393 https://github.com/prusa3d/Prusa-Firmware/pull/2393 #2390 https://github.com/prusa3d/Prusa-Firmware/pull/2390 #2368 https://github.com/prusa3d/Prusa-Firmware/pull/2368 #2395 https://github.com/prusa3d/Prusa-Firmware/pull/2395 in single-language (English only).

This is unofficial/testing stuff, so you know the risks. I tried all combinations I could think of (M601 via USB or SD, M600, change of filament (M600) via tune during a pause triggered via M601) but I'd love if somebody should give it more testing.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/prusa3d/Prusa-Firmware/issues/1378?email_source=notifications&email_token=AODDQ6NKKIW6QCHJKA26GPLQ3YSLNA5CNFSM4GH6KSDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH65Z7A#issuecomment-570285308, or unsubscribe https://github.com/notifications/unsubscribe-auth/AODDQ6PZI6Z3CG5WKXKW5E3Q3YSLNANCNFSM4GH6KSDA .

wavexx commented 4 years ago

On Sat, Jan 04 2020, Mito57 wrote:

I'm not really sure how it's supposed to work though. I had to go to the "resume print" option on the printer's menu to keep going.

That's how it's supposed to work using the M601 instruction inserted by PrusaSlicer. It's a generic pause function: it does exactly the same as if you paused the print via the LCD.

There's a custom message too (using M117), but it's displayed for a fraction of a second only before being replaced by "Print paused".

This needs to be improved.

I thought that is should have displayed a custom message and only pressing the button was needed to resume?

There's a different gcode for this, M0, which should prompt for the user. I didn't test this one yet.

I did use M0 with stock marlin, but I still recommend to use M601 instead. With a regular pause you can use the settings menu to move the extruder higher if you need, and then also resume the print. Very useful!

clintonefisher commented 4 years ago

Yes! Using 3.9.0-RC1, I was able to pause the print (a 3D BB Maze), install a captive BB, and successfully resume the print. Fantastic! Thanks everyone!

kingigi commented 4 years ago

✅ : The Prusa Firmware 3.9.0-RC1-3272 solved the pause-resume-loop problem for me too. I used PrusaSlicer 2.2.0 to slice the model.

bivaterl commented 4 years ago

I was having the infinite loop issue (not infinite; I was able to do it over and over and eventually it resumed). However, due to this thread, I installed 3.9.0 RC1 (whatever is current as of 4/9/2020) and the loop issue was resolved! Penny slugs to give weight to my plastic coins achievement unlocked!

cnlson commented 4 years ago

I just had this happen when using a pause at height from 2.2.2 prusa slicer. Lost that print and re sliced with filament change and that worked to drop in a nut.

Running 3.8.1 mk3s

jessearmstrong commented 4 years ago

I'm also having this loop on my MK2.5s

leptun commented 4 years ago

@jessearmstrong what fw version?

jessearmstrong commented 4 years ago

I am running 3.8.1 on my MK2.5s and while this first started happening on Octoprint I disconnected and ran the print from SD card, tried several times. same results.

wmajst commented 4 years ago

I use such workaround for this: use M601, when paused take off sd, replace M601 with M602, insert card, use LCD to resume print

WRidder commented 4 years ago

I encountered this issue as well, experiencing an infinite pause/resume loop upon inserting a pause. Upgrading to 3.9.0 fixed the issue for me.

3d-gussner commented 4 years ago

@TheHammockGuy As we fixed this issue it would be great if you could close this issue. [stale][fixed]

JohnnyDeer commented 4 years ago

I'm closing this issue as stale, thanks for understanding.