Intro: Super Easy PC Control of 110 Vac Using a Crydom Solid-State Relay
I'm getting ready to try my hand at doing some hot plate soldering. Therefore, I needed a way to control 110Vac from my PC.
This instructable shows how to easily control 110Vac from a serial output port on a PC. The serial port I used was a USB type. Any standard serial port should work.
The idea is to connect the DTR (data terminal ready) pin from the PC serial port to a Crydom solid-state relay. The Crydom relay accepts a control signal of 3 to 32 volts to turn on the solid-state relay. The Crydom relay can also handle up to -32 volts on the control input to the relay. See attached datasheet.
Under normally conditions the DTR signal switches between +10 volts and -10 volts. This works out perfectly for the Crydom relay. The Crydom relay turns on at anything above 3 volts. Any voltage below 1 volt is guaranteed to turn off the relay. So, using the +10 to -10 volts of the DTR signal is perfect. The Crydom relay has a maximum load of 2mA on the DTR signal.
Switching the DTR under program control is also really easy. I've attached a little Python script that toggles the DTR pin every couple of seconds. The Python script is only 16 lines long!
To make the Python code work you will need to add an extra little package to Python called PySerial. I've also attached the windows installer for PySerial to this instructable. With a quick Google search, you can find PySerial on Source Forge easily too.
Step 1: Wiring Crydom
Caution! Make sure you tripe check everything when working with 110Vac.
The wiring circuit couldn't get much easier than this! The Crydom block is simply inline with the hot side of the 110Vac line. The neutral side passes right through. Pass the ground through too. But, also connect the ground to the heatsink/Crydom block to ground.
I know, I know, the wiring I used on the AC side is to small. I've got a really big Crydom relay (40 Amps!) so I should have some big mother wires. My house has 15 amp breakers so #12 wiring would be OK. I just grabbed an old PC cord and forgot how small the wires are. I think my wiring on the AC side is #18. So far I've just been playing with a 100 watt lamp, so no problem. I'll rewire before plugging in a big hot plate.
Step 2: Python Test Code
Below is the magic Python code. Again, can't get much easier than this. I've also attached the code in a file called "Test.py".
import sys, serial
from time import sleep
COM_PORT = 7
BAUD = 9600
ser = serial.Serial( COM_PORT-1, BAUD, timeout=0.5, rtscts=0 )
# Toggle the DTR pin on for 15 seconds, then off for 5 seconds.
while ( 1 ) :
ser.setDTR( 1 )
sleep( 15 )
ser.setDTR( 0 )
sleep( 5 )
Step 3: Be Careful
Before I use this Solid-State relay I'm going to mount some Plexiglas over the AC side of the relay. The 110Vac can really bite so be careful!
Hope this helps - Thanks,