Wednesday, July 8, 2009

Relay on LPT port



I made this (on a piece of leftover junk PCB) to remotely switch an external HDD connected to my home server on/off.
I went with the "Safer New Design" from here, but then decided to opto-isolate it anyway. An LPT port data pin switches the led in a 4N25 opto-coupler, which then switches an external power brick's connection to the board. The relay then switches the mains on an extension cord. I pulled the NAIS 5v/220V relay from a broken monitor. Although with this design the switching voltage isn't really that important. As long as it's within the accepted ranges of the opto-coupler and transistor.


Coded up this simple command-line tool in FreeBasic to use it with:

dim as string myCmd
dim as ubyte myState

myCmd = ucase(command$(1))
if myCmd <> "ON" and myCmd <> "OFF" then goto state
if myCmd = "ON" then out &h378,1
if myCmd = "OFF" then out &h378,0

state:
myState = inp(&h378)
if myState = 0 then print "Relay is OFF" else print "Relay is ON"

Update:
I decided to release my board layout along with some notes on this project, in case anyone wants to build this. The notes say it all.

You can check it out here or download it as an Eagle BRD (v5.6)

In case you build it, leave a comment :)

1 comment:

  1. I wish I had seen this when I needed a controlled relay for something I built the other day.

    I ended up tying the DTR and RTS pins of the serial port together to run a small reed relay- when you bring them both high it produces ~5V.

    It's a nice way of triggering a contact closure on the security system of our office building from trixbox for when I forget my pass :-)

    ReplyDelete