06-15-2010 12:42 PM - edited 06-15-2010 12:43 PM
Oh dear...and why not use the abort button to stop?
06-16-2010 07:32 AM
06-16-2010 09:28 AM
Well, i'd say since it is a local variable, the user could press that button.....
But the outer loop cannot be stopped except by ABORT.....which reminds my of the famous tree.
06-16-2010 02:52 PM
07-23-2010 12:44 PM - edited 07-23-2010 12:44 PM
Here's another one.
08-23-2010 06:52 PM
More Localistis here: http://forums.ni.com/t5/LabVIEW/Red-line-inside-of-case-structure/m-p/1224614#M521381
08-30-2010 08:14 AM
Here's an excellent post / explanation from Norbert.
It is found here: http://forums.ni.com/t5/LabVIEW/Having-Trouble-Copy-and-Pasteing-Local-Variable-in-LabVIEW-2010/m-p/...
@Norbert B wrote:
I think it is a good time to tell him the reason for locals being "bad":
Local variables are (using terms of other programming languages) "call by reference" only for writing. Reading is done "by value" so each reading local variable represents a copy of the value from the control the local is linked to.
Taking into account that the local variable node does not provide an error in/out for "synchronization" purpose, the read is done any time the dataflow would allow it. This "random moment in time" for reading is commonly the reason for race conditions: you read old or new data but you never know for sure.
This is the reason for using variables (globals work the same!) should be avoided. But as different persons already posted: variables have their use and therefore cannot be removed from LV. But please do not consider variables to be botch! They simply work different compared to other programming languages.
Regarding performance:
Using the terminal/wire to transfer data is using X. Variables introduce a slight overhead. Sadly, this overhead depends on the system you are running on and on the LV version.
Just to give you some figures: I use LV 2010 and the local variable is about 10% slower than writing to the terminal for update of the indicator.
The value-property node is about 1000 times slower than the terminal due to the switching of threads (as being posted before). You can "cheat" a bit by hiding/minimizing the frontpanel, but it'd be still about 900 times slower.
This is the reason why the VI Analyzer suggests you to exchange all value-property nodes with local variables. This can be done when:
a) error in/out is not used for synchronization
b) performance matters
So please make it a rule of thumb:
- Try to avoid any type of "remote access to controls/indicators". Those mechanisms are local/global variables and value-property nodes. The latter ones lack of performance due to heavy thread swaps and all of them easily create race conditions if not used properly.
- There are situations where variables come handy and can be used. Those are most of Write Once, Read Many. But you should read the info tbob linked in his "signature" because this is an elegant way to prevent using variables.
hope this helps,
Norbert
PS: Without seeing the issue you described in your very original post, we cannot give you any valuable information about the issue. So please post code where we can reproduce this. Otherwise, you will never get any answer!
08-30-2010 10:47 AM
@Ray.R wrote:
Here's an excellent post / explanation from Norbert.
It is found here: http://forums.ni.com/t5/LabVIEW/Having-Trouble-Copy-and-Pasteing-Local-Variable-in-LabVIEW-2010/m-p/...
@Norbert B wrote:
Taking into account that the local variable node does not provide an error in/out for "synchronization" purpose, the read is done any time the dataflow would allow it. This "random moment in time" for reading is commonly the reason for race conditions: you read old or new data but you never know for sure.
Should we propose error in/out for local variables for synchronisation purposes? Would this make Locals less evil?
08-30-2010 01:14 PM
I was thinking about that this morning.
Then you would have people not wiring the error-in/out...
Maybe simply change their name so that people not confuse them with text-based "Local" variables.
Humm..... in essence, they are similar, in that it is local to the VI or function... But it is more of a copied instance of the data than the variable itself..
If it wasn't for the dataflow and the parallelism in which LabVIEW executes, then they would be fine...
I don't know what the solution is... And I hate seeing the communitu divided by a Local Variable.. 😞
08-30-2010 01:49 PM
@Intaris wrote:
@Ray.R wrote:
Here's an excellent post / explanation from Norbert.
It is found here: http://forums.ni.com/t5/LabVIEW/Having-Trouble-Copy-and-Pasteing-Local-Variable-in-LabVIEW-2010/m-p/...
@Norbert B wrote:
Taking into account that the local variable node does not provide an error in/out for "synchronization" purpose, the read is done any time the dataflow would allow it. This "random moment in time" for reading is commonly the reason for race conditions: you read old or new data but you never know for sure.
Should we propose error in/out for local variables for synchronisation purposes? Would this make Locals less evil?
You would have to re-invent the local such that it was protected by a semaphore so we could do a "Locked-Read" proprty taht would return the value along with a semaphore locking reads of the local until that thread wrote back to the local and released the semaphore.
So whole idea;
Only one local write allowed.
All others must be a protected write.
Seems silly,
Ben