LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why aren't my SubVI's indicators showing readings?

I am intigrating 3 programs into one and this is my first time working with SubVIs. I have created the terminals in the connector pane of the VIs, put them on the new block diagram (as a subvi) and attached the indicators directly to them from the outputs and all 3 are in a While Loop. When I run the program it shows no errors but all the indicator readings show 0 which is not correct. As i said this is my first time so I probably did something wrong, can someone help me out?

Thanks.
0 Kudos
Message 1 of 8
(3,333 Views)
As a guess, you may be passing values out of a while loop which doesn't end... can you post your code?
0 Kudos
Message 2 of 8
(3,333 Views)
Are the indicators with the (incorrect) 0's on the sub-VI's front panels or on the calling VI's front panel?
If they're on the calling VI, are the terminals for the indicators in the While loop or outside of it? If they're outside of the loop, they won't get updated until the loop completes all its interations. If they're inside the loop, they will get updated on each iteration of the loop when the subVI that feeds them is complete (but not before).
Are there endless (or long) loops in the subVIs?
If the indicators are on the sub-VI front panels, are they properly updated when you run the sub-VI stand-alone?
Message 3 of 8
(3,333 Views)
All of the VIs work correctly on their own front panels but on the program that I have integrated them on the indicators stay at 0.

Do I need to do something besides simply attaching indicators to the corresponding terminals in a loop?

Thanks.
0 Kudos
Message 4 of 8
(3,333 Views)
Make sure the teminals for the indicators on the main VI are also in the loop. That's all you should need to do.
If you can't get it working, can you post your VI?
0 Kudos
Message 5 of 8
(3,333 Views)
Yes, the VI I am posting is the overall itegrated VI. Thanks for the help in advance.
0 Kudos
Message 6 of 8
(3,333 Views)
Also, here are each of the SubVIs in there origanel programs.
0 Kudos
Message 7 of 8
(3,333 Views)
It looks to me like the problem is that your sub-VIs are in loops waiting for Stop to be pressed. A subVI does not provide its outputs to the calling VI until the subVI is complete. Your subVIs won't be complete until you press Stop on the subVI front panels. So your calling VI won't get any data from the subVIs until then.
This feature is part of the very foundation of the dataflow paradigm of LabView. A node (function, structure, or subVI, etc.) will not start to execute until it gets data on every wire going to it. A node won't provide any outputs until the node's execution is complete.
Review the section in the LabView User's Manual, Chapter 5, Section titled "Block Diagram Data Flow".
You can solve your problem in a number of ways. Here are a few.
1. Remove the loops from your subVIs. This is a quick fix, but it makes your subVIs less usable standalone.
2. Add an input to the subVIs: a boolean called Wait for Stop. If Wait for Stop is TRUE, stay in the loop and wait for Stop to be pressed. If it's FALSE, execute the loop only once. Wire this new input to a FALSE constant in your calling VI and default it to TRUE on the subVI front panel so it's TRUE by default when running stand-alone. This is probably the way I'd go to fix your problem.
3. Use global variables: write globals in your subVIs, read globals in you calling VI. Use a global for each inidcator you want to pass to the calling VI. I don't recommend this: as in any language, you should use globals sparingly and be careful of race conditions.
4. Use control references in your calling VI to read the data on the subVI indicators. I don't recommend this: it's more complicated than you need for your application.
In options 3 and 4, since the loops repreatedly reading the data will still be in the subVIs, you'll need to put the reading of the globals or the control references in a nested loop. The main loop in your calling VI will execute only once until all subVIs are stopped. That's another basic part of LabView that's important to understand. In a loop, everything in the loop executes once per iteration, and the loop doesn't go to the next iteration until everything in the loop is done.
I have to warn you about the way you're using arrays. Whenever you call Insert Into Array or Build Array, LabView needs to create a copy of the array. As the array continues to grow, the operation gets slower and slower. It would be much more efficient if you could save a fixed number of readings and using Replace Array Subset to create a circular buffer in the array.
Another warning: you're only saving the data to a file at the end of the program. If the PC crashes or someone presses the Abort button, you won't save any data. Especially since you seem to want to take a reading only every second, you have plenty of time to open the file, write one record, and close the file on each iteration.
0 Kudos
Message 8 of 8
(3,333 Views)