Large Relay Array

Hello All,

I am new to the arduino forums and the arduino platform its self. I have knowledge of electronics just not to much with micro controllers themselves. Im currently working on a project with a 33 quantity 12v pump array and need to run them off an array of 33 relays. Just wondering what would be the best route in controlling the relays. Im trying to limit the amount of i/o's on the board because i need a couple others for other components. So iv been trying to figure out a way to run all these maybe off a data line that will run into another IC that has a large amount of outputs? Did some searching around and couldn't find anything. So if anyone can help me out or point me in the right direction would be awesome.

Also as a side note, only one pump will be running at a time. I don't need to be running multiple pumps at the same time but they all need to be able to be controlled separately.

Thank you guys!!

Look for a demultiplexer with 32 outputs. Something functionally similar to 74ls138.

This will allow 5 x outputs to to be decoded to 32 individual outputs. The last pump can then have its own output pin.


5 daisy chained shift registers, each controlling the state of 8 relays. 3 output pins:

// did an output bit get updated?
if (outputFlagChange ==1){
outputFlagchange = 0;  // reset for next pass thru loop
digitalWrite (ssPin, LOW);
SPI.transfer(relayArray[0]; // D10 to RCLK on all registers
SPI.transfer(relayArray[1]; // D11 to Ser data in on 1st chip
SPI.transfer(relayArray[2]; // D13 to SRCLK on all registers
SPI.transfer(relayArray[3];  // Q7 to Ser data  in on next chip in line
SPI.transfer(relayArray[4];  // relayArray[0 to 4] holds the 40 bits (33 used) to control the relays
digitalWrite (ssPin, HIGH); //  outputs change on this rising edge

More than likely TPIC6B595 with 150mA output sink capability per pin continuous can drive your 5V or 12V relays.
I used one here to drive 8 5V relays.
(actually TPIC6C595, 100mA output)
I' m thinking of making this a separate shift register controlled card, standalone from any particular processor. Only need 3 control pins, easy to daisychain, less confusing than the optoisolated relay cards currently available.

Here's the new design I think I will go forward with using a shift register to control the relays.
Master clear is pulled down, user can connect to +5 if not using, or control from sketch.
Output enable is pulled up, use can connect to Gnd if not using, or control from sketch.

Input header & output header for daisy chaining.
G5T-1A 5A relays.
TPIC6C595 shift register, control with SPI.transfer() or shiftout().
Indicator LEDs to let you know a relay is energized.
3.5mm screw terminals, or 0.1"headers or connecting signals to be switched.
Multiple ways to connect +5V to the coil; or bring out from Arduino - each relay needs 40mA, so all 8 active may make regulator hot.

Okay just wanna make sure I am understanding you correctly. Your running a TPIC6C595 daisychaining the i/o's on the chips? Only thing I dont understand is if you are running 4 of these in a chain how are you telling this chain using the data line that you want chip 3 relay 5 to activate without pulling each chip down on separate data lines. Thank you so much for the help so far. With the SPI transfer would it know that it would be relay 20 using.
" SPI.transfer(relayArray[20]; "

Hey still kinda throwing this thing together. I did some research on shift registers and I understand the concept behind them now. Only thing I don't get is the daisychain setup. If you can clarify a little more on how they are controlled together id really appreciate it. Thanks for all the help so far, this is what iv put together with 5 chips daisychained ( Using your setup ) with a 36 relay setup. Figured id add a couple extra in just in case.

BTW ignore the relay components used in the sch. I used them as a filler till I figure out what one I wanna use.

With the shift registers, you send out 4 bytes, all outputs update together with the rising edge of the latch pin.
Shift out all 4 bytes, if the output is to stay the same then you will not see any change at the output.

I do the same on this card - 12 bytes are sent out, whether they change or not.

Easy way is to have the data in an array, when something in the array change, you send it out again.

What cap rating and resistor ratings are you using for the shift relay? I picked a couple up but i cant get them to work. Iv tried using the sample code and sample schematics off of arduinos shift relay guide too. Thanks for all the help so far i just cant get it to work.

Mogler you have R3 and R4 pulling the CLR line both high and low. Take another look at CrossRoads' example.

Absolutely do not neglect to add capacitors between the VCC and GND of each shift register. See Grumpy Mike's decoupling tutorial. One .1uF ceramic cap per IC is the rule of thumb but if you're making a production board it's nice to include a few extra places where you can add more or higher value caps if needed.

It would be easier (and about the same price) to use relay boards instead of discrete relays. As you have it drawn you would wind up pulling too much current through those shift registers and you have no protection from the inductive kickback when the relays de-energize. Relay boards take care of all that junk for you.

Just a suggestion when you're drawing large schematics, it's much neater to just draw short wires connected to the input/outputs of things like the shift register outputs and on the corresponding relay inputs, not connecting them, but using Eagle's "name" function to give both wires the same name (right-click the wire, select "Name"). You can also use the "Label" function to show that wire's name if needed. It's functionally equivalent to having them connected. I'll say you've done an incredibly neat job with what you've done with organizing those long wires but you can save a lot of time doing as I suggested.

Alright thanks for the tip I haven't used eagle in years. And I was running a smaller cap than a .1uF so ill change that up when I get home from work. So on the CLR and G line am I so post to be pulling down the lines with like a 10k-100k? or what resistor value are you guys running on those two lines. I have them connected to the GND and 5V but I was trying random resistor values because I couldn't find any info.

The pull up/pull down resistors aren't critical and not even required. The CLR and G (OE) lines don't consume any mentionable amount of current; the only reason to include them is just the safety aspect when you have them directly connected to a power source and not an Arduino IO pin. 10K-100K should be fine.

Lot's of good design stuff here.

Still, with an Arduino Mega having 50+ I/O's and costing About $20 for a decent clone like THIS:, Why not just wire a mega to optoisolated relay boards like THESE:

DISCLAIMER: Mentioned stuff from my own shop... (Which is what I know best...)

Add a Mega Sensor shield like THIS: and you have lots of I/O Pins with Voltage and Ground Pins. So you can plug it all together with 10-wire strips from a rainbow flat cable like THIS:

Wish I could design hardware as fast and good as Crossroads, but I take the Easy Way when possible.. :slight_smile: