12-04-2010 10:33 AM
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.
12-05-2010 02:04 AM
What is actually your question?
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
12-05-2010 04:56 AM
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 😉