Pages: [1] 2 3 4   Go Down
Author Topic: debounce problem  (Read 7227 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 301
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I have a plan to install a bumper switch in the neck of the robot and just set it up on breadboard to test. I used standard hardware debouncing by using an SN74AC04 hex inverter and 10k resistor and 10mf capacitor and a microswitch.

For test program I attached the zero interrupt of pin 2 and it works, but not well enough: it sometimes makes a mistake. Seems to me not a fast enough debouncing. If I press the switch repeatedly around 2 times a second, it makes mistakes sometimes.

My question: is there any way I could guarantee its operation, or a better way of implementing such a limiting switch, as it is to sit with a dc motor and just imagine if the bot is turning the neck and limiting switch won't work!
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34246
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
and 10mf capacitor
I bet you haven't, I suspect you have a 10uF (micro Farad ) capacitor.

If this is not giving you long enough debounce then make it bigger. However, it would be good to see the schematic of what you think is standard.
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you considered adding a software debounce ?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34246
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Have you considered adding a software debounce ?
It is a lot more tricky on an interrupt pin, because the delay is in the ISR which is never a good thing.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 301
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

True, can't do software debounce for I'm on ISR, no delay() !

I drew what I call 'standard', sorry if not very clean drawing, and yes, I made a mistake, 10uF for sure!

Edit:
Sorry for I forgot: the resistor is connected to +5v.


* schema1.PNG (4.16 KB, 372x272 - viewed 66 times.)
« Last Edit: October 01, 2012, 01:15:19 pm by ironbot » Logged

USA
Offline Offline
God Member
*****
Karma: 14
Posts: 644
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I drew what I call 'standard', sorry if not very clean drawing, and yes, I made a mistake, 10uF for sure!

Well as Grumpy_Mike pointed out, you should try a larger capacitor.  I don't know what you have available, but the delay of an resistor-capacitor circuit will be R*C, in seconds.

Edit: So in your present circuit you have 10*10^3 * 10*10^-6 = 0.1
« Last Edit: October 01, 2012, 01:34:54 pm by Far-seeker » Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Have you considered adding a software debounce ?
It is a lot more tricky on an interrupt pin, because the delay is in the ISR which is never a good thing.

Next time I need to read more carefully, I didn't notice the OP was using an interrupt  smiley-roll-blue

I was wondering whether a simple state machine could be embedded inside the isr to provide a form of software debounce nonetheless...
Logged

USA
Offline Offline
God Member
*****
Karma: 14
Posts: 644
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was wondering whether a simple state machine could be embedded inside the isr to provide a form of software debounce nonetheless...

IMHO that would be more trouble than it's worth, unless it was somehow impossible to get a working RC circuit.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 301
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you all, like always my mind got clear by refering to Arduino Forums!
Logged

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1100
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Has anyone ever used a hardware debounce solution like the Motorola MC14490?  Are those effective?
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No,  the problem is the inverter!  It _must_ be a schmitt-trigger input. a 7414 not a 7404 for instance.

If you were using CMOS you could add hysteresis with a resistor feedback network, but that's tricky with TTL,  I think that 74AC04 must go.  Try a 74HC14 then you can use a much smaller capacitor (0.1uF and a 100k pull-up for instance gives 10ms time-constant)

The existing 10uF is being shorted into the switch each time it closes creating a tiny spark, which may eventually erode the contacts if the switch is small.  Adding 100 ohm or so in series with the switch will prevent such damage.  With a 0.1uF cap this damage is negligible.
Logged

[ I won't respond to messages, use the forum please ]

Nice, France
Offline Offline
Full Member
***
Karma: 11
Posts: 237
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I drew what I call 'standard', sorry if not very clean drawing, and yes, I made a mistake, 10uF for sure!

It is probably worth reading a bit more about debounce circuits. In particular your trigger is the wrong part, and a second resistor is advisable.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6619
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a reason you are using an interrupt? I normally poll pushbuttons either in a tick interrupt or from a task that is scheduled to run every few ticks. This makes it very easy to debounce the switch in software. I only use an interrupt when I want the button to wake up the mcu from sleep mode, and once it has woken up I disable the interrupt and revert to polling.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I drew what I call 'standard',

There is a missing resistor there.

Seriously, I have had this exact type of circuit resetting the mcu every time the button was pushed. And that mcu in question here was known to deal with interference.

I suggest that 1) you put back that missing resistor; and 2) if you have to go down with it, use a LOW-Quality (and I am not kidding here) button with high on-contact resistance. With a high-quality button, you run a substantially higher risk of resetting the mcu.
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The existing 10uF is being shorted into the switch each time it closes creating a tiny spark, which may eventually erode the contacts if the switch is small.

The most insightful comment in this whole thread.

MarkT is absolutely right here.
Logged

Pages: [1] 2 3 4   Go Up
Jump to: