This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Debounce Using Shift Registers?

I am rather new to this and I have a project where I need to debounce a switch using some sort of algorithm. I choose to go with utilizing shift registers rather than a delay because of the versatility of it. I think I have the basic outline of how I am going to do it i.e use timer interrupts call the debounce sub routine etc etc being new to coding this is where I am falling short. I know I need to set a threshold so the switch knows it is debounceed but I don't know how to set that up. I am using assembly language but any help would be appreciated. Also any tips on implementing this would be great as well. Thanks!

  • Hi Michael,

    here are some nice articles about debouncing digital inputs:

    A guide to debouncing

    Smoothing digital inputs

    And for the people familiar to the german language:

    Entprellung

    Hope it helps,
    Christian

     

  • bouncing events cann be of very high frequency. While the MSP ports will detect bouncing with up to 25MHz and trigger interrupts, the CPU is far too slow to handle every bouncing event directly. So there is a chance of lockups or missed button actions.
    This is why the delay approach is by far more reliable. And easier to code too.

    However, there ar emany other ways to do it, depending on expected signal behaviour (min/max trigger frequency, minimum delays between actions).

    E.g. you can check the port pin every 1ms, and when it has the same value for a number of consecutive reads, it is considered stable. If it is different from the last stable result, then this is a state change. Works well for relay signals wher ethe bouncing time is short and the signal time too. On human-operated pushbuttons, bouncing can take quite some time, but any button press takes an eternity. here the delay is a good approach: when the port pin changes state and triggers a port pin interrupt, further port interrupts are disabled and a tiemr is started. After a certain time, the timer expires and hte tiemr ISR checks the now current port state, determining whether it is pressed or not. And re-enables the port port interrupt.

**Attention** This is a public forum