03-22-2016 05:49 PM
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
03-22-2016 06:04 PM
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.
03-22-2016 06:09 PM
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.
03-22-2016 06:12 PM
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
03-23-2016 08:27 AM
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.
03-23-2016 08:29 AM
@gregoryj here is a picture with the VI. the indicator is in the while loop
03-23-2016 08:35 AM - edited 03-23-2016 08:36 AM
and how can I make it to pass the distance as output in the VI for every itteration of the SubVI?
03-23-2016 08:54 AM
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.
03-23-2016 08:56 AM
@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.
03-23-2016 10:08 AM
I removed the while loop, and I replaced the case structure with a flat sequence. And all is working now