07-23-2014 04:40 PM
Hi
i would like to ask how it si with evaluation while loop in for loop. I have made for loop with code and also a while loop inside it and i have to know when the evaluation of while loop starts. I think that it has to start after the code in one cycle of for loop is finished but i don´t know and i have no idea where can i find it. I would like to have fisrt evalution for loop after it while loop till stop condition and than new cycle of for loop and again.
I am beginner with labview so thanks a lot for help.
07-23-2014 04:51 PM
It all really depends on your data flow. LAbVIEW is a dataflow language. So you have to see what data is available. But the everything in a loop must complete before it can iterate. Therefore, the While loop must complete before the FOR loop can iterate.
07-23-2014 05:58 PM
07-23-2014 06:45 PM
Standard and easy way to control the order of program execution is to pass an Error cluster through every step. Even if you don't actually look at the error value, the error cluster that comes into one VI is passed out at completion, and any VI that is waiting for that error wire to be populated has to wait for that value to arrive before it executes.
Since I learned this trick I haven't used a flat sequence to control program execution for about 2 years.
Once your VI is ready to run, turn on "highlight execution" and single step through the code with the debugger. You'll see what happens and when. Sometimes you'll be surprised. Sometimes steps on the right side of the block diagram run what looks like "early" and you might think that the steps on the left would execute first. But physical placement in the block diagram doesn't mean anything.
If a step inside the iteration of the FOR loop needs a value that comes out of the WHILE loop, then the while loop will execute before the step that needs that input. But, if a separate step in the for loop doesn't rely on output from the while loop, then that step can execute first, or even simultaneously with the while loop. Labview executes a step when all of the necessary data for that step is ready.
07-23-2014 06:47 PM
PS, pass your error cluster through the loops in a shift register, or labview will build an array of error clusters, which you don't want.
07-24-2014 07:25 AM - edited 07-24-2014 07:28 AM
Hi jeseter,
I think you might find useful this: Execution Structures in NI LabVIEW. It's part of Introduction to NI LabVIEW educational material that is available online for free. You can find other educational resources by simply using the search field on www.ni.com.
NI also offers broad range of training courses that can accelerate your learning. These can be led by instructor in a classroom, or self-paced online. See NI Training and Certification to find which fits you the best.