LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Access while loop in subvi pls help

Solved!
Go to solution
It would be better if you attach the VI along with the LV2G you created.
-----

The best solution is the one you find it by yourself
0 Kudos
Message 11 of 21
(937 Views)

The main apx file has the control

 

this sub vi manipulates the data.

 

More sub vi s will manipulate the control as they will be added but right now This is my application. This wont run without the apx drivers sorry....

Download All
0 Kudos
Message 12 of 21
(935 Views)

and the functional global

0 Kudos
Message 13 of 21
(934 Views)

I think I am trying to simultaneously read and write into the same control that is the problem.

 

The sub vi should start only if start is true. there are many loops inside the sub vi each has its own exit condition. If any loop reaches its condition

 

it stops and should turn the start off as well. same goes vice a versa. if start goes off (through user action) then all the loops should stop as well.

 

 

0 Kudos
Message 14 of 21
(929 Views)

I am not able to correct it ... pls help..

0 Kudos
Message 15 of 21
(923 Views)

In the sub-vi you use the AE unnecessarily to handle the stop condition. Since you write and decide a value in the inner loop, pass that value out to the loop stop condition. Right now you check if loop should stop, probably, long before you've executed the inner loop. Run the program in Highlight mode and Retain wire values and i'm sure you'll see what's happening.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 16 of 21
(914 Views)

I will wire the data out in the innermost loops.

 

but the main prob i am facing - when i change the value of start to false while the vi is running(user action), the data is not entering the AE, I dont understand why..

 

same thing vice a versa too, when the inner loop (inside subvi) programmetically sends the data it is updated in all loops except the start control...

 

 

0 Kudos
Message 17 of 21
(908 Views)

It is obvious that when you start the sub VI it will struck into the while loop inside the sub VI and it will not take the command from the start anymore. One thing you can do is place another while loop parallel to the sub VI and have a control seperately and the LV2G inside it then when you update it it will take it but still this is not the right way of programming. Read the LabVIEW coding guidelines and do the coding accordingly. It would be worthy to read this and this

-----

The best solution is the one you find it by yourself
0 Kudos
Message 18 of 21
(903 Views)

P Anand :

It is obvious that when you start the sub VI it will struck into the while loop inside the sub VI and it will not take the command from the start anymore. One thing you can do is place another while loop parallel to the sub VI and have a control seperately and the LV2G inside it then when you update it it will take it but still this is not the right way of programming. Read the LabVIEW coding guidelines and do the coding accordingly.

 


Yes I know that is the mistake I am doing but I am not sure how to solve. I read your links. I think a filter event or a qeued state can be used. But I am just a beginner and I am not really sure  which to apply and how.

I tried using an event structure which checks for command from start but in case the vi is stopped programmetically instead of the user interaction it goes into an infinite state.

0 Kudos
Message 19 of 21
(899 Views)

In your main vi you have no structure to read/update/handle the Start-button, so it's only handled at program start.

A simple solution could be to add a small while-loop with a 100ms wait that reads the start button and sends it to the AE and/or the opposite.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 20 of 21
(892 Views)