To download NI software, including the products shown below, visit ni.com/downloads.
This example demonstrates how to change the value of a Front Panel element from a SubVI.
Description
Did you ever have a subvi running, with some numerical calculations taking place, but your main vi looks frozen because the update does not occur until the subvi is done?
These two example VI's show how to get the SubVI indicator's values and display it on the Main VI Front Panel during execution. In other words, as the SubVI is executing, the indicator value is shown on the Main VI, even though the SubVI front panel is not visible. This technique can be used with any type of indicator, even a progress bar.
You can see that an indicator has been created in the Main VI. From this indicator, a reference has been created. This reference is passed to the SubVI as an input. In the SubVI, a control refnum was created to accept the reference input from the main. A value property node was created. The control reference was wired to the value property node. The SubVI indicator is wired to the value input of the property node.
When the SubVI executes, the instantaneous value of the indicator is passed into the property node. This value immediately shows up on the Main VI Front Panel.
To create from scratch, follow these steps:
1. Create an indicator of the appropriate type on the main vi front panel.
2. In the block diagram, right click on the indicator and select Create - Reference. The reference object is place on the block diagram.
3. Create a subvi with code that writes values to an indicator which you want to be displayed on the main vi.
4. Create a control refnum on the subvi front panel and tie this control refnum to a terminal pane.
5. In the subvi block diagram, create a value property node, and wire the control refnum to the property node. You may have to right click on the property node and change the mode to Write.
6. Wire the subvi indicator to the value input of the property node.
7. In the main vi, drop the subvi into the block diagram, and wire the reference to the subvi input terminal.
8. Run the main. It will call the subvi, and the main indicator will be updated in real time as the subvi executes.
What happens here is that the Main VI reference passed into the SubVI is actually the memory address of the Main VI's indicator variable. In the SubVI, the value property node writes the value that is wired to it into the memory address specified by the control refnum. Since it is the same address as the Main VI indicator, the main is updated from the SubVI during execution.
Requirements
Software
Hardware
Steps to Implement or Execute Code
Additional Information or References
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
this is very useful. thanks ![]()
Very simple example doing exactly what I needed. Thank you.
Exactly what I was looking for. I supposed it was difficult and... NO, it's not difficult!
Thanks.
How to display multiple indicators by using only a single control refnum
Fantastic,
is there any trick to make it work on FPGA targets?
Cheers
This is so much useful.
Do anybody know how to apply this method to cluster? Or do I need to take another way?