LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use a boolean cluster to stop a while loop

I'm using Labview 7.0 and have made a boolean cluster to try and stop a while loop but it doesn't work. Below is the vi. Could someone identify the problem.

Thanks,

Steve
0 Kudos
Message 1 of 3
(2,391 Views)
Steve,

The way it's programmed, your code's behavior is to output a "true" only if the fourth element in your array is true or the fourth element of your cluster is true, which is presumably not what you had in mind. The reasons are:

- You are wiring arrays of two different length into your For Loop and using auto-indexing. As a result, the loop iterates to the end of the shorter array and then stops, so the last few elements in the longer array (the one from the cluster) are ignored.
- You are not using auto-indexing on the boolean output tunnel of the For Loop, which means that LabVIEW simply outputs the value sent to that tunnel during the fourth and last loop iteration. That logical value is ((fourth array element) OR (fourth cluster element)).

If you're trying to make the VI stop anytime any of the buttons in either the array or the cluster is pressed, then you can:
1. Concatenate your two arrays inside the For Loop using the Build Array function (Array palette)
2. Use the output of the Or Array Elements function (Boolean palette) to determine if the loop stops or not

Hope that helps,
John
0 Kudos
Message 2 of 3
(2,383 Views)
You've got a couple of problems. First, the for loop will only execute 4 times. When you wire arrays into a for loop, the loop count is determined by the size of the smallest array. Second, the value passed out of the for loop with indexing turned off is the result of the last iteration. In your case, only when Boolean 4 is true does the for loop return a true and stop the loop. If all you want to do is stop the loop when any one of the Booleans in the cluster is true, take the Or Array Elements on the Boolean palette, wire the input to the cluster to array output, and wire the output to the loop termination terminal. See the attached picture.
0 Kudos
Message 3 of 3
(2,381 Views)