LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to update subvi boolean array within while loop

The attached files are a building block of a program I'm writing. L2 calls l3 and creates an array. However, L3 in my circumstance must be contained in a while loop and the array is not updated to indicate the controls of L2. If I remove the while loop in L3, the changes in L2 are updated fine in L3. How do I get L3 to update correctly when it is contained in a while loop?
thanks
0 Kudos
Message 1 of 5
(2,991 Views)
We may need more info on what you expect the operator to see while your program is running: what is the main goal? Is the goal to monitor the array that L3 ultimately creates and observe how its value changes as lower-level booleans (gates, valves, etc.) on L2 fluctuate?

If that is what you are after, it almost seems as if you have the roles reversed here, and L2 needs to be a subVI in L3 so that its fluctuating values are passed to the logic of L3 with each loop iteration.

I rewriting the app in this manner and attaching it so you can see what I mean. Now you can run L3 and open L2 at the same time, and see the array on L3 change as you operate the booleans on the L2 front panel. If this isn't what you're after, then go ahead and provide some more info.

Best regards,
John
0 Kudos
Message 2 of 5
(2,982 Views)
Hi John, I guess I'm getting myself tangled up and I had to add another element. I'll try to explain the situation a little better. I have a 6 channel x 8bit optical control matrix I have to use to control valves with. I have a working program but it is very hard to interpret because everything is packed in one program. I split the operations into modules to make the program more legible. My scan and read ops are fine, but the valve control has some issues. l1 is the actual controls I need to exercise, l2 has all 6x8 controls... the contros (bits) I do not need at this time are default set to logic 0. l3 is what feeds the control box... it also has a bunch of rs232 config stuff I removed for now. when I switch a control in l1, it should be fed into the sub arrays of l2 where the individual arrays are fed into the l3 "Control Array"... that is the problem, when I switch a control in l1, it should change the control array in l3, but l3 has to stay in the while loop. The way it is now, I change something in l1 that does not cascade down to l3's control array.

see attached

thanks
Scott
0 Kudos
Message 3 of 5
(2,968 Views)
It's admirable and correct that you're seeking to modularize this system, and your block diagram comments are helpful.

Let me answer your main question, which you raised in your first post but I didn't specifically address: why don't your L1 changes cascade down to your array indicator in L3? The answer is that L3 only reads those values one time--the first (and only) time L3 is executed on the block diagram of L2. You can observe this if you turn on execution highlighting (the light bulb) and run L2. You'll see that values are passed to L3 once and then L2 is done, never able to pass any updated values to L3.

I want to make sure you took a look at the code I attached above. There you can see that the values from L2 are read fresh in each loop iteration inside L3, and that's the kind of thing you'll need to construct in order to get the behavior you're looking for. It's most common to see LabVIEW modularization take the form of subVIs that all share the same block diagram and pass values along from one to the next.

Now, there are shortcuts that you can take to sort of brute-force the behavior you expect and allow "wireless" communication between VIs--namely, global variables. But there are better ways to solve the inter-VI communication problem, such as a queue (Advanced >> Synchronization) or even TCP/IP. And anyway, I'm inclined to think that your best solution is to rearchitect your system so that everything is taking place on one block diagram.

Regards,
John
0 Kudos
Message 4 of 5
(2,955 Views)
Thanks for your input John. I'll look closer at your example.
0 Kudos
Message 5 of 5
(2,949 Views)