Searching \ for '[PIC]: Intrpt Bounce' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Intrpt Bounce'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Intrpt Bounce'
2003\02\10@064803 by Howard Simpson

flavicon
face
Hi all,
I have a reed relay on the RB0 Interrupt.  It's very slow, say a second
on, and a few seconds off - to ground.
RB0 is made to detect the interrupt on the falling edge, that's OK.  A
falling edge - jump to ISR - wait there if necessary till reed stops
bouncing, then exit ISR.
Problem occurs when reed opens again, a second or so later.  The contact
bounce creates a couple of rising and falling edges again, the latter of
which trigger interrupts.
Can't put delays in, because reed on and off times vary considerably -
seconds to many, many, seconds, even minutes.
I have used a 555 to create a one shot which works OK, just wondering if
there was another way.  Schmitt trigers capture the bounces too.
Regards
Howard Simpson.

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu>

2003\02\10@070920 by Jinx

face picon face
> Problem occurs when reed opens again, a second or so later.
> The contact bounce creates a couple of rising and falling edges
> again, the latter of which trigger interrupts

Put a trap at the start of the ISR to test the state of the b0 pin.
Interrupts
are turned off on entry to the ISR, so further transitions on b0 will have
no
effect. If you don't want to run the ISR code then simply wait until the
bouncing has stopped and then jump to the retfie, which will re-enable
INTE for the next legitimate closure. Make sure to clear INTF before
leaving the ISR as the bouncing will set this flag, causing immediate
re-entry into the ISR as soon as retfie is executed and interrupts are
re-enabled

Alternatively a simple RC filter should get rid of most of the noise
so that b0 sees only one transition

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu>

2003\02\10@074652 by hael Rigby-Jones

picon face
{Quote hidden}

Well, if the maximum switching speed of the relay is of the order of a
second or greater I see no reason why you could not use a delay effectively.


One possible method is to change the edge on which you interrupt, so the
interrupt service always catches the first edge and can then wait until all
bouncing has finished: e.g.

if RBIE = 1
       if INTEDG = 0  // falling edge
               // do your stuff here
               // debounce routine here
               INTEDG = 1              // check for rising edge next time
       else
               // debounce routine here
               INTEDG = 0              // check for falling edge next time
       end if
       RBIE = 0                // clear interrupt
end if


Cheers

Mike


--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu>

2003\02\10@081558 by Roman Black

flavicon
face
Howard Simpson wrote:
>
> Hi all,
> I have a reed relay on the RB0 Interrupt.  It's very slow, say a second
> on, and a few seconds off - to ground.
> RB0 is made to detect the interrupt on the falling edge, that's OK.
> Problem occurs when reed opens again, a second or so later.  The contact
> bounce creates a couple of rising and falling edges again, the latter of
> which trigger interrupts.


Force a timed delay period of 0.2 seconds etc
where the contacts MUST be open. Only after this
"safe" period is the system enabled ready for
the FIRST falling edge.
-Roman

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu>

2003\02\10@085341 by Olin Lathrop

face picon face
> I have a reed relay on the RB0 Interrupt.  It's very slow, say a second
> on, and a few seconds off - to ground.
> RB0 is made to detect the interrupt on the falling edge, that's OK.  A
> falling edge - jump to ISR - wait there if necessary till reed stops
> bouncing, then exit ISR.
> Problem occurs when reed opens again, a second or so later.  The contact
> bounce creates a couple of rising and falling edges again, the latter of
> which trigger interrupts.
> Can't put delays in, because reed on and off times vary considerably -
> seconds to many, many, seconds, even minutes.
> I have used a 555 to create a one shot which works OK, just wondering if
> there was another way.  Schmitt trigers capture the bounces too.

Configure OPTION_REG to interrupt on the next expected edge.  On a real
edge interrupt, disable RB0 interrupts completely.  Clear timer 0 and
enable timer 0 interrupts.  With the prescaler you can get a delay up to
13mS even with a 20MHz oscillator.  Now process the interrupt and return
normally.  Any new bounces will be ignored because the RB0 interrupt is
disabled.  On the timer 0 interrupt, disable the timer 0 interrupt, flip
the RB0 edge appropriately, clear any pending RB0 interrupt condition,
then enable RB0 interrupts again.

In other words, this scheme ignores any new reed switch edges for a
debounce blockout period after the first edge.

Another scheme I usually use for mechanical switches is to poll every
millisecond or so from an interrupt.  The interrupt routine sets the
global flag bit to indicate the switch state only when it's been the same
for 50mS in a row.  The foreground event loop then handles the switch
state.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu>

2003\02\11@063411 by Howard Simpson

flavicon
face
Howard Simpson wrote:
>
> Hi all,
> I have a reed relay on the RB0 Interrupt.  It's very slow, say a second
> on, and a few seconds off - to ground.
> RB0 is made to detect the interrupt on the falling edge, that's OK.  A
> falling edge - jump to ISR - wait there if necessary till reed stops
> bouncing, then exit ISR.
> Problem occurs when reed opens again, a second or so later.  The contact
> bounce creates a couple of rising and falling edges again, the latter of
> which trigger interrupts.
> Can't put delays in, because reed on and off times vary considerably -
> seconds to many, many, seconds, even minutes.
> I have used a 555 to create a one shot which works OK, just wondering if
> there was another way.  Schmitt trigers capture the bounces too.
> Regards
> Howard Simpson.

Thanks to repliers.
Hmmmm. I see the trick is to determinie how long the unwanted trigger
lasts, and allow for it.  Unwanted trigger from bounces will be short,
and wanted ones, even the shortest ones, will be much, much longer.
One thing I didn't mention that, at some point, the reed may be closed
for a long time, even days, but that should not matter as RB0 triggers
on edges only. (falling in this case)
So basically, if there is a falling edge, the input must stay low for a
period longer than a bounce, for the edge to be assumed valid.
Howard Simpson

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\11@080611 by Jinx

face picon face
> Hmmmm. I see the trick is to determinie how long the unwanted
> trigger lasts, and allow for it

One trick that may work is to start a counter on receipt of the first
transition. You set the counter to increment until it reaches a
certain value, but only if there are no pin readings opposite to the
one you're looking for, otherwise it resets to 0 and starts again. If the
counter reaches the certain value you've set then it's safe to assume
that the bounce noise is finished. For instance, detecting a 0 to 1
switch closure. You have a delay loop that takes 1ms. Read the pin,
if 1 then increment the counter. If 0, then clear the counter, and so on.
When the counter reaches 50 you know that 50ms has elapsed with
no 0's on the pin, even though it may have been longer than 50ms
since the first 1 that started it all

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...