# Can I drive a 4N26 with a 74HC595

Discussion in 'Electronic Basics' started by James W, Feb 19, 2004.

1. ### James WGuest

With help from this group in the past, I've decided that I'd like to use
a 74HC595 shift register in my relay circuit board.

I'd planned on using the '595 to sink individual 4N26's which in turn
would drive PNP transistors to turn on some relays that require ~150mA
of coil current.

I'm attempting to read the spec specs for the 4N26 and the ~595 and I'm
not clear the '595 can sink enough current per pin to 'light' the LED in
the 4N26

The '595 is spec'd (I believe) to be able to source or sink 6mA per
output pin. However, the 4N26 is spec at 10mA for I-forward... so this
seems to be a no-go.

What do people generally use to 'turn-on' opto's? Was the 4N26 a good
choice for my opto?

- jim

2. ### Fritz SchlunderGuest

The 6mA (continuous DC) per output pin is in the ballpark for HC logic. So
is 6mA adequate for driving the 4N26? Yes it is, but it depends upon how
much output current you want the 4N26 output stage to provide.

For this post I'll refer to this datasheet for the 4N26:

http://www.fairchildsemi.com/ds/4N/4N26.pdf

Under the transfer characteristics the CTR for this device is specified as a
minimum of 20% with a test LED current of 10mA. This 10mA rating is just a
simple test condition. You can drive the LED with quite a bit less or quite
a bit more than this (from 0-100mA DC, more for pulsed operation) and the
optocoupler will still work.

So what does the CTR mean? It stands for Current Transfer Ratio. If you
multiply the CTR by the forward LED current you can get a rough idea of how
much current the output transistor of the optocoupler can provide. For
example: suppose you drive the LED with a forward current of 6mA. Then the
minimum guaranteed current the optocoupler output transistor can sink (or
source depending upon circuit configuration) is theoretically something like
6mA * 0.20 = 1.2mA. Basically this behaves very much like a bipolar
junction transistor with a beta of about 1/5 or 0.2. Other optocouplers
with CTRs greater than 100% are available and are not necessarily more
expensive than the 4N26. Take a look at the large array offered by your
favorite distributor such as Digikey or Mouser.

In practice the above formula (LED current * CTR = output current) isn't
quite perfect. The problem is the CTR is not a perfect constant property of
the optocoupler. Instead the CTR is somewhat a function of LED current.
Look at figure 4 of the datasheet for instance. For small LED currents the
CTR is somewhat lower than at 10mA. For instance it appears with a LED
current of about 1.8mA the CTR drops to a mere 0.8*0.20 = 16%. On the other
hand with an LED current of about 6mA the CTR is slightly higher than the
10mA test current conditions at around 1.08 * 0.20 = 22%. At very high and
very low currents relative to the 10mA test current we can see the CTR drops
quite a bit.

So the bottom line is with the 4N26 you can drive it with 6mA, but you will
be limited to something in the range of 1.2mA of output current. So this
means in order to drive your 150mA relay you would need a PNP transistor
with a minimum DC gain of around 150ma/1.2mA = 125. Generally you want to
drive both the optocoupler and PNP transistor with a bit more current to
insure good saturation in all conditions.

If this problem were up to me I would certainly not use the 4N26. It is a
rather pitiful device, and doesn't even really command much (any?) price
advantage over other superior optocouplers. Some device like the NEC PS2501
for instance provides more bang for the buck.

Datasheet at:

http://www.cel.com/pdf/datasheets/ps2501.pdf

Notice this part comes in a variety of flavors. One type comes with two
optocouplers in a single package while another type has four inside. It
sounds like your project may need more than one, so this might be a good
choice.

For pricing and looking for other possible choices use your favorite
distributor's catalog such as:

http://dkc3.digikey.com/pdf/T041/1200-1205.pdf

3. ### JeffMGuest

I'd planned on using the '595 to sink individual 4N26's
1) Do you need the isolation which the relays provide?
2) Do you need the isolation which the optos provide?
3) Have you already bought the BJTs?
4) Could you use 1 FET each to replace the whole lot?

|
____|____
| |
|_________|
|
___ |
| ||--
| ||
| ||__
|-----|| |
| ||--|
___| |
|

4. ### CFoley1064Guest

From: "Fritz Schlunder"
A well-considered response. I'd go with the PS2501L-4, available from
Digi-Key. For each HC595, you could use 2 PS2501-4s. Use 560 ohm series
resistors to get your 6 mA into each LED. Then you can set up the opto
transistor (80% CTR min, 300% CTR typ) as a current sourcing output (collector
to V+, emitter driving output) *directly* into a ULN2803 input if you're +5V on
the other side, ULN2804 if you're +12V, and then drive the relays from that. 8
relay drivers on one 18-pin IC. You don't even need series resistors for drive
transistors, or diodes across the relay coils (connect pin 18 to V+). All of
this is available from Digi-key. Minimum pin count, least hassle, get on with
it. Life is good, eh?

Good luck
Chris

5. ### Robert C MonsenGuest

I apparently missed this thread. Why are you using an optoisolator? Are the
control inputs offboard? Note that the coil is already isolated from the
switch, so you don't have to worry about that.

If you don't really need the isolation, an NPN transistor like a 2N2222
would be fine. Connect the coil to Vcc and the collector. Parallel a diode
like a 1N4003 to protect the transistor (it has to point from collector to
Vcc.) Then, connect the emitter to ground, and the base to the 595 through a
1k resistor. Then, assuming a beta of about 100, your 6mA would be able to
push 600mA through the relay (the relay won't draw it, of course, due to its
internal resistance.)

If you don't like the idea of using discrete transistors, you can get arrays
of transistors like the ULN2803, which would work perfectly for this
application. http://www.doc.ic.ac.uk/~ih/doc/stepper/control2/2803.html

Regards,
Bob Monsen

Regards,
Bob Monsen

6. ### James WGuest

The relays are controlling LARGE loads.. ~35A at 12V, so yes, I want the
relays.

The opto was just becuase I'm paranoid.. realy no reason for it.

Ok... here comes the WHOLE story.

My needs are a microcontroller that controls a large enough number of
relays that I WANT to use a shift register ( to provide port expansion )
at the business end. Now, I've got one more wrinkle. I need to be
able to override the microprocessor and EASILY turn on individual
relays. Ideally, buy simply grounding a pin.

So, the current plan is to use an AVR microprocessor to control things.
It will communicate with a 74HC595 ( SPI ). Now, to accomplish the need
for the switch override, I thought I'd run the parallel outputs from the
'595 to NAND gates ( 74HC00 ).

Pullups on the switches. If a switch is closed OR the 595 asserts a
ZERO, the NAND drives hi.

Take the output of the NAND into a FET/BJT(npn) to turn on the relay (
~150mA coil current) with the requisite diode pointing uphill to save
the transistor when the coil is turned off.

I had planned to put the opto (4N26) between the NAND and the FET/BJT
just because I'm so paranoid, and thought "IF the FET/BJT fails and
feeds 12 though the gate/base back to the NAND AND the NAND fails and
backfeeds 12v to the 595 and the 595 fails and backfeeds 12v to the AVR,
then other things under control of the AVR might be effected. Ok.. now
that I've written it out, it seems absurd.

So..
RELAY_COIL
|
AVR--->595---\ |/
= NAND--->resistor--->base(2N222)|
GND---SPST---/ |\
| |
pullup GND

Reasonable?

7. ### CFoley1064Guest

From: James W
I don't think you're being too cautious. The success/satisfaction level you
get from these projects is primarily dependent on how well they work. There
are few things more annoying than having a cool little microcontroller setup
that keeps spitting up or dying for an unknown reason. Ground loops are one
really significant failure mode, as is the EMI caused by relay arcing. By
happen. Using optocouplers is a good way of eliminating ground loops which can
cause your AVR to lose its place in the program, reset output bits, or even
cause damage to the IC. Since you're a newbie and don't have the equipment to
measure the bad things which might happen, preventing them is a good idea. For
a one-off, your approach is a good one.

Here's how to use a SPDT three-position switch ( ON-(OFF) - ON ) to do what you
want. In the first switch position, the opto controls the relay. In the
middle position, the relay will always be off. In the third position, the
relay will always be on. (As always, fixed font or M\$ Notepad):

Opto Relay Driver With Switch Off /Override
+12VDC
|
SW1 o----------------.
ON(OFF)ON \ |
\ |
o \o |
| | |
1/4 | | |
PS2501-4~ |/ | |
~ -| | C|
~ |> | RY1 C|
| | C|
| | |
| | |\ |
'---'----| >O----'
|/
1/8
ULN2804

Good luck
Chris