LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sub VI not working

Hello, in the attachment there is an example of what I'm trying to solve in a more complex situation....but the stupid (I thought this) solution doesn't pass in my mind.

 

Input and output data are inside a while loop and all is working fine at VI level. But once created a sub_vi and imported it in a new vi the program doesn't work.

 

Thanks for your help.

 

E.B

 

 

 

0 Kudos
Message 1 of 13
(1,614 Views)

If you can save the vi in a slightly older version (2018 seems to be very common still) more people will be able to help.

I am sure it is something simple... once I get to look at it.

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 Kudos
Message 2 of 13
(1,608 Views)

I attach 2018 version

0 Kudos
Message 3 of 13
(1,599 Views)

@brambo60 wrote:

Hello, in the attachment there is an example of what I'm trying to solve in a more complex situation....but the stupid (I thought this) solution doesn't pass in my mind.

 

Input and output data are inside a while loop and all is working fine at VI level. But once created a sub_vi and imported it in a new vi the program doesn't work.

 

Thanks for your help.

 

E.B

 

 

 


  1. You didn't include the sub VI "test.vi"
  2. What does "the program doesn't work" mean?
"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 4 of 13
(1,592 Views)

If you unzip the file you'll find both VIs

 

Not working means that in Test VI moving input output follow, in the Test Sub VI not.

0 Kudos
Message 5 of 13
(1,576 Views)

When you run "Test sub-vi.vi", it calls "Test.vi".

"Test.vi" doesn't finish until the user clicks the "Stop" button *

But if you don't have the front panel of "Test.vi" open, you can't click the "Stop" button.

 

  1. Open the VI properties of "Test.vi
  2. Select the "Window Appearance" category.
  3. Select "Dialog".
  4. Click OK

 

 

* That code is greedy; should use an event structure.

"If you weren't supposed to push it, it wouldn't be a button."
Message 6 of 13
(1,566 Views)

There is a fundamental flaw in your program. The sub-vi has an endless loop. IE. How do expect to press the "stop" button in your sub-vi?

 

Frozen_0-1666883452572.png

 

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
Message 7 of 13
(1,564 Views)

You need to start with the basic tutorials about dataflow.

 

You also need to explain exactly what you are trying to do.

 

  • Don't have the main VI have "sub" in the name and the subVI not. That's just confusing.
  • The caller needs a toplevel loop and a reasonable wait. no need to spin an interactive loop millions of times per second.
  • Eliminate all loops from the subVI.

 

altenbach_1-1666889013609.png

 

There are many other possibilities depending on what real problem you are trying to solve, so please explain exactly what the user does, and what he expects to see.

 

0 Kudos
Message 8 of 13
(1,513 Views)

I realize that this may be a scaled down example, but you do need to explain a bit more what your ultimate goal is. Do you want to have a window pop up with the front panel of the subvi? If so then you need to set the subvi to open the front panel when called. Do you want the values of X and Y to be updated on the front panel as the subvi executes? If so then you should move the loop outside of the subvi as altenbach suggested. 

0 Kudos
Message 9 of 13
(1,495 Views)

Yes, you have well understood. This is a scaled down example of a complex VI where more while loops are used.

 

As I don't want to open the Suv vi panel during the execution of Test sub vi, the answer of what expected to do is in your second question.

The solution to move the loop outside the sub_vi in order to implement in a Test sub vi it's clear and already used in others program I've. But applying this solution in a complex vi require a lot of modification. For this reason, I asked for this issue in order to verify if there was a simpler solution that was not present in my understanding, helping me to prevent in the future to fall into this situation again.

 

Thanks.

 

 

 

  

0 Kudos
Message 10 of 13
(1,465 Views)