LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

go to next iteration in for loop and continue the execution of the previous iteration

Solved!
Go to solution

Hello everybody,

I would like to execute a for loop with a delay in each iteration. I explain: I want to execute a task several times ( for loop) but with a variable delay in each iteration.

So, if we put t=0 before executing the for loop and I use 3 iterations. I put an execution of the first ieration after 3s then go to the next iteration of course without waiting the end of the previous iteration and execute the current iteration after 1.5s and go to the third ieration (again without waiting the last iteration).

I conclude: it is a simultaneous execution of a for loop (10 to 50) begining in different times ( variable delay between t=0 and each exution of each task.

The problem I found in the for loop is the fact I have to wait the end of the delay time in each iteration bfore going to the next one.

 

Best regards,

 

0 Kudos
Message 1 of 4
(4,175 Views)

Hi ziedhosni,

 

no, FOR loop iterations will happen one after the other (unless you enable parallel execution).

 

You should consider redesigning your VI. You may re-sort your function calls and call them by timestamp rather then by delaying each call...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(4,160 Views)

Thank you for your response.

But when I use time stamp I should fix the time and I will have the same problem. In my case , I want to use a random delay for each iteration.

With the for loop working in parallel. I think it is a good idea. But I want to ask you whether I can put a big number of parallelism without crashing the VI.

Actually I don't need more than 12 iteration and I want to do them in parallel but this number is variable. Can I put for instance 20 parallelisms and N which is variable is between 5 and 12 ?

 

Thank you again.

0 Kudos
Message 3 of 4
(4,153 Views)
Solution
Accepted by topic author ziedhosni

In every language, a FOR loop iteration happens AFTER the previous.  Though, going with the parallelized FOR loop may get you there.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 4
(4,150 Views)