Debounce
- jensor
-
Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 84
- Thank you received: 3
09 Feb 2017 15:35 #87665
by jensor
Debounce was created by jensor
Can someone give me an example of a POSTGUI_HALFILE containing the debounce component for debouncing a switch input?
Please Log in or Create an account to join the conversation.
- bkt
-
- Offline
- Platinum Member
-
Less
More
- Posts: 1211
- Thank you received: 112
09 Feb 2017 16:07 #87672
by bkt
I hope these help
Giorgio
Replied by bkt on topic Debounce
loadrt debounce cfg=5 (for 5 comp input declare in hal file)
addf debounce.0 servo-thread
setep debounce.0.delay 4 (for ex .... 4*servo-thread ... normally 1ms so 4ms)
************************************************************************************************
(in your postgui)
net xxx-switch debounce.0.0.in <= (your phisical pin) hm2_5i25.0.7i77.0.0.input-33
net home-xxx debounce.0.0.out => (your signal with filter-delay) joint.0.home
net morehot-switch debounce.0.1.in <= .....
net veryhot-switch debounce.0.1.out => .....
I hope these help
Giorgio
Please Log in or Create an account to join the conversation.
- Todd Zuercher
-
- Away
- Platinum Member
-
Less
More
- Posts: 4974
- Thank you received: 1449
09 Feb 2017 16:11 - 09 Feb 2017 16:13 #87673
by Todd Zuercher
Replied by Todd Zuercher on topic Debounce
It depends a bit. If you already have the switch connected else where in hal you will need to change that to insert the denounce between those connections.
Here is an example that would debounce the input from parallel port 0 pin then send that signal out to parport.0.pin-01-out.(I must type slow.)
Here is an example that would debounce the input from parallel port 0 pin then send that signal out to parport.0.pin-01-out.
loadrt debounce cfg=1
addf debounce.0 servo-thread
setp debounce.0.delay 10 # Sets number of thread cycles the input has to be true before the output changes. (Has to be 2 or more to actually do anything.)
net debounce-in <= parport.0.pin-10-in => debounce.0.0.in
net debounce-out <= debounce.0.0.out => parport.0.pin-01-out
Last edit: 09 Feb 2017 16:13 by Todd Zuercher.
Please Log in or Create an account to join the conversation.
- jensor
-
Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 84
- Thank you received: 3
09 Feb 2017 19:47 #87695
by jensor
Replied by jensor on topic Debounce
You are very informative. However more questions.
Can this portion be put in postgui file?:
loadrt debounce cfg=5
setp debounce.0.delay 4
Or must it go in hal file?
And would this be proper?:
loadrt debounce cfg=3 (assume used for 3 different switches)
setep debounce.0.delay 4
addf debounce.0 servo-thread
addf debounce.1 servo-thread
addf debounce.2 servo-thread
net A input.0.sw0 => debounce.0.0.in
net A1 debounce.0.0.out => whateverPin1
net B input.0.sw1 => debounce.0.1.in
net B1 debounce.0.1.out => whateverPin2
net C1 input.0.sw2 => debounce.0.2.in
net C1 debounce.0.2.out => whateverPin3
Can this portion be put in postgui file?:
loadrt debounce cfg=5
setp debounce.0.delay 4
Or must it go in hal file?
And would this be proper?:
loadrt debounce cfg=3 (assume used for 3 different switches)
setep debounce.0.delay 4
addf debounce.0 servo-thread
addf debounce.1 servo-thread
addf debounce.2 servo-thread
net A input.0.sw0 => debounce.0.0.in
net A1 debounce.0.0.out => whateverPin1
net B input.0.sw1 => debounce.0.1.in
net B1 debounce.0.1.out => whateverPin2
net C1 input.0.sw2 => debounce.0.2.in
net C1 debounce.0.2.out => whateverPin3
Please Log in or Create an account to join the conversation.
- Todd Zuercher
-
- Away
- Platinum Member
-
Less
More
- Posts: 4974
- Thank you received: 1449
09 Feb 2017 20:09 - 09 Feb 2017 20:16 #87698
by Todd Zuercher
Replied by Todd Zuercher on topic Debounce
It can work in the post gui hal file, but it is the best practice to put all of your loadrt and addf lines in one place (at the beginning of the 1st hal file), because it makes it easier to keep track of them all and keep your addf lines loading in the necessary order, and because you can't loadrt any component more than once.
For debouncing 3 switches using the same delay timing, you would only addf debounce.0 servo-thread. Debounce.1 and debounce.2 would not be used.
If you needed 3 different time delays for your 3 switches you would use
loadrt debounce cfg=1,1,1 (would give you 3 different debounces for debouncing 3 pins each with it's own debounce time.)
loadrt debounce cfg=5,3,4 (would give you 3 different debounces one for debouncing 5 pins with one time period, one for 3 and one for 4.)
For debouncing 3 switches using the same delay timing, you would only addf debounce.0 servo-thread. Debounce.1 and debounce.2 would not be used.
If you needed 3 different time delays for your 3 switches you would use
loadrt debounce cfg=1,1,1
setp debounce.0.delay 4
setp debounce.1.delay 10
setp debounce.2.delay 20
addf debounce.0 servo-thread
addf debounce.1 servo-thread
addf debounce.2 servo-thread
(and the pins would be)
debounce.0.0.in...
debounce.1.0.in...
debounce.2.0.in...
loadrt debounce cfg=1,1,1 (would give you 3 different debounces for debouncing 3 pins each with it's own debounce time.)
loadrt debounce cfg=5,3,4 (would give you 3 different debounces one for debouncing 5 pins with one time period, one for 3 and one for 4.)
Last edit: 09 Feb 2017 20:16 by Todd Zuercher.
The following user(s) said Thank You: Franklin
Please Log in or Create an account to join the conversation.
Time to create page: 0.055 seconds