08-21-2014 10:39 AM
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!
08-21-2014 11:14 AM
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.
08-21-2014 11:26 AM - edited 08-21-2014 11:27 AM
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.
08-21-2014 11:40 AM
@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.
08-21-2014 01:29 PM
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.
08-21-2014 02:21 PM
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.
08-21-2014 02:31 PM
@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).
08-21-2014 02:39 PM
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.....
08-21-2014 02:59 PM
The best way is to write directly to the indicator.
/Y
08-21-2014 03:34 PM
But you cannot write directly to the front panel from two or three levels down in a sub-vi.