Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Set a variable with external switch

Status
Not open for further replies.

BiDoU

Newbie level 6
Joined
Jan 23, 2005
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
121
Hello,

I want to use external push button to setup a variable in my microcontroller. I have two button: up and down. I use a debounce algorithm to assure that when I push the button one time only, the variable is incremented one time only...

But the problem for now is when I keep the button pushed, the variable increments at the rate of my debounce cycle time. I want to increment the variable very rapidly if I keep the button pushed for more than 2 seconds (and as well that I keep the button pushed when it's is increment very rapidly). And, before the 2 seconds, I don't want that the variable be incremented.

Maybe someone have an idea or refer me on some web site?
 

Try to add algorithm that will be looking at the "release switch" action before increasing value of the variable again..
 

    BiDoU

    Points: 2
    Helpful Answer Positive Rating
In my previous project, i used a counter to count how many time the debounce cycle time has passed. I checked the counter against a limit value before incrementing the variable. The limit value is placed in another register so that it can be modified. At first placed a long enough limit, and gradually decreased the limit to get a 'getting faster' effect.
 

Use that algorithm : ;-)



Code:
Switch pushed ?
 - No --> loop
 - Yes --> x,xx sec. debounce tempo, Increment variable, when timing variable oveflowed, goto :

x,xx sec. counter
Switch still pushed ?
 - No, goto...
 - Yes, Is counter variable overflowed ?
 - No, continue to count
 - Yes, increment variable, and loop.

Regards,

Manu
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top