From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

End While Loop after False Case Structure is Executed

I have all of the program executing properly except for ending the program after we have executed the false case structure.  Can someone help me end the program after the false structure has been executed.  I want to continue executing the while loop if the AND function is true.

0 Kudos
Message 1 of 8
(4,376 Views)

You already have it set up right.  The same condition that determines the case structure also determines whether the loop continues.  Just wire that to the loop condition (continue if true)

0 Kudos
Message 2 of 8
(4,359 Views)

When I connected the continue if true to the AND function it stopped the loop prior to executing the false case.

0 Kudos
Message 3 of 8
(4,351 Views)

I would recommend adding a case structure with an enum. Have attached the code, check if it works.

 
0 Kudos
Message 4 of 8
(4,343 Views)

I am away from my hardware and machine that has labview, but will give it a try when I get back to it next week! Thank you!

0 Kudos
Message 5 of 8
(4,339 Views)

Don't create a DAQ task inside the loop every iteration, and certainly not if you fail to close the task.  Right now your endless creation of task is a memory leak that will eventually crash your computer.  Put the Create Task outside the while loop and a Clear task after the while loop.

 

Your True and  False cases are nearly identical other than the constant wired into the analog write.  No need to duplicate the code.  Pull it out of the case structure other than the constants.  And since it is "either" one constant or the other, get rid of the case structure and just use a Select statement.

 

Since your loop is set to continue when True, just wire the comparison to the Continue Terminal?  It will continue the loop when true and stop the loop when false.

 

One problem you might have is the use of the Dynamic Data Wire.  You really don't know what type of data is on that wire, boolean or numeric, and whether it is a scalar or an array.  Convert the blue wire to a real datatype as soon as possible.

Message 6 of 8
(4,336 Views)

Is this how you think it should look? I still think this loop will stop before writing a 0 if the AND becomes false.  Right?

 

I still have to place a clear task as well.

0 Kudos
Message 7 of 8
(4,277 Views)

Loops always complete internal code before exiting, so it should work fine, assuming the stop terminal understands that dynamic data.

0 Kudos
Message 8 of 8
(4,267 Views)