100 Switches

Hi there,

I've been struggling to find a direction to go in with my new project.

I have been asked to monitor and count 100 switches. Each switch may switch 3 to 4 times per second.

My question is, would I be able to use arduino(s) to do this or should I look down the PLC route or is there another option?

Thank you.

Multiplexing is your friend - look for digital input multiplexing chips. An Arduino is perfectly suitable sampling at about 400 Hz. You should consider using direct port writes instead of the Arduino-macros.

Thank you very much derVernichter, off I go on another whirlwind adventure :slight_smile:

Hi,
How are the switches wired, are they connected to another system and you need to monitor them.
Or are you monitoring the switches to pass the results onto another device?

What is the application?

Tom..... :slight_smile:

Hi Tom,

The switches are connected to a small voltage (not sure what yet) on one side and a common on the other. All wires come back to a connection panel.

Currently there is a plc connected to the, but it has stopped working and the company who installed it have since vanished. My choices seem to be to either replace the PLC (and write new software for it) or start from scratch with arduino. As I have zero experience with PLCs but a little with arduino I thought I'd go down this route.

So the answer is, I need to monitor the switches and pass the results to possibly a webserver or just a standalone machine.

Thank you,

The switches are connected to a small voltage (not sure what yet) on one side and a common on the other. All wires come back to a connection panel.

This make no sense :confused:

It would help a lot if you tell us what are the switches for . . .

Best Regards.

tjsantos:
I've been struggling to find a direction to go in with my new project.

I have been asked to monitor and count 100 switches. Each switch may switch 3 to 4 times per second.

My question is, would I be able to use arduino(s) to do this or should I look down the PLC route or is there another option?

I'd suggest to look after the keypad library: Arduino Playground - HomePage

100 switches require 10 rows and 10 columns wired = 20 pins on the Arduino board.

You can't multiplex the switches if they are all common connected on one side.

vffgaston, is this not the same condition common to switches and pullup resistors? - Scotty

Hi,
Are there times when more than one switch will be ON at the same time?
Did the original PLC system have 100 inputs?

Tom.... :slight_smile:

TomGeorge:
Hi,
Are there times when more than one switch will be ON at the same time?
Did the original PLC system have 100 inputs?

Tom.... :slight_smile:

Or even better, can you give us a complete description of the entire original system, including the PLC connections? Try to anticipate questions based on the fact that we can't know anything about it.

vffgaston, is this not the same condition common to switches and pullup resistors? - Scotty

Maybe: OP don't say anything about resistors.

Regards

Any case,

100 switches are many switches; up to three times/s is not a slow rate . . .

WOH is the system for?

(By this time we are all intrigued)

Regards

6 of these (and 4 switches just to pins):

16bit P to S ICs

Tie a current limited line from an arduino pin to the pins M to pull it high.

Tie the Clock Pulse lines (CP pin) on the chips together and connect them with a current limiting resistor to an arduino digital pin.

Make the CP pins high and then low. This will read the states of the 96 switches.

Then you can pull pin M LOW so it is now in "Serial Mode" so then on each clock pulse, the ICs will feed a bit along, you can use the arduino pin to read the output.

Collect the 96 bits by making CP go high and low 96 time, recording the output and adding it to an array or shifting in (see shiftIn()) bits in to an array of bytes or whatever.

Set M back to HIGH -> The process can then be repeated.

The SO (serial out) of one IC must be fed in to the next IC's SI pin ofc.

The maximum clock frequency these can deal with is around 100MHz...so you can do a lot of processing in very little time. You could read the pins and spit the output out about 1 million times a second if you really wanted to...of course the arduino reading the pin state takes some time...but you will be easy hitting the 100s of Hz.

Yes, I'd go with 13 daisy chained shift registers with 8 inputs each pulled high.
Each switch can pull an input low.
Read them all in:

digitalWrite (loadPin, LOW);
digitalWrite (loadPin, HIGH); // capture input states
// read in the data:
dataArray[0] = SPI.transfer(0);
dataArray[1] = SPI.transfer(0);
dataArray[2] = SPI.transfer(0);
dataArray[3] = SPI.transfer(0);
dataArray[4] = SPI.transfer(0);
dataArray[5] = SPI.transfer(0);
dataArray[6] = SPI.transfer(0);
dataArray[7] = SPI.transfer(0);
dataArray[8] = SPI.transfer(0);
dataArray[9] = SPI.transfer(0);
dataArray[10] = SPI.transfer(0);
dataArray[11] = SPI.transfer(0);
dataArray[12] = SPI.transfer(0);
// react to any 0s received

Daisychained cd74HC165's would be good for this, with pullups to 5V for the inputs, using 9-pin bussed resistor networks, one per shift resistor.

Not knowing what is being done with the values, I would offer that the fastest way is to use 2 mega's. with 50 available pins each, two would handle the whole lot.

Depending on the voltage, you might be able to just use a resistor to limit current and bring in the signal without any other parts.

How about 7 each MCP23016 I2C I/O expanders. That would be 112 inputs using 2 pins. Add an 8th chip with the interrupts from the other 7 as inputs to fire an interrupt when any button is pushed. The 23016 also has built in internal pull ups that can be enabled.

One thing I am kinda unsure of...is with 100 switches, this gives 100! permutations.

A nice 9E157 ish possible outcomes.

This would need over 520 ish bits to represent all possible permutations as a number.

SO even if you could track the combinations...you need a 9E157 bit sized table to give the permutations if each combination of switches does something different...Is there even that amount of storage space in the world?

If you are just tracking individual switches for maybe 100 outcomes such as "if 5 are on...do this" then yeah...but otherwise...is tracking the known position of each switch really a logical thing to do :|?