LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How is phase handled when changing period in timed loop?

I'm troubleshooting another problem that I'm having with a timed loop, and realize that I don't understand how the timed loop is supposed to work (which may or not be relevant to my other problem). If the period is changed during loop execution, can the loop be forced to mantain phase for the new period with the original start time?

Let me be more specific: If I have a timed loop with a period of 5, and code inside the loop that takes 1 sec to execute, normal behavior will be for LV to execute the code, then wait the balance (4 sec) for the iteration of the loop to finish before repeating. Thus, each iteration of the loop will begin on a multiple of 5 (0,5,10,15...).

What happens if I change the period to 7 during the second iteration of the loop? Imagine that I use the output node on the right side of the loop, which gets updated when my code is completed. In this case, the second iteration of the code started at 5. The code completed at 6 (and LV was aware at this point that I want to change the period to 7). Does this iteration of the loop complete (wait until 10) before starting the next iteration, which will have a period of 7? OR, does the third iteration start at 7?

Recapping, do the start times go 0, 5, 10, 17, 24, 31???
Or do they go 0, 5, 7, 14, 21???

Thanks in advance for your help!!
0 Kudos
Message 1 of 4
(2,870 Views)
Bump.

Doesn't anyone know?
0 Kudos
Message 2 of 4
(2,839 Views)
Instead of using a timed loop why not use a While Loop with a Wait command inside the loop.  This is a much simpler "Timed Loop".
Especially if you aren't too familiar with the traditional Timed Loop, like myself.
0 Kudos
Message 3 of 4
(2,832 Views)

LabVU_dog,

The way timed loops work is like a normal loop with a Wait Till Next ms Multiple VI in it. When you set your period to 5 seconds and your calculations take 1 s, then the whole cycle will execute within 5 seconds. If you change the period during execution, the current loop will execute with the original period, and the next one will have the updated period.

Loop 0, initial period 5 / no change / end the iteration at 5 Loop 1, initial period 5 /change to 7 for the next iteration / end at 10 Loop 2, updated period 7 / no change / end at 17

Look at the attached picture below. The initial period is 1000 ms. 10ms are added to the current period value on every iteration.

Message Edited by Kalin T on 11-22-2006 03:39 PM

Kalin T.
0 Kudos
Message 4 of 4
(2,821 Views)