RS-232 control of several relays

I want to use an RS-232 port to control several (at least 8, but preferably

16) relays individually. The load on the relays is low voltage/low current.

Basically, I want to use RS-232 to close the relay to replace a PC power switch, so I can boot a machine on demand from another.

This is a school project, so I'm looking for a low-cost solution. I'd prefer a trip to Radio Shack instead of a commercial solution. I did find this component, which looks suitable:

formatting link

Any suggestions? Am I on the right track?

Thanks for the help! Steven

Reply to
Steven Endres
Loading thread data ...

Are you intending to build something? Why not use the parallel port? Do the relays take turns or can they be on in any combination? Are you able to write software? Can you program a PAL (22V10) or a PIC?

The RS232 has a couple of handshake lines and the RS-232 line. There are several things you can do to make the hardware simple at the cost of making the software more complex.

If you think of the lines as just signals you can make go high and low and pulse and not as RS-232 data, I think you'll see some of the ideas right away.

8 relays won't be very cheap BTW.
Reply to
MooseFET

Yes, you are on the right track, however becareful of the head-on train.

You have not mentioned weather you are able to code and program your own chips. Like the one from elabinc.com.

So, I would guess that you are _not_ able to code and program your own chip, if you did, you would be done by now.

So, please help us help you.

1) Do you know how to program ? a) in assembly code b) in "C" c) in Basic

2) Do you know how to solder ? a) two wires together b) parts on to a PCB c) you can only burn yourself.

3) Do you understand that RS-232 is a voltage level standard and serial ports use those voltage levels for Asynchronous Serial Communications ?

There are many other question that can be asked, but, now its your turn.

donald

PS: If the questions above are beyond you, just buy the chips from labinc.com. You will get something done quicker and you will feel like you have accomplished something. After the first one, you then can move on to your own design, coding, burning, frying parts, makeing lots of smoke, debugging code, finding bad parts from the vendor, learning about how currents will flow into the path of least resistance, etc, etc, etc.

Good Luck

Reply to
Donald

preferably

current.

prefer

preferably

current.

prefer

Both of you asked for some clarification as to the nature of the project and my skill set, so I'll answer you both together.

I can assemble a professional project from a schematic. I can layout and etch a PCB and solder components etc. But I have no experience in designing the circuit itself.

No particular reason. The controlling system is a Sun server which has two serial ports and one parallel port, so either option is fine.

My goal is to boot a number of Sun servers on command from a master Sun server. Sun systems can accept a power-on signal through their keyboard connector, since their keyboards include a power button. Basically, shorting POWER_ON (pin 7) to GND (pin 1) on this connector will boot the system. Here's a pinout:

formatting link
(bottom figure) These pins only need to close for a moment (~1 sec) and can then switch back off. And note that we're switching a low-voltage, low-current circuit, so I don't necessarily need a relay if some other cheaper/simpler device will accomplish the trick.

As each server has a significant current draw (~7 amps peak) I would like to stagger the timing such that I don't get a big spike by booting all systems simultaneously. As soon as I can borrow one, I plan to put an ammeter on a system to determine when peak demand is reached after boot, so I can set a delay between each boot appropriately. I'm guessing this will fall in the

10-20 second range. Ideally each relay would be individually addressable,and the delay would be adjustable in software, but in a pinch I can settle for a circuit that has a fixed sequence and timing between "turn-ons".

Yes, I can write in C, C++, Basic, Java, and several scripting languages without trouble. I'd use C given the choice. I can do assembler as well, but it's been years and I'm rusty. And I haven't had a need to program serial or parallel ports before, so I'd need to look that up.

Yes, I would prefer a solution with more simple hardware and more complex software if given the choice, as that would likely cost less.

I have not sone so, but I'm sure I could learn.

I hope this answers your preliminary questions, and I thank you again for the help.

Steven

Reply to
Steven Endres

Don't know about your part of the planet, but here in Australia there are kits which offer that sort of functionality for both serial and parallel ports.

If they are still in operation (their head honcho died a couple of years back, and I haven't looked in there since) Kits'r'Us in HongKong did this type of kit also, and they are a mail order specialist.

Personally I favour the parallel port for this type of control.

Reply to
budgie
8 Both of you asked for some clarification as to the nature of the project and
8 I hope this answers your preliminary questions, and I thank you again for

Yes, you are now ready.

The first question is a religious one.

What chip to use ?

There are many chips to chose from, PICs, AVRs, MSP430s, 8051s, and the ARM world extends this list further.

The list is long and each has its own set of challenges and features.

So, do you have a preference ??

This project sounds like a one off, maybe two for backup.

Since you have a real project in mind, how fast do you need it ?

Getting a proto-board and soldering down a chip can be daunting to a beginner. But I bet you can handle that.

Getting a prebuilt proto-board with a chip on it would get you up and running quickly and many demo boards comes with assemblers or compilers.

For a quick one off project like this, I get boards from Sparkfun.com.

I have compilers for most of the small 8/16 bit chips on the market. So I tend to use AVRs or MSP430s.

As far as compiler/assemblers are concerned, do you want to use a development environment on said SUN systems ??

Are you unaffected by using WinXP based tools ?

OK, go to this link :

formatting link

download the schematics and docs.

This will give you a good idea on how to build your own version.

Good Luck

donald

PS: send pics :-)

Reply to
Donald

On Jul 2, 9:34 pm, "Steven Endres" wrote: [....]

Ok.

This is good. Interfacing to the parallel port will be easier than doing the RS232 version.

Beware that on some PCs, the printer port shuts down if it not used. This is most common on laptops. I'm going to suggest that the design latch the information for other reasons anyway but this is just another reason.

The parallel port has 8 data lines. You want more than 8 relays controlled so the simple design where each pin is used to control one relay. We will need to decode the output to select which latch gets the data.

Decoding and latching can all be done in one chip.

formatting link

I'll start by explaining 8 bits worth but leaving a consideration or two out and then expand from there:

Hardware: Port Chip GND ------------------------ GND D0 ------------------------- Data In D1 ------------------------- A \ D2 ------------------------- B ) Address pins D3 ------------------------- C / D4 ------------------------- Enable/ (Active low)

Software to set one bit:

Temp = BitValue + (BitNumber SHL 1) + 10H ParaPort = Temp ParaPort = Temp AND 0FH ParaPort = Temp

This works but it has four problems. (1) It only does 8 bits (2) When the Enable is moved, there may be glitches on the other lines. (3) It may do something when the port is shut down (if it is). (4) It is not protected against static.

Solving (1): On the second chip use the D5 instead of the D4 as the enable. The third chip used D6 if you need one and so on. This means that the software will have to change just a bit to run it.

UpperMask = 10H SHL (BitNumber SHR 3) Temp = BitValue + ((BitNumber AND 07H) SHL 1) + 0F0H ParaPort = Temp ParaPort = Temp AND NOT UpperMask ParaPort = Temp

Solving (4): Right near the chip put a 10K resistor in each line and a 0.01uF to ground. This will slow down and spread out any ESD spikes. Unfortunately, you have to change the software a bit to work with this. 10K and 0.01uF cause all the signals to move more slowly. After each write to the ParaPort, we need to add a delay of at least

1/2 a millisecond. 10K --/\/\--+-- ! --- --- 0.01 ! GND

Solving (3): Add this line: ParaPort = 0F0H

at the end of the code and don't use the "0" output of any of the chips to do anything.

Solving (2): Our ESD protector, filters out any glitches so this isn't a problem.

You now have more logic lines than you need to control the relays.

We need to know how much current is really needed for this. If it is really tiny, the IC can drive it. I expect that you will need more than that so I suggest each have a transistor on it. The 2N2222 can likely do the job.

------- server 1K !/c Q---/\/\----! 2N2222 !\e -------GND

When Q goes high, (5V - 0.7V)/1K = 4.3mA flows into the base. The

2N2222 can be easily trusted to switch up to 25 times its base current so this will be good up to about 100mA.

The above circuit is very general purpose. It is slight overkill because it can assert any combination of pins.

One thing to worry about is differences in ground voltages. I suggest that you run a big fat wire between all the chassis to ensure that they are all at the same voltage. I have seen wall outlet grounds up to 3VAC different. Only trust a wire you can see for this. Wall outlet grounds may only connect together at the far end of the building.

I think I've done that.

I think I've removed the need for anything special in programming.

Reply to
MooseFET

shorting

figure)

back

so I

like to

systems

a
a

the

addressable,and

for a

Okay, so far I like this option, as it seems the most striaghtforward to me (both to build and to program), and it looks like it can be built at the lowest component cost.

I share your concern about ground voltages. Perhaps to be on the safe side we should modify the output circuit to use an optocoupler to isolate the circuit being switched? I see that the Sparkfun AVR uses 4N37 optocouplers on its inputs. I presume this technique could be adapted for the outputs? The 4N37 is a single-channel optocoupler; perhaps there's a 4-channel or

8-channel equivalent?

Thanks again to MooseFET, Donald, and budgie for taking the time to help.

Steven

Reply to
Steven Endres

So many folk say you should make a computer to handle the task... they're all thinking inside their box.

Instead, consider the humble LM567 tone decoder, that responds with a logic output whenever it hears its programmed frequency.

You can queue up a kilobyte of zeros and ones for the serial port, with any pattern that you need to generate the frequency of interest.

Just program a bunch of decoders, for 200 Hz, 240 Hz, 270 Hz,

300 Hz, 330 Hz...

Condition the EIA-232 with some limit diodes and a crude filter. Isolate the target computer's reset pin with an optoisolator. You're done except for connecting the wires.

It might pay to use a small capture bandwidth and 'learn' each center frequency.

Reply to
whit3rd

I suggest that you consider running the logic on its own power supply and not using the +5V on the printer port connection. If you use the printer port connection's power, you have to worry about what happens if the plug is plugged or unplugged with the power on.

Non Darlington

formatting link
?Ref=490349&Row=192078&Site=US

Darlington

formatting link
?Ref=488533&Row=193515&Site=US

330 +5V --/\\/\\----- ! ------Input of PC V -> !/c --- -> ! ! !\\e From logic -------- -----GND of PC

The HCTxxx chips pull down better than up. The LED current is about

I = (5V - 1.6V) / 330 = 10.3mA

I think that is enough if the load is small.

The non-Darlington is better if the signal is really logic. It will pull about 10mA down to a legal logic low. It is also nice that the two LEDs prevent you from getting it hooked up backwards.

The Darlington will pull down a lot more current but not to a legal logic low.

I suggest you use sockets and use the Darlington's pinout. This way you can change your mind if you want to use it for other purposes.

Reply to
MooseFET

Do you _have_ to use RS232? If you just want to boot other PCs you may wake them up using your LAN. Google for "wakeonlan".

Pere

Reply to
oopere

About the only suitable product available from Radio Shack is the Parallax Basic Stamp kit, and this costs about $75. That has everything you need to get the project up and running very quickly though. Basic communications is all through the serial port and the project board has ample room to insert relay drivers. By the time you nickel and dime with piece parts, this may ultimately be the cheapest way too, not too much you will end up with a lot better product.

Reply to
Fred Bloggs

There are a number of places robotic types of places that sell serial to parallel chips and boards starting at ~$10 for the chips and ~$40 for the boards. The cheapest chip is probably the SN74LV8153 TI chip.TI will send you samples of the chips for free, or you can get them from Digikey for $1.38. I'd connect this chip to the 74hct259 latching chips ($.50 or less) to be able to do a lot of descrete on/off operations. As for relays, the below parallel port relay board is inexpensive and can be connected to the output of the 74hct259 chips in stead of the parallel port. Some have said to use the parallel port, but a number of its pins go hi/lo during a computer boot, and could cause some unintended situations. You could get around this by using it to operate the 74hct259 chips. Programming wise, you can actually use simple batch files to send the desired bytes to the chips via the serial port. Below are some links that might be of interest.

formatting link
formatting link
formatting link
formatting link
formatting link
formatting link

Reply to
Si Ballenger

I don't see what an HC259 will buy you. I'd use (up to) 3 of the control lines (if I needed 8 x 8 bits out) for address, the fourth one for strobe, and just use a 74HC138 or something for a decoder, and how ever many latches you need.

formatting link

Pseudocode: write 0nnnb to control port, where nnn is port address write data to data port write 1nnnb to control port - this should latch the appropriate latch. write 0nnnb to control port - this ends the write strobe.

And if you want, there are 5 input lines where you can read status or whatever you want. (they used to simulate a bidirectional port by nybble-banging - they'd send a byte 4 bits at a time to the status inputs.)

Cheers! Rich

Reply to
Rich Grise

On a sunny day (Wed, 04 Jul 2007 18:38:26 GMT) it happened Rich Grise wrote in :

OK ENOUGH OF THIS IF YOU DO NOT WANT PIC: I USE A PCF8474 IO EXPANDER ON THE PARPORT VIA I2C PROTOCOL, 3 PINS: CLOCK, DATA, AND DATA PULL DOWN VIA A DIODE.

IT WILL HOLD DATA WHEN THE PC IS OFF. IT WILL NOT GET CONFUSED BY INTERRUPTS IN CLOCK IN A MULTITASK OS. IT ONLY USES MICROWATTS. IT CAN USE 5V FROM THE PAR PORT FOR SUPPLY. IT CAN ALSO READ FROM THE PINS. IT HAS 8 IO PINS AND AN INTERRUPT. IT CAN DRIVE LEDS DIRECTLY. I HAVE PCF8591 ADC/DA ON IT TOO. YOU CAN HAVE MORE THEN ONE ONE THE SAME I2C BUS.

I HAVE C COURCE CODE FOR THIS FOR THOSE WHO WANT IT UNDER GPL LICENSE.

THANK YOU FOR YOUR ATTENTION.

Reply to
Jan Panteltje

- Can be done in a simple microcontroller with UART and enough IOs to control the relays. PIC, SILABS, ATMEL, and much more...

- Can be done with a simple FPGA and some VHDL programming.

- Can be done with two 8bit shift registers and some glue logic around.

Heinz

Reply to
Heinz Liebhart

Sun

keyboard

system.

pinout:

formatting link

switch

circuit,

will

ammeter on

set

in

settle

me

side

optocouplers

outputs?

formatting link
?Ref=490349&Row=192078&Site=US

formatting link
?Ref=488533&Row=193515&Site=US

help.

Okay, thanks for this info. I have found some additional information on this topic by including /parallel port/ AND /robotics/ in my searches. I'm going to try during the upcoming days to compile the best features of a few approaches into a schematic.

BTW, where does an IEEE 1284 parallel port provide +5V? All the pinouts I've come across do not list this as a feature.

If I have any further questions, I'll probably request a "schematic review" under a new thread.

Thanks agin, everyone, for your suggestions.

Steven

Reply to
Steven Endres

If you are looking at a specific PC, you probably need to check the voltage with a multimeter. Come current parallel ports may only output ~3.5v.

Reply to
Si Ballenger

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.