Oscillo - readings not clear to me


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938

    Default Oscillo - readings not clear to me

    Hello,

    As buttons present some difficulties with PICs (bouncing issue), I thought I could try to improve the situation by adding a kind of RC filter (Button_shematic.JPG).

    I have connected my oscillo to the circuit and started measurements.

    As I am not an expert, I have difficulties to understand what I am reading (I know, it sounds stupid but the oscillo's help file doesn't really help...).

    I have setup the oscillo to trigger one button press (at least I think I did so).

    Does someone feel comfortable with oscillos and tell me what this trace (Oscillo_Button.JPG) says?
    Attached Images Attached Images   
    Roger

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Use the Button function

    Hi,

    PBP takes care of your button debouncing problem. Use the BUTTON function. Besides debouncing it also does some neat autorepeat for you when use it in a loop.
    Regards

    Sougata

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    The oscillo trace show you exactly what is suppose to happen with any mechanical push-button.

    theory and explanation bellow
    http://www.elexp.com/t_bounc.htm

    Solution... there's many different. Using PBP BUTTON command, use Timers interrupts, OR use a simple loop

    Code:
    PushButtonA VAR PORTA.0
    '
    '
    '
    '
    IF PORTA.0=1 THEN
        ' Do your Stuff
        '
        WHILE PORTA.0=1 : Wend ' wait untill push button is release
        PAUSE 50 ' Debounce delay
        ENDIF
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Short pause

    Good information.

    If I don't like to use the BUTTON command or WHILE/WEND artifices, it's because of this short pause that has to be artificially created to avoir the bouncing.

    It sounds silly but I like to hear the button's "click" and see the display (or LED or any other action) react at the same time.

    Instead of waiting for the button to debounce, wouldn't there be a solution to use the only the very first raising/falling edge of the signal and make the PIC ignore the following pulses for some milliseconds meanwhile it exectues the program?
    Roger

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Well, that's what my previous example did?

    It read the Button, then 'Do your Stuff' And wait untill you release the button. then debounce it.

    If you released the Button before your 'Stuff' is executed, it will just execute the PAUSE 50. No harm at all.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default WHILE/WEND is sometimes a blocking solution

    I have made a timer using the TMR0 interrupt.

    With the settings I use, I can't PAUSE for more than 16ms or I'll miss a tick.

    So I have to slice a
    PAUSE 50
    in
    PAUSE 10 : PAUSE 10 : PAUSE 10 : PAUSE 10 : PAUSE 10

    But this is not a problem.

    I have already used the WHILE/WEND loop followed by a PAUSE. And here, some problems occur from time to time.

    I'm not absolutely sure but I think it can miss the "real" button state. The WHILE/WEND loop can "see" a bounce of the button and not the real state of the button you actually want it to have. It may not have the desired effect.

    Moreover, this WHILE/WEND loop is a blocking loop since it will prevent the PIC to give the hand to the Interrupt as long as the button is pressed.

    I would really prefer some kind of interrupt scanning for a raising/falling edge of I/O ports with an internal routine preventing consecutive (bouncing) inputs whithin a certain time frame.

    Maybe something already existing in PICs, maybe something to do?
    Roger

  7. #7
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Why not Instant Interrupts

    Hi,

    I can't PAUSE for more than 16ms or I'll miss a tick
    Look at this: http://www.picbasic.co.uk/forum/showthread.php?t=3251
    Regards

    Sougata

Similar Threads

  1. Does CLEAR Command clear return adrress of a subroutine?
    By sayzer in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 19th February 2008, 16:25
  2. Replies: 14
    Last Post: - 26th September 2007, 05:41
  3. LCD and "count": need to clear LCD?
    By Mugel in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd October 2006, 09:55
  4. having problems with Hantronix 20x4 lcd
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 22nd December 2005, 12:22
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29

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