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 ads by
Signing UpStep 1Wiring Crydom
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.
| « Previous Step | Download PDFView All Steps | Next Step » |









































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
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
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
errors.
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.
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
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
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
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.