in reply to Using Perl to make a hot-lead from any port

As zentara just said and I posted in Re: Does Perl ring a bell?, a simple optoisolator will help you out with a minimal # of components. A 4N27 is a good choice, and it's dirt cheap, less than $0.50USD in single quantities. Current capacity of the phototransistor is only 50 ma, so you need to keep your driver relay small. A larger one, with a FET output phototransistor, is an NTE 3085. This one can handle 100ma. In either case, you can pulse a higher-current relay safely, but be aware that the length of the pulse needed is longer that the actual "clap" you will end up with, due to the mechanical nature of the system.

Another possibility to explore is Opto-22 Solid-State Relays and similar generic products. These are commonly available on the surplus market, and can be wired up (in carefully sealed boxes!!!) to control such things as coffeepots and other AC appliances. I buy them surplus for $5 - $10USD and they're just as easy to use as the little DIP versions. Take care, though. Playing with AC can be deadly if you do not protect your wiring. I usually mount the SSR inside a steel 4"x4" deep handi-box along with a regular outlet and 3-wire plug on SJ cord.

Be aware that once you start making your computer go "thump!" in the night (or "ding!", or "buzz", or ???), it's hard to stop. Embedded systems are some of the most fun computing systems around; they're highly addictive.
  • Comment on Re: Using Perl to make a hot-lead from any port

Replies are listed 'Best First'.
Re^2: Using Perl to make a hot-lead from any port
by aufflick (Deacon) on Oct 05, 2005 at 02:38 UTC
    As mentioned by a few people in Does Perl ring a bell?, one of the oldest and easiest (and hackiest) way to get digital control out of PC style hardware is the parallel port. If you don't have one, a USB one should work since the windows or linux dirvers will take care of making it seem like a normal printer port.

    http://ourworld.compuserve.com/homepages/Bill_Bowden/page6.htm shows a simple circuit that uses only a single 5v relay and one resistor or very simple circuits using transistors to run a 12v relay. As others have said though, you should probably add in an opt-isolator. You could use the output of a low voltage one to drive a transistor output stage much like the non-isolated 12v on on the page linked.

    One of the big beneifts of the parallel port over USB is that it supplies 5v, which means you have a lot more relays/opto-thingamies that you can use.

    Ah this makes me remember why electronics was so much fun when I was a kid :)

    PS: Great stuff with the volunteer work, just don't electrocute yourself in the process!

      One of the things to be careful of when using TTL-level signals is that 'low' is not 'off'. Low is typically 'anything less than 1.3 volts', which will often leave you with a measurable current draw even if your relay does not trip. The serial port goes from +12 to -12, and so an LED behaves as a diode, passing zero current when your bit is 'off'.

      The parallel port is indeed a great place to tie digital signals; but it is HIGHLY recommended that you use an optoisolator there as well. Most ports are implemented on the motherboard these days, and motherboards still cost a bit more than a bucket of sand. :D