Shop OBEX P1 Docs P2 Docs Learn Events
Pin conservation, sneaky modulating tricks? — Parallax Forums

Pin conservation, sneaky modulating tricks?

Jason SmithJason Smith Posts: 2
edited 2007-08-21 14:50 in BASIC Stamp
I'm creating a game show buzzer, and have hit a hurdle in that I need more pins than I have available. I use 3 pins for the buzzers (1 each), 4 pins for LEDS to indicate status (player 1,2,3 buzzed, and buzzer ready). Status updates are sent to the computer via serout, so I need those pins too. Now I have 3 judge panels, with three buttons each (thus requiring 9 pins) that I need to read. Is there some quick and clever way to use one pin for the three buttons? Maybe some easy way to create an oscillating signal I can interpret?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-16 16:51
    Basically, you can use the RCTIME statement to measure a resistor. Each judge panel has 3 switches with a different resistor in series with the switch, the 3 resistor/switch combinations are connected in parallel to form the resistance R as shown in the Stamp manual in the section on the RCTIME statement and the Stamp can tell which one (or none) were chosen. It can't determine if more than one is pressed ... That's why you'll need one pin for each panel. Typically, you'll use 3 resistors with each one 2-4 times the value of the previous, like 4.7K, 10K, 22K (with a 0.1uF capacitor). These will give you 3 different values (plus "infinite" ... for no button) from the RCTIME statement.

    If that won't work for you, use a 74HC165 serial shift register to expand the Stamp's input pin capability. There's a discuss of this and some programming examples in the StampWorks manual that you can download.

    Post Edited (Mike Green) : 8/16/2007 5:11:43 PM GMT
  • D FaustD Faust Posts: 608
    edited 2007-08-16 17:22
    I would use the RCTIME idea.· Use larger resistors as Mike said, otherwise the RCTIME command will take longer.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    LOOKDOWN ThisThread, [noparse][[/noparse]Your_?, My_?, Cool_Thing], looknum
    LOOKUP looknum, [noparse][[/noparse]1, 2, 3], subnum
    ON subnum GOTO Hope_this_helps, Thanks!, WOW!!
    END 
    
  • Jason SmithJason Smith Posts: 2
    edited 2007-08-16 17:30
    wow! quick reply and great suggestion, this will work perfectly (assuming I don't mess it up) as I only need to know which button was pressed, multiple buttons will not be pressed at once. Thanks!
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-16 17:46
    To simplify things, I'd put a 100K resistor across the capacitor in the diagram. This provides for 4 discrete resistor values rather than 3 and "infinite". The parallel 100K won't affect the other resistances much.
  • Vern GranerVern Graner Posts: 337
    edited 2007-08-16 18:04
    Jason Smith said...
    Is there some quick and clever way to use one pin for the three buttons?

    You could use the 74LS165 multiplexer chip to read up to 8 inputs with only 3 pins.

    There are schematics and source code examples detailed in the Stamp Works article available on Parallax's web site here.

    I used this with great success in my RoboSpinArt project. The 74ls165 reads four direction joystick switches and four pump activation switches.

    smile.gif

    Vern

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
    Senior Systems Engineer    | obviously incompetent so why are we
    Texas Information Services | paying you? Of course,if the network
    http://www.txis.com        | is up, then we obviously don't need
    Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG
    
    
  • David H.David H. Posts: 78
    edited 2007-08-16 21:10
    If you just need more IO pins, you could use the BASIC Stamp 2p40 module.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    David


    There are 10 types of people in this world,...
    Those that understand binary numbers, and those that don't!!!
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2007-08-19 04:08
    You could daisy chain several 74HC165 to get many inputs out of 3 pins.

    3 chips will give you 24 inputs from 3 pins!

    And while your at it get some 74HC595 and do the same with the outputs.

    ·Parallax sells them:

    http://www.parallax.com/detail.asp?product_id=602-00010

    http://www.parallax.com/detail.asp?product_id=602-00009


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR

    Post Edited (TechnoRobbo) : 8/19/2007 4:14:53 AM GMT
  • D FaustD Faust Posts: 608
    edited 2007-08-21 13:32
    Is a shift register the same thing, as a serial to parallel chip?· Thanks.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    LOOKDOWN ThisThread, [noparse][[/noparse]Your_?, My_?, Cool_Thing], looknum
    LOOKUP looknum, [noparse][[/noparse]1, 2, 3], subnum
    ON subnum GOTO Hope_this_helps, Thanks!, WOW!!
    END 
    
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2007-08-21 13:39
    yes - Shift register is what they call it on the datasheets
    [url=:openreq('http://www.ortodoxism.ro/datasheets/philips/74HC_HCT165_CNV_2.pdf')][/url]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR
  • D FaustD Faust Posts: 608
    edited 2007-08-21 14:01
    thanks!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    LOOKDOWN ThisThread, [noparse][[/noparse]Your_?, My_?, Cool_Thing], looknum
    LOOKUP looknum, [noparse][[/noparse]1, 2, 3], subnum
    ON subnum GOTO Hope_this_helps, Thanks!, WOW!!
    END 
    
  • pwillardpwillard Posts: 321
    edited 2007-08-21 14:50
    Some of Jon's N&V articles also point out the use of I2C Chips like the PCF8574... you only lose 2 pins and you can attach quite a few other different I2C devices to the same bus.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    There's nothing like a new idea and a warm soldering iron.
Sign In or Register to comment.