02-25-2014 07:57 AM
Hi everyone
How can I make a sequence executing every 1s while continue executing other code in the meanwhile.
e.g.: A ligth should blink with a frequency of 1s. This should be done independently from other code running the same time.
I really was trying it out a plenty of time unsuccessfully. "wait" does not work, "wait until" not either nor does event struct or anything else work out for that... well I thought "simple" issue.
Could anyone give me a hint or even a example code? Please note that in my issue I don't only want to execute only a blinking LED. Lets say I want to receive updates from a board via rs232, but only every 10 seconds. Meanwhile I want to execute other code.
Thanks for help!!
Background inforamtion:
Since 2 month I am programming a GUI with LabView that gives me the ability to control instruments via the rs232 interface. Until now I figured out a lot of LabView by my self but here I got stuck 😕
Solved! Go to Solution.
02-25-2014 08:15 AM
Use a parallel loop with a wait XXXXX ms timer. If the two loops are essentially independent but need to be connected (i.e., to stop the program when one loop is finished), there are several ways to do it - master/slave, producer/consumer, actor network, or even just a plain old local variable from one to the other working as a stop loop boolean.
Cameron
02-25-2014 08:21 AM - edited 02-25-2014 08:29 AM
"wait(ms)" or "wait until..." should never be used for application timing, they are used for loop iteration and synchronize loop processes. Use the other timing functions like elapsed timer or tick count....
CLD....
b. Timing functions
1. Use the Wait function to control the loop execution rate and allow the processor to respond to external events and system tasks
2. Use the Wait Until Next ms Multiple function to control the loop execution rate and to synchronize multiple loops
3. Avoid using any of the Wait functions to time a software operation
4. Use the Tick Count function and the Get Date/Time in Seconds function to time software operations
02-25-2014 08:34 AM
@apok wrote:
"wait(ms)" or "wait until..." should never be used for application timing, they are used for loop iteration and synchronize loop processes. Use the other timing functions like elapsed timer or tick count....
CLD....
b. Timing functions
1. Use the Wait function to control the loop execution rate and allow the processor to respond to external events and system tasks
2. Use the Wait Until Next ms Multiple function to control the loop execution rate and to synchronize multiple loops
3. Avoid using any of the Wait functions to time a software operation
Well, I was just focusing on the blinky, and didn't figure it to be a time-critical operation (I figured the same thing for the data acq every 10 sec, but this may not fit his requirements). What I do when I just want to make a blinky is to set up a loop which switches the LED between off and on. That way I can change the period, otherwise, I would just use the "blink" property node (1 sec period, IIRC).
But, as you say, in time-critical operations, you do want to use the time functions which do depend on the absolute value of the system clock. In a parallel loop.
Cameron
02-25-2014 08:40 AM - edited 02-25-2014 08:42 AM
no problem....we've seen this before many times when someone sets his application to a certain "wait" time frame and wonders why the front panel controls/indicators does not respond?
02-25-2014 09:40 AM
Thanx a lot for help. Let me get through this and see if I get along with your inputs.
02-26-2014 03:37 AM
"elapsed time" was the solution for my issue. Thx again for your support!