Shop OBEX P1 Docs P2 Docs Learn Events
74HC165 for pushbutton input expansion — Parallax Forums

74HC165 for pushbutton input expansion

Scott4Scott4 Posts: 45
edited 2009-08-30 19:32 in BASIC Stamp
I copied out the attached 74HC165 input expander circuit·to give myself more inputs then realized I was using momentary contact switches.

With the discussion about switch de-bounce etc. I was wondering if this circuit would·reliability record and latch the button pushes until my program·came around and read them.
684 x 473 - 39K

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2009-08-30 14:44
    Seeing a switch open or close is always dependent on whether the Stamp is watching at that instant. This is so whether its a single switch on a dedicated pin or by using some expansion technique.

    What you can do to minimize the problem is to always read all your '165 switches in a tight loop. Save that status as a byte or word then process each bit one at a time through your program.

    Then, repeat.

    If your momentary switches are opening and closing faster than the Stamp program scans, you'll have to add some front end latches.

    Cheers

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • dev/nulldev/null Posts: 381
    edited 2009-08-30 15:43
    Wouldn't it also be suitable to use (say 100 or 470 uF) caps to prolong the signal? Put them in series with the 10K resistors. When the switch opens, the cap will discharge through the resistor and keep the ground signal going for some time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
  • everesteverest Posts: 141
    edited 2009-08-30 15:55
    I actually need to do something very similar. . .I'm monitoring a bunch of switches in my application and I'm short on Stamp pins. Can you post some code for how you use this?

    -Jeff
  • dev/nulldev/null Posts: 381
    edited 2009-08-30 19:30
    I haven't tested this circuit, but it should work. The delay will affect both ways, so the switch will react slower, but that's ok for most applications.

    The difference from HIGH to LOW when the switch closes is 5V to 1.4V (assuming TTL levels) which is 3.6V. When the output reaches 1.4V the input will be a logic LOW.
    It then takes t = -1 x R1 x C1 x ln(voltage difference)
    Which is t = -1 x 1000 x 0.0001 x -1.27 = 0.13 seconds

    When the switch opens, the delay i approx the same. Use a larger resistor and/or capacitor to lengthen time. The resistor should be well below the 10K pullup (or the line won't go low).

    rcswith.jpg

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
  • dev/nulldev/null Posts: 381
    edited 2009-08-30 19:32
    The 220K should be just 220 Ohms. Error in the schematics.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
Sign In or Register to comment.