09-22-2007 01:11 PM
09-22-2007 01:27 PM
Hi Drew,
I think what you're after is a "Local Variable" - right-click on the diagram terminal and choose create\local variable. Locals can be configured for Reading (a data source) or Writing (a data-sink.) Old LVers use "locals" sparingly because wiring directly to the (one) control is more efficient for LabVIEW and the wires you seek to avoid may actually assist in debugging (tracing the source of data-changes.)
Cheers!
09-22-2007 02:09 PM
To answer your question; No, there is no way to have multiple copies of a control/indicator.
Local Variables are the easiest way to pass data between Loops, but as mentioned, they are not very efficient and can make things difficult to troubleshoot. They can also introduce race conditions because they do not follow the data flow paradigm that LabVIEW uses.
You also can't have a control outside a loop/loops and read the value inside the loop. With the control outside the loop, the value of that control will be read once before the loops start iterating, that value will be passed into the loops and that value will essentially become a constant inside the loop. The control would have to be read again to get a new value, but since it's outside the loops, it can't.
The best way to pass data between loops is to use Queues, Notifiers or Functional Globals. There are some good examples that ship with LabVIEW show the use of Queues and Notifiers. (Help>Find Example. Search for Queue and Notifier) And there are several article on ni.com you can search for show the use of Functional Globals.
For single loop architectures, you're better off passing everything with a wire. Using a State Machine architecture can keep your diagram neat by passing most, if not all of your data around using clusters in shift registers. This can make your data available everywhere in your application.
09-22-2007 02:43 PM
Hey Drew,
A slight clarification...
@Ed Dickens wrote:
You also can't have a control outside a loop/loops and read the value inside the loop. With the control outside the loop, the value of that control will be read once before the loops start iterating, that value will be passed into the loops and that value will essentially become a constant inside the loop. The control would have to be read again to get a new value, but since it's outside the loops, it can't.
What Ed means is: If a control's value is wired into a loop, then the value inside the loop (coming from the tunnel) will always be the same value - the value the control had before the loop started executing. If a control's value is read via a local-variable it will be the newest/current value, even if the control is changed/updated outside the loop. The "stop" usage you described is a great example of a simple use for a "local": here, a notifier or occurance might be used instead but they're probably overkill.
Cheers!