LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

timer

Hi,

 

I was wondering: I have a timer. Inside the timer callback I have a function that should be running once the timer is ON. but I notice that this function is beeing executed 5 times before exit. any explaination?

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

Are you filtering events inside the callback? You should execute the code only for EVENT_TIMER_TICK event, otherwise the callback could be executed for other events like EVENT_DISCARD and so on.



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 4
(3,139 Views)

Here is what I have:  

 

int CVICALLBACK timer3 (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 switch (event)
 {
  case EVENT_TIMER_TICK:
   
   enablingTest();
   
   break;
 }
 return 0;
}

 

enablingTest() function is just a function executing without any delay or sleep inside.

Some variable in this functions will be used by other. Which seems to create a delay of about 4 sec as this function is executing about 4 times before exit.

 

 

 

also to mention, in my application I have 2 other timers but they running other functions independant to this.

0 Kudos
Message 3 of 4
(3,131 Views)

Which is the timer interval? And how long takes the function to execute?

Could you print some debug informations to help discriminating how it is working? Something like that:

int CVICALLBACK timer3 (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 double tini;

 switch (event)
 {
  case EVENT_TIMER_TICK:
   tini = Timer ();
   enablingTest();
   DebugPrintf ("%s Inside the switch. Time taken: %.2f\n", TimeStr (), Timer () - tini);
   break;
 }
 DebugPrintf (%s Out of the switch. Event %d\n" TimeStr (), event);
 return 0;
}

 

 



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?
Message 4 of 4
(3,127 Views)