LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVi and WhileLoop

Solved!
Go to solution

Hello,

i am using a Vi to read the Resistance of an Ohmmeter. This works fine, also i can let it run continously, to get the values.

However, now I want to use this VI in another one. For this purpose, i use a while loop, and place the beforementioned VI inside, connect it to a numeric indicator. When i start, the first vale is shown in the indictor, but no new values are sent to it...?

 

I have no idea why or whats going on.

Thank you for our help,

Markus

0 Kudos
Message 1 of 21
(3,059 Views)

You don't understand data flow.

 

Your calling VI calls the subVI and waits for it to finish.  You have a while loop running continuously so it doesn't finish.  As a result, the calling VI is stuck waiting.

 

 

0 Kudos
Message 2 of 21
(3,055 Views)

Hi Markus,

 

so there is a problem in YOUR VI and you need to debug YOUR VI on your own.

Or you might just attach YOUR VI here…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 21
(3,053 Views)

Thanks for your answers.

But i dont see whats wrong. When i run the Vi which i call by itself, everything works fine - no error, no infinite while loop, all good...

 

main.pngSo i Call the Vi Read Omega, i get the first value. Then in the second run everything stops working.

Why? The ReadOmega Vi works fine when i just let it run continously by itself - so i guess it does finish?

0 Kudos
Message 4 of 21
(3,046 Views)

I just tested gain the step by step run - There is no loop and the VI does finish! I just that only the first value gets send to the indicator? The i can go on further step by step but the value is not updated anymore?

 

I also added an indicator to the loop variable i - and it does increase! No waiting for the Vi to finish, but why is the new value not passed to the indicator?

0 Kudos
Message 5 of 21
(3,040 Views)

Presumably the Read Omega vi is returning the same value over and over, but without being able to see what's happening inside of it there's no way for us to know. Can you post the whole project?

0 Kudos
Message 6 of 21
(3,030 Views)

read.png

0 Kudos
Message 7 of 21
(3,017 Views)

Even if it doesnt work, the first loop is cancelled when i>10, the second loop stop if a \n is read (the std. output after each send). So no infinite loop. Anyway that is not the problem as said above. But what could be the problem here?

0 Kudos
Message 8 of 21
(3,007 Views)

Have you tried to debug your Vi will it is running? 

 

What is the string that is return from the instrument? 

 

(And why are you not using VISA in the correct way? Use the termination character option on the VISA)

0 Kudos
Message 9 of 21
(3,001 Views)

@MarkusSt85 wrote:

the second loop stop if a \n is read (the std. output after each send). So no infinite loop.


And what if you are not getting any data?  Oh, you will have an infinite loop!  Anyways, your two loops there could be done with just two VISA Reads with the Termination Character enabled (default when using the VISA Configure Serial Port).  You just tell the VISA Read to read more bytes than you expect in a message and it will do the rest.  Furthermore, you will get a timeout error if data is not coming in.


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 10 of 21
(3,000 Views)