0
Offline
Sr. Member
Karma: 0
Posts: 301
Arduino rocks
|
 |
« on: September 30, 2012, 04:18:04 pm » |
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
Brattain Member
Karma: 277
Posts: 25556
Solder is electric glue
|
 |
« Reply #1 on: September 30, 2012, 05:02:50 pm » |
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
Edison Member
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
|
 |
« Reply #2 on: September 30, 2012, 06:16:56 pm » |
Have you considered adding a software debounce ?
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25556
Solder is electric glue
|
 |
« Reply #3 on: October 01, 2012, 11:15:39 am » |
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
Sr. Member
Karma: 0
Posts: 301
Arduino rocks
|
 |
« Reply #4 on: October 01, 2012, 01:13:06 pm » |
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.
|
|
|
|
« Last Edit: October 01, 2012, 01:15:19 pm by ironbot »
|
Logged
|
|
|
|
|
USA
Offline
God Member
Karma: 14
Posts: 644
|
 |
« Reply #5 on: October 01, 2012, 01:31:44 pm » |
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
Edison Member
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
|
 |
« Reply #6 on: October 01, 2012, 01:51:07 pm » |
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  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
God Member
Karma: 14
Posts: 644
|
 |
« Reply #7 on: October 01, 2012, 02:04:36 pm » |
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
Sr. Member
Karma: 0
Posts: 301
Arduino rocks
|
 |
« Reply #8 on: October 02, 2012, 11:16:00 am » |
Thank you all, like always my mind got clear by refering to Arduino Forums!
|
|
|
|
|
Logged
|
|
|
|
|
Samplefinger
Offline
God Member
Karma: 8
Posts: 822
ALWAYS ASK FOR THREE. One to use. One to lose. One to abuse.
|
 |
« Reply #9 on: October 02, 2012, 03:44:08 pm » |
Has anyone ever used a hardware debounce solution like the Motorola MC14490? Are those effective?
|
|
|
|
|
Logged
|
Latest Sampling Scores: ATXMEGA64A3U-MH x3, ATXMEGA256A3U-MH x3, SST38VF6404-90-5C-EKE x3, SST38VF6402-90-5C-EKE x3, PGA870 x3, THS770006 x3
|
|
|
|
0
Offline
Tesla Member
Karma: 73
Posts: 6631
Arduino rocks
|
 |
« Reply #10 on: October 02, 2012, 05:43:41 pm » |
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
|
|
|
|
|
Nice, France
Offline
Full Member
Karma: 10
Posts: 232
|
 |
« Reply #11 on: October 03, 2012, 05:15:51 am » |
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
Faraday Member
Karma: 131
Posts: 4687
|
 |
« Reply #12 on: October 03, 2012, 01:18:30 pm » |
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. http://www.eschertech.com
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #13 on: October 03, 2012, 01:27:44 pm » |
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
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #14 on: October 03, 2012, 01:29:27 pm » |
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
|
|
|
|
|
|