Jump to content
IGNORED

Best way to sense switch and/or lamp matrix?


Recommended Posts

I'm looking at doing some extra effects on my machine, using an Arduino. For that, I'd like to sense the state of a small number (3-5) switches and lamps.

 

Sampling the switch matrix is not all that trivial, seeing that it's multiplexed. My current thought is that, if I want to, say, sense the state of a switch in column 3 and row 4, I can use column three and row 4 as the inputs to a NOR gate. On a SAM system, as far as I know, the columns go low one by one, and the rows are normally high. When a switch is closed, its column is low, the corresponding row will also be low. So, my NOR gate should give me a high output whenever the switch is closed and the corresponding column is being polled, low otherwise (because the NOR gate inverts the output; when both inputs are low, it'll be high; low otherwise).

 

To latch in the state of the switch, I was thinking of using the column as the clock input to a D-type flip flop. The flip flop is rising-edge triggered; so, when the polling interval for a switch ends, the flip flop will latch in the state of the switch and hold it steady until the switch changes state. (I can do the debounce in software.)

 

All this is theoretical, though. Does anyone know whether I'm going to have a hope of succeeding with this scheme? (I don't have an oscilloscope, so I can't look at the signal timings.) Will what I suggest work? If not, any suggestions? If it does work, but there is a more elegant way, I'd like to learn about that, too.

 

My approach requires two NOR gates and one D-type flip flop per switch; could it be done with less, or some pre-made IC?

 

All this is for a SAM system, BTW.

 

Thanks,

 

Michi.

Link to comment
Share on other sites

At the part of the matrix you wish to sample, I would put in a diode facing away from the switch and control your circuit from that point.

 

It will stop anything coming back into the matrix but allow you to monitor from that point as if it were in the matrix.

 

From the other end of the diode you should be right to do as you wish.

 

Just bare in mind the signal from that point will be zero or high, not low and high.

 

If you run this signal through a device like a 4049, 4050 IC gate, then you will end up with a high or low signal.

 

Remember, never leave an imput "floating". It MUST be a high or a low only unless you want to play with fuzzy logic but that is another story.

Link to comment
Share on other sites

OK, cool, thanks for that! Sounds like I'm not totally off-side :) I guess I'll have to try. If it doesn't work, I'll beg, borrow, or steal an oscilloscope and see why…

 

Michi.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...