From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing Values To Front Panel Controls (Most Efficient Method)

Hi everyone, I've always wondered which is the best way to write a value programitcally to a front panel control.

 

In the past I have used local variables but I know this can also be done with property value nodes.  I know local variables are actually faster but they also use a lot of memory space.

 

What is the most efficient method to write to front panel controls?

 

Thanks so much!

0 Kudos
Message 1 of 33
(3,164 Views)

Local variables.

 

I woudn't say they "use a lot of memory space".  What do you consider a lot?  It makes a copy of the memory, but if it isn't a large and complicated of a structure, that amount of space won't be a lot.

Message 2 of 33
(3,147 Views)

How often are you writing to controls where efficiency may be an issue? Controls are generally meant for user input. If you are writing to them often, you have to be careful that you aren't constantly overwriting something that the user is trying to input.

Message 3 of 33
(3,140 Views)

@testdesign wrote:

Hi everyone, I've always wondered which is the best way to write a value programitcally to a front panel control.

 

In the past I have used local variables but I know this can also be done with property value nodes.  I know local variables are actually faster but they also use a lot of memory space.

 

What is the most efficient method to write to front panel controls?

 

Thanks so much!


 

If you're looking for speed, local variables should be used. But local variables break data flow so make sure you use them properly.

 

BTW, in a simple For Loop, writing the loop iteration counter to a property node of an I32 control100,000 times took 9.39 seconds on my computer. It took 5.8 miiliseconds to write to a local variable of the same control. Ignoring the overhead for the For Loop, and timer functions, that's a factor of 1600 so local variables are MUCH faster. Just keep the data flow caveat in mind.

 

------------------------------
All statements are my opinion and worth every cent you paid for them.
Tom Whitaker, CLD
- - - - - - - - - - - - - - - - - - - -
"Give every man thy ear but few thy voice."
Polonius in Hamlet.
Message 4 of 33
(3,130 Views)

My use case here is really not speed dependent but I like to chooose the most efficient methods when coding.  The reason I am having to update controls during VI run time is because the VI I am creating can be pulled up on demand from a test executive.  The VI takes in user P/F input (which are the controls) and stores them to a file for analysis.  This VI can be run multiple times in one complete DUT test.  I want to dynamically update the front panel controls each time the VI is called based on what the control values were set at from the previous VI run.

 

Thanks for the feedback everyone.

0 Kudos
Message 5 of 33
(3,103 Views)

So where do shared variables fit into this equation as far as speed and memory.  Since it is a variable and not a prop node does it go faster? and since it has error wires it can maintain the flow of the code.

Doug

"My only wish is that I am capable of learning each and every day until my last breath."
Message 6 of 33
(3,091 Views)

@dacad wrote:

So where do shared variables fit into this equation as far as speed and memory.  Since it is a variable and not a prop node does it go faster? and since it has error wires it can maintain the flow of the code.


They are slow, especially if they are network published shared variables.  And they are also a copy of the data.  Plus they don't write to the front panel.

 

The order that I have actually tested for writing to front panel controls are in order of speed: the terminal!, local variable, and property node (like 1000x slower).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 33
(3,083 Views)

OK, So when you have to control top level items from within sub-vi's and sub-sub-vi's and such, would you prefer a shared variable or a global variable?

 

While the shared variable doesn't write to the front panel directly you can use a variable specific loop or the timeout case in an event structure loop update front panel nodes written from the shared variable.

 

Just trying to gain insight into best practices.....

Doug

"My only wish is that I am capable of learning each and every day until my last breath."
0 Kudos
Message 8 of 33
(3,073 Views)

The best way is to write directly to the indicator.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 33
(3,063 Views)

But you cannot write directly to the front panel from two or three levels down in a sub-vi.

Doug

"My only wish is that I am capable of learning each and every day until my last breath."
0 Kudos
Message 10 of 33
(3,045 Views)