How do I eliminate the bounce effect due to ...

Status
Not open for further replies.

mabauti

Member
the pushbuttons? (specifically in this circuit)
**broken link removed**

I'm using those PB's for interrupt service. The pin 6 in the PIC is set to 0 temporally for reading the PB's.
 
You need a debounce circuit. If you have a ton of buttons it might be easier to get a debounce IC. I don't know circuits any off hand, but here are some debounce ICs

**broken link removed**

You could also do it in software, though it can be a pain since the uC has to be really on top of things to be able to catch it all. I guess you could simplify things by making the uC react only if it detects X number of contacts within the next T seconds or something. Pick a number and a time interval where probability makes it very likely that the micro will detect it if the button is pushed. But it might still miss it every now and then if the button bounces really fast for a really short time.

I think the easiest thing to do would be to code the uC so it only reacts to the first pulse and ignores all subsequent pulses for the next 500ms or something.
 
Last edited:
Do you have the RBo/INT pin programmed for weak pulluup? It is not good to have it floating. A capacitor to ground will solve the debounce problem, try .01uF.
 
A simple resistor in line with a capacitor to ground (a passive low pass filter) will completely eliminate the contact bounce effect, and also serve to limit the speed with which the buttons can be pressed (to a human level)
Use larger values of capacitors and resistor to increase the R/C time constant, which makes you have to press the button for longer and longer periods of time until the voltage is high enough to trigger the I/O line.
 
Last edited:

The main problem is that RB0/INT is needed to be as logical 0 sometimes and sometimes as logical 1.

same problem with this:
**broken link removed**
 
I sure don't get how your 4 switches work on RB0. Where do D, E, F and G connect? How do you tell the difference between the switches in your ISR?

Also, it's really not a good idea, even with debounce, to hook a switch to an interrupt input.
 
The buttons are attached to the LED segment lines. I don't think a debouncing capacitor will do too much in this configuration - software is the only way of doing it. - RB0 would be an output, and RB4...RB7 would be the inputs.

The LED display will have to be multiplexed at a >100Hz or so rate, which is a pretty good frequency for debouncing. Every time the display is updated, figure out which buttons are pressed, and only accept button presses if they have been continuously pressed for x update cycles. You'll have a counter for each button....
 
I remember the "good old days" when watches had an LED display that lighted for a moment when you pressed a button.

I also remember old circuits that got hot and wasted a lot of power because they used old TTL 74xx ICs.

I don't think a 6V lantern battery would last very long driving the high current of TTL ICs. This old TTL clock could be portable if it is powered by four #6 dry cells. They are only 1.5V each but weigh a few kilograms each. They should last a few hours.

My Cmos watch runs for about 1 year on its tiny button battery cell.
My Cmos clock has digits 2cm high and runs for a long time on its tiny button battery cell.
 
Ah, I see. RB0 or RB4..7, it doesn't matter - he said they were for interrupts. It's just a bad idea. It's much better to poll switches and debounce in SW. a 10 mS period timer tick would do the trick. there is lots of code floating around that shows how to do it.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…