LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Main Vi not showing SubVi Output

Solved!
Go to solution

Hi everyone,

 

Fairly new at LabView and I am designing a Vi that takes a current reading and translates that measurement into a PSI reading. I made the Vi and it works as intended, but when I make it into a SubVi and connect everything, I don't get an output to the main vi. What's interesting is that when I run the main Vi and look at the front panel of the SubVi, the values there are changing. Been stuck on this for hours and can't figure it out. I saw some posts on using references but others are discouraging the usage of them. Some input would be great.

 

Thank you!

 

yup860_0-1724797224397.pngMain Vi

yup860_1-1724797252763.pngSubVi

 

Untitled 1.vi (main)

prsi-transmitter.vi (subvi)

 

Download All
0 Kudos
Message 1 of 7
(579 Views)

The outputs from a subVI only output when the subVI finishes running.  If you're just sitting there as the subVI spins through its While loop forever, nothing gets output to the main VI.

 

Whatever you read about references being a bad idea is correct.  Not because it doesn't work, but because it's not flexible or scalable, i.e. you can get it to work on this project but as soon as you want to copy this code to use somewhere else or modify it to work differently it will cause problems.  Depending on how it's done it can also slow down your program a fair amount as the LabVIEW user interface loop is slow in some circumstances.

 

If you were to do it properly I would recommend a Notifier-based messaging system, but that's not your only option and may or may not be best for whatever your program gets expanded to later.

Message 2 of 7
(550 Views)

Ok gotcha. I'm also reading about using global variables and functional global variables. But there are so many differing opinions on which to use. This system I am building is going be using at least 5 pressure transmitters (as well as a BUNCH of other sensors and water valve controls). So I am trying to make the sub-vis as compact, efficient, and reusable as possible. Based on this information, do you have any more comments to add? Thanks for responding by the way.

0 Kudos
Message 3 of 7
(528 Views)

Hi yup,

 


@yup860 wrote:

Ok gotcha. I'm also reading about using global variables and functional global variables. But there are so many differing opinions on which to use.


Don't use globals for data exchange (more than one direction of dataflow)…

 


@yup860 wrote:

 Based on this information, do you have any more comments to add?


Based on the images in your first message I recommend to get rid of the (mostly useless) MainVI and only use the subVI…

 

Other recommendation: don't put any (quite endless) loop in your subVI. Place the loop in the MainVI and split your subVI into 3 VIs: init, DAQ, cleanup. Call those 3 new subVIs from a statemachine in your new MainVI…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 7
(503 Views)

My thinking might be a bit wrong, but this is what I'm imagining. I'm going to have a lot of these PSI sensors so I need to make a subvi so that I don't have the copy and paste the code a bunch of times in the main vi. This project at the end is going to have A LOT more stuff in it. Is it bad practice to make the who psi vi into its own subvi and expect it to function properly?

0 Kudos
Message 5 of 7
(475 Views)
Solution
Accepted by topic author yup860