05-11-2009 10:12 AM
I recently downloaded the LABWindows CVI 9.0 Evaluation Version. I built my first program. It consisted of a unique graphic interface and only had to make a prinf() every second, using a timer.
The printf was executed every ~4.5 seconds. I really can't understand what's the matter and I would like to fix it beforemaking the order.
I submit the callback function:
int CVICALLBACK TimerFun (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
double d;
switch (event)
{
case EVENT_TIMER_TICK:
GetCurrentDateTime (&d);
printf("%10f\n", d);
ResetTimer(0,0);
break;
}
return 0;
}
Thanks,
Luca
05-11-2009 10:20 AM
First of all, I would delete the ResetTimer () call which is not needed in this code (and hardly is at all, at least in my experience).
Seond hint can be to set CVI not to sleep while waiting: this is set by an option in the panel shown by Environment... menu option: it is possible that this option is set to Sleep more which can be excessivefor your system. Despite the online help recitating Generally for Windows, National Instruments recommends the Sleep more mode, I never put it lower than Sleep some, and often have set it to Do not sleep when my application is intended to run as the unique application driving some critical equipment.
05-11-2009 10:28 AM
Thanks Roberto,
I deleted the ResetTimer() line and tried changing the setting to "sleep some" and "do not sleep", but the result is always the same.
I have a Windows XP OS downgraded from Windows Vista.
05-11-2009 01:38 PM
Can you set the timer period to 0 (zero)?
This would cause the callback to be called as fast as possible.
Let's see how fast it can get first.
05-12-2009 05:54 AM
there was a strange bug in older versions of CVI, where the timer control would fire events 2 times. in specific cases, this makes the timer control appears to run 2 times faster than its setup frequency.
i don't know if this bug has been corrected in CVI 9.0, but it appeared until at least CVI 8.5.
06-09-2009 08:26 PM
The attached CVI project works correctly as I run it in XP and Win2K.
You can see it prints the date/time and plots line in every second.
My default sleep mode is "sleep more". This project is built in CVI 6.0.