MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.36k stars 19.26k forks source link

[FR] Recover from Power-loss #2085

Closed galeots closed 6 years ago

galeots commented 9 years ago

You can enter in the firmware resurrection wasp mode? So in case of power failure it can pause and resume printing the extruder to get up so as not to damage the piece and resume printing when you want?

https://www.youtube.com/watch?v=ZmfGlsUGVs0

thinkyhead commented 9 years ago

I like the concept, and detecting loss of power without a dedicated circuit could be done in some creative ways, such as noticing a sudden switch in state among many components at once. The biggest caveat is that Marlin must support many boards, and they will vary very widely in the amount of time available to process before power to the CPU is lost. Writing to SD or EEPROM adds a risk of data corruption that we would also need to mitigate.

http://www.wasproject.it/w/en/resurrection-system-a-3d-printing-revolution/

ntoff commented 9 years ago

That looks like it would require extra hardware as well. Also it seems to power the arduino from the 12v supply, what if you've converted it to run off the +5vsb rail so the printer can turn the PSU on and off? ATX PSU's have a power good wire which you could monitor instead. There are so many ways this could be monitored and implemented.

thinkyhead commented 9 years ago

@ntoff Yes, theirs has a diode in series with the power supply. Of course with an Arduino connected to USB you are correct. It will stay powered from the USB. And since most users now use laptops, it will probably stay powered for a long time. So this is still very useful for those cases where power is lost only to the high current circuits.

Let's set aside what a print looks like after a hot nozzle has been oozing on it for several minutes...

ntoff commented 9 years ago

That's why OP said move the nozzle up and away but THAT would definitely require extra hardware (a UPS) to power the motors.

Still, it should be trivial to sand / file that one damaged spot on a 60+ hour print (someone on reddit just did a 65 hour print) rather than starting all over again from scratch.

Mine are both powered by the 5 volt standby line from the power supply so they work without the PC being hooked up but yeah with the laptop connected the arduino still gets power so there'd be plenty of time for that to save the data or even send the position back to the host and let the host do all the hard work.

thinkyhead commented 9 years ago

@ntoff In the demo video the delta gets stuck and stays in one spot. Maybe it has a fast-cool nozzle. :8ball:

galeots commented 9 years ago

I have downloaded, their firmware and I'm trying to figure out the pieces of code in more. if you look in firware in cardreader.cpp function it was planned but not implemented

if (store_location) {
     // future: store printer been, filename and position for continuing a stopped print
     // I know one can unplug the printer and continue printing the next day.
   }
}
galeots commented 9 years ago

you could integrate into the firmware this thing !? It would be helpful to all in case of low or tebsione and resumed printing when you want.

thinkyhead commented 9 years ago

@galeots Someone around here will experiment with it when we have more time.

boelle commented 9 years ago

with our agreement that we should limit the list of supported hardware maybe this one is more easy? and if no one is going to implement it then i think i should be closed...after all we are only 4 that have made a comment about this

but i like the idea too

galeots commented 9 years ago

I would like to take this project forward with you very helpful to all of you!

Roxy-3D commented 9 years ago

I would like to take this project forward with you very helpful to all of you!

This is very complicated for several reasons. First, the G29 Correction Matrix and Zero would have to be stored so it can be recovered and used. Without that, a recovery would not be possible. And you can't re-probe the bed with a part already half built.

Are you thinking about doing the firmware to accomplish this? Because, if you are, I think we can coach you on the necessary components and how to proceed.

galeots commented 9 years ago

if you download from their site you understand where to add the code! I'm not good at planning but we must add a paritore sensing the voltage drop ... http://www.personalfab.it/download/19162/

KiteLab commented 9 years ago

An here is the hardware part of the story. http://www.wasproject.it/w/en/resurrection-system-a-3d-printing-revolution/

Roxy-3D commented 9 years ago

One problem with this is it appears it is aimed at Power Failures. It would be easier to get everybody to agree that the cost, effort, support issues, etc. made sense if it handled any generic failure causing the print to stop. For example, a computer crash or a communication failure to the printer.

galeots commented 9 years ago

as now in the firmware in case of power failure throw it all away! hours in case of printing is a waste! in their gaming system can resume printing the following day if it takes too long!

Roxy-3D commented 9 years ago

as now in the firmware in case of power failure throw it all away! hours in case of printing is a waste! in their gaming system can resume printing the following day if it takes too long!

I do appreciate the innovation and use. Mostly, I'm asking "How hard would it be to make this handle the generic case of any failure?" If it could be made to handle the generic case, I might personally jump in and help code it. The big problem right now is we need to clean up and simplify Marlin. So there are a lot of trade offs that have to be made.

When I get a chance... I'll check out what they have done and see if there are things we can leverage.

KiteLab commented 9 years ago

@galeots Are you sure you linked to the right software. Can't find where an extra adc is read. Can't find a 'resume'-menu. Can't find writing or reading to/from the sd-card. Can't find "resurrection" as a string. Can't find anything relevant

ntoff commented 9 years ago

The problem still exists that this feature will require at least some sort of power reserve in the form of either a small battery or capacitor bank. There's no way to implement this feature in just firmware.

Just hook a UPS to the board, power_good wire to one of the RAMPS pin and when the power good signal goes bad it shuts down the heaters and parks the head. Since power is technically never lost you wouldn't need to re-home (unless the UPS battery goes flat but if they can run a PC for a few hours surely it could keep an arduino on for a day)

giutrec commented 8 years ago

wait, the WASP team has just released the version of the firmware for delta wasp open (which is the smaller wooden version of the delta wasp) and do not believe in that version have implemented the resurrection, nor will the Lazarus that are present in commercial versions, and it's released in CC, I think as written in the article below it to him asking if we could give us the implementation http://www.wasproject.it/w/en/resurrection-system-a-3d-printing-revolution/

thinkyhead commented 8 years ago

It will require a lot of preliminary work generally, because Marlin doesn't have formal support for stopping and resuming a print yet, not at all. We need to develop some good, clean ways to accomplish that first, before even beginning to think about how to catch a power failure and respond meaningfully. For example, what if the print is using bed leveling compensation? Upon restoring power, that compensation would be disabled, so the print would resume in the wrong location. So… lots to do.

ghost commented 7 years ago

Hi , i'm not sure if this thread is solved or anywhere else I'm just a beginner and i don't have learned all the marlin code yet I don't want to be stupid here , but i need to contribute in a solution for all and for dummies Not all are devellopers , not all understand GITHUB lol , not all are electronician

I will offer my solution 'for dummies '

We have many sources that can apply a pause in this firmware ok We know that stopping the motors will not resume their perfect original position We know that the homing will not resume the original position perfectly We know autolevel code too young and not ready for resuming ' for the moment ' Impossible to be sure the stepper will not move after turned off , in my case , the pipes , the cables apply forces and the carrier will be pushed , and resuming will be DEAD

So ; We have ONLY ONE POSSIBILITY , never stop the power ! And it's not a big difficulty , i think it's more easy to made than many weeks of programming and testing that will not make results

So , everybody have to make their own extra power hardware , it's not expensive , it's not needed to be enginner

My solution ,
1-) An UPS or 12v/24v battery with diodes on the power 2-) A 220V/110V switch wired on the ' FILAMENT RUNOT SENSOR ' to make pause when loss 3-) Bed power stop when FILAMENTRUNOUT active ' option on the lcd if we want resuming system '

Ups must be able to produce enough time to wait the power restart '24h is very sure 'in reality 10/12h is enough , but for high security i prefer to wire battery directly by diode on the out of the power supply , we can gain more hours just by this .The advantages of direct battery is that in the case of very low voltage 8/7/6/5 critical volts , the motherboard have chance to stay functionnal , unlike an UPS that will brutaly stop The active steppers and motherboard have a low consumption so , it's easy to have long standby mode with the bed off ' We don't forget to apply more DIMAFIX coat to avoid risk of detachements '

This solution is perfect , FOR DUMMIES too , the cost is not expensive , i thing if you have a printer , you have a home for the printer , you have the money for the filament , you have a computer and INTERNET , you have enough money for one battery and a 220v switch

If stupid comment , please delete I can make cad schématics and tutorial for dummies , i can make a stronger hardware for not dummies , that have battery test panel , and automatic charging , i can make this.
You just have to make a menu on the LCD ' cold pause + RESTART when filament sensor become OFF' , if not exist, or simplify use and unused pin ' this will need to check all motherboards and have a big work of programming , testing, and supporting' , use the filament runout is IMMEDIATLY functionnal for all

In the case of filament pausing ' real ' , the user need to deactive the ' restart ' in the lcd , and easily change the spool , and restart manualy ' and reactivate the autorestart'

Thks

Roxy-3D commented 7 years ago

1-) An UPS or 12v/24v battery with diodes on the power

My FolgerTech only has a 12 volt supply. Nothing else comes out of the power supply. I'm not quite willing to do this, but if I put a small 6" x 4" x 4" tractor battery on the +12 volt power rail, it would probably handle the 20 minute power blinks I get. Something like this:

http://www.ebay.com/itm/Mighty-Max-12V-12Ah-F2-SEALED-LEAD-ACID-DEEP-CYCLE-RECHARGEABLE-BATTERY/191115358342?rt=nc&_soffid=100&_soffType=SaleAndClearence&_trksid=p5731.m3795

If I were to do this, I would probably want to adjust the power supply's output to be more like 13 volts just so it is always lightly charging the battery. That would be a very simple and effective solution for printers with a single 12 volt power supply.

ghost commented 7 years ago

after long reflexion about all the possibilities , the low cost requested , the long life without problems , i have decided this diagram , and all other economical system will not be sure . Printing need stable electrical system , no rapid composed diagram I have gather all the conditions , cheap , easy for dummies , evolutive for each budget , no safety risks , long life durability , no code no upgrade , work with all printer immediatly ' or all have pausing pin '

1 batterie of your choice , 15$ to more 1 charger low cost 5$ or more 1 220v relay 10$ ' high current needed ' 1 capacitor and some connectors/wires easy to find every where

sans titre

Here is for me , the unique diagram for the better ups securised home made system for 3d printers

ghost commented 7 years ago

@thinkyhead @Roxy-3D and others

Here are my suggest , the ideas of non confirmed and experiment develloper , but develloper too !

CASE OF UPS SHUTDOWN and motherboard turn off

Now We have , all on the SDCARD , we can now make the homing with just the zmax endstop , substract the height , apply autobed mesh perfectly and restard at the good line

I don't have enough knowledge of MARLIN labyrinth for the moment , BUT I HAVE IDEAS !!

@ Everybody

boelle commented 7 years ago

@thinkyhead @Roxy-3D and others... i think this one should be taken away.

very little interest have been shown and it just adds more complexity than its worth.

I would say that if people want this kind of security an UPS is the way to go. you can get an APC unit with expansion port for almost nothing is you get them used. replace the internal batteries and add external ones to suit needs

Grogyan commented 7 years ago

Recently, and since Prusa brought out their I3 Mk3 with resuming after loss of power, I feel it should be looked at again. As a UPS is generally too expensive for most people.

ghost commented 6 years ago

My idea 👍

OUTAGE PROCESS 1-) Ups with enough energy to finish the current layer 2-) A new gcode instruction M1000 , that i place in the layer change of my slicer 3-) A hardware outage detection , on a free pin 4-) A pause program , that idle the machine , if OUTAGE detectir + M1000 5-) The layer is finished , Carriage in pause park 6-) Program save last height in EEPROM 7-) If power back print restart

If UPS is down then RESUMING

1-) A program for resuming :(need human intervention to check if the object haven't pop off the bed and can continue the print) --- That ask to move manually the nozzle to find a solid layer to probe z on the object --- With babystep we will set it perfectly when print restart But now we have the problem to retrieve the perfect X/Y homing ...

Solution 1 --- Ultra high end endstop with high repeatability and the normal homing give good results Solution 2 --- Use very low feedrate and babystep in realtime for x/y , if the object is easy ok , but if a mad object , impossible to make it in a short time , and without make some traces ...

Solution 3 --- Place jauge comparator on the printer , and before the print , we place the carriage at x0y0 and we make the measurement. When we will resume , we will replace the carriage and with babystep we remake the same value , and print can begin

But , i need a good idea , to babystep without a ton of adventure or anything that is too much ... Thks for all idea , all are welcome

Grogyan commented 6 years ago

I don't see why a gcode is needed, when you could just add into the Configuration_adv.h that you have a UPS, so that would auto-magically finish the current layer, then store the next line onto an SD card.

If someone lives in an area where power outages occasionally happen, or regularly, then an EEPROM is a bad idea, as you will wear out said EEPROM. Besides as the move towards 32bit, most boards do not include EEPROM.

anton-piliugin commented 6 years ago

Can you test out the solution with a "secret voltmeter"? This solution can work on many of Atmega chips including ATtinyx4. I just bought the CR-10S so I can't test if it will work and how much time the microcontroller can work without a power.

Link on the code example for voltage metering: http://www.instructables.com/id/Secret-Arduino-Voltmeter/

My thoughts about how it should work:

  1. Detect the voltage drop (voltage lower than 4800 mV for example - this can be added as a parameter in configuration file for easy tweaking) on internal, so called "secret voltmeter" + Stop the X, Y, Z axis and filament movement (retract a little bit?).
  2. Write the position of X,Y,Z to SD card or EEPROM (or both?). CRC for data may be required.
  3. Try to move Z axis away from the printed object (IDLE mode can be used to save some power?) + Try to notify the Octoprint about the power problem.
  4. Then after power resume: 4.1 Show confirmation message about the power problem and ask user if he want's to resume the printing + Notify the Octoprint about the power problem. 4.1 Return X,Y,Z to home. 4.2 Move X,Y,Z to a last position and continue printing.

P.S.: I think you can keep the actual position of X,Y,Z in a memory to be able to write it on SD card or EEPROM fast enough.

thinkyhead commented 6 years ago

The CR-10S has a Mega2560, not a 168 or 328, so it's not likely to be much help.

anton-piliugin commented 6 years ago

I've posted a link on a code for 2560 and other microcontrollers: http://www.instructables.com/id/Secret-Arduino-Voltmeter/

thinkyhead commented 6 years ago

Aha! Well, that is cool.

ghost commented 6 years ago

@Grogyan Tell me How the machine knows when we make a layer change ... Because in a print , you have zlift , you have fwretract , it's impossible for the machine to know how it's a layer change It's why we add the gcode instruction in the slicer , not a difficulty and sure and , now , we are sure that the current layer is FINISHED. We are sure that the object have a precise planned surface , the best starting point for recovery. When printing , if we have the outage detection , the machine continue to print while appears the M1000 gcode , and now the machine knows the layer is finished and can go in pause park

Most board does not include EEPROM I didn't know that ... 😱

ghost commented 6 years ago

@thinkyhead , my new idea is to use the new sensor or MK3 prusa , and to mount it under the carriage , just for X/Y homing. The optical tracker will scan a fix point of the machine when homing but can be used , to make detection of the edges of an alreadry printed object The question is ... What is the precision/repetability

I have a ' silhouette cameo ' plotter , and the system is the same , an optical tracker scan the paper to find some printed marks before to start the cutting

Grogyan commented 6 years ago

@Studiodyne The machine could know by checking, once power loss has been detected, if the next gcode in the buffer has a Z change, then, you can decide if you want to do an X and Y home, or just move the tool head out of the way, the to an X and Y home once power has been restored and print resumed.

Homing accuracy on X and Y depends entirely on your particular endstops, optical tends to be more accurate than a microswitch.

ghost commented 6 years ago

@Grogyan In the situation of a print in dual extrusion mode , with ZLIFTING , and with separate printed object , where we have Zlift up = G1 zxxx , the layer is not finish . In my system , we ensure a finished layer , to have a plane surface , for more solving solution , if the object is simple , the user can make a new print of the rest , if the user want to resume , it is possible And with a totally plane layer , it's possible to make a z homing everywhere

About the endstop... Yes , it's true , it's my last job , find or make some endstop ultra high precision. I'm sure that if I found/make a device with ' 0.05mm' repeatability , i'm winning But i need the EEPROM + Human intervention for resuming , not automatic mode The autoresume will never exist as a system for all machines , only some custom machines can make this

In a case of CNC , the carriage cannot move , because of the guiding screws , and if stopped , we are sure to retrieve the same exact position of all the machine , and it's easy to resume , but on a chip printer , when power is down , the carriage moving by the force of the cable , the filament and more

My project is simple ' ALL MACHINES ' with EEPROM ' of course '+ Ups + OUtage detector hardware

-If ups falls , when reboot the menu tells me


Place manually the nozzle on the object to find the z0
Apply position 
Home x/y 
Read sdcard 
   --> set z height and heaters
  --> find the last M1000 <z height> 
 --> start print

The program to make , is simple , asking user to place manually the nozzle to find a solid layer for probing z , with babystep we will perfect it when restart , make a homing x/y and restart print at the layer stored in eeprom

SIMPLE and PERFECT ! But need ultra high precision x/y repeatability

Grogyan commented 6 years ago

@Studiodyne You are making this more complicated than it should. WASP has working code for an old version of Marlin, that just needs to be worked into the current BugFix.

Using the EEPROM us still not a good idea. I personally do not know if there is enough space left for storing the bytes of the last/next line. Good for quick experiments, but probably not long term.

Checking for Z change once power loss is detected is relatively straightforward. In my opinion, I am not a dev, nor can speak on their behalf, but I see no need for another gcode be added, just to get a resume going. The layer change means you know the Z height, no need to home that, would be dangerous if settings are not correct, may end up with a broken printer.

FYI a 3D printer, is CNC (Computer Numeric Control)

Grogyan commented 6 years ago

I have compared the Creality firmware that Naomi (SexyCyborg)acquired to WASP to Marlin 1.0.1 (as this is the oldest I can find that is similar enough to compare)

All are about the same (more or less) with no specific functions/calls to a pin, or M112 (emergency quickstop)

So either the functions are already in Marlin, or there is proprietary code to execute saving the last gcode line, and resuming from said line. However, these functions, by themselves, already exist in Marlin, just not implemented in a way to be automated in the case of power loss.

ghost commented 6 years ago

I have ordered some ultra high precision x and y endstop ' METROL 1µ'

I will make my test like this

I make a print with cylinders and square towers , and every 25 layers ' 10mm ' , i will make a G28XY homing , and every 25 layers i will see , if the homing have bad effects on the print If i have good result , i will start programming this

The feature is really simple and need hardware -one UPS -One outage detector on a free pin

If outage

if power resumue

If UPS down

SIMPLE !

The convenient is , AN UPS , DIMAFIX GLUE ON THE BED to ensure no ' pop off '

I promise , i will make it soon But i will need thinkyhead , to make the storing , and the SD CARD FEEDING until z found The rest i can !

Grogyan commented 6 years ago

I have begun the slow process of writing up backup and restore functions last night, as there did not seem to be much progress in this area. However i'musing the SD card for back up and restore information.

My limited coding ability will mean this will take a while.

ghost commented 6 years ago

Why finish the layer ? Because , so easy to resume a print if the current layer from zero , the probing of restart is so easy too It's why i will use UPS , because large format printer , need a true solution !!!

Grogyan commented 6 years ago

It's a good starting point.

ghost commented 6 years ago

I WILL MAKE IT and thinkyhead will make it really functionnal for all machine No need of special mechanicals system

FOR ALL MACHINES but need

Sensor high end ........ 120$ UPS 200$ outage detector 5$

Grogyan commented 6 years ago

That is very expensive to a lot of people. But it is a good starting point

anton-piliugin commented 6 years ago

Most UPS'es has USB data line to signal if power outage is detected, IMHO. You can try to use UPS connected to a Raspberry Pi + Octoprint for that. But it will be better if someone will test if atmega printer boards have enough power to save the progress on SD card

Grogyan commented 6 years ago

M27 reports the current byte, getting an accurate location which can be done when SD printing is paused via M25.

Knowing also what the filename was when prematurely stopped is also important, which can be also stores as bytes in the EEPROM. How much free EEPROM space is there on the Arduino MEGA 2560?

anton-piliugin commented 6 years ago

EEPROM size in ATMega2560 is 4096Bytes = 4KBytes https://www.arduino.cc/en/Tutorial/EEPROMRead

ghost commented 6 years ago

Yes .... expensive ... But this resume feature is for large format machine. May be for little if has money. Large format machine can burn 2 or 3 spools and can play more than 100 hours. It's a lot of stress to have bo possibility to use the already printed object.

Note: 1 micron are really expensive and ... too much for me for the moment so i will wait a few weeks

ghost commented 6 years ago

@thinkyhead @Roxy-3D NEED EXPERTISE PLEASE

GOOD NEWS - POWER OUTAGE RESUMING FOR ALL MACHINES IS NOT A DREAM NOW !

A very good news today , i have made a print , and each 20 layers of 0.3 mm , i have placed a XY homing , and , you cannot imagine my surprise when i've seen , the differences are so little , so acceptable , and NO NEED OF PRECISION ENDSTOP , to home XY after a power loss

POWER OUTAGE SURE RESUMING

My project : 
- A sure system to ensure resuming a print after power loss
- When outage detection , the printer finish the current layer and go to pause parking
- Needed : 
  -  UPS
  -  Litte hardware for outage detection  and a free pin 
  -  M1000 gcode instruction inserted in ' layer change tab ' of your slicer

How it works : 
- Each M1000 increment a counter on each new layer change
POWER LOSS start : 
- If a power outage appears , wait the ' M1000' gcode , 
to be sure the current layer is finished
- and go to PAUSE PARK
- Store the current M1000 count + Z HEIGHT + current FEEDRATE  in SD or EEPROM 
- If power is back , print continue 

If UPS is down

RESUMING : 
Only if the object is glued on the bed , and after expertise to continue the print
- Click on the last file and print it
- The firmware ask to help to make a contact with nozzle and object last layer
- By LCD/USB , you will manually make the contact  with the object last surface
- When ok , the firmware will set the Z HOMED and add clearance
- Now the firmware make XY homing ' the loss is minimal with chinese endstop  '
- Now the print can restart 
- Temps + setting 
- ALL MOVEMENT GCODE are ignored until appears  the count of M1000 '
- Stored Z height is applyed  + M1000 count updated +FEEDRATE and Print continue
- May be , a little babystep needed for restart 
- Z height stored is deleted , and the printer is now ready for another outage detection

Some lights about this ways Why finish the current layer ?

Why UPS ?

Why a new Gcode in slicer layer change tab ?

Why homing z by hand ?

Why homing x and y ?

Why make a counter of M1000 ? To have a turbo feeding of the file while the count is not reached

Why all this process ? Because the challenge is FOR ALL MACHINES , and no exception , to resume a print is easy , if you have created a special locked mechanics when power loss , but all the cheap printers and many expensive don't have a resume possible mechanics , and it's why , we need an universal SYSTEM UPS + a little board , and it's ALLLLLLLLLLLLLL !

Why Feeding the files and not storing the restart line ? Because if usb printing feeding or restart is impossible , it's why for compatbility with all machines , it's better to make an ignore movements procedure to reuse the original file

Why a human intervention for restarting ? Because an automated restart is impossible ON ALL MACHINES , and the object need a human expertise to be sure , no pop off and to continue is possible

THANKS FOR EXPERTISE

@thinkyhead , please trust this project , and help me to make the program , it's easy , not really difficult , but my little brain , my low knowledge of language , and how to store something on sd or eeprom is at zero , you can make the program in one or two days , for you , it's a game . And your Firmware , will have the best magic feature possible and that WORKS ! Not a commercial illusion that works only ' if , and i f , and if , and if ' but never works Thks

Grogyan commented 6 years ago

Prusa Mk3 Firmware @thinkyhead Looks like Josef has uploaded to his github the firmware source for the MK3 which includes the power panic (Blackout) detection But you might have already talked to him about it at MRRF.