ADC - Keypad resistormatrix

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all. I am trying to build a keypad using the AD converter on a ATMega48. I've been doing some research on google and found out that is best achieved using a resistor matrix.

I also found an example of such a matrix and some code examples to help me on my way. I think I understand how it all works, but I am struggling with a very basic question. Why these values?

I can understand that you have different resistance on each key, and that leads to different voltages to be read by the ADC. But why should it be 3K3 ohm and not 3k, why 15K and not 10K. Is there a reason for this, are there best practices for this? Is there a formula or proccess for creating these?

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A question contains good portion of answer methinks.
Resistor values should be selected to make voltage readings as evenly distributed as possible. On the other hand, these values shall correspond standard resistor values, on the other hand.
Instead of struggling one may give a try and calculate all voltage readings in this set up and different resistor values.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

. But why should it be 3K3 ohm and not 3k,

Read about "E series" on this page:

http://en.wikipedia.org/wiki/E48...

Note that in E6/E12/E24 that the value around "3.x" is actually "3.3" (or "33") not "3.0"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks! I knew there was a reason. I will read up some more.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, so the reason is that they are manufactured that way. But there is no reason it should not work if I use slightly different resistors. I'll go try it. Thanks.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kludge. The keyboard is digital. You need rows x columns of ins and outs. If you dont have enough digital IOs, you need a digital IO expander like an LS165 on the SPI. You dont try to use an analog channel to guess if 3.5V should be the 3V key or the 4V key. Might as well get a big rotary switch with a big resistor ladder and have the dude dial in the number he wants and push an enter key.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob -

That is a little harsh. While I would not choose this way, it is perfectly valid, if properly designed.

The big short-coming is key-rollover, I think. What does it read if two adjacent keys are pressed at the same time. And, will that be interpreted as a valid key that is NOT one of the single keys? That probably depends on which two are pressed. I am not going to go out of my way to check this, however.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are making only a few of this design, then I suggest using a standard old-style PS2 purple-connector (miniDIN6) PC keyboard. It is far easier to interface and design for than a matrix of push-switches.
You may have far more keys than you need but the software can be expanded to use these keys -OR- sections of the standard PS2 keyboard can be used for selections - OR- just use the keypad.
The PS2 keyboard uses two lines (one clock, one data) to send the keypress bytes in serial format. The clock goes to INT0 and the data goes to any other input. I have posted code for keyboards here in the projects section. It's in assembler but it's not too difficult to convert to C.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's for a one time theater prop, so it's not going to have to be perfect.

I think I got it working halfway decent so far, I'll show of what I have when it's done. Thanks for the tips.

Code, justify, code - Pitr Dubovich