This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

SubVI Indicator Resets to Default Value when Case Structure State Changes

Updated Aug 23, 2023

Reported In

Software

  • LabVIEW Base
  • LabVIEW Full

Issue Details

I have a numeric indicator that has a set default value. The indicator is placed in the True case of a case structure on the block diagram. The False case of the same structure is empty. 

When the True case executes, a new value is written to the numeric indicator. During the False case, nothing happens. When I make this VI into a subVI and associate an output terminal on the icon with my numeric indicator, I notice that when the True case executes, the numeric indicator is updated correctly, but when the False case executes, the numeric indicator resets to its default value. 

Why does the numeric indicator not stay at the value that was last written to it in the True case, and why does it reset to its default value when the False case executes?

Solution

When an indicator is associated with an output terminal, it must output a value to that terminal every time the VI executes. Since the numeric indicator's value is unknown during the execution of the False case, the default value of the indicator is sent to the output terminal.

It is generally not recommended to place controls or indicators within case structures; instead, you should place these items on the outside and modify what happens inside the structures to accommodate the change. In order to have the last updated value be sent back to the output terminal in the False case, you can use an uninitialized shift register with a while loop which only runs once.

In the figure shown below, the desired value is written into the shift register in the True case and is sent to the output indicator once the loop finishes. In the False case, the value of the shift register from the last time the subVI was executed (which is also the previous value of the indicator) is passed again to the shift register and output indicator, and no change is observed.

 
The while loop is set to only run once by wiring a True constant to its conditional terminal. You could also replace the while loop with a for loop which only runs once and achieve the same result.