LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the same numeric control to read and write values

I would like to use a numeric control to write a value, but also be able to write values to that same control.  Is this possible?  Is there a better way to do it?
0 Kudos
Message 1 of 7
(6,555 Views)
to write a value to a control programatically use a local variable.
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 2 of 7
(6,552 Views)
I made this program. Hope it helps. The numeric control "C1" may act as a control or an indicator, depending what you specify.
 
Cheers.
Ali
0 Kudos
Message 3 of 7
(6,550 Views)
I'm a relatively new LabView user and have been using property nodes to set a control's value. Is that considered bad programming style? When I first looked at Ali84's vi, I had trouble understanding it at first.
0 Kudos
Message 4 of 7
(6,529 Views)
It is okay to set the value by way of a property node, but it does execute much slower than by local variable.  To set a value or two, you won't notice much of a difference, but if you were updating a value in a very fast loop you would.
 
There may be other reasons as well that local variable is better than a property node.  No matter which you use, be wary of race conditions.  When you can't control when a value is being written vs. read, you can get duplicate or stale values, or may miss a value.  Or if you have two locations writing to the same local variable, they would essential compete as to which value sticks in the local variable.
 
One situation where the property node is better is if you were using the value(signalling) property.  If you were using an event structure to detect when a value of a control changes, writing a value to that property node signals to the event structure that the value changed just as if the user had typed in a new value.  The regular value property node does not signal the event structure, nor does the local variable.
0 Kudos
Message 5 of 7
(6,525 Views)

Another use of using value property to write the value of a control is when you want to update the control from another vi,  Locals are exactly that, local.  They only reference controls on the same vi, often I need to update a control from a subvi and you can use the property node here too but it is faster and cleaner to use locals over property nodes in general, and to use data flow over locals when ever possible.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 6 of 7
(6,503 Views)
Both local variables and property nodes are useful in this situation.  You might also want to have a look at the following KnowledgeBase article to help better understand the differences between the two approaches:
What is the Difference Between a Local Variable and a Value Property Node


0 Kudos
Message 7 of 7
(6,479 Views)