Electronic – shift register that accepts 3.3V to drive several 5V relays

raspberry pirelayshift-register

I want to switch several (10-20) relays with a raspberry pi.
I will use darlington arrays like the ULN2003 to drive the relays, and a shift register to not use up all of my GPIO pins.

I will use an external 5V power source just to be extra safe, in case I switch all the relays at once.

Since the raspberry uses 3.3V TTL logic, while my relays require 5V, I was looking for a shift register that converts the 3.3V to 5V.
I found the 74HCT595, which works off of 5V and is TTL compatible and can be cascaded. However, it seems noone sells it in a DIP package, and the stores I looked at have none in stock and need months to restock (mouser europe). Also, I'd really prefer a large package.

The 74HC595 (same data sheet, no "T") barely meets the requirements for the 3.3V input, and is available as PDIP. Would that be an alternative, or will I get erratic behaviour?

Another alternative I found is the SN74AHCT595N, which seems viable as well, however I am unsure if I can cascade it. I want to avoid buying the wrong part (again ;-/ ) and since I barely find any information on this part, I need some help ( all searches turn up the information on the parts without "A").

The datasheet mentions cascading, but it is not completely clear to me which pins I should use? Can I just connect QH' to SER of the subsequent register? (for the other registers there was always some pin called SEROUT or somesuch.
Also, can I both source and sink current using this register, or are there some limitations? And where would I find this information in the datasheet, I don't see it.

Or should I use another shift register altogether?
I'd be happy for any pointers, thanks.

edit:
I checked the datasheet of the mentioned TPIC6x595 (where "X" is "B" or "C") and they seem nice, however now I have more questions. Both mention relay applications. The relays are dual coil latching KMET EA2-5TNJ and have an operating power of 140mW at 5V. The "B" outputs 140mA continous current, so I am covered, but will I still need darlington arrays to take care of the back-action during switching, or can I leave them out?

However, the initial idea was to use the raspberry 3.3V logic.
If I tie the relays to an external 5V and use the "B" driven by 3.3V logic to sink current, then I can switch to 0V just fine, and both coils of the relay will turn on when I want them to (The set voltage of the relays is 3.75V for both coils). While this may work, it doesn't seem proper, since I can never turn the coils off properly. Outputting high on the shift register gives me 3.3V, which means the coils are not active (5V-3.3V = 1.7V < 3.75V), however they aren't completely off either.

So in summary:

  • Do I need a darlington array with the TPIC6B595?
  • Should I just use a level shifter and be done with it, or can I make do without?
  • In case I need a level shifter, which one would be a normal one to use? Would a SN74AHCT245N be okay?

Best Answer

I will use darlington arrays like the ULN2003 to drive the relays

The ULN2003 requires an input voltage of 3 volts maximum to guarantee a collector current of 300 mA. See section 6.6 of the Texas Instruments data sheet for this part. This means there is no need to have a level shifter because a 3.3 volt compatible shift register will be able to adequately drive the ULN2003.

I'd be happy for any pointers

However, using the ULN2003 might mean you don't get enough voltage across the relay. The ULN2003 has a collector saturation voltage of up to 2 volts and this eats away at the 5 volts you thought you might be able to drive the relays with. Look at figure 1 in the data sheet.

So, either use a MOSFET package or a greater supply voltage (maybe 6.5 volts) or choose a relay that will work down to about 3.5 volts.

A possible option is to use the TPIC6B595N - it is a shift register with N channel MOSFET drivers built in. However, it needs 5 volt logic signals on data in and clock but you should be able to find a level shifter circuit from 3.3 volts to 5 volts for data and clock fairly easily.