Sign in to follow this  
Followers 0
loolykinns

parallel port?

6 posts in this topic

I've been workin' on "Relay switchin' via Parallel port" which wasn't so hard... but I am limited to 8 lines to control... is there any way I could increase the control lines ?

here's the sketch

post-10172-1180185786_thumb.jpg

0

Share this post


Link to post
Share on other sites

I've done a bit of parallel port development under Linux; I use a C/C++ lib called parapin. It allows the use of input/output on /any/ of the parallel control lines (of course, some are input-only, or output-only, and there's an interrupt generator).

As far as multiplexers, they're fairly easy to use. Think of them as a rotary switch, that instead of rotating a shaft to select a data input/output, you feed it a binary address. For instance, you may have a 1-of-4 multiplexer. This is a device in which there is 1 input pin (technically, an output device is a de-multiplexer) and 4 output pins. Feeding it the binary number 0 on the address pins directs the state of the single input pin to the #0 (or first) output pin of the multiplexer. Similarly, a binary 3 will direct the state of the input pin to pin #3, the last pin. The great thing about multiplexers, is that you only need two address lines to control an unlimited number of multiplexers. If you use two lines not associated with the 8 parallel port "data" lines, you can then use up to 32 lines from the original 8. If you need a constant output, you can "gang" the outputs of the multiplexers into 4 8-bit channels, each of which has a latch. The latch will allow you to "lock" the data at its outputs. This is done by setting the states at its /inputs/, then pulling a Latch Enable line true (whether this is high or low depends on the latch). When this occurs, it doesn't matter what's happening at the inputs, the outputs remain in the same states as when the Latch Enable became true. This allows you to set the data on a particular 8-bit channel, and then do more data manipulation on other channels.

0

Share this post


Link to post
Share on other sites

I don't immediately see a way to use multiplexers to solve this problem unless you only want to have a single relay active at once.

Here's an idea that will reduce your component count and solve your control issues, all for free, it's also easily scalable (you should only ever need 3 or 4 parallel port pins, and you can control as many relays as you want, and as many relays can be on as your power supply can energize). Texas Instruments makes these chips called "Power Logic" shift registers (see docs: http://focus.ti.com/docs/prod/folders/print/tpic6b595.html).

In case you don't know, a shift register is a logic device that takes a data input and a clock input and basically the data is clocked in sequence through a line of one-bit registers each time a clock edge occurs (see wikipedia:http://en.wikipedia.org/wiki/Shift_register). So, basically all you need is a clock line, the data line, and a few other signals coming from your parallel port.

Each of those tpic6b595 chips has eight one-bit registers arranged so that when a new input comes into the SER IN pin (and the clock goes high), the input is latched into bit 0 of the latch, and the old bit 0 is latched into bit 1, and so on. The old bit 7 is latched to the SER OUT pin, which can be connected to the SER IN pin on another tpic6b595 chip, forming a cascade of shift registers. The register is internally double-buffered, so you won't see the outputs immediately (I'll explain this in a second).

The DRAINx (where x goes from 0 to 7) is a DMOS transistor output that can sink up to 150mA, and it has the built in flyback protection diode built right into the chip! So, all you have to do is connect one end of your relay coil to +5V and the other end to a DRAIN pin and you've got yourself a way to energize or de-energize the relay coil.

To control this sucker, you'll need at least three, maybe four outputs from your parallel port (run through optocouplers, like you show in your diagram). These lines will connect to the SER IN pin of the first chip in the cascade, the SRCLK and RCLK lines. When you want to change which relays are turned on, you'll send a string of 0's and 1's to the shift registers that tells each relay whether it should be turned on or off. For instance, if you want the 5th relay to be turned ON, and all others off, you'll shift out a binary 00010000 (assuming you start counting relays at one and not zero).

Assuming you are controlling eight relays and you want only the fifth to be turned on, your control software would do the following:


- Set SRCLK and RCLK low.

- Put the highest bit of the pattern onto the SER IN line.
- Raise SRCLK high and then put it back low.
- Repeat this process until you've shifted out all eight bits.

- Raise the RCLK line high and then put it back low.

This last line makes the data you shifted in available at the DRAINx outputs of the shift register (this is the internal double-buffering thing I was talking about). By doing this, you make sure that none of your relays change accidentally while you're shifting a new configuration out to the shift registers. This will all make more sense if you read the chip documentation that I linked to above.

And you can get the shift register chips for FREE, because they're available in DIP packages through TI's IC sampling program.

Hope you find this interesting. I might just have to go make one of these now that I've thought all this up. Let me know if you have questions, etc...

Edited by parnekin
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0