probonopd / WirelessPrinting

Print wirelessly from Cura, PrusaSlicer or Slic3r to your 3D printer connected to an ESP8266 or ESP32 module
352 stars 65 forks source link

Implement "Abort Print" function #5

Open probonopd opened 7 years ago

probonopd commented 7 years ago

Implement "Abort Print" function (there is a button for it in the Cura GUI on the "Printer Monitor" tab).

How would this actually have to work? Skip all commands until the ;End GCode?

My printer likes something like this to end a print:

;End GCode
M104 S0 ;extruder heater off
M140 S0 ;heated bed heater off (if you have it)
G91 ;relative positioning
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 X-20 Y-20 F50.0 ;move Z up a bit and retract filament even more
G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way
M84 ;steppers off
G90 ;absolute positioning
M104 S0

Is there a generic way to do this, or can I query the (Marlin) printer for the correct end sequence?

probonopd commented 7 years ago

Check M108, M112, M410

M112 - Emergency Stop Used for emergency stopping, M112 shuts down the machine, turns off all the steppers and heaters, and if possible, turns off the power supply. A reset is required to return to operational mode.

M112 is the fastest way to shut down the machine using a host, but it may need to wait for a space to open up in the command queue. Enable EMERGENCY_PARSER for an instantaneous M112 command.

http://marlinfw.org/docs/gcode/M112.html

and

M410 - Quickstop Stop all steppers instantly

Stop all steppers instantly. Since there will be no deceleration, steppers are expected to be out of position after this command.

http://marlinfw.org/docs/gcode/M410.html

probonopd commented 5 years ago

Actually this seems to be working, at least from Cura:

https://github.com/probonopd/WirelessPrinting/blob/427d8d4d9411a73ebf3416fc4d4ece6d374b3820/ESP8266WirelessPrintAsync/ESP8266WirelessPrintAsync.ino#L743-L744

It would be nicer, though, if we could somehow extract the end gcode and send that, or at the very least move the nozzle up a few centimeters before the M112.

GMagician commented 5 years ago

The real problem is...every slicer write the same info to let us be able to do that? Otherwise we have to write a per slicer handling (and also scan and interpreter gcode to find these info)

ipepe commented 5 years ago

I'm not familiar but You could check into OctoPrint what actually happens there. It would be shame to restart printer after aborting?

chepo92 commented 5 years ago

What about an user configurable endgcode?

probonopd commented 5 years ago

configurable

Let's try to avoid configurability where we can. Whatever can be configured can be configured wrong.

ipepe commented 5 years ago

I think that current abort print is a bit too excessive. Can we just stop sending GCODE commands to printer? Power cycling whole printer seems a bit excessive.

probonopd commented 5 years ago

Imagine you are not at home and you see via the camera that something terribly bad is going on. I guess you want to reset the printer in those cases. Also, we are now sending more than one line of GCODE, so that simply sending no more might still result in activity for a while which may be undesirable.

ipepe commented 5 years ago

I'm never leaving printer alone because I don't trust it 🤷‍♂️ Well, could we have at least both? Graceful stop, and nuke from the orbit stop?

ipepe commented 5 years ago

We could make it a "defined" variable and I could use M410 instead of M112

probonopd commented 5 years ago

What advantage does M410 give you over M112?

ipepe commented 5 years ago

I assume that I don't have to power cycle my printer after M410?

probonopd commented 5 years ago

I don't know but what is the problem with power cycling? If it increases safety...

ipepe commented 5 years ago

Because it takes so much longer. When You abort a print on OctoPrint it doesn't do this. If I'm aborting print, it's because I changed my mind, or I can see that it will fail, or I chose wrong gcode (and noticed during heating that I want another one), or I noticed that I want different color filament. I'm not having emergency 5 times a day, I'm just aborting a print. Especially that printer is 30 cm next to me, on my desk.

If it would be emergency, I don't need to send M112, I just cut off power to printer.

Emergency Stop != Abort Print

probonopd commented 5 years ago

Emergency Stop != Abort Print

Agree, let's have 2 buttons. Pull request welcome.

ipepe commented 5 years ago

What about abort print from Cura?

probonopd commented 5 years ago

Isn't Cura sending C-code? I have not checked how it works.

ipepe commented 5 years ago

https://github.com/probonopd/WirelessPrinting/blob/master/ESP8266WirelessPrintAsync/ESP8266WirelessPrintAsync.ino#L307

positron96 commented 4 years ago

Any news on this? Every time I abort a print, I get very upset about having to power cycle printer - ESP gets power cycled as well, Cura looses connection, a somewhat frustrating experience. Or is this project abandoned?

probonopd commented 4 years ago

Pull requests welcome.

GMagician commented 4 years ago

AFAIK M112/M410 may not be executed immediately. It depends on how firmware is compiled (EMERGENCY_PARSER). In worst case printer will need to purge all queue commands before they can do their job. With EMERGENCY_PARSER best will be M410 (abort all commands) and a custom gcode (on SD or hardcoded)

These are Marlin gcodes, don't know if worldwide supported

positron96 commented 4 years ago

For me, every other option would be better than current situation since it moves the printer into inoperable state until power cycled. Actually just stopping sending further codes and letting the printer finish its queue seems acceptable. Above @probonopd described a use-case with monitoring the print via webcam remotely and needing to shut the machine immediately. I would argue that if printer has been failing for some time (you don't watch every second of printing via webcam, do you?), a couple of extra seconds of printing would not matter much.

probonopd commented 4 years ago

What does matter though is that the print will be stopped with certainty, and the hotend and heatbeds will be switched off with certainty.

GMagician commented 4 years ago

Both M112 and M410 turn off heaters and steppers (Position is not valid after M410 since it abruptly stop moving motors, not sure about m112)