Pages: 1 [2]   Go Down
Author Topic: Help on momentary push switches in series.  (Read 959 times)
0 Members and 1 Guest are viewing this topic.
Maryland, USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Why did you start a whole new thread on this keyboard?


To pose appropriate questions in appropriate forum.

Sensor question in sensor, multiplexing in multiplexing, audio in audio etc.
It is the same project which has different aspects to it.
It is is moreappropriate I can ask All the questions in a single thread, but then we will have audio, multiplexing, programming, sensor etc. In a single thread in which most of the questions will not be pertinent.

It's kind of like when a patient comes to see me for an eye problem, a dermatologist for a skin problem and an OBGYN for, well, another problem smiley even if it's the same individual.

Also, while we are on the topic (forgive the pun) i found interesting partial answers to my questions in older posts, but they were closed so i could not follow up with questions or comments. Why close old topics? Most of them are relevant with current devices.

Logged

There are three kind of people in the world: Those who can count, and those who can't

Maryland, USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
R-2R networks only work with SPDT switches, not SPST push buttons.

Are you sure about that? smiley

With a r2r type button, you can read multiple buttons from one pin, and you can detect simultaneous presses as well.


Thank you for pointing me t R/2R networks.
I'm no expert (in fact i learned about it today) but from the wikipedia article it would seem they would work also with momentary pushbuttons.

The problem of the low separation of voltages still remains as the resolution, for 12 pins is:
5/2^12 = 0.00122V
Logged

There are three kind of people in the world: Those who can count, and those who can't

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, the adc keyscan approach isn't very good with many buttons, as it is limited by the adc's capabilities.

In this case, you can break the buttons up into two or even more pins with multiple r2r ladders.
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 517
Posts: 26282
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So you have a 20-IO pin device, you need 13, you need to be able to detect multiple key presses.
How does adding an R2R ladder help here?


* switches_pots_transmitter.jpg (55.49 KB, 960x720 - viewed 13 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think this is a more generic solution:

Code:
#define KEY_1 0x01 //key1
#define KEY_2 0x02 //key2
#define KEY_3 0x04 //key3
...

//macro to read 6 keys
#define adcKeyscan6(pin)  ((analogRead(pin) + 2) >> 4)

  key_pressed = adcKeyscan6(BUTTON_PIN1); //read button_pin1
  if (key_pressed & KEY_1) {
    //key_1 pressed, do something
  }

  if (key_pressed & (KEY_2 | KEY_3)) {
    //key_2 or key_3 pressed, do something else
  }

  if ((key_pressed & KEY_4) | (key_pressed & KEY_5)) {
    //key4 and key_5 pressed.
  }
  ...

You can expand it to read more or less pins. It assumes 10-bit adc and buttons are pulled to Vref.
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 158
Posts: 2879
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Quote from: dhenry on Today at 06:00:09 AM
Quote
R-2R networks only work with SPDT switches, not SPST push buttons.

Are you sure about that?

With a r2r type button, you can read multiple buttons from one pin, and you can detect simultaneous presses as well.

The correct answer is you need to use SPDT switches on the side resistors. This way you get the proper voltage
changes for all bits, so every change is an exact multiple of the LSB change.

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

The R2R ladder network works properly by virtue of the "summing point impedance [resistance]" always being
exactly 2R when looking back down the network [right to left] at each and every node.

This only happens if you use SPDT switches.

Logged

0
Offline Offline
Shannon Member
****
Karma: 199
Posts: 11650
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
R-2R networks only work with SPDT switches, not SPST push buttons.

Are you sure about that? smiley

With a r2r type button, you can read multiple buttons from one pin, and you can detect simultaneous presses as well.


Yes I'm sure.  With only SPST you need an R-2R-4R-8R-16R-32R-64R-... network.
Logged

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

Pages: 1 [2]   Go Up
Jump to: