12-02-2010 06:50 AM
In the CVI 2009 SP1 Contents Help for Timer() function I find
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.
12-02-2010 07:15 AM - edited 12-02-2010 07:19 AM
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
12-07-2010 04:23 AM
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:
12-07-2010 08:02 AM
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
12-07-2010 02:56 PM
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]);
12-09-2010 02:29 AM
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...