LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

timers in CVI behave uncorrectly

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

0 Kudos
Message 1 of 6
(3,359 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 6
(3,355 Views)

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.

0 Kudos
Message 3 of 6
(3,349 Views)

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.

S. Eren BALCI
IMESTEK
0 Kudos
Message 4 of 6
(3,335 Views)

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.

0 Kudos
Message 5 of 6
(3,303 Views)

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.

 

 

0 Kudos
Message 6 of 6
(3,196 Views)