Hi
I had to delete all your 3D panel components as they were confusing, being duplicates of 2D.
I am not at a PC, but easy to implement switch off by having counter one test. It switches on at 150 (2 seconds) so test again for 175 (OK so that is around an extra 333mS) and switch off.
I can modify my example but not until later.
Regards
Implementing a non blocking delay
-
chipfryer27
- Valued Contributor
- Posts: 1861
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 407 times
- Been thanked: 632 times
-
chipfryer27
- Valued Contributor
- Posts: 1861
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 407 times
- Been thanked: 632 times
-
chipfryer27
- Valued Contributor
- Posts: 1861
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 407 times
- Been thanked: 632 times
Re: Implementing a non blocking delay
Hi
If you look at my example and previous post you will see that we have (for each switch) three variables.
Count 1 is a simple counter.
Sw1 is status of switch 1 (on/off)
Trig1 let's us know if Sw1 has been/is switched.
Initially everything is at "0"
Counter increments in background.
You press the button and Sw1=1
In the decision box we branch only if Sw1=1 AND Trig1=0
In the branch we reset Count1 to 0 and set Trig1 to 1. This prohibits the counter being reset during next loop if the Switch is still on.
Later we test for Count1 to equal our value (150). We branch only if Count1=150 AND Trig1 = 1. This prevents the branch just if the counter reaches the value.
Of course you should also include a way to reset the above once whatever you want to happens has occurred. Without knowing more about your application there are many possibilities.
Is it a momentary button press / is it from an MCU that will go low after a condition / etc.
Regards
If you look at my example and previous post you will see that we have (for each switch) three variables.
Count 1 is a simple counter.
Sw1 is status of switch 1 (on/off)
Trig1 let's us know if Sw1 has been/is switched.
Initially everything is at "0"
Counter increments in background.
You press the button and Sw1=1
In the decision box we branch only if Sw1=1 AND Trig1=0
In the branch we reset Count1 to 0 and set Trig1 to 1. This prohibits the counter being reset during next loop if the Switch is still on.
Later we test for Count1 to equal our value (150). We branch only if Count1=150 AND Trig1 = 1. This prevents the branch just if the counter reaches the value.
Of course you should also include a way to reset the above once whatever you want to happens has occurred. Without knowing more about your application there are many possibilities.
Is it a momentary button press / is it from an MCU that will go low after a condition / etc.
Regards
Re: Implementing a non blocking delay
Hi
The signal is from PLC which will only give a momentary trigger from its relay output and go low. It is basically recording temperature from my thermal camera and giving the respective output in form of momentary trigger.
The problem I face in the program is my outputs B5, B6 and B7 don't stay low. Like it is supposed to momentarily go high and turn off which it is not doing for some reason.
Uploading the latest code for guidance.
Regards
The signal is from PLC which will only give a momentary trigger from its relay output and go low. It is basically recording temperature from my thermal camera and giving the respective output in form of momentary trigger.
The problem I face in the program is my outputs B5, B6 and B7 don't stay low. Like it is supposed to momentarily go high and turn off which it is not doing for some reason.
Uploading the latest code for guidance.
Regards
-
chipfryer27
- Valued Contributor
- Posts: 1861
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 407 times
- Been thanked: 632 times
Re: Implementing a non blocking delay
Hi
So it is normally low, and goes high before returning low. How long roughly is it high? As it is a relay you will need to take switch bounce into consideration either in software or physically.
Regards
So it is normally low, and goes high before returning low. How long roughly is it high? As it is a relay you will need to take switch bounce into consideration either in software or physically.
Regards
Re: Implementing a non blocking delay
Hey
The relay bounce time is generally 5ms being a mechanical relay, but online it is suggested to use a software debouncing of 20ms.
It should be high for roughly 200ms but I’m not sure as that I’ll need to test it and amend accordingly.
What I am currently stuck at as the outputs not actually behaving like expected hence I uploaded the program. I have a crystal oscillator of 10Mhz on my PCB, so I’ve set the speed accordingly.
Regards
The relay bounce time is generally 5ms being a mechanical relay, but online it is suggested to use a software debouncing of 20ms.
It should be high for roughly 200ms but I’m not sure as that I’ll need to test it and amend accordingly.
What I am currently stuck at as the outputs not actually behaving like expected hence I uploaded the program. I have a crystal oscillator of 10Mhz on my PCB, so I’ve set the speed accordingly.
Regards
-
chipfryer27
- Valued Contributor
- Posts: 1861
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 407 times
- Been thanked: 632 times
-
chipfryer27
- Valued Contributor
- Posts: 1861
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 407 times
- Been thanked: 632 times
Re: Implementing a non blocking delay
Hi
This example turns on a led after x-seconds, then off after a further y-seconds, resetting trigger so it can run again.
Hope this helps
This example turns on a led after x-seconds, then off after a further y-seconds, resetting trigger so it can run again.
Hope this helps
- Attachments
-
- Thermaltimingjan_Example.fcfx
- (23.11 KiB) Downloaded 29 times