PDA

View Full Version : Debounce PULSIN?



Tomexx
- 26th November 2004, 20:13
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?

scorpion
- 26th November 2004, 20:36
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?

Tomexx
- 26th November 2004, 22:28
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.

scorpion
- 26th November 2004, 22:42
cant you use debounce and incriment a counter??

kattronics
- 26th November 2004, 22:46
Can you use an Optocoupler?

Tomexx
- 26th November 2004, 22:50
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.

scorpion
- 26th November 2004, 22:51
oh sorry. how long they are high for.... oops

scorpion
- 26th November 2004, 22:53
will it never be less than 20ms?

Tomexx
- 26th November 2004, 22:54
It is low all the time except for 4 times per second goes high for about 20ms

scorpion
- 26th November 2004, 23:01
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

peu
- 5th March 2005, 21:15
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

mister_e
- 6th March 2005, 10:24
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.

Acetronics2
- 6th March 2005, 13:47
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

Warrier
- 6th March 2005, 14:45
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