Shop OBEX P1 Docs P2 Docs Learn Events
Button array?? — Parallax Forums

Button array??

nisbusnisbus Posts: 46
edited 2010-04-10 15:28 in General Discussion
Hi,

I'm new to electronics and would like to build something like the following image on a breadboard.

N2i5oew2L9gPVFBpuBgQAA?feat=directlink
image link

I don't mind creating a smaller grid (2x2) for just getting the theory of it but I really don't understand the image (got it from a Tips and tricks pdf for PIC microchips.)

I have some tactile buttons to play with but I just don't understand the drawing.
I also have the propeller protoboard and an extra breadboard for testing.

Can someone please help me get this thing going on a breadboard (pictures would be nice)?

Any help would be really appreciated.

What I don't get is that each button has one line running to it while my switches have 4 legs (I realize that it's legs are paired).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks,
nisbus

Comments

  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-04-06 01:07
    It looks like it is determining what button is pressed by measuring the voltage on the input pin. You will have to either use 2 pins with the Propeller or use an Analog to Digital Chip. When you press a button you allow current to flow through one of the resistors on the top row and one of the resistors on the left. These two resistors form the top half of a voltage divider. The resistor connected to ground is the bottom half of the voltage divider. Selection of the values of the resistors is key. At least that is what I think it is doing

    John Abshier
  • nisbusnisbus Posts: 46
    edited 2010-04-06 09:18
    That's exactly what I'm trying to do.

    The problem is that I don't understand the drawing compared to a tactile switch and I don't know what kind of resistor I should be using on either end.

    I would like to be able to use the VDD on the protoboard (3.3v).

    I'd just like to see this work using a meter before I plug it into the propeller.

    Could anyone draw this up using a tactile switch for me please?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thanks,
    nisbus
  • LeonLeon Posts: 7,620
    edited 2010-04-06 19:22
    You need different resistor values, and an ADC to measure the voltages. I think that is how it was done with a PIC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Leon Heller
    Amateur radio callsign: G1HSM
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2010-04-06 20:50
    I would use different values like, 1K, 2.2K, 3.3K, 4.7K, etc. across the rows and then on the columns, invert the values so that the sums are close to 10K each. This will allow for varying voltages depending on what button was pressed and the ADC value could be looked up in a table to match the key code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    ·
  • nisbusnisbus Posts: 46
    edited 2010-04-07 00:02
    Thank you, I really needed some info on the resistor setup.

    No I just need to see how to wire it.

    I've tried to decorate my original image with the way I think this should be done so please correct me if it's wrong.

    yyh33g7mif1GlMjbPB4M6Q?feat=directlink
    image link

    Red is 3.3V and brown is ground.

    Sorry for the drawing, my artistic skills aren't that great.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thanks,
    nisbus
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2010-04-07 01:34
    Hi, the drawing looks good but the values won't work. For example button "A" and button "P" both give 5.7k other buttons get duplicated too .

    Stick along the lines you have , just try and adjust your resistor values to be unique with each button.

    Also bear in mind that you expect to see a different voltage for each button , thats 16 buttons with 3.3 volts to work with , so perhaps calculating resistances that give each button a seperation of 0.2 volt or thereabout might make things easier.

    Jeff T.
  • nisbusnisbus Posts: 46
    edited 2010-04-07 01:41
    Thanks,

    I'll try with different combinations of resistors.

    Would this work for chording as well?
    What I'm looking to achieve is a different voltage reading for combinations of keys as well as single key presses i.e. A+P is different from A or P.

    Also do you know of any object in obex that uses 2 pins for analog processing?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thanks,
    nisbus
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2010-04-07 17:33
    Yeah, now that I look at it, certain combinations will give roughly 1/2 VDD for example, which isn't good. It almost seems better to have all the row resistors the same value and change just the column ones now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    ·
  • ercoerco Posts: 20,256
    edited 2010-04-07 17:47
    With that grid array, you can still only press one button at a time, right? Seems like that approach uses more pins than necessary. If you just had a string of series resistors and each button tapped into that, you can do it per "One Pin, Many Switches".
    See ~2/3 of the way down: http://www.emesystems.com/BS2rct.htm#switches

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2010-04-07 19:01
    Nisbus said...
    What I'm looking to achieve is a different voltage reading for combinations of keys as well as single key presses
    Maybe you could·consider a digital keypad multiplexer/decoder circuit , it might be easier than trying to read or achieve the analog voltages you would need·.

    Jeff T.
  • ercoerco Posts: 20,256
    edited 2010-04-07 20:23
    If you want to detect multiple keys being pressed (still using just one pin), you could use resistor combinations from which RCTime yields binary numbers. One key switches in a resistor that measures 10, another measures 20, another 40, another 80, another 160. Pressing the first two measures 30, pressing the last two 240 and so on. Possible, but it will require experimentation to get the right resistor values. May be temperature sensitive, too, if you try to get too much precision from cheap resistors.

    Anybody tried this or seen it done? PhiPi, you are always one step ahead of me...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • nisbusnisbus Posts: 46
    edited 2010-04-08 00:01
    Ok, I did some experiments with the resistor values (using only one line of buttons, thanks erco for the link) and RCTime but as I'm a total noob at electronics I can't even figure out the color scheme of the resistors so this is a rather frustrating experiment.
    I did manage to get the RCTime object to display a number when I pressed a key and my meter measures different voltages on key presses (as well as combinations) but it seems to be extremely fickle (most likely due to the random selection of resistors[noparse];)[/noparse]).

    As for the "digital keypad multiplexer/decoder circuit", it's the first I've heard of it and I wonder if this is something I can buy or I need to (can) build myself.
    Googling for multiplexer came up with a lot of circuit diagrams that I don't understand.

    I know I'm way out of my league at this (I'm a programmer trying to understand electronics) and I want to thank you all for your patience.

    Since you've come up with several good ideas for a solution to this problem I wonder if there might be something obvious that I'm still missing.

    What I'm trying to build is a 10 key keyboard that supports chording so that I would have 1024 (2^10) keys available.
    When that is done I would feed the key to my PC and there convert it into keystrokes.
    I've already been successful in getting data from the propeller to the PC so I feel I'm half way there [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thanks,
    nisbus
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2010-04-08 01:45
    Here's a brief description of one way of decoding a keypad using a modified version of your picture.

    P0 through P3 are inputs (columns) and P4 through P7 are outputs (rows).

    P0 through P3 are held at 3.3v by the pull up resistors so the binary value seen on those pins is 1111

    To read the keypad you start by setting row P4 low (logic level 0) and then reading the values on P0 through P3 .

    If no key is pressed P0 through P3 remain at logic level 1 (1111) , but say button A is pressed then column P0 would be logic level 0 and the other 3 at logic level 1 = 0111.

    The process is then repeated with row P5 then P6 and finally P7 , now every buttons condition has been read lets start from the beginning again.

    There are plenty of explantions better than this on the internet but maybe this gives you an idea what to look for.

    Jeff T.
    332 x 476 - 22K
  • ercoerco Posts: 20,256
    edited 2010-04-08 01:52
  • kwinnkwinn Posts: 8,697
    edited 2010-04-08 03:47
    If you want to use resistors for detecting button presses this is a simpler way of wiring it. Like the one already posted it can only handle single button presses correctly.
  • RDL2004RDL2004 Posts: 2,554
    edited 2010-04-08 13:21
    Some info I ran across:

    www.dribin.org/dave/keyboard/one_html/

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2010-04-08 21:28
    If you used binary multiples on all of the resistors 100, 200, 400, 800, 1.6K, 3.2K, 6.4K, 12.8K then wouldn't the voltage for any key always be unique?
    You'd have no chance with multiple simultaneous keys though.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Signature space for rent!
    Send $1 to CannibalRobotics.com.
  • ercoerco Posts: 20,256
    edited 2010-04-08 23:26
    For fewer keys and single-key operation, you could get away with some resistors, caps & switches on just a couple of pins. But you want it all, and that doesn't come easily. To accurately read 1024 combinations of all 10 keys, you'll need to use more inputs: one per row & column and scan the keys continuously.

    Here (as in most places) you can pick two of these three: fast, cheap, or accurate.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • kwinnkwinn Posts: 8,697
    edited 2010-04-09 12:42
    @CannibalRobotics, you really don't need binary or unique values for all the resistors to generate a unique voltage for each individual key press. The circuit I posted earlier will provide that using only 10K and 2K2 resistors. Generating unique voltages for every combination of key presses might in theory be possible but in practice is not.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-04-10 03:25
  • ercoerco Posts: 20,256
    edited 2010-04-10 15:28
    @PJ: Thank you for that excellent link, which also has pertinent quadrature encoder info (another current forum topic). I clearly need to familiarize myself with the wealth of info which Tracy Allen has already shared. The first date on that website is 1998; Tracy addressed many current forum questions TWELVE YEARS AGO!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
Sign In or Register to comment.