Sunday, November 11, 2012

Auto shutoff at end of print

Kill your 3D printer when it gets lazy !


Given the heat a 3D printer can generate, even when idle, I would better kill it than let it powered unattended, both for the planet, and to reduce the slightest risk of fire. ;)

I stick here to the simplest and most straightforward modification, partly because it is already supported by the Marlin printer firmware.

By the way, the total cost is less than $10, and you will just need a few solder points!

The BOM


  1. a solid state relay (SSR). Mine is an oversized Fotek one, that I purchased on ebay for about $8, shipping included. Now, the smaller SSR-25 DA ($3.80 S&H included) should be quite OK. These are electrically operated switches, that work just like regular relays, by letting big AC current through a pair of contacts when a small DC current is applied to another pair of contacts. You could use or make a cheaper opto-triac also (because we are dealing with AC current). Beware of fakes, they are everywhere (hence the need to oversize).
  2. "a momentary push button", (about $3 on ebay max). The connection is made when the button is pushed, and opened when released or idle (which is the standard behavior if not specified). I recommend one suited to your mains (220/110V AC), but since the button is used for a short period when the printer draws almost no power (no heating), I used a less robust 3A 125V that I had in stock (see the pictures), and screwed it directly in the plywood as it was robust enough.
  3. some short wire suited to the mains, solder and two pin if you want it clean or removable. Heat shrinking tubing is almost free and always good to have also, as it protects you from electric shocks, the electronics from shortcuts, and soldered connections from abusive bending.

Really, that's all for the bill of materials!

How it works 


The Ultimaker embbeded Marlin firmware supports auto-shutoff, else check with your firmware. At worst, use an opensource firmware, find an unused pin on the electronics and write a few lines of code to implement the same functionality... or design something else, such as an independent watchdog (out of the scope of this post).

How to die?

Committing suicide is a matter of adding a single "M81" line at the end of your sliced 3D object. For example, in Cura advanced mode, simply go to the tab named "Start/End GCode" and add M81 on the last line of "end.gcode":


;End GCode
M104 S0    ;extruder heater off
M140 S0    ;heated bed heater off (if you have it)
(...)
G28 X0 Y0  ;move X/Y to min endstops
M84        ;steppers off
G90        ;absolute positioning
M81        ;added here: commit suicide (shut pin A0 down)


As soon as the firmware is booted, Marlin sets the A0 pin to high (5V). And whenever it decodes such a M81 g-code command, it sets the pin to ground (zero volt).

So technically, it is as simple as using the state of A0 to command the relay: when A0 is powered (aka "high"), the relay is closed and the printer is powered. When it is low, the relay is opened and everything is switched off at the root. Once again, we can directly plug A0 into the relay command because we are using a solid state relay, and NOT a hungry coil-based relay which does require more power, hence a few more electronic components.

But then... how to live before dying?

Now, obviously we need to let the system boot until it has the opportunity to raise A0 and hold the relay closed by itself. Otherwise nothing can ever happen... the egg and the chicken.

This is where we add a push button in parallel to the relay, to temporarily restore the wire we just cut. Holding it for one or two seconds is sufficient to bypass the A0-relay functionality, until the software is up and running and deals with its own life.

Cabling instructions


Strip enough cable from your main power cord. Cut one power wire (not the green/yellow earth wire of course!), and route both ends to the two "~" AC connectors of the relay (they are not oriented).

Additionally, connect a the same two AC relay connectors to a cable that ends on your push button. Hence the mains current flows whatever the relay state when you push on the button.


The top picture will show it installed to the power supply, located below the printer since my hotbed addition.


One warning: make sure you will not electrocute yourself with the push-button connectors, since they are connected to the mains! Either choose an appropriate button with a safety cap, or add heat shrinking tubing and/or hot glue if you do not have protected connectors. Also do not let it loose, screw it in place on the plywood.

Now, the SSR has two oriented DC connectors. Connect the "minus" (ground) one to a ground pin of your Arduino board. The "plus" connector goes directly to pin A0 of your board.

This is a 1.5.4 board. Just connect any of the two GND pins to the "minus" SSR connector,
and the "0" (which really is the A0 Arduino pin) to the "plus" connector of the SSR 


In my opinion though, better do not solder cables directly to the board. You can add a 13-piece 2.54mm right angle row pin header to the board. Then, use crimp terminal connectors for example, protected with small pieces of heat shrink tubes around it once the cable is clipped. This way, your cables are removable and your setup more versatile.

A row pin header and one crimp terminal connector (both extremely cheap en ebay)

On my side, sadly, my board came with a vertical (straight) pin header already soldered. It does not help really because the fan shroud will then leave no room to connect anything to it. I had to bend my connector quite hard, which is bad.

Conclusion

That's it, now just tell your printer to kill itself when it gets bored because it is idle.

If you own an Ulticontroller, you can create a one-line gcode file on your SD card and run it to shut your printer off without the need for any more hardware. Just write "M81" to a text file named "off.gcode" on your SD card.

Final  note: when the board goes through a reset, the relays temporarily switches off. What probably happens is that the rebooting board still has time to raise the command before power drains completely. If it ever causes a problem, either I would hold the push button during a reset, or I would add a diode plus a small polarized capacitor on the SSR command pin to hold the signal longer and filter out this temporary condition.



No comments:

Post a Comment