Go Down

### Topic: 112 switches need reading (Read 7317 times)previous topic - next topic

#### themotorman

##### Nov 18, 2012, 02:48 am
I have 112 switches that output a 0 or 5 volts. I need a way to send this to an Arduino, MEGA2560  , by the serial port, using some CMOS logic or? so that I can tell which switches have changed state. Normal condition is that all 112 are HI=5 volts. Ideas please. The Arduino and the switches are about 5 feet apart but in a noisy environment.
thanks

#### runaway_pancake

#1
##### Nov 18, 2012, 03:00 am
A 10x12 (120) matrix and a 14x8 (112) matrix would both take up 22 pins, but the 10x12 would have room for adding more switches later!    ( :
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

#### retrolefty

#2
##### Nov 18, 2012, 03:08 amLast Edit: Nov 18, 2012, 03:16 am by retrolefty Reason: 1

I have 112 switches that output a 0 or 5 volts. I need a way to send this to an Arduino, MEGA2560  , by the serial port, using some CMOS logic or? so that I can tell which switches have changed state. Normal condition is that all 112 are HI=5 volts. Ideas please. The Arduino and the switches are about 5 feet apart but in a noisy environment.
thanks

Well you state the switches already have a 0 or +5vdc signal value. Scanning 112 'dry contact' switches is pretty straight forward in simple 2D matrix scan using 22 arduino I/O pins, however if the switches already have a 'foreign' voltage (no free 'dry contacts') wired to them then it's not possible as the arduino has to be able to activate voltage on one dimension of the matrix to then read back the other dimension to tell is a specific switch is closed or not. So what are the switches now controlling and or wired too?

So assuming the switches are performing some electrical function already and you just want to 'monitor' their output states, then you probably need to use lots external logic chips like input shift registers (parallel in/serial out) or digital encoder chips (say lots of 16 in /1 out mux chips. It will not be a low parts count application that is for sure.

Lefty

#### themotorman

#3
##### Nov 18, 2012, 03:27 am
THey are as you described external and I don't have any way to connect to the Arduino except as a serial line. I am hoping someone will have some idea of what CMOS logic chips might do the job. I realize that this is not a simple problem but I am willing to build the PCB to put the chips on it. Just haven't worked with CMOS for some time and need some help with the CMOS family, decoders, etc... also need to take the logic output and have a way to read the data. I did think that a way would be to use 2 MEGAs, since that would give me enough inpins and then send the data from these to the remote ARduino via the serial line. Although not cheap it it seems that it might be the simplest... Opins?

#### MarkT

#4
##### Nov 18, 2012, 03:31 am
How many will be LOW at any one time?  Just a few or potentially many?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### retrolefty

#5
##### Nov 18, 2012, 03:39 am

THey are as you described external and I don't have any way to connect to the Arduino except as a serial line. I am hoping someone will have some idea of what CMOS logic chips might do the job. I realize that this is not a simple problem but I am willing to build the PCB to put the chips on it. Just haven't worked with CMOS for some time and need some help with the CMOS family, decoders, etc... also need to take the logic output and have a way to read the data. I did think that a way would be to use 2 MEGAs, since that would give me enough inpins and then send the data from these to the remote ARduino via the serial line. Although not cheap it it seems that it might be the simplest... Opins?

Well before you start designing something one really needs to understand the circuitry the existing switching is wired in. There are questions like is there a common ground used in the existing wiring and connection available for any new logic or arduino additions. Are the voltage states always defined electrically, or is there a 'floating input pin' possible problem to be aware of? I would not start the effort or expense of such a project without a compete electrical schematic of what you are working with. At least that is my advice.

Lefty

#### John_Smith

#6
##### Nov 18, 2012, 04:57 amLast Edit: Nov 18, 2012, 05:31 am by Boffin1 Reason: 1
Seven  CD4067 mutiplexers, driven by a binary counter which is clocked and reset by the arduino, or directly  from 11 pins of the arduino, with one input back from the multiplexers.
45 years of editing projects with a knife and soldering iron, then I found Arduino !

#### themotorman

#7
##### Nov 18, 2012, 07:57 am
thanks for the advice. I suddenly realized that I can arrange the 112 as a 7 x16 array , read it with an Arduino and send the data to the main Mega... I am sure that the code to read an array is in a library... anyone know where I could look for this? The switches are all fully floating so making them as an array is simple.
thanks

#### John_Smith

#8
##### Nov 18, 2012, 08:07 am
45 years of editing projects with a knife and soldering iron, then I found Arduino !

#### runaway_pancake

#9
##### Nov 18, 2012, 01:59 pm

I suddenly realized that I can arrange the 112 as a 7 x16 array...

That's 23 pins.

.

"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

#### John_Smith

#10
##### Nov 18, 2012, 02:05 pm
have to use a mega
45 years of editing projects with a knife and soldering iron, then I found Arduino !

#### retrolefty

#11
##### Nov 18, 2012, 04:27 pmLast Edit: Nov 18, 2012, 04:36 pm by retrolefty Reason: 1

thanks for the advice. I suddenly realized that I can arrange the 112 as a 7 x16 array , read it with an Arduino and send the data to the main Mega... I am sure that the code to read an array is in a library... anyone know where I could look for this? The switches are all fully floating so making them as an array is simple.
thanks

Quote
The switches are all fully floating

What does that mean? Does it mean there are no existing wires and voltages on the switches? If there is, there is a problem reading them in a classic arduino driven matrix method.

You failed to understand my first post on this issue. You can only use an arduino to scan the switches in a matrix setup, and read the switches if there is no external voltage already on the switch terminals. Scanning a switch matrix involves the arduino setting an output pin high (+5vdc) on only one of the 'Y' matrix lines and then reading all the 'X' inputs, one at a time, via arduino analog input pins. It then sets that 'Y' line to input mode and outputs a +5vdc on the next 'Y' matrix line and then again reads all the 'X' matrix lines, lather, rinse, repeat for all the 'Y' lines then start all over.

If there already is external voltages (ground or +5vdc) on the switch terminals, the arduino will read back false values for the switches. So unless you replace all 112 switches with DPST switches and use one set of contacts for the arduino and one set for the existing circuit you really won't be able to scan the switches using the matrix method, you instead need 112 independent digital input points to read the switches.

That make better sense?

Lefty

#### themotorman

#12
##### Nov 18, 2012, 05:41 pm
THanks , the switches are just SPDT, not connected to anything yet,  so I can do whatever I like. Looks like the array is simpler than using shift registers with PISO system. I have to do a PCB to mount all the switches which are the other half of the switches on 112 relays.
Even using another Mega is less than doing a board with the CMOS logic as it already has the serial built in.

#### dc42

#13
##### Nov 18, 2012, 09:24 pm
If more than 2 switches may be closed at a time, the you'll need to connect a diode (1N4148 or similar) in series with each switch, otherwise you won't be able to determine exactly which ones are closed.

A 10x12 matrix would use one less pin than a 7x16 matrix.

As an alternative to using a Mega, if you will be connecting diodes in series with the switches, then you could use a 74HC4515 demultiplexer to generate 16 column lines from 4 pins. Then you can read a 7x16 matrix using just 11 Arduino pins (i.e. 4 for the column outputs and 7 for the row inputs).
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#### themotorman

#14
##### Nov 19, 2012, 07:37 pm
Thanks for the demultiplexer idea, Not sure that you need the diodes , my thoughts run like this:  assume it is a 7 x 16 crosspoint array and they are A thru G for the the 7 lines and 1 thru 16 for the 16 lines. If A is connected to 1 and A is also connected to 2. Then if you put a hi on the pinin that is A and read out the 1 thru 16 lines then you would get a Hi on pinin 1 and also pinin 2 , this then says that both A1 and A2 are closed. What am I missing when you say I need diodes?

Go Up