From: James W
[email protected]
Date: 2/14/2004 9:19 AM Central Standard Time
Message-id: <
[email protected]>
Chris, Thanks for the detailed answer.
The ACTUAL application is automotive. I'll have 3 big relays (~30A), and
3 small relays (~1A), with coil currents of ~150mA and ~10mA
respectively. Top side of the relays will of course be 13.8V.
Control needs to come from EITHER simple switches that will ground a
pin, or from a microprocessor (AVR) that will also ground a pin. I
intended to have the AVR connected to this relay 'board' using a shift
register, to cut down on pin count. The shift registers in turn would
drive opto's.
The guaranteed initial state request was so that if the AVR was not
present (mostly during the develpment stages) the relays would all be
open, unless overridden by one of the switches I mentioned above.
If I were to supply the power to the SIPO via the AVR, such that the
SIPO would have no power unless the AVR was present to control it, what
could I expect the SIPO's output pins to behave like? High-impedence?
- jim
Good. More info, more suggestions. It works.
First off, you want to be careful clocking a shift register with a switch of
any kind. All switches have contact bounce, which will mean multiple shifts
(possibly even off the chip into the bit-bucket). Better would be to have the
data switch and the clock pushbutton as uC inputs, and use software debounce.
You can then control the shift register directly from the uC.
Here are two options to get you started with the shift register thing. Both
will give you known outputs (the '595 will be tri-state, and the '164 will be
low) at turn-on. As another post mentioned, you can use pullup/pulldown
resistors to make tristate a known logic state. (View in fixed font or M$
Notepad):
AVR Guaranted with HC595
AVR OUT 1-------------------------------.
|
AVR OUT 2--------------------------. |
| | .-------------.
AVR OUT 3-----------------------. | | 14| |
| | '----oSDI o------
AVR OUT 4---------------------. | | 11| o------
| | '---o-----oCLK o------
AVR OUT 5-----------. | | | 10| o------
| | '----o-------oRST o------
VCC | | | | 12| 'HC595 o------
+ | '---o----------oLATCH CLK o------
| | | | | 13| o------
| | .-|--|-|-----oOE |
| | | | | | 9| |
1uF --- | __ | | | | .--oSDO |
--- '--|>=| | | | | | | |
| |1 |o----| | | | | '-------------'
o-----|__| | | | | |
| | | | | | .-------------.
| | | | | |14| |
.-. | | | | '--oSDI o------
| | | | | | 11| o------
22K | | | | | '-----oCLK o------
'-' | | | 10| o------
| | | '-------oRST o------
=== | | 12| 'HC595 o------
GND | '----------oLATCH CLK o------
| 13| o------
'------------oOE |
| |
| |
| |
'-------------'
AVR Guaranteed Cheapie with HC'164
VCC
+ .------------.
| | |
'--o S1 A o----------------o
AVR Out 1 | o----------------o
o-----------------o S2 o----------------o
| o----------------o
| HC164 o----------------o
| o----------------o
.-----------o CLR o----------------o
| | H o----o-----------o
| | | |
o--------o--------o CLK | |
AVR Out 2| | | | |
| | | | |
| | '------------' | Outputs to Opto
| | |
| | .-----------------------'
VCC | | | VCC .------------.
+ | | | | | |
| | | | '--o S1 A o----------------o
.-. | | | | o----------------o
22K| | | | '-----o S2 o----------------o
| | | | | o----------------o
'-' | | | HC164 o----------------o
| | | | o----------------o
o---o--|--------o CLR o----------------o
|+ | | H o----------------o
1uF--- | | |
--- '--------o CLK |
| | |
=== '------------'
GND
created by Andy´s ASCII-Circuit v1.24.140803 Beta
www.tech-chat.de
The basic question here is if you can slam data through the shift register
faster than the relays can react. The answer with the AVR is probably "yes",
and if so, and if you're really hard-up for pins and don't need any other
outputs that can't squiggle around for a few dozen microseconds, the second
circuit is probably a safe shortcut. The first one is the standard AVR/PIC
"full metal jacket" solution. It assumes you're going to set Output Enable on
the '595s as soon as the processor clock stabilizes and you're started up (this
shows about 12 ms -- increase the 22K resistor if you need more - the time
constant can be conservatively figured at 1/2 RC). The outputs will remain
tri-stated (if you're driving the opto with less than 8 mA each, you can do
this directly, and don't need pulldowns or pullups -- tri-state means off for
anything that needs current to turn on) until you can take the controls and set
the chip. It is a bit of a pig, though, and requires 5 uC pins (or 4 if you
only need the tri-state on power-up, probably not a good idea). The idea,
though, is that these 5 pins can control an essentially unlimited number of
outputs by daisy-chaining more '595s. For both circuits, if you really want a
guarantee, you'll want an external low power/watchdog reset circuit, and you'll
NOR with that your AVR signal, you'll have more security -- neither setup above
does anything about a processor upset or restart.
There are "guarantees" with even greater degrees of confidence, but that
involves more time and hardware. If this is "mission critical" or involves
safety, leave it to an engineer.
I hope this has been of help.
Good luck, and be safe
Chris