Hi
What methods have been used to detect the long press of a switch/tactile?
I have a project that needs to detect if a press the switch briefly or for say
3 secs, to generate different response like display a different menu on LCD
screen?
Switch bounce is not an issue, i have a dedicated hardware cct taking care of that.
Just want to know what effective methods have been used before. Also must
be able to detect any release of the switch within the long press period and reset
or restart the detection (any release of switch within the 3secs will re-start the
detection).
Thanx
Mark
Detect long press of switch/tactile
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Detect long press of switch/tactile
Hi Mark.
If you place a switch i/p, small delay e.g 50ms and count=count+1 calculation box within a loop that is exited as soon as switch is pressed, then when loop is exited (at the end), the count variable can then determine if long or short press.
I can post an example if your stuck.
Martin
If you place a switch i/p, small delay e.g 50ms and count=count+1 calculation box within a loop that is exited as soon as switch is pressed, then when loop is exited (at the end), the count variable can then determine if long or short press.
I can post an example if your stuck.
Martin
Martin
-
- Flowcode v5 User
- Posts: 118
- Joined: Thu Sep 17, 2009 1:30 pm
- Has thanked: 3 times
- Been thanked: 11 times
- Contact:
Re: Detect long press of switch/tactile
Hi Martin,
Sounds like a good idea. I will try it out and see if it works in my application.
In the meantime, if you get a chance, could you show me an example
program? I have both FC V4 and V5
Thanx
Mark
Sounds like a good idea. I will try it out and see if it works in my application.
In the meantime, if you get a chance, could you show me an example
program? I have both FC V4 and V5
Thanx
Mark
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Detect long press of switch/tactile
Attached is one such routine.
The switch detection length routine is only short.
Rest of the flowchart was just a way to display results (loop- non timer interrupt method). The other way of length of time detection is use a timer interrupt.
When switch is first pressed reset timer counter.
When switch is released store and used the final timer counter.
Hope this helps
Martin.
The switch detection length routine is only short.
Rest of the flowchart was just a way to display results (loop- non timer interrupt method). The other way of length of time detection is use a timer interrupt.
When switch is first pressed reset timer counter.
When switch is released store and used the final timer counter.
Hope this helps
Martin.
- Attachments
-
- Switch Press Test.fcf
- (13.95 KiB) Downloaded 294 times
Martin
-
- Flowcode v5 User
- Posts: 118
- Joined: Thu Sep 17, 2009 1:30 pm
- Has thanked: 3 times
- Been thanked: 11 times
- Contact:
Re: Detect long press of switch/tactile
Hi Martin,
Thanx for the example.....will take a look and see how it works
Can you tell me what version FC you did this?
Thanx
Mark
Thanx for the example.....will take a look and see how it works
Can you tell me what version FC you did this?
Thanx
Mark
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Detect long press of switch/tactile
Your welcome Mark,
Created with Flowcode V5.5.2.1
Martin
Created with Flowcode V5.5.2.1
Martin
Martin