TMR1 counter debounce?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    >> Temp var TMR1H

    possibly part of the problem ... this gets redeclared each time through the "loop". You might want to move it up above where your other declaration resides.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    >>My 16F689 TMR1 counter is counting too well

    After sleeping on your question, it sounds like you need a hardware debounce filter, possibly like

    http://www.elexp.com/t_bounc.htm

    I do not know how to add one in software when using the TMR1 as a counter. You could switch to another software means of counting all together (e.g., Interrupt on change of one of the port pins, etc) where adding software debounce would be a piece of cake.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3


    Did you find this post helpful? Yes | No

    Default

    If he is counting edges for some type of signal, a series R - shunt C filter may be better than the debounce filter. Just pick the 1/RC time constant to be higher than the max frequency of the signal you are trying to count, the nyquist freq (f*2) being a good starting point.
    Tim Barr

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Thanks to every one for your help. Sorry for the delay in responding, our internet connection was down for 12 hours. I am trying to count the number of switch closures of a very fast reed switch. TMR1 is counting edges on T1CKI, just as it's supposed to. Ultimately,this switch will wake the program from SLEEP, and resume counting. I haven't as yet quite figured out how to use DT's Instant Interrupts to do this, but in doing so, maybe this will help with the "debounce" problem.

    For now, I may use Paul's idea of just counting the pin, or try using falingtrea's RC filter.

    Thanks again.

  5. #5
    Join Date
    Jul 2005
    Location
    Midwest
    Posts
    81


    Did you find this post helpful? Yes | No

    Red face

    I added debouncing for a switch to >> timer input of a F876 back in the day.

    I tried using a simple R/C network but found that the slow rise time of the signal as it was charging the capacitor back up violated the maximum rise time for the pic I/O.

    I ended up using the R/C filter but fed it into a schmidtt trigger prior to sending it to the timer I/O.

    This took care of things, I routinely test my devices by having another pic activate a relay thousands of times and test to see that the receiving pic counted correctly.

    fwiw

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. 20 Digit Virtual LED Counter
    By T.Jackson in forum Code Examples
    Replies: 9
    Last Post: - 19th November 2007, 05:02
  3. Replies: 14
    Last Post: - 26th September 2007, 05:41
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Asynchronous counter mode on TMR1
    By micro in forum General
    Replies: 1
    Last Post: - 8th April 2006, 15:42

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts