Page 1 of 1

E-Blocks 2 settings

Posted: Wed Mar 27, 2024 9:22 am
by walbeek
Hi there,

I have made a counter program with interupts on the inputs.
In simulation modes the program works well.
When programmed in the e-blocks BL0080 programmer, the switches don't work very well.
When pushed once, the counter changes with more than one in most cases.
The debounce of the switches is set to 40ms but there seems to be no change.
Can anybody give me some tips on this?
Maybe something like edge-detection instead of debounce?
Please let me know.

Rinie

Re: E-Blocks 2 settings

Posted: Wed Mar 27, 2024 10:31 am
by mnfisher
If you post your chart - someone will surely be able to help...

Martin

Re: E-Blocks 2 settings

Posted: Wed Mar 27, 2024 11:10 am
by medelec35
Hello
As a general rule the debounce will only work if you use the function of the switch e.g ReadState.
If you use the Input command icon then there will be no debounce function.

I thought I would mention this for anyone who has a similar issue.

Following Martins (mnfisher) advice is what I would recommend.

Re: E-Blocks 2 settings

Posted: Thu Mar 28, 2024 7:40 am
by walbeek
Hi there,

Yesterday I have tried to post an update but it seems to be disappeared.
I read about the debounce only be available with the Component Macro's.
So I did change the buttons macro to that.
In the attachment are the old (V001 - Input) and new (V002 - Macro) versions.
However, I still have mistakes in the counting.
I have put the debounce time on 40mS and later 100mS.
Still, every fourth or fifth time the value changes with more than one.
In the V002 version I have also included "Wait Until Low"
In an older program I checked an input and waited a while.
Than check it again and if it's still high, than react.
This was meant to avoid spikes but it might be better do debounce?

debounce.jpg
debounce.jpg (26.41 KiB) Viewed 937 times
Please let me know your opinion.

Re: E-Blocks 2 settings

Posted: Thu Mar 28, 2024 10:21 am
by medelec35
Hello.
This is the debounce routine for the switch read functions:
Debounce.png
Debounce.png (54.98 KiB) Viewed 929 times
if you believe the debounce is not working then we will investigate further.
You need to rememberr that the code within a microcontroller is accessed so fast, delays or WaitUntilHigh or WaitUntilLow (depending on the polarity.), will be required to prevent switch being read too quickly