Pages: [1] 2   Go Down
Author Topic: 112 switches need reading  (Read 1528 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Edison Member
*
Karma: 56
Posts: 2184
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!    ( :
Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16517
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: November 17, 2012, 09:16:50 pm by retrolefty » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Online Online
Shannon Member
****
Karma: 161
Posts: 10437
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How many will be LOW at any one time?  Just a few or potentially many?
Logged

[ I won't respond to messages, use the forum please ]

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16517
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1183
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: November 17, 2012, 11:31:19 pm by Boffin1 » Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1183
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

try  keypad.h
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Offline Offline
Edison Member
*
Karma: 56
Posts: 2184
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

That's 23 pins.

.

Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1183
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

have to use a mega
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16517
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: November 18, 2012, 10:36:32 am by retrolefty » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

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.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Pages: [1] 2   Go Up
Jump to: