View previous topic :: View next topic |
Author |
Message |
valemike Guest
|
Switch Bounce RC circuit? |
Posted: Wed Nov 03, 2004 2:50 pm |
|
|
Which circuit below is good for debouncing ground bounce noise? THe top or bottom circuit? I've seen both but I would think the circuit on the bottom is better at shunting ground bounce noise to ground than the circuit on top of the page.
[imt]http://www.iit/edu/~valemic1/switchbounce.jpg[/img][/img] |
|
|
John Morley
Joined: 09 Aug 2004 Posts: 97
|
|
Posted: Wed Nov 03, 2004 3:01 pm |
|
|
Hi,
Well, your link doesn't work so we can't check it out for you. I'm curious why you are looking for a hardware solution to debounce a switch input? You can do it just as easily in software, assuming you have the time (cycle overhead) to do it. Here is a link to a good description of both methods: http://www.ece.utep.edu/courses/web3376/concepts/debounce.html
Good Luck! _________________ John Morley |
|
|
valemike Guest
|
the picture |
Posted: Wed Nov 03, 2004 3:04 pm |
|
|
Here is the picture...
|
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Nov 03, 2004 3:19 pm |
|
|
Of those two the S2 circuit would be preferred. R4 does nothing for switch bounce, and connecting C2 directly across the switch could theoretically reduce the switch life. Select R3 based on switch size and available power. Preferably the current through the switch should be at least 1% of the switch rated current to avoid "dry contact" problems. But if the switch is rated for "dry contact" service this minimum current is basically zero.
If possible I would poll the switch, and confirm the reading a few milliseconds later. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Wed Nov 03, 2004 3:22 pm |
|
|
There are a number of hardware and / or software combinations commonly used for debouncing switches. Where the switches are located remotely from the PIC (off board) then hardware debounce circuitry is often used to provide harware protection from possible over and under voltage transients.
In the upper example R4 will limit the input current into the PIC in the event of overvoltage condition occuring on the input either as a result of interference or possible phyically interference. I typically add a diode across R1 (cathode to +5V) in this configuration to provide this protection or, for very long runs, a transorb across C2 would be better. These circuits work best when fed into the schmidt trigger input of the PIC.
The lower example is flawed. If you consider the case when S2 is open the capacitor will charge to +5V via R2 and R3. When S2 is closed, the input to the PIC will be driven down to -5V while the capacitor is discharged through R2 / S2. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Wed Nov 03, 2004 3:32 pm |
|
|
SherpaDoug wrote: | Of those two the S2 circuit would be preferred |
Well obviously we disagree on this point :-)
Quote: | connecting C2 directly across the switch could theoretically reduce the switch life |
Yeah right - in a typical debouce application the life will reduce from somewhere around 1,000,000 operations before failure to 999,999 operations before failure... _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
valemike Guest
|
|
Posted: Wed Nov 03, 2004 3:57 pm |
|
|
I got the S2 circuit from the PICDEM-2 Plus demo board.
As for the top circuit, that's the one on my dad's previous designs (there is a an inductor and capacitor before it (not shown) to filter out EMI. That's also the circuit shown in Embedded Systems Programming back in the Summer 2004.
I would think that the resistor in the S2 circuit both limits current as well as acts as part of a low pass filter. Any switch bounce noise would go through the capacitor and not be seen as much since the resistor would provide an impedance.
Who knows! Almost everything that I thought I learned in circuit analysis class doesn't hold anymore. |
|
|
Guest
|
|
Posted: Wed Nov 03, 2004 4:04 pm |
|
|
[quote="valemike"]I got the S2 circuit from the PICDEM-2 Plus demo board.
CORRECTION:
I have it swapped around. The S1 circuit is from the PICDEM. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Wed Nov 03, 2004 4:21 pm |
|
|
Quote: | I would think that the resistor in the S2 circuit both limits current as well as acts as part of a low pass filter. Any switch bounce noise would go through the capacitor and not be seen as much since the resistor would provide an impedance.
|
The resistor does limit the current but does not solve the -ve input to the PIC input I mentioned previously. But for a debouce capacitor (low value of capacitance) this is not a really problem - similar the the "theoretical" point that SherpaDoug made. The circuit I normally use is a hybrid of the two original circuits. Move R3 to the other side of R2 and add the diode across R3 or the transorb across C1.
Quote: | Any switch bounce noise would go through the capacitor and not be seen as much since the resistor would provide an impedance. |
Unfortately this is a little too simplistic. It is ok when feeding into a schmidt trigger input but for a normal input you potentially have a slow rise time into a cmos digital input and you can get transitions occuring in the input stage of the device potentially leading to large transients currents flowing within the device which in turn can manifiest itself as high frequency noise. Schmidt trigger inputs do not have this problem because of the hysterisis on the inputs. To minimise this issue limit the rise time of the input and ensure you have a decoupling capacitor as physically close to the device as possible. >100 millisecond rise time = UGLY. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
|