01-22-2013 05:23 AM
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,
Solved! Go to Solution.
01-22-2013 06:23 AM
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...
01-22-2013 07:00 AM
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.
01-22-2013 07:12 AM
In every language, a FOR loop iteration happens AFTER the previous. Though, going with the parallelized FOR loop may get you there.