[MOD] Auto shutdown with & without OctoPrint

Share your hardware improvements for your HIC i3, the good and the bad!
Post Reply
ieatacid
Reactions:
Posts: 45
Joined: August 12th, 2017, 1:48 pm
Location: Scranton, PA
3D Printer(s): Hictop 3DP-03

[MOD] Auto shutdown with & without OctoPrint

Post by ieatacid »

When I started on this project I wanted something that I can switch on or off on-the-fly. Sometimes I'll slice a design and send it to the printer without checking the estimated print time. When bed time comes, if it's still printing, I have to leave the printer on all night. No longer!

This will work for anyone that has a D12 pin set on their ramps board. They often say "Servos" underneath them and if you happen to be using a BLTouch, like I am, you should have that plugged into the D11 pins. I highly recommend the BLTouch, by the way, but back on topic. If you have this (or, better yet, a dedicated PS_ON pin!) then you can continue. You'll also need to be able to edit your Marlin firmware and flash it to your board.
2.jpg

Parts

- (1) Momentary push button (normally open) I got mine from work and can't find it online, but you want something that can handle direct mains voltage. I'd go with something rated for 250V or greater -- mine is rated for 350V and works great. I found some on Amazon that are similar: link, link, link

- (1) Solid state relay (SSR) that will handle 5V on one side and mains voltage on the other. This is the one I'm using.

- (1) 250V 5A fuse. Here's a 5 pack for 3 bucks

- (1 if using OctoPrint) 10V 22000uF electrolytic capacitor

- Heat-shrink tubing (optional, but safer with it)
- 14 AWG wire

Only needed if you use my enclosure design
- A couple M3 screws to mount the SSR to the enclosure
- (4) 2-32 x 3/8" self-tapping screws (or similar) to screw the enclosure shut


Wiring schematic


Assembly
I bought a new power cord as the one that came with the printer was flimsy and only had two leads. I got mine at Lowe's or Home Depot but it's similar to this one that has 16 AWG wire in it. I just cut the end off (the side without the metal prongs!).

Assembly is easy if you can follow a wiring schematic (linked above), so I won't type it all out step by step unless someone gets stuck -- then feel free to post and I'll do what I can to help 8-) You can skip the capacitor if you're not using OctoPrint.

Here's a picture of my board with the wire that controls the relay connected to D12 and a BLTouch connected to D11
4.jpg

Everything wired up, before I screwed the enclosure shut. I put some hot glue around the top of the capacitor to make sure the leads are insulated.
5.jpg

All closed up and working
6.jpg
Firmware update
The only thing you need to change is in Configuration.h around line 210. POWER_SUPPLY has to be changed to 2

Code: Select all

#define POWER_SUPPLY 2
Then save and upload to your printer. This enables D12 as the PS_ON pin and lets you turn it off with M81.


Implementation (gcode)
In your slicing program you'll need to add some commands to the "end gcode" section. I only know where that is for Simplify3D (Process settings -> Scripts tab -> Ending Script). You should wait until it cools before shutting down so heat doesn't creep up through your heat-break and melt filament up where it shouldn't be melted, causing a big headache. So, something like this:

Code: Select all

M117 Cooling down ; display message on LCD
M109 R30  ; set extruder to and wait until temp reaches 30°C
M81 ; power off
You could probably use a higher temp like 40°C. It's probably safe to set that to whatever temperature PLA (or whatever material you're using) solidifies at.


Enclosure STL Files
https://www.thingiverse.com/thing:2581181
Attachments
auto_off_schematic.png
Last edited by ieatacid on October 13th, 2017, 5:19 pm, edited 1 time in total.
ieatacid
Reactions:
Posts: 45
Joined: August 12th, 2017, 1:48 pm
Location: Scranton, PA
3D Printer(s): Hictop 3DP-03

OctoPrint instructions

Post by ieatacid »

The problem I faced with OctoPrint was that when it would initially connect or when it needed to be restarted after installing a plugin, it would reset the control board which would cut power to the SSR. Then the system would have to be powered on again by pressing the start button. To solve this I put a 10V 22000uF capacitor across the the 5V side of the SSR which gives it enough power to keep the SSR latched when the control board reboots.

I also wanted to be able to set the printer into auto shutdown mode on-the-fly, without having to modify gcode. And it would have to first wait until the extruder cooled to a low enough temperature before powering off. After some searching, I found a neat little bash script lets you issue commands to OctoPrint from a command line or bash script on your RasPi. Then I wrote a small script to tie it all together.


- Install Automatic Shutdown on OctoPrint.

- Download OctoControl (download link is at the bottom of the page) to your RasPi then run this command to extract it to /usr/local/bin

Code: Select all

sudo tar -xzvf OctoControl.tar.gz /usr/local/bin/

- Create our shutdown script in the same location as OctoControl.

Code: Select all

sudo nano /usr/local/bin/octo_shutdown.sh
Past in the following

Code: Select all

#!/bin/bash

# the temperature you want the extruder to be
# before turning off the machine (and fans)
SHUTDOWN_TEMP=30

# make sure bed and extruder are off
8settemp 0
8setbed 0

# message to display on LCD
8msg "Shut down at ${SHUTDOWN_TEMP} deg"

# quietly wait until extruder temp reaches 30deg C.
# changing this to '8alarm'  will make it beep when
# the set temperature is reached
8alarmq d t $SHUTDOWN_TEMP

# send shutdown instruction
8gcode "M81"
Then this command to set its permissions

Code: Select all

sudo chmod a+rx /usr/local/bin/octo_shutdown.sh
- In OctoPrint's settings, click the 'Server' section on the left and change the 'Shutdown system' command to 'octo_shutdown.sh' and then save your settings.
8.jpg

- Automatic Shutdown places a checkbox on the bottom left side of the OctoPrint page like so
7.jpg

All done!

Just check that box after a print starts and it will execute the above bash script after the print is finished which will:
1) Make sure bed and extruder heaters are off
2) Wait until the extruder cools to the temperature specified by 'SHUTDOWN_TEMP' then
3) Send M81 to the printer, causing it to shut down completely

Enjoy! If you need help or have a question don't hesitate to drop a line below 8-)
Post Reply

Return to “Hardware Modifications”