Search code examples
labview

Create subvi from output of loop


Labview is very frusturating to me having used C/Java before.

I have a simple problem I dont know how to solve.

My program does some operations in a loop and updates an indicator inside the loop. I would like to make this loop (and the inputs it requires) into a VI but I have no idea how to make the indicator an output of the VI.

I would like to be able to reuse this VI, connect an indicator to it, and have it automatically update without creating any loops outside of the VI.

In C I would be able to do this by either returning a pointer or passing by reference to a function.


Solution

  • A) The image below shows how to do this. B) This style of programming works in small applications, but as an application grows larger, I would encourage you to explore an actual architecture for producing data in one hierarchy and consuming it in another (as alluded to by other answers to this question). In particular, do File >> Create Project and choose the Producer/Consumer template to explore a good starting point for such architectures. There are more sophisticated ones, but that makes an excellent beginning. Diagram transformations from original that updates a front panel terminal in a loop to the final that is a reusable subVI using a reference