LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding the duration for a Timed Loop execution

Please refer to the attached VI that shows two different methods to find out the actual time it takes for the complete code inside a Timed Loop to execute. In this case on my laptop ( P4 with 6GB RAM and 2.53GHz i5 CPU ) it takes 4ms as reported by the left side "Iteration" in left side data node. And the value as reported by the subtraction of the ms timer reports a constant 10ms which is what I have configured. I guess in this case of Timed Loop it is only expected to show this programmed value ?

 

Question is : How accurate is the value reported by the Iteration data node ??

 

thanks.

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 3
(4,980 Views)

What is actually your question?

 

 

  • The "iteration duration" shows how long it takes to execute all code per iteration.
  • The "period" just returns whatever you have configured as period (10ms in this example)
  • The tick subtraction shows the time it actually took per iteration.

 

 

As long as the "iteration duration" can fit comfortably into the "period" duration, the loop can keep up. and the rate is constant and predictable. If it does not fit, you are in trouble.

 

An illustrative experiment would be to change the FOR loop "N" to 10x larger. Now the code will take longer than 10ms and:

 

iteration duration >>10ms

Period=10ms

tick subtraction >>10ms

Message 2 of 3
(4,960 Views)

Thanks its clear now . Probably I should explain why this started ! 

 

I have developed a very large code for machine control and one of the constraints was to control four machines with a common cyclic timer signal ( 400ms ON and 400ms OFF ). The required functionality has been achieved with four state machines running inside a common 10ms loop. And as part of the state machine operations, there are writes to disk and waveform display. 

 

But there was this occassional Finished Late boolen lighting up.

 

So I was curious to know if  all  the code inside the Timed Loop was executing in less than 10ms and hence wired up  all the three methods as I had did in  the sample code to indicators. Out of this the Iteration duration alone was showing 4 to 6 ms  and rest both were showing a fixed 10ms. 

 

I then realized the differences and modified  the same sample loop and I guess the Tick Subtraction as done  now shows the same value as the Iteration duration. Aditional confirmation that the code takes less than 10ms to execute 😉

 

 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
Message 3 of 3
(4,951 Views)