How to control 60 switches with arduino

Hello everybody !

For my project I need to found a way to control 60 switches. Each switches, will do turn on a circuit powered by 9v battery . I'd like to control with arduino the delay time of every switches , so as to Set the ignition of every circuits in a different time

It's possible to do it with Arduino UNO ? Or I need Arduino MEGA ?

Thanks

You could daisy-chain 8 shift registers to the SPI pins and have 64 pins able to change in less than a millisecond.

Like goForSmoke says, shift registers are the answer. but check the current rating of the shift registers. If they're not up to driving the load you want you can put a transistor on each output, to increase the power available.

Even transistors are available as arrays on ICs though, so this shouldn't be too hard.

thank you GoForSmoke ,

Do you think this could be a good solution also if I need to turn on one circuit after the other?

for example:

switch on 1th circuit and after a few seconds also the 3rd and 4th.. then, after 1 minute, switch on the 54th and power off the 1th , 2nd , 3d and 4th

_tuft:
Do you think this could be a good solution also if I need to turn on one circuit after the other?

Just keep an array of 8 bytes to store the state of each “switch”. (one bit per switch). Then you just need a simple function that shifts these bytes out to the shift registers.

Whenever you need to change one switch, just update the relevant bit and shift out the whole lot again. As goForSmoke has said, this whole process will take less than a millisecond.

are you looking at 60 inputs?

or 60 outputs?

dave-in-nj: are you looking at 60 inputs?

or 60 outputs?

To control switches. That does sound like output. There are input shift registers too, and bi-directional ones and port expanders if you want to get fancy. There are even PWM output shift registers.

Tuft, KenF outlined just what I was thinking. Keep your switch states as bits in a byte array and when you change any, write the lot out through SPI and when you set the latch, the pins will all update at once. If a pin is given the same state as before, it won't change at all.

What could slow this down is changing a lot of pins through complex processes (especially if floating point is used) to which the general answer is to find a better way as there usually is at least one.

You can always get less performance and always use more code. The trick is to get more from less.

Ok thank you KenF ;)

dave-in-nj: are you looking at 60 inputs?

or 60 outputs?

I need 60 outputs like GoForSmoke said

However, I will try to daisy-chain 8 shift registers with arduino uno and then start to test a way to have the correct timing of start and stop in every circuits

_tuft: Ok thank you KenF ;) I need 60 outputs like GoForSmoke said

However, I will try to daisy-chain 8 shift registers with arduino uno and then start to test a way to have the correct timing of start and stop in every circuits

How close does this timing need to be? And how many/what kind of changes? Anything like patterns can generally be taken advantage of. Knowing what it's for couldn't hurt either.

I last got shift registers through Yourduino at 5 for 75 cents but one thing, there is no writing on the chips I got but just molded in letters which is a real pain when you order 12 kinds of chips!

The TPIC6b595is a shift register with high drive capacity.

GoForSmoke: How close does this timing need to be? And how many/what kind of changes?

I'd like to set these switches like this :

1st starts - after 5 seconds starts the 2nd, after 7 seconds start together the 3rd, 4th, 5th and so on, in this way after 3 minutes, all circuits are switched on and in function;

then, the "power off" process start in the same way, until just the 1st circuit remain in function. After 20 seconds also the last one will be off.

All the process could last for 5-6 minutes in total and then restart in loop

That’s entirely workable, you should be able to get timing down to the limits of your Arduino clock plus 1 millisecond easily.

If you don’t know bits then you have a minor task of learning there, simple ideas with powerful uses.
Aduino has special bit functions to help with that.
http://arduino.cc/en/Reference/BitWrite

A function to set or clear any bit in an 8 byte array is going to be easy.

This could be done using delay() but if you do that, the resulting code will be very inflexible.
If you do it using millis() time based code (BlinkWithoutDelay), the result will be very flexible.
Flexibility here is about being able to add to and/or change the sketch to make a new sketch.

:D :D Thank you very much GoForSmoke!

I'm writing the shopping list, which kind of shift register can I buy, the TPIC6B595 like nilton61 says,

(Or also it's possible to recycle this from an old device)?

I have a pcb design with TPIC6B595 and 8sptd relays. Contact me by pm if you are interested

I have a working card too, posted this a while back. Can daisy chain these, or in March I will have standalone cards that need just 5 connections to an Arduino: Gnd, SCK, MOSI, SS, or their shiftOut() equivalents. Video clip can be found at the “5A relay board” topic

I've used 74hc259 latching multiplex chips to control various things on/off. Below is an old parallel port christmas light project that might be of interest.

http://computerchristmas.com/christmas/link-how_to/HowToId-4/How_To_Build_A_Parallel_Port_Controller_Box