From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
11-12-2012 10:14 AM
Hey everyone,
I need to toggle a Boolean variable for a short period of time (~0.5 seconds but it does not have to be exact as long as it can be changed) when the trigger signal is on.
- basically the Signal variable should remain False until Trigger indicator is True
- then Signal should turn True for ~0.5 sec and turn back False after
The program needs to be in the main while loop (data acquisition loop). Use of timing could affect the data acquisitive (not shown in sample program).
I attempted doing this with a case structure and a flat sequence but unsuccessfully. Any suggestions are welcome. THANKS YOU FOR YOUR HELP!!!
Solved! Go to Solution.
11-12-2012 10:26 AM - edited 11-12-2012 10:27 AM
11-12-2012 10:29 AM
First you have a race condition between the delay and the local variable. Second, you have no delay in the "off" state. Hence your sequence will be one of the following:
1. Wait 500ms
2. Turn LED on
3. Turn LED off
4. Repeat
This would show an LED always off
Or
1. Turn LED on
2. Wait 500ms
3. Turn LED off
4. Repeat
This would show an LED always on
You will want to assign a delay to your off time as well as switching the delay to the time delay express vi (this has error terminals for controlling execution). To find the time delay, type "Time Delay" into quick drop.
11-12-2012 10:51 AM
Thanks for the qucik replies... This didn't solve the problems but perhaps I did not explain it well. With the changes I always get the Triger and Signal going T when >10 and F when condition <10.
I need an impluse signal only once once the condition: Dial > 10 is met. Basically when Dial > 10 i need to send an audio "beep" (controlled by Signal boolean varialbe). Just one short "beep" every time Dial > 10.
1. Signal off
2. Dial >10
3. Signal on
4. Wait 0.5 sec
5. Signal off (regardless of Dial value).
6. Repeat everytime Dial > 10
Thank you for your help
11-12-2012 11:17 AM - edited 11-12-2012 11:18 AM
Something like this?
11-12-2012 12:57 PM
This works!!! Thanks a lot... I haven't used the event structure but this works perfectly.
11-12-2012 01:37 PM - edited 11-12-2012 01:40 PM
Unfortunately, the event structure is not a good choice of you are e.g. polling an external voltage.
The "signal" is true for one iteration whenever the voltage goes from below to above the threshold. It stays off for all other cases.
Here's what you can do in the more general case. much more lightweight. 😉
11-12-2012 03:14 PM
This also works really well!!! Thanks for improving the efficiency of the code 🙂
Cheers.