Instructables

Super Easy PC Control of 110 Vac using a Crydom Solid-State Relay

Featured
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.
 
Remove these adsRemove these ads by Signing Up
frankenp4 years ago
Thanks!  I just built a similar device to switch off my old analog stereo gear (no remotes) when I put my computer to sleep.  Just tapped into the 5V line on a spare PC power connector.  The hand drawn diagram was very helpful.

jimk3038 (author)  frankenp4 years ago
That is a cool idea.

I wonder if I could use my laptop's USB port? I'm assuming it switches off too when entering into sleep mode. I could use that to switch off my space heater I use under the desk.

Nice idea,
Jim
My PC keeps the USB ports turned on during sleep.... so I had to use a power plug.  Some PC's keep their USB powered while others do not.  I like having USB powered during sleep because I can use my wireless usb keyboard to wake the PC.
On my PC, the front USB ports turn off but the back ones only provide power...
Pics of my build mentioned above.  I used two small 3A relays one for each plug..  3 amps per plug is more than enough for my use and the relays fit nicely inside a two gang box.
100_1108.JPG100_1112.JPG100_1113.JPG
jimk3038 (author)  frankenp4 years ago
Really nice. I like how everything gets packaged into a plastic box. Being a computer guy 110Vac always makes me nervous. Having everything sealed up is nice.

One thing to watch out for - the 3Amp rating is only good for Crydom modules that have a heat sink / good ventilation. I learned the hard way that the large module must be bolted to a heat sink. I'm not sure about the small modules you are using. But, packing them inside a small box might be a problem. Based on your mounting, I would derate them down to 1 amp.

Looks good,
Jim
cowen3 years ago
I know this is an old Able but what would a circuit look like if you would use a parallel port instead of serial?

LPTs use multiple data lines (8) instead of the serials one line.

By comparison you can use lpt1, 2, and 3 with just 3 cards, where you need a serial port for each control port. USB to serial dongles would allow for more then 4 easily added ports.

Do you think you could email a simple .py file for that interface?

Thanks
jimk3038 (author)  cowen3 years ago
This was really intended as a quick and easy way to control a single 110Vac device. I used it to control the temperature on an electric skillet while reflowing solder paste.

If you want to control a bunch of outputs at the same time I would be inclined to use a Pic, MBed, Arduino embedded micro instead. With one USB connection you could control an unlimited number of output channels.

Note, there are already these kind of devices on the market. Folks use them to control outdoor Christmas lights under computer control.

Sorry I couldn't be more helpful. I've just never fooled much with the parallel port.

Good Luck,
Jim

cgrooms3 years ago
I have another question for you! Is there any way you can have multiple replays on one serial and if so What pins would I use?. My goal is to control multiple lights. or is that not possible and you have to use two serials pins 4 and 5
jimk3038 (author)  cgrooms3 years ago
Nope, one relay per comm port. However, I can think of two options. You could use a small micro like a Microchip to control a bunch of relays on the comm port. That would make for a low cost solution. Or, you might want to look at an off the shelf solution. Do a Google on "vixen". Folks use that software to control Christmas lights. There are a bunch of relay boards that work with vixen. So, by searching on vixen you will find the relay boards. Good luck, Jim
cgrooms3 years ago
Thanks so much for your help! I got it to work last night! I just needed for some reason to install python-serial and to specify what serial port I had to modify the code a little
cgrooms3 years ago
Thanks, I fix that problem now I have this error File "temp.py", line 7, in ser = serial.Serial( COM_PORT-1, BAUD, timeout=0.5, rtscts=0 ) File "/usr/lib/python2.6/dist-packages/serial/serialutil.py", line 166, in __init__ self.open() File "/usr/lib/python2.6/dist-packages/serial/serialposix.py", line 175, in open raise SerialException("could not open port %s: %s" % (self._port, msg)) serial.serialutil.SerialException: could not open port 6: [Errno 2] No such file or directory: '/dev/ttyS6'
jimk3038 (author)  cgrooms3 years ago
Looks like your trying to open a serial port that does not exist. The easiest thing to do is to use another terminal program to verify which ports are available on your machine. Make sure the terminal app can successfully open the port - if the terminal app can't open the port then Python will also fail by throwing the exception you see in your error message. Edit the known good port name into the Python code and you should be good to go. Good luck, Jim
cgrooms3 years ago
having the same problem getting errors File "test.py", line 8 print "On" ^ IndentationError: expected an indented block
jimk3038 (author)  cgrooms3 years ago
Sorry to hear your having problems. The Indentation Error is a common error.

Python is kinda weird, in that, it's really picky about indenting in the source code. It drives Python crazy if you happen to indent with tabs and spaces within the same file. Either use spaces, or tabs, but never both in the save file. Some of the better editors have the ability to show tabs with special visible characters. Using this special mode you can verify you have not mixed spaces and tabs. To execute a block of code within some loop like a "while" loop, Python looks for an extra level of indention. The syntax would look like the following.

while 1:

print "Hello World"

This loop would print forever to the console simple because "print" is indented under the "while" statement.

Help this helps,
Jim

I can't get this to work. All I get is a
errors.
jimk3038 (author)  Crimson-Deity4 years ago
What error are you getting? What line number does it complain about? Can you capture the error message and post it?
Thanks for the quick respons ! :D

I have never, ever programmed ANYTHING before so I'm a noob to the max. Could you make a tutorial on how to use Python? I tried to copy and paste the "Test.py" content into the IDLE Python text thing, but some sort of error occured. My laptop is somewhere out of my reach at the moment so ill post a picture ASAP.
jimk3038 (author)  Crimson-Deity4 years ago
You have made a good choice with Python as a starting language. Python is kinda like a Swiss Army Knife for programmers. Python can be used to code really simple stuff. Or, full blown object oriented code.

Anyway, step number one - go out and buy two books. Learning Python and Python Cookbook. These are really good to get you jump started. I've attached a picture of my two books. You can see my books are kinda beat up - that is a good sign - means the books are used a lot!

Next, try to run my little code block. I'm guessing your missing the extra serial port package. Python does not have support for serial ports by default. No problem - go back to my instructable and download the extra installer for the serial port package. This package adds serial port control to Python.

Next, run each line of code in IDLE. IDLE will tell you when you hit a problem. But, once you install the serial port package I guessing you won't have any problems.

Good luck,
Jim


DSCN1110.JPG
I remember when I was in electronics, building a SSR was one of our last projects. Then we had to use our "8088 Primer Trainer" (kit using an 8088 processor to learn to program machine language) to turn on 3 items, a light bulb, a blender and a drill press. So we had to break up into groups of 3 and hook up the hardware to the computer then write the necessary code to turn on one item for 3 seconds then the next and so on. Lots of fun...and we actually built the relays also..if I remember right they were capable of over 20A @ 120V...although its been a number of years.
jimk3038 (author)  Swishercutter5 years ago
SSR are not good on inductive loads like blenders and drill presses. As a plant engineer many years ago, I tried jogging a conveyor belt using a big Crydom SSR relay. I sized the relay to handle the motor and provided a nice heatsink. The relay only lasted one day before failing. Of coarse, the thing failed in the middle of the night too! So, yes, the SSR can be used for a little fun. But don't count on them switching motors for very long!
I have no experience with the Crydom or any other manufactured SSR's. Just the ones we built from scratch for educational purposes. I never extensively tested it but it seemed to do just fine. I imagine there may be some issues with the initial current requirements of a large inductive load like a motor (there are ways around that) but they worked in the short term amount of time for our final lab exam. I will have to find the schematic with the part numbers and show how to build one from scratch sometime. Although, I never seem to find the time to actually do an instructable on anything though.
you could just use a pull-up transistor and a regular relay
cirvin5 years ago
That's quite a heatsink you have on that SSR. I have a few of these wired up in a steel electrical box with a plug in my dorm to switch a 600 watt lamp, without a heatsink attached. I haven't noticed any appreciable heating of the units. Please comment when you test this out, I'd like to know how your device behaves under your load.
jimk3038 (author)  cirvin5 years ago
The Crydom blocks will get hot when switching heavy loads. The datasheet has a couple of tables that show derating curves based on switching load. Without a heatsink the relays derate to 8 amps at 25 degrees C. So, you should be able to switch up to about 800 watts at room air temperature. In hot ambient temperatures, derate even more down to 6 amps.

However, with a simple heatsink the permissible switching load goes way up. The steel electrical box your using probably would act as a good heatsink. Also, here is a link to a heatsink Crydom makes: http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=CC1113-ND As with everything from Crydom, it's pricy (12 bucks at Digikey).

Ten years ago I smoked a big Crydom by not heatsinking it. So now I always make sure they are well sinked. You can also fry a Crydom by switching inductive loads - just a word to the wise.
Hmm I found some cheap-no-name brand SSRs on ebay for $7.50 shipped. Will try that out, I looked at the prices on the Crydom relays... WOW
gentry5 years ago
How much did that SSR cost? I found some 15a Sharp brand ones at digikey for about $5.
gwhamilton5 years ago
What are the chances of powering the SSR from a USB port? The 5 volt signal should work. I work with SSR's everyday but I need to find a program to switch USB power. Thanks
Pretty easily, you should be able to grab an FTDI type device and just use that as an USB to Serial converter, you should be able to use the TTL serial signal straight from the FTDI to switch the SSR. Other than that, you can follow this instructable for the rest of the instructions.
Honestly, I know very little about USB programming but since it is a serial connection I would imagine that it would be easy to make a hardware serial to parallel converter with some flip flops on the output set up to drive the relays (not really as simple as I make it sound, but not too bad). By doing this you will not only be able to control power, you will be able to control multiple relays using BCD (Binary Coded Decimal) or something similar to specify which relay is being controlled. With flip flops on the output it makes it so that an item turns on and waits for another signal to turn off (also makes it so you don't have to send a different message to turn off the item, just send the same on message to switch the flip flop).
Berserk875 years ago
cool. i was looking for ways to control high voltage with low voltage things like computers or micro controllers.
servodave5 years ago
Cool. Best thing about this is that the computer is optically isolated from the ac line. I've built dozens of these for the research lab I work for over the years. SOOOOO Useful for turning things off and on--solenoids, fans, small motors. Usually I put a BNC bulkhead connector on the input and a neon lamp on the output for diagnostics. You might want to add a fuse and some sort of enclosure with vent holes and a fan if you are pushing a lot of power though the relay. Maybe gut an old PC power supply to get the power entry module. Other than that: good show!