Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

How To Debounce a Switch 10 ms edge triggered....

How To Debounce a Switch 10 ms edge triggered....

2005-09-02 by Venkat Nagappan

Dear Friends kindly send me codes to debounce a switch

assembly language avr program is needed...,

kindly help m eout friends


venkattttttttttttttt


	

	
		
__________________________________________________________ 
Yahoo! India Matrimony: Find your partner online. Go to http://yahoo.shaadi.com

Re: [AVR-Chat] How To Debounce a Switch 10 ms edge triggered....

2005-09-02 by Peter Gargano

Venkat Nagappan wrote:
> Dear Friends kindly send me codes to debounce a switch
> assembly language avr program is needed...,
> kindly help m eout friends
> 
> venkattttttttttttttt

Sure, and will you do my history assignment if I tell you how?


P.

Re: [AVR-Chat] How To Debounce a Switch 10 ms edge triggered....

2005-09-02 by Farzlina Ab.Hadi

ha ha...i do a lot of programming but really, nothing compares to the great experience of solving problems...sure you can cut and phase examples but wouldn't gain anything...maybe you should rephrase your question..
-------Original Message-------
Date: 09/02/05 19:41:07
Subject: Re: [AVR-Chat] How To Debounce a Switch 10 ms edge triggered....
Venkat Nagappan wrote:
> Dear Friends kindly send me codes to debounce a switch
> assembly language avr program is needed...,
> kindly help m eout friends
>
> venkattttttttttttttt
Sure, and will you do my history assignment if I tell you how?
P.
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:

Re: How To Debounce a Switch 10 ms edge triggered....

2005-09-03 by arhodes19044

In software, when the edge is detected, then just wait for the  time 
it takes a switch to finish bouncing before you ever re-check the 
state of the switch.  Use a delay or whatever.  

I prefer hardware debouncing (just a low pass RC filter, and a 
schmitt trigger inverter), that way I do not waste processor time 
needlessly.  One hex inverter will work for 3 or 6 depending on the 
logic output you need.  3 switches if you need to uninvert the 
inverted signal, 6 if you do not.

The actual software debouncing implementation is trivial, and left 
as an exercise for the reader.

If you need to trigger an interrupt on both rising and falling 
edges, it can get more complicated  SR latches and stuff will work.  
There is a ton of stuff on the internet when you look under switch 
and debounce.

-Tony

--- In AVR-Chat@yahoogroups.com, Venkat Nagappan 
<venkatnagappan@y...> wrote:
> Dear Friends kindly send me codes to debounce a switch
> 
> assembly language avr program is needed...,
> 
> kindly help m eout friends
> 
> 
> venkattttttttttttttt
> 
> 
> 	
> 
> 	
> 		
> __________________________________________________________ 
> Yahoo! India Matrimony: Find your partner online. Go to 
http://yahoo.shaadi.com

Re: [AVR-Chat] How To Debounce a Switch 10 ms edge triggered....

2005-09-04 by erikc

Venkat Nagappan wrote:
> Dear Friends kindly send me codes to debounce a switch
> 
> assembly language avr program is needed...,
> 
> kindly help m eout friends
> 
> 
> venkattttttttttttttt
> 

Excuse my enthusiasm, but I came across this trick a few years back; it 
is incredibly elegant, and is now just about the only debounce routine I 
use for mechanical switches.

[1] It debounces all the bits on a port at the same time.
[2] It is inline code with no loops or branches, hence it operates in 
constant time.
[3] It will basically work on anything.  I have used it on 8051, 68HC11, 
  80x86, and just recently, AVR.

but, here's the caveat:

[4] You DO have to either call it from a timer interrupt or on a polling 
basis.

Just hold your noses and look at this PIC page.  ;-)
http://www.dattalo.com/technical/software/pic/debounce.html

Here is the "C" code taken from there:

====begin code====
static unsigned clock_A,clock_B,debounced_state;
debounce(unsigned new_sample)
{
   unsigned delta;

   delta = new_sample ^ debounced_state;   //Find all of the changes

   clock_A ^= clock_B;       //Increment the counters
   clock_B  = ~clock_B;

   clock_A &= delta;         //Reset the counters if no changes
   clock_B &= delta;         //were detected.

       //Preserve the state of those bits that are being
       // filtered and simultaneously
       //clear the states of those bits that are already filtered.
   debounced_state &= (clock_A | clock_B);
       //Re-write the bits that are already filtered.
   debounced_state |= (~(clock_A | clock_B) & new_sample);
}
=====end code=====

Read the cited web page for an explanation.


erikc
--
"The kind of man who wants the government to adopt and enforce his
ideas is always the kind of man whose ideas are idiotic."
    -- H. L. Mencken

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.