Shop OBEX P1 Docs P2 Docs Learn Events
Switch debounce circuit questions — Parallax Forums

Switch debounce circuit questions

dbritta1dbritta1 Posts: 36
edited 2013-03-10 16:20 in Propeller 1
Project UI has multiple NO spst switches on 18" 22ga 3-conductor twisted cables in noisy environment connected to Propeller USB board.
I presume debounce can be done in code.
Switches have common ground and I am planning to use either 10k or 4.7k pull-up resistors on Prop IO pins.

What is optimal value for pull-up?
Would a bypass cap be appropriate, if so what value?
Would series resistors be appropriate, if so what value?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-03-09 09:35
    In a noisy environment, you want a relatively high current through the cable, so I'd choose 4.7K or lower. Your pull-up will be to 3.3V (Vdd), so I'd even go with 1K which would only draw 3.3mA per switch maximum. If power consumption is an issue, I'd go with 3.3K.

    A bypass capacitor isn't really in this case. You've got an RC filter which is actually useful here. Look at this article for information and formulas on switch debouncing. There are some formulas starting on page 14 that cover debouncing with RC filters.
  • dbritta1dbritta1 Posts: 36
    edited 2013-03-09 10:55
    Mike,
    Thanks for link and expert advice.
    I was refering to RC filter when asking about bypass cap, should have been more specific.
    Dennis
  • Mike GreenMike Green Posts: 23,101
    edited 2013-03-09 11:15
    You might look at this Application Note as well. An RC filter plus a Schmitt Trigger makes for the best debouncing.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2013-03-09 12:03
    If the environment is too noisy, you could consider using NC contact switches. you could then use fairly high pull up resistors at the prop pins and since the normal condition closed would be ground that could minimize noise problems. (Since you are concerned about noise, would my guess that this is for an industrial application be far off?) Additionally you would be able to add in a safety factor by looking at the switches at initial time for an open circuit. Can't do that with NO contacts.
    dbritta1 wrote: »
    Project UI has multiple NO spst switches on 18" 22ga 3-conductor twisted cables in noisy environment connected to Propeller USB board.
    I presume debounce can be done in code.
    Switches have common ground and I am planning to use either 10k or 4.7k pull-up resistors on Prop IO pins.

    What is optimal value for pull-up?
    Would a bypass cap be appropriate, if so what value?
    Would series resistors be appropriate, if so what value?
  • dbritta1dbritta1 Posts: 36
    edited 2013-03-09 12:46
    Gentlemen,
    Thanks for comments!
    Can replace NO with NC switches in design, let me think about it.
    NO was "safe" position in logical design, cable disconnect would not allow "unsafe" action.
    Thought switch fail open was more likely than switch fail close, and cable short unlikely.
    Can have user perform manual diag of switches at startup (or as required).
  • jmgjmg Posts: 15,173
    edited 2013-03-09 22:03
    dbritta1 wrote: »
    Gentlemen,
    Thanks for comments!
    Can replace NO with NC switches in design, let me think about it.
    NO was "safe" position in logical design, cable disconnect would not allow "unsafe" action.
    Thought switch fail open was more likely than switch fail close, and cable short unlikely.
    Can have user perform manual diag of switches at startup (or as required).

    If you have individual switch lines, then NC are easier to fault find and self test.
    NO are better if you scan a matrix, and only expect 1 of N active at a time.

    You can cover a cable-disconnect by sensing an all-activated state as illegal, (even have a connected-verify jumper on the cable-end)
    Also, if you trigger on the edge(s) of the switch, then a power up with a faulty switch, will not be considered an activation.
  • tonyp12tonyp12 Posts: 1,951
    edited 2013-03-10 11:56
    I like this one as the RC works on both push and release.
    debouncerrc.jpg
    http://www.edaboard.com/thread187944.html
  • dbritta1dbritta1 Posts: 36
    edited 2013-03-10 13:01
    tonyp12,
    Thanks for schematic, have not had chance to properly review Mike's links yet.
    Given prior comments, what would be component values if active device in schematic was Prop IO pin?

    jmg,
    Think I understand basis for NC approach, but fail-safe more important than noise immunity.
    Intermittant spurious switch states very bad, but as example, ENABLE_MOTORS system state due to hardware fault would be fatal design flaw.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2013-03-10 15:39
    What I have seen in Medical imaging devices breaks down two ways, NC switches/connectors for safety monitoring systems like contact emergency stops for things like collision sensing, and NO switches for command functions such as x-ray release footswitches. The hazards of failure seem to determine the method. For shorted footswitch at power up the unit logically knows that it is unlikely that any person would be pressing the footswitch and block functions such as x-ray on. For image grid collision guards, normally closed allows the unit to see a collision or open safety loop as a fault at any time and block movements by dropping a contactor or disabling the drive function.
  • dbritta1dbritta1 Posts: 36
    edited 2013-03-10 16:20
    frank,
    Excellent comments, switch type should match intended function.
    NO for potentially dangerous user commands.
    NC for safety loops and hardware fault detection.
    I will select switch types as appropriate.
Sign In or Register to comment.