LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Timed Loop

Solved!
Go to solution

how can I configure a timed loop to execute upon entry, rather than waiting for the first delta time?

 

If my delta time is 10 seconds, I get my first execution after 10 seconds. I would like to execute the loop when it is initially entered (second 0) then wait every 10 seconds after that.

 

Thanks.

0 Kudos
Message 1 of 9
(3,266 Views)

I don't think you want to use a Timed Loop here.

Timed Loops are meant mainly for RealTime systems which need to be deterministic on relatively short timescales.

 

For a 10 second wait, you should be using a normal loop with a 10 second wait inside of the the loop.

Message 2 of 9
(3,250 Views)

What are you seeing that makes you think things are executed after the loop is done instead of immediatley?  Can you let us see your problem code?

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
0 Kudos
Message 3 of 9
(3,249 Views)

Thanks, but you're missing the point. The 10 second timing is to demonstrate the problem I'm trying to solve.

 

0 Kudos
Message 4 of 9
(3,223 Views)

Here is a very simple example. You will notice that the initial increment of the iteration counter occurs after a 5 second wait, which is the delta time. I would like this to execute immediately then every 5 seconds thereafter. (Sorry for changing the 10 seconds to 5, but wanted a shorter time)

0 Kudos
Message 5 of 9
(3,219 Views)
Solution
Accepted by topic author rls9642

The first iteration of a loop, any loop, is iteration 0.  That will not change to iteration 1 until the next iteration has started.  This is expected behavior.  Anything inside the loop will execute immediately but the iteration counter won't increment until the next iteration starts.

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
0 Kudos
Message 6 of 9
(3,212 Views)

Set your iteration count to -1 before running.  Then you will see that the iteration goes to 0 for the first iteration (yes, i is 0 based) quite quickly.


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
0 Kudos
Message 7 of 9
(3,201 Views)

copy the code inside the timed loop and put the copy outside of the loop.  This way, the code will execute once before entering the timed loop. 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 8 of 9
(3,191 Views)

@jyang72211 wrote:

copy the code inside the timed loop and put the copy outside of the loop.  This way, the code will execute once before entering the timed loop. 


Having redundant code accomplishes nothing.  The code will already execute immediately on each iteration of the loop.

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
0 Kudos
Message 9 of 9
(3,184 Views)