Shop OBEX P1 Docs P2 Docs Learn Events
Do I need a "latch" to capture a momentary button push. — Parallax Forums

Do I need a "latch" to capture a momentary button push.

SpigiSpigi Posts: 4
edited 2009-10-02 13:22 in BASIC Stamp
I'm just getting started with the BS2 and I am attempting to build a device that will send basic telemetry from a couple of cars to a base station. I want to be able to detect when the driver has pushed a button in one of the cars. I plan on using the XBee Pro XSC RF modules for communication. I had planned to have the base unit poll each car unit and have the car units send back their data. However, if the driver pushes a button (momentary on) and the BS2 isn't looking at that input, I am assuming that it won't register. Do I need to use a latch (with a 4043) and just reset the latch once I have read the value? Or am I making this more complicated that it needs to be?

Thanks!

Andy

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-24 03:57
    You could use a latch. You could also use a high value pullup resistor to charge up a capacitor and have the pushbutton discharge the capacitor to ground. It would take a few tens of milliseconds if you choose the resistor and capacitor properly (see the RCTIME statement description for the formula) and the Stamp would sense whether the capacitor has charged at least 1/2 way or has discharged. The BS2 doesn't have to look at the input all the time because it will take a while to charge up and look like it wasn't pushed. In other words, the RC circuit will remember whether it has been activated for enough time for the Stamp to get around to look at it.
  • SpigiSpigi Posts: 4
    edited 2009-09-29 16:41
    Thanks for the reply. I hadn't thought of using RCTIME. I'll definitely give that a try.

    Thanks!

    Andy
  • dev/nulldev/null Posts: 381
    edited 2009-09-29 18:05
    Would this work out?

    attachment.php?attachmentid=64081

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
    476 x 377 - 14K
  • Scott4Scott4 Posts: 45
    edited 2009-09-30 21:55
    My program was so busy I was not satisfied with my ability to get back to sample the buttons in time, plus, (and this is just me) I can't stand the idea of a switch event "decaying". 8 buttons would have taken too many pins. This MCP23008 General Purpose I/O chip (see attached picture)·is pretty sweet. I really like the I2C devices.

    Here is a chip carrier that carries a 16 channel GPIO that you can put in your breadboard.

    http://stores.shop.ebay.com.my/GravitechEstore__W0QQ_armrsZ1QQ_fsubZ18905089

    -Scott
    1111 x 483 - 13K
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2009-09-30 22:10
    Scott4

    Can you share the code that you use with the MCP23008

    Thanks for your time and help that you can give

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them smile.gif

    ·
    ·
    ·
    ·
    Sam
  • Scott4Scott4 Posts: 45
    edited 2009-10-02 13:22
    This example from the link I sent previously should give you an idea how it works. You will however have to use a BS2p, BS2pe or BS2px chip to use the I2CIN & I2COUT commands. The Stampworks Manual (download from the Parallax website) has code to use the I2C protocol without the I2CIN & I2COUT commands. -Scott
Sign In or Register to comment.