LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Timer( ) resolution in CVI 2009 SP1

In the CVI 2009 SP1 Contents Help for Timer() function I find

  • The resolution is normally 1 microsecond. However, if you set the useDefaultTimer configuration option to True, the resolution is 55 milliseconds.

But if you click on the useDefaultTimer hyperlink, a new page is opened, where you can read that the resolution is 1 millisecond if you set useDefaultTimer to False.

 

Which is the right resolution?

I wrote my application considering 1 microsecond, but I found strange problems, and I think it is 1 ms.

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 1 of 6
(4,463 Views)

I also would expect 1 millisecond to be the best time resolution possible - but you can check using the function GetAsyncTimerResolution; on my system it returns 1 millisecond... since the regular timer is not expected to be more accurate than the async timer you probably found a typo...

 

I should add that 'my system' also is CVI2009SP1

0 Kudos
Message 2 of 6
(4,454 Views)

On my system GetAsyncTimerResolution returns 1 millisecond too.

 

Probably I found a typo, and I hope one of the NI developers can fix it.

I think I found another typo in the prototype of the GetAsyncTimerResolution function:

  • in the .fp file it is "int GetAsyncTimerResolution(double *Resolution)" and this is OK
  • in the Contents help (F1 key) it is "int GetAsyncTimerResolution(double **Resolution)" but the double '*' is wrong

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 3 of 6
(4,400 Views)

Odd, but I can't find useDefaultTimer in my registry at all. GetAsyncTimerResolution does however return 0.001, suggesting 1ms. Regardles have attached the first few calls to my maincallback, which suggests the resolution is actually 1us, even if the actual cycles are 2-3us. I'm an old fogey btw, still on XP

0 Kudos
Message 4 of 6
(4,386 Views)

Hi vix,

 

Thanks for bringing those documentation problems to our attention.

 

1. There does seem to be a problem with a lot of the function prototypes in the .chm help in the CVI 2009 SP1 and 2010 versions, where an extra asterisk seems to have been added to a number of output parameters. We'll fix this and post a corrected version of the affected .chm files as soon as possible. In all these cases, the parameter data type as it appears in the Parameters section of the help topic is correct, as is the prototype in the corresponding function panel.

 

2. Concerning the timer resolution issues, the async timer resolution is in fact 1 millisecond, as confirmed by the GetAsyncTimerResolution function. But note that asynchronous timers are a library in and of themselves, and are not covered by what is discussed in the documentation of the Timer() function or the useDefaultTimer option.

 

The resolution of the Timer() function should be 1 microsecond, as of CVI 9.0 and later. The function documentation is correct. When that change was made, however, the documentation of the useDefaultTimer option was incorrectly not updated. It should say that "the performance counter timer provides a resolution of 1 microsecond".

 

You mentioned that you didn't think that the resolution of the Timer() function was 1 microsecond. If you run the following code, what do you see?

 

int     i;
double  time[10];

for (i = 0; i < 10; i++)
    time[i] = Timer();
for (i = 0; i < 10; i++)
    DebugPrintf ("timer = %f\n", time[i]);

0 Kudos
Message 5 of 6
(4,359 Views)

 


If you run the following code, what do you see?

 

I tried and I see an increment of more or less 4 microseconds every call to Timer( ).

When I wrote mi post I suspected the Timer( ) resolution because I see false communication timeouts when my board respond quickly (less than 1 ms).

I'll have to investigate deeper on this problem...

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 6 of 6
(4,313 Views)