LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Asyn timers for timeout > 600 seconds under CVI7.0

Seems async timers go crazy with timeout values >= 600 seconds. They
start firing on random intervals. I am using CVI7.0.

Any help is much appreciated.
0 Kudos
Message 1 of 4
(3,458 Views)
Hello Vishi
I am having the same problem when I set the
timer to 900 seconds (15 minutes).

Mano
0 Kudos
Message 2 of 4
(3,460 Views)
Vishi,

This might be a bug but we need to investigate it further. In the meantime, may I suggest that you use the timer control instead? With such large timeouts the asynch timer might not buy you that much in terms of accuracy. If we found that it is a bug and there is a workaround, I will post it here.

Thank you,
Azucena Perez
National Instruments
0 Kudos
Message 3 of 4
(3,458 Views)
Hello all,

As an update to this problem, the CVI asynchronous timers rely on the Windows multimedia timers (see ..\CVI\toolslib\toolbox\asynctmr.c for details) to fire the event at the appropriate time. The incorrect behavior you are seeing is caused by an issue with the windows timers where they wrap around every 429496 milliseconds. For any interval, x larger than 429496 milliseconds, a wrap occurs and the timing interval is actually x-429496 milliseconds. This issue has been reported to Microsoft. More information on the behavior of the multimedia timer and the bug report can be found in the following MSDN discussion.

As a workaround, you can changed the interval of the timer to 1 second (i.e. use single shot events), manually track the number of elapsed timer ticks and perform an operation after the desired time elapses. For instance, instead of setting the timer interval to 600 seconds, set the timer interval to 1 second and increment a counter in the timer callback each time it is called. On the 600th call to the timer callback, perform the code you would like executed every 600 seconds.

Note: This behavior only occurs when the time interval is larger that the wrap around interval of the Windows multimedia timer. Therefore, if you keep the asynchronous timer interval below the wrap around time specified above, you can avoid this behavior.

Hope that helps.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 4 of 4
(3,387 Views)