Trossen Distance Sensor  Top Banner
Page 1 of 4 1234 LastLast
Results 1 to 10 of 35

Thread: Turning analog inputs into multi-switch digital inputs?

  1. Lightbulb Turning analog inputs into multi-switch digital inputs?

    As you may notice from the other new thread I just submitted, I am interested in creating an interactive LED gameboard of some kind (or even a sort of "Stargate" DHD-type sci-fi prop!), where each square or tile is lit up from below by either a single white LED or an RGB combo.

    It always occurred to me that I'd love it if I could have each tile be responsive to touch. Nothing fancy, just a simple on/off switch. But the project I have in mind would either be 21 RGB tiles or 64 white or monochromatic ones... and that's a lot of controllers!

    Then I came up with a way to use an analog input controller that's so crazy it just might work :

    If I assemble a set of resistors, each selected to resist a discrete percentage of the total analog input voltage, and connect each resistor to a momentary switch, and put them all in parallel on the same analog input circuit, then each switch would lower the voltage by a different amount, and (with the right code, of course) that could be properly interpreted as the depression of that switch, and (for example) the appropriate LED could be illuminated!

    (Hell, for all I know, that's more or less how early electric keyboards worked! )


    In other words, for example, if I have switches labeled A through H, and switch A allows the analog input to receive 0.5V, and switch B allows the analog input to receive 1.0V, and so on all the way up to H, which provides 8.0V to the analog input, then it should be simple to write code that interprets each of these discrete voltage amounts as "representing" the depression of a particular switch, so that the rest of the code can respond appropriately.

    In fact, theoretically, if I come up with the right combination of resistors for each "column" of switches, I could even arrange it so that you could press more than one switch at the same time, and the code would recognize that unique new aggregate resistance properly as the combination of certain depressed switches!

    However, even if you *could* only press one button at a time -- and that certainly would be easier -- that's still a way to, for example, turn 8 analog inputs into 64 digital inputs! That's enough to create a fully interactive, light-up chessboard with only an LED64 controller and a single 8/8/8 controller (you could use the other I/O connections for things like GAME SELECT and RESET and whatnot!), or to create a Stargate dialing device, where the tiles light up and unique SFX are triggered as you press them down.

    Damnit, why can't I win the lottery so I can just buy a bunch of Phidgets!?

    Anyway, I was just curious if this was feasible, or if anyone has actually tried it and had some success?

    Rock on, y'all!

  2. Re: Turning analog inputs into multi-switch digital inputs?

    That trick definitely works. I rigged up a system similar to what you're talking about back when I was in college. I was using a 68HC11 dev board, not an 8/8/8, but the concept is the same. I had no real reason for doing this, I think I was just struck by the idea and wanted to try it.

    For each button, I used a precision multiturn potentiometer to create a voltage divider that could be tuned to a very specific voltage. I only ended up using five of them on one A/D input, but I'm sure you could cram a lot more in there. Since the 8/8/8 has 10-bit inputs, you could theoretically increment each button by 5 mV and put 1023 switches on each analog input! Actually, the 0-1000 limitation in the Phidget system would limit you somewhat, but you get the idea. Realistically though, I bet you could get 20 switches to work reliably on one input without much trouble.

    Now the problem of identifying multiple buttons simultaneously in a system like this, that's a tough one. For that you'll need to consult someone who has much more free time than I do.

  3. Re: Turning analog inputs into multi-switch digital inputs?

    Hey, I'm actually working on a project (FINALLY!) that's using the principle I describe at the top, but now that I actually have the LCD / 8/8/8 unit, I see that the Analog Input has 3 contacts: +5V, ANALOG INPUT and GROUND. Even the diagram for hooking up a simple potentiometer shows that all three contacts are used. I'm afraid my electronics skills are insufficient for me to grasp the concepts, so... if I wanted to build the circuit I describe above, and I just want to use simple resistors (instead of pots that have voltage dividers with which I could hook up to all 3 contacts), so that the only contacts used in the Analog Input circuit at all were the +5V and ANALOG INPUT (between which would be the big resistor/switch circuit described), would that work? Does the 8/8/8 unit care if anything is going to GROUND in conjunction with any particular Analog Input?

    Is it that the Analog Inputs need to have a total of 5V coming in at all times between ANALOG INPUT and GROUND, and the ratio between them determines the returned value, such that having zero volts going to GROUND would mess up the circuit or even be dangerous? Or is it just that complex sensors (with onboard chips running code and whatnot) all generally need to be hooked up to a steady +/- circuit, and need that 3rd contact (ANALOG INPUT) to which to actually send the sensor signal?

    Thanks very much for your help!
    Last edited by Clavis; 08-29-2009 at 08:06 AM. Reason: Clarified question (whole end of 1st paragraph)

  4. Trossen Hexapod  Thread Banner
  5. #4
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,347
    Rep Power
    158

    Re: Turning analog inputs into multi-switch digital inputs?

    No ground, no circuit.

    GND -> goes to your circuit and the board
    +5v -> goes through your circuit -> goes to the analog input

    Whatever remains of the +5v after your circuit works it over is the analog input value that then gets scaled to digital.
    I Void Warranties´┐Ż

  6. #5

    Re: Turning analog inputs into multi-switch digital inputs?

    Old keyboards were of the matrix variety. The pressed button is determined by the button's location, row and column. A simple parallel to serial shift register can be used to convert the row/column to a binary number which is shifted one bit at a time to a micro. Or you can skip the shift register and go with a microcontroller.



    Last edited by MikeG; 08-29-2009 at 02:23 PM.

  7. Re: Turning analog inputs into multi-switch digital inputs?

    Thanks for the helps, folks... Unfortunately, I'm a little confused -- I thought things went *to* GROUND, not the other way around... but maybe I'm thinking (literally) backwards...

    Anyway, here's a picture that represents what I'm trying to do -- this diagram represents the five switches I would hook up to one analog input... I recycled graphics from the LCD / 8/8/8 PDF, and made a change based upon Adrenalynn's feedback (great name, by the way) ... Please check this out and see if at least it makes sense, even if it may not work...



    I guess I know a heck of a lot less about electronics than I thought I did (which would explain a few things), but... can anyone tell me why my idea above won't work, and what basic concepts of electronics I'm failing to grasp that led me to this sorry state of affairs?

  8. #7
    Join Date
    May 2008
    Posts
    2,219
    Images
    155
    Rep Power
    109

    Re: Turning analog inputs into multi-switch digital inputs?


    Connecting 5V to ground is a sure way to blow stuff up. I'm guessing that's an error though in your schematic. If you take the link out between 5V and R0 (leave R0 connected to ground), this should work. However what if two buttons are pressed? You'd have to make sure that you choose your resistors such that you can tell which buttons are pressed even if two or more are pressed at the same time, or make it well known to the user that two cannot be pressed at th same time...

    EDIT: I'd also probably make sure that R0 > all other R, so that it quickly pulls the state back down to 0V when the switch is disconnected....

    -Fergs
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	20kc51y.gif 
Views:	1475 
Size:	26.6 KB 
ID:	1458  
    Last edited by lnxfergy; 08-29-2009 at 11:00 PM.

  9. #8
    Join Date
    May 2008
    Location
    TN
    Posts
    852
    Images
    99
    Rep Power
    55

    Re: Turning analog inputs into multi-switch digital inputs?

    You are seriously limiting the capabilities of this project by using one analog input and the phidgets board. There are a number of small LCD's on the market that also have a keypad input for around 16 keys. Take a look at matrix orbital. Here is one that might work but they sell a bazillion different ones:
    http://www.matrixorbital.com/lk2047t1utci-p-227.html

    Note you can also do the same with a microcontroller. They are cheaper but you don't get the cool LCD.
    "If A is a success in life, then A equals x plus y plus z. Work is x; y is play; and z is keeping your mouth shut."
    -
    Einstein

    Don't be a HelpVampire

  10. #9

    Re: Turning analog inputs into multi-switch digital inputs?

    Thanks for the helps, folks... Unfortunately, I'm a little confused -- I thought things went *to* GROUND, not the other way around... but maybe I'm thinking (literally) backwards...
    This image might be easier to understand

    Last edited by MikeG; 08-30-2009 at 12:25 AM.

  11. #10
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,347
    Rep Power
    158

    Re: Turning analog inputs into multi-switch digital inputs?

    It's a great matrix, Mike, but aren't you doing multiple digital inputs there?

    And yeah, if you hooked it up that way Clavis, it'd destroy the microcontroller
    I Void Warranties´┐Ż

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Contest Entry Bioloid Gripper
    By JonHylands in forum Project Showcase
    Replies: 12
    Last Post: 12-26-2008, 03:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •