Debounce problem
Leon
Posts: 7,620
Has anyone been able to get this debounce code (obex.parallax.com/objects/489/) to work properly? I'm trying to debounce five buttons on a membrane keypad, but get multiple closures even with a 100 ms delay.
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
Comments
I have never used a time delay to prevent bounce. I always use an OR to prevent bounce. With the OR scenario, the program will always need to make at least two loops to see the input (button down), and will release after two successful loops without the button pressed. It takes a little more to do it that way, but does free up a cog.
With the OR method....you must program to toggle only when the OR'd input changes to 1, not every time the input is one.
I think you will have more luck with the OR method.
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Please note: Due to economic conditions the light at the end of the tunnel will be turned off until further notice. Thanks for your understanding.
That is you have to see the button down 2 out of 3 times through the loop.
I too think the OR loop method is better.
Jack
Jack,
I have done that too, but wanted to get the simple across first, then if there were problems to put the majority loop in.
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Please note: Due to economic conditions the light at the end of the tunnel will be turned off until further notice. Thanks for your understanding.
[noparse][[/noparse]Edit] Just a thought: If your debounce timing is 100ms but you accessing the debounced result more frequently than that you could be seeing false positives (from the previous scan). Perhaps what you need to do is clear the result after reading it.
I just added this method to the version on my computer:
Post Edited (JonnyMac) : 10/21/2009 5:36:25 PM GMT
Here's my test code:
I need to stop it repeating if the key is held down, but that should be easy.
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
Post Edited (Leon) : 10/21/2009 6:11:56 PM GMT
Add ! in front of ina for active-low inputs -- result is still expressed as 1 = button pressed.
The key is to check to see if the new key press is the same as the previous; if yes, don't do anything.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)
· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle