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.
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?
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.
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....
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.
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.
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 :|?