ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Two timed loops in parallel

Im working on a simple project where i need to have two loops. One updates a numeric indicator every 10ms and the other updates a numeric indicator every 100ms and stop button is supposed to stop both loops. 

Problem is when i use two timed loops in parallel only one runs and the other not.

0 Kudos
Message 1 of 3
(2,936 Views)

Remember the Principle of Data Flow, which is the central "Rule" of LabVIEW -- with (very) few exceptions, no Structure (such as a Timed Loop) can be entered until data are present on all of its inputs, and until a Structure (such as a Timed Loop) exits, data will not be presented on any of its outputs.

 

Your two Timed Loops are connected (serially) by a pair of wires.  Until the first loop finishes, the second cannot begin.  The other interesting "feature" is that you have a feedback node (which I rarely use, as I find their metaphor confusing to me) seems to be connected "backwards", input side connected to an input, and output side connected to an output (note -- it might be correct, but, as I said, I find it confusing enough that I haven't "mastered" its use).

 

Bob Schor

0 Kudos
Message 2 of 3
(2,916 Views)

You already learned about dataflow and data dependency, so here are a few more observations:

 

  • Equal comparisons on DBL values are dangerous. Maybe you want to change to integers instead?
  • If you need to pick between three possible strings for an indicator, zero or one case structure is sufficient.
  • You don't really need two loops. You can update the other indicator every 5th iteration.
  • I doubt you need a timed loop. A plain while loop with a wait would be fine here. (not shown)
  • Please check the help on "elapsed time". Whatever you have wired to the target time ("[i]" or "high resolution relative seconds") makes absolutely no sense!
  • You don't really need the elapsed time express VI.
  • Most likely your feedback node got auto-inserted because you created a wire loop, so don't worry about it and just delete it.
  • Instead of three different comparisons (>, =, <), you can subtract the two values and see if the sign of the result is -1, 0, or 1.
  • Learn about arrays. they greatly simplify the code.
  • If you have three LEDs where only one can be TRUE at any given time, a radiobutton indicator would be more reasonable (not shown).

 

The attached modification is probably not the exact solution you want, but study it. Maybe it can give you some general ideas.

0 Kudos
Message 3 of 3
(2,887 Views)