LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

labwindows timer problem

I have a simple LW app that uses the timer callback at 50 Hz, using LW 8.5 with Vista.  I increment a counter at every callback, read the PC multimedia clock, and write both the counter and the clock to a disk file.  After 100 second run, the counter has been incremented more than it should, based on the PC clock.  This means that the LW callback is running faster than 50 Hz, but it is sporatic. It looks like the app is running about 1.03 times realtime, on average.  Sometimes it is called at the correct rate, and sometimes much faster.  This LW app runs correctly using LW 6.0 and Windows XP Pro.

 

Has anyone experienced a similar problem, or has a suggestion on how to make this timer app run near realtime (I know I need an RTOS to run truly realtime, but it should be closer than it is now).

 

Thanks in advance.

0 Kudos
Message 1 of 4
(3,657 Views)

What you're describing sounds like a known issue in CVI 8.5. Every now and then, the timer control fires two almost consecutive events, instead of just one. Over time, that could account for the your higher than expected tick count.

 

If you'd like to confirm that it is this bug that you are seeing, you can log the time interval that is sent to the callback function (eventData2). The interval should hover around 0.02 seconds every time, with some natural variation depending on computer activity. But with this bug, sometimes (rarely) you get some very, very small intervals.

 

This bug has been fixed and will be included in the next version of CVI. In the meanwhile, the only workarounds I can think of would be either rejecting callbacks in which the time interval is below a certain arbitrary threshold, or use the toolslib\toolbox\asynctimer.fp library instead of the UI timer control.

 

Please do let me know if what you are seeing doesn't really match what I described.

 

Luis

0 Kudos
Message 2 of 4
(3,646 Views)

Luis,

 

Do you know if this problem exists in CVI 7.1? I'm seeing something suspiciously like it.

 

Thanks,

Chandan

0 Kudos
Message 3 of 4
(3,490 Views)
The issue has been seen in CVI 8.5 and earlier (which would include 7.1). The Timer function has been a carry over for quite some time and the reason you may not see the issue as often as with CVI 7.1 is that CVI 8.5 is more robust and bulkier. The best workaround would be using the async timer instead, then you won't see the problem at all.
0 Kudos
Message 4 of 4
(3,454 Views)