Switch debouncing

Thread Starter

helloeveryone

Joined Apr 8, 2011
64
Hello,

how much of a role does the oscillator frequency play in switch bouncing and debouncing? For example if I used a 16MHz oscillator and then switched to a 1MHz oscillator would the bouncing problem be A LOT less of an issue?
 

Markd77

Joined Sep 7, 2009
2,806
Not much at all. A switch might take 20ms to stop bouncing, that's still 5000 instruction cycles at 1MHz, if you get 1 instruction cycle per 4 clock cycles.
 

takao21203

Joined Apr 28, 2012
3,702
If you use a 32 KHz crystal you don't need I2C delay anymore.

:):):):):):)

But there is still a chance to see a switch bounce.

Why worry it is only a few lines C to get rid of the bouncing.
 

tshuck

Joined Oct 18, 2012
3,534
Switch bounce has nothing to do with the oscillator ( whatever that means...). The bounce occurs for a time and settles to make firm electrical contact.

Where the oscillator may come into play is it you attempt to debounce this button using a digital system, then you will need to determine how many clock periods occur before you count a switch as changing states ..
 

Thread Starter

helloeveryone

Joined Apr 8, 2011
64
When using the counting method of software debouncing what is the most important thing?

i) that a defined amount of time passes between readings
ii) we precisely know the switch characteristic
iii) that the readings are done successively without any unnecessary waiting

I think it's i) but I'm not sure.
 

takao21203

Joined Apr 28, 2012
3,702
You need a lowpass, the exact frequency is not so important, normally 50 mS or so, and not based on delays.

Most softwares use a timer interrupt and a simple scheduler, so you need to learn about that.

There is not really a thing such as exact switch characteristics, at least it is not important to know.

Some websites eventually offer a datasheet for buttons but it is not really needed except for a commercial circuit.
 

tshuck

Joined Oct 18, 2012
3,534
Is there a more direct answer you are looking for, or are we going to continue beating around the bush with arbitrary questions?
 

ErnieM

Joined Apr 24, 2011
8,415
Homework questions should be put in the homework section. <g>

When using the counting method of software debouncing what is the most important thing?

i) that a defined amount of time passes between readings
ii) we precisely know the switch characteristic
iii) that the readings are done successively without any unnecessary waiting

I think it's i) but I'm not sure.
Is seems your teacher has some specific method in mind when posing this question.

It is NOT (ii) as that is never known about any part ever.

(iii) seems to be continuously polling the switch which is definitely not to be done.

As some minimum time should pass between readings (i) is the best answer.
 
I have done this loads of times using a pic.
If the switch is active low.
I take any low as the switch being pressed.
Then I wait for no zeroes for 20ms before accepting switch is off.
This has worked for 20 years worth of projects with no problems.
 
Top