LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real Time Patterns

My General overall question is which of the below patterns is more efficient / readable / not frowned upon.

 

The use case here is tripping an alarm. The alarm is a simple boolean single process global that can be set on a number of conditions. In the attached example I've created 3 condition VIs. I get staticly typed VI references to each, and then iterate over them at a set interval to see if any of their conditions trip the alarm. They have standard connector panes.

 

Would it not be better to just run each of these in it's own timed loop or SubVI containing a timed loop? Which is more efficient?

 

- Ken 

0 Kudos
Message 1 of 5
(2,715 Views)
Forgot to attach the image!
0 Kudos
Message 2 of 5
(2,714 Views)

Ken-

 

Timed Loops operate a little differently than a While Loop.  With a While Loop, the execution can be broken down into different threads on the processor.  With a Timed Loop, it only uses one thread and tries to get that one thread done in the time specified.  The best is to have multiple Timed Loops, but be sure that they aren't all top priority, that can cause resource problems.  The only warning I would give is to reprogram it so that you don't have three copies of the "Reason" shared variable.  You don't want a race condition with that.  I would merge the outputs of the timed loops and throw the data into one shard variable.

National Instruments
Applications Engineer
0 Kudos
Message 3 of 5
(2,691 Views)
Why would I have three copies of the reason variable?
0 Kudos
Message 4 of 5
(2,671 Views)
I'm sorry if I wasn't clear.  It would be wrong to have three timed loops with the "reason" variable in each loop.  You should have three timed loops for each alert VI, and make sure that they are being written to one copy of the variables.  That way you don't run into race conditions.
National Instruments
Applications Engineer
0 Kudos
Message 5 of 5
(2,665 Views)