LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI doesn't return the desired data continuously

Hello. I made a VI that calculates distance from a PING)) Sensor. After, I selected the elements from it and convert in a subVI which will return Distance as output.  After, I made a new VI where I inserted the subVI and I created an indicator for the output (Distance) and I put them in a While loop....but the distance from the VI doesn't update, it shows only the first value written by the subVI (and the subVI is still running and the distance is updating in it)....the only way when the indicator is updating (in the VI) is when I press the stop button from THE SUBVI (and the program doesn't stop when I press Stop button, only stop from writting the distance in the subVI and starts writting it as a single value in the VI, but not continuosly). Can somebody help me? 

 

I attached the VI and subVI:

subVI: Untitled 4 (SubVI)

VI: Senzor vi

Download All
0 Kudos
Message 1 of 20
(4,035 Views)

Hi DC20,

 

Can you post for LV 2014 or earlier? My guess would be that your "Distance" indicator in your Main VI is outside of the while loop, so it will only update once at the end of the program. If you move it inside then it will update every iteration. But this is just a shot in the dark without seeing your code.

0 Kudos
Message 2 of 20
(4,026 Views)

Of course it doesn't.  The output of a subVI does not become active until everything inside of it is complete.  You need to allow the "Stop" case in your state machine to stop the loop in the subVI.  You might want to just move the state machine to your main VI instead of the subVI.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 20
(4,021 Views)

Dataflow.

 

Your subVI has a while loop in it that won't stop until you hit its stop button.  It only passes out the distance once it is done running putting it out through the connector panel

 

I would recommend you learn more about LabVIEW from here. How to Learn LV

0 Kudos
Message 4 of 20
(4,015 Views)

I understand, but I need to make a subVI to give as an output the distance, because I will use the distance in another VI then...for example: I need to make a robot to move and then I made subVI for wheels, a subVI for servo and a subVI for this sensor and to put them together in another VI and use them combined.

0 Kudos
Message 5 of 20
(3,953 Views)

@gregoryj here is a picture with the VI. the indicator is in the while loop

 

Capture.PNG

0 Kudos
Message 6 of 20
(3,949 Views)

and how can I make it to pass the distance as output in the VI for every itteration of the SubVI?

0 Kudos
Message 7 of 20
(3,944 Views)

You have to do what the others have said, take out the loop from your distance calculation SubVI. 

 

Turn on the highlight execution light bulb on your Main and Sub VIs and you will see when your Sub VI actually outputs the data.

0 Kudos
Message 8 of 20
(3,931 Views)

@DC20 wrote:

and how can I make it to pass the distance as output in the VI for every itteration of the SubVI?


Here are a few options:

1. Get rid of the subVI and move the state machine code to use the main loop.

2. Move the subVI to be in parallel with this main loop and use a queue or user event to pass the results to whoever needs it.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 20
(3,928 Views)

I removed the while loop, and I replaced the case structure with a flat sequence. And all is working now

0 Kudos
Message 10 of 20
(3,908 Views)