Monday, January 31, 2022

[3D Printer Series] AC powered heated bed and safety

 A normal 24v DC heated bed usually takes a while to come up to temp, especially if you want to print with higher temperature filament. Not only does it take a long time, but it also consumes a lot of the PSU power. That's why if you want to heat up your bed faster, you'll want an AC powered unit.

I purchased this:

Which perfectly fit my new cast aluminum plate and it's mounting holes. Since we can no longer use the Robin Nano controller board to feed this 120V AC and 750 watts is much more than my PSU can handle, I also got a 40amp solid state relay (SSR). You'll want an SSR so that the Robin Nano can still control the heater with a PWM signal. The SSR needs to support a control input of 24V DC and be able to switch 120V AC. For our needs a good quality 10A SSR would suffice but since I don't trust these off brand models I went with a 40A model for extra insurance.

DC to AC 40A SSR

Thermal Runaway

Even good SSRs can fail and the worst way for it to fail is if they fail with the circuit closed (i.e. permanently on) which would mean there's nothing stopping the AC power from flowing to the heater until it catches on fire. 

First line of defence: Thermal Fuse

To prevent this, I added a thermal fuse in series with the wire for the heater power. If the temperature exceeds a certain level, the fuse should blow and the heater should get disconnected. To attach the thermal fuse, I used RTV silicone sealant, which seems to be the adhesive of choice for this task among the Voron crowd. Then to insulate the bottom, I added a self stick foil faced insulated pad used on automobiles. The adds another layer of insurance to keep the thermal fuse in contact with the heater pad.
 
Thermal Fuse

Insulated Pad

RTV Silicone Sealant

2nd Line of defense: Pi controlled relay

Relying just on the thermal fuse might be okay if you plan to continuously monitor your printer but I don't want to monitor my prints so closely. So for an added measure of safety, we want to make sure our heater bed remains disconnected at all times except when the bed is heating. A regular relay can do this for us if we connect the wires leading to the SSR through our relay using the relay's NO (normally open connection). This is nice because we have to actively supply power to the relay to keep the power flowing to the heated bed. The relay I used is the Elegoo 4 relay module. It's nice because the inputs can be isolated from the power used to energize the relay coils.
Elegoo 4 relay module

Why do we need to electrically isolate?

The logic/GPIO pins on the RPi operate at 3.3V but the coils on the relay work on 5V. To make this work we need to separate the relay's logic voltage from the relay's coil voltage. According to the documentation this can be done by removing one of the jumpers:

Remove the jumper to allow mixed voltages

Then you can wire up the module like so. (Note only the top pin under the jumper should be supplied with 5V)


Luckily, the RPi has some 3.3V pins close to some GPIO pins so I chose the first 3 pins since I knew I wanted to control 2 relays, but you can choose the ones that work for you. 
I chose these pins (green), but you do you
For the 5V and ground connections, you can either use the same 5V PSU connections as the RPi or daisy chain it from the header pins (pins 4 & 6).

Configuration

In OctoPrint, I first used the GPIO Control plugin which is good if you want to manually control the relay. The thing to remember is that you need to configure the "Active" dropdown to "LOW" to indicate that activating the relay requires the GPIO pin to be connected to ground (0V). That's usually how these relays work. If you see the relay light come on when you command the pin to be "ON" then it's configured correctly. If the light doesn't come on then you might have a relay that's configured for active "HIGH". If the light works correctly, but the relay itself is opposite, then you've likely wired the output of the relay to the "NC" (normally closed) pin instead of the "NO" (normally open) pin which we want for passive safety. The "GPIO" number should match the label in the pic above.
Active should be set to "LOW" for most relay modules

 Advanced Configuration

Using GPIO Control is relatively straight forward, but you'll have to remember to turn on your heatbed before every print and then turn it off after. I'd rather have Klipper do that for me automatically. Additionally, since Klipper has temperature safety checks, that will shutdown the printer when it detects a temperature abnormality, I want that to also shutdown the relay controlling the heat bed. But how can you get it to trigger a GPIO pin on the RPi? Answer: RPi microcontroller 

You can add the RPi to Klipper as a secondary microcontroller (mcu) and use it's GPIO pins as if it was just another driver board. To do so, follow the instructions in the link above and in the end you should have added something similar to the following lines to the klipper printer.cfg:

[mcu pi]
serial: /tmp/klipper_host_mcu

In my case, I named the RPi mcu as "pi" but you can name it whatever you like, just remember it.
At this point your config doesn't do anything, it just establishes the RPi as something klipper can control. To have it turn on the heated bed when the bed is active we can use the [controller fan] configuration which essentially enables the configured pin when the specified heater is active. Just make sure we keep the speed at 1.0 (ie 100%) since we don't want to pulse the pin on/off. Luckily the default config is just that.

[controller_fan heater_relay]
pin: !pi:gpiochip0/gpio3
heater: heater_bed

Notice that we include a "!" in the pin configuration. That inverts the logic of the pin just like how we set active to "LOW" using GPIO Control. The rest of the pin configuration is explained in the klipper docs.

Now I just start my prints as normal and the heater bed relay turns on automatically, sweet!

No comments: