switch debounce

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

switch debounce

Post 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

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: switch debounce

Post by Enamul »

Hi
I have moved that to general programming which you can access and has no problem with v4 or v5.
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: switch debounce

Post 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.
Attachments
SW.fcf
(8 KiB) Downloaded 339 times
Enamul
University of Nottingham
enamul4mm@gmail.com

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: switch debounce

Post 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
Martin

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: switch debounce

Post 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.
Enamul
University of Nottingham
enamul4mm@gmail.com

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: switch debounce

Post 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
Martin

siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

Re: switch debounce

Post 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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: switch debounce

Post 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
Martin

Post Reply