Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

pic12F683 Button de-bouncing.

Status
Not open for further replies.

lurkepus

Member
I'm adding a button to my pic12F683 and i'm using GP3 as input,

According to the datasheet GP3 has a Schmitt Trigger buildt in , will i need additional debouncing like software or hardware ?
 
You will need debouncing. You can use a resistor-capacitor network to slow the signal down and the Schmitt trigger will make sure that you only get one transition.

Alternatively, you can use software. I use a timer so that a high input is only taken as high if it has been high for several milliseconds, with another counter for low inputs.

Switches will turn on and off hundreds of times in a few milliseconds, and the input will go fully high or fully low lots of times if there is no debounce.
 
thanks for the reply :) my current button settup is 10K pull up resistor , the button is connected to ground .. can i just add a cap across the pins of the button ?? if yes what typ can i use ? would a 1uF electrolytic cap do the trick (i just got a few in the mail today) ?
 
Are you short of pins? If not, I would not use GP3 (MCLR) and very useful for ICSP.

John
 
Hi John i'm new to electronics and Pic mcu's so at the moment i'm not really short of pins but i have a few ideas witch may use more pins in the future , i'm not using ICSP since all my work is done on a breadboard , Reason for my choice using GP3 as an input is that it is just an inputpin so i want to be able to use the others as output pins ...
 
Wait until you start using SMD versions. Then the ICSP becomes pretty attractive.
John
 
i know and i will be looking into the ICSP thing :) but rigth now i'm just learning the basics and i take one stepp at the time :)
 
Last edited:
Hey, I am with you on that. The problem is that it is getting harder and harder to find TH (though hole ) components. Even getting components that you can handle without a microscope is getting hard. That's why bought a dissecting scope a couple of years back. Age does make a difference, but it is not good.

John
 
i just bought a 500X usb microscope and i guess that should do the trick :) yeah i know ther are parts witch are just made as SMD type components the smalest SMD components i have used is 1206 and i can solder em using regular reading glasses :) anyway back to de-bouncing .. do you think a 1uF cap across the pins of the button will be ok for debouncing the button ??
 
Thanks John :) i have a lot of reading ahead and i will try both hardware and software debouncing .. as i said i'm new to electronics and MCU's :)
 
Last edited:
Why do think you can't use mclr as switch and icsp Jpanhalt ? As long as your not trying to hold the pin low you'll not have a problem.
And even if that was the case you could add solder jumpers they don't take much space, which on a 8 pin part that's not a bad idea any way
because you may also need to isolate the data and clock pins too.

I've never had a problem with mclr on any 8 pin chip it's always been the data and clock pins that gave me problem. So I always added jumpers to isolate the program pins that could be set for programming
 
Last edited:
If I am not short of pins, my preference is not to use it for input for the reason you state.
As long as your not trying to hold the pin low you'll not have a problem.
I did not mean to imply you can't use that pin and ICSP. It is just easier not to use it. Note, the OP is using a button switch on that pin, and I assumed one state of the switch was low.

John
 
Last edited:
The op will have no problems if his mlcr pin is being used as stated
my current button settup is 10K pull up resistor
but if his load on the data and clock lines is holding it's state low or high he will need jumpers on the pins

I would just plan that there all loaded and and add jumpers to all 3 pins mclr,PD,PC that way he could do as he like's with theses pins and still program in circuit.
Using ICSP
 
Hi,

The switch can discharge the cap very suddenly so it's not really a good idea to place the switch right across the cap. A better idea is to use a small series resistor that does not reduce the low level voltage too much. IN fact, you can connect two resistors in series also in series with the cap and connect the switch at the center tap. That way there is a delay on both edges and no high current surge through the switch or cap either.
Also, the RC time constants should be calculated based on the expected Schmitt trigger levels, not on the Vcc level.
 
Last edited:
Thanks for the answers , i haven't been able to play around with electronic design lately but i'm back and i will work on geting the de-bounce working.
As i said i'm not short of pins but i still want to learn about the button debouncing since i will add buttons to my projects.

When it comes to the ICSP i think i will go with Burt's suggestion and use jumpers , i know there are other ways to isolate the mcu from rest of the circuit but jumpers are the simplest way ...
 
Before starting on a button debounce, you have to decide if you want the program to loop around a number of instructions when the button is pressed, or allow the program to continue execution and record the action of the button.
This is important if you have a display, for example. You don't want the display to freeze as soon as the button is pressed, waiting for it to be released.
 

I had a look and i'm wondering if it ould be possible to rewrite the code so i can use it on a 12f683 .. i won't be using that many switches but i would need 2 or 3..

Before starting on a button debounce, you have to decide if you want the program to loop around a number of instructions when the button is pressed, or allow the program to continue execution and record the action of the button.
This is important if you have a display, for example. You don't want the display to freeze as soon as the button is pressed, waiting for it to be released.

I guess i will need the pic to recodt the button state and continue operations , i haev looked for example files but i haven't found any..
 
Status
Not open for further replies.

Latest threads

Back
Top