Debounce PULSIN?


Closed Thread
Results 1 to 14 of 14
  1. #1
    Tomexx's Avatar
    Tomexx Guest

    Default Debounce PULSIN?

    Hi,
    I'm trying to measure a pulse using the PULSIN command.
    Everything works when I'm sending a clean pulse from the Pulse Generator. But then when I move into the real world (a push button switch changing from 0V to 5V) things stop working.

    I suspect that contact bouncing on the switch is the problem.

    Can I software debounce the PULSIN command somehow?

  2. #2
    scorpion's Avatar
    scorpion Guest


    Did you find this post helpful? Yes | No

    Default

    im fairly new to this, but i love to put in my 2 cents. haha

    could you see the pin go high, wait a bit, then start the pulsin and add the time it takes for the wait?

  3. #3
    Tomexx's Avatar
    Tomexx Guest


    Did you find this post helpful? Yes | No

    Default

    Well, I can't really put any timing delays because this circuit is going to be hooked up to a machine and can't miss any pulses. Here's how it works:

    A machine sends about 4 pulses per second (noisy signal) and my pic is supposed to count their high states and average the last 10. If the average falls out of range, then my pic sends a pulse to PLC which will stop the machine. Normally the pulses are high for about 20-40 ms.

    I've done the pulse counting and averaging but since the pulses are so noisy my pic pics up the garbage. So I need to clean the signal comming out of the machime.

  4. #4
    scorpion's Avatar
    scorpion Guest


    Did you find this post helpful? Yes | No

    Default

    cant you use debounce and incriment a counter??

  5. #5
    kattronics's Avatar
    kattronics Guest


    Did you find this post helpful? Yes | No

    Default

    Can you use an Optocoupler?

  6. #6
    Tomexx's Avatar
    Tomexx Guest


    Did you find this post helpful? Yes | No

    Default

    Scorpion,
    What do you mean by debounce & increment counter?

    Kattronics,
    I'd rather keep parts to a minimum. I can always use a hardware RC network + Schmit trigger gate but would like to try a software solution. The damn thing works with a pulse generator like a charm.

  7. #7
    scorpion's Avatar
    scorpion Guest


    Did you find this post helpful? Yes | No

    Default

    oh sorry. how long they are high for.... oops

  8. #8
    scorpion's Avatar
    scorpion Guest


    Did you find this post helpful? Yes | No

    Default

    will it never be less than 20ms?

  9. #9
    Tomexx's Avatar
    Tomexx Guest


    Did you find this post helpful? Yes | No

    Default

    It is low all the time except for 4 times per second goes high for about 20ms

  10. #10
    scorpion's Avatar
    scorpion Guest


    Did you find this post helpful? Yes | No

    Default

    can you wait for it to go high, start counting, then watch for it to go low after 10-15ms? ignore anything that happens before that 10 - 15

  11. #11
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default debounced switch

    Quote Originally Posted by Tomexx
    Hi,
    I'm trying to measure a pulse using the PULSIN command.
    Everything works when I'm sending a clean pulse from the Pulse Generator. But then when I move into the real world (a push button switch changing from 0V to 5V) things stop working.

    I suspect that contact bouncing on the switch is the problem.

    Can I software debounce the PULSIN command somehow?
    Different application, but I have the exact same problem, in Proteus VSM my program works perfect, since proteus have "perfect switches" but when I wire up the protoboard and program the pic, the switch does not work as expected.

    Now I'm looking for a sure& safe way to debounce it, any ideas will be appreciated !

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    in the TTL stone age, we was using an RC circuit. output of the switch to a pull down resistor an to a capacitor, the other side of the capacitor to the PIC input and to a pull down resistor.

    Some will also prefer to use a Schmitt trigger or a voltage comparator with a close to VDD treshold.
    Steve

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

  13. #13
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,617


    Did you find this post helpful? Yes | No

    Talking

    Hi, Picmen

    Being a little mocking, I would point out this kind of measure is based on DIGITAL inputs and not Analogic swinging voltages ...

    The answer is here: you want to measure something, but don't really know what !!!

    If you use a calibrated PAUSE, from the first detection, say 20ms ( i.e.) not to deal with bouncing and use a RCTime command just after, you just will have to add the PAUSE time to your result ...
    The Button command could also be taken for that ... as debouncing time is known. of course always followed by a RCTime.

    Those are just little ideas ...

    Alain

  14. #14
    Warrier's Avatar
    Warrier Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Tomexx:

    Are you measuring pulse width (dwell time from your machine)? If yes, then how do you define pulse width on a noisy bouncing pulse?

    If you know the rising or falling edge jitter, and if you have an additional output pin, then you can output a one shot (triggered by input "noise") having width wider than bounce width and feed back to the input to "clean" incoming machine pulses.

    But then you also say "I have done pulse counting...."
    If pulse counting is what you need then I would suggest using the Button cmd. It has built in debouncing and state of pulse (hi or low)

    Pulsin is used mainly to measure pulse width.

    -warrier

Similar Threads

  1. Replies: 17
    Last Post: - 12th April 2014, 02:17
  2. Better understanding PULSIN
    By Wirecut in forum mel PIC BASIC
    Replies: 12
    Last Post: - 29th June 2008, 10:17
  3. Funny PULSIN values: what is going on???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th April 2008, 08:02
  4. Pulsin 16F819 problem
    By rekcahlaer in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th April 2007, 13:52
  5. PULSIN and RCTIME
    By Dwayne in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th November 2004, 14:45

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