Sunday, August 30, 2009

A little info...

...on the controller I'm going to build.

Like I said before, I plan to control all the elements of my haunt with Brookshire software's Visual Show Automation (VSA) software. VSA's a pretty amazing piece of software, able to control all sorts of hardware interfaces. One of those interfaces is a parallel port relay board, more commonly known as a kit 74. I plan to build a version of this controller, (2 of them in one enclosure, actually) with one slight modification.

Hauntforum member Monkeybasic has written a really cool add on for VSA called Helmsman. Helmsman lets you create playlists of VSA routines and .mp3 or .wav files, control the volume of each routine or sound file individually, control the relays of a kit 74, and most importantly for my application, provides external triggers through the parallel port. And best of all, it's free! My relay controller will have terminals exposed for the triggers. If you don't have a need for the triggers, I'd recommend saving yourself the headache and just buy the kit 74. I'm building mine because I have most of the parts on hand, and I'm a glutton for punishment.

The way the parallel port relay board works is really pretty simple. Pins 2 - 9 of the port are the data pins, D-0 to D-9. When VSA tells relay 1 to turn on, what it's really doing is telling the computer to send 5 volts to pin 2 of the parallel port. So all we have to do is use that 5 volts to trigger a relay. Simple, right? Well, almost. The parallel port can't provide enough current to trigger a relay and it's pretty sensitive to power spikes and shorts, so we need to give it a little protection.

To do this, we'll use a transistor. Transistors are cool. (I think I'll have that printed on a t-shirt - I'm proud of my geekiness.) A transistor works like a switch. When you apply a small amount of current to one pin, it allows a larger amount of current to pass between the other two pins.

The transistor I'll use is a 2n-2222 switching transistor. You can pick up a pack of 15 at Radio Schmuck for less than $3. The pin configuration is shown above. The middle pin is called the base. When you apply 5 volts from the parallel port to the base, it allows enough current to flow from the top pin (called the collector) to the bottom pin (the emitter) to trigger the relay.

Just to be on the safe side, I'll place a 1k resistor between the parallel port and the base of the transistor, to limit the current flow to the transistor and help protect the parallel port.

With the transistor handling the current, I can add in the relay. The relay is just a switch that uses an electromagnet to turn it on and a spring to turn it off. When you apply power to the coil of the relay - in my case 12 volts - it triggers the relay. So it's just a matter of connecting one side of the coil to a 12 volt power source, the other side of the coil to the collector of the transistor, and the emitter of the transistor to ground.

Sounds simple enough, and it would work if I stopped right there. But there's one more area that could potentially cause a problem, and it's not at all obvious. Put your propeller beanie on, cause this is gonna get a little geeky. When you pass an electrical current through a coil of wire a magnetic field is generated. That's how the relay works - the current turns the coil in the relay into an electromagnet which in turn pulls the contacts closed. But - here's the part that's not obvious - when the current is removed from the coil, the magnetic field collapses and creates a spike in voltage. This spike can be as much as 200 volts, which would wreak havoc on our poor transistors and computer port. So, I'll need to give that nasty energy spike some place to go. I'll do that with a diode.

A diode is a nifty little piece of hardware that kind of acts like a one way valve for electrical current. What I'll do is place a diode across the coil of the relay in such a way that it won't interfere with the normal operation of the relay, but will give the spike (called back EMF) a place to go once the parallel port tells the transistor to stop passing current.

That pretty much covers the basics. Just build, rinse, repeat. I'll get some pics of the actual build as soon as I actually build it.

No comments:

Post a Comment