Page 1 of 1
switch debounce
Posted: Tue Dec 04, 2012 4:14 pm
by siliconchip
hi all,
when using switches in flowcode 5 and clicking on ext properties for the switch, if a value is placed in the switch debounce box ie 100ms is this automatically put in the program you compile to hex so that if you build your project you will have a built in time delay for debounce, sorry about asking this in flowcode 4 but i cannot start a new topic in flowcode 5
Re: switch debounce
Posted: Tue Dec 04, 2012 4:23 pm
by Enamul
Hi
I have moved that to general programming which you can access and has no problem with v4 or v5.
Re: switch debounce
Posted: Tue Dec 04, 2012 4:29 pm
by Enamul
Hi
I have tried to see whether 100ms switch de-bounce in switch property has any effect in the c code or not. But unfortunately I can't see any effect there. I don't think Flowcode component property 100ms de-bounce will put that in hardware.
Re: switch debounce
Posted: Tue Dec 04, 2012 7:51 pm
by medelec35
I seem to recall that debounce settings only worked with WaitUntillHigh & WaitUntillLow.
What I do with the switch is place in a loop with Loop count of 2.
Read switch, delay 5ms
So the switch is read twice.
Martin
Re: switch debounce
Posted: Tue Dec 04, 2012 8:04 pm
by Enamul
I seem to recall that debounce settings only worked with WaitUntillHigh & WaitUntillLow.
Yes, you are right. It works for READ State as well. I have checked, in all three macro the c code is using the de-bounce delay.
Re: switch debounce
Posted: Thu Dec 06, 2012 8:48 am
by medelec35
I have just completed a quick test.
Easiest way is to use ReadState of Switch component, and set debounce for approx half required value.
E.g If debounce is set for 2ms then it will take 4.7 ms for action to be taken.
Martin
Re: switch debounce
Posted: Thu Dec 06, 2012 9:16 pm
by siliconchip
hi martin just to clarify if i use component macro for the switch and click on read state this will add my desired debounce time from the ext properties of the switch in my compiled code
bob
Re: switch debounce
Posted: Thu Dec 06, 2012 9:40 pm
by medelec35
siliconchip wrote:just to clarify if i use component macro for the switch and click on read state this will add my desired debounce time from the ext properties of the switch in my compiled code
Yes that is correct.
The ReadState is accessed, then the next component will not be accessed until double the entered debounce time has elapsed
Enter 1/2 your desired time.
Martin