LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Read back elapsed timer value

I use a timer in LabWindows to check the communication between hardware and PC. I send a GET_STATUS command to the hardware. When doing so I enable the timer. If the hardware couldn't respond between the specified timer intervall, the callback function of the timer generates an error message. If an ACK is returned by the hardware, before the timer intervall has been reached, I want to check how much time has been elapsed from enabling the time till receiving the ACK.
0 Kudos
Message 1 of 2
(2,623 Views)
Hello

It might be better to use the async timer for this rather than the UI timer. The UI timer runs in the same thread as the the UI so if there is alot of stuff happening in that one thread, you might start skipping timer events. It would be better to use the async timer, which also provides timer functionality, but runs in another thread. Depends on what you need.
Having said that, check out the "Programming with Timer Controls" section in the CVI help. The UI timer event callback provides you with parameters that give you data like timer elapsed since the last timer callback and the current time.
Or if you want to check out the async timer, you can go to ..\cvi\samples\toolbox\asyncdem.cws.
This is what the documentation states for the callback of the
async timer.

int CVICALLBACK FunctionName(int reserved, int timerId, int event, void *callbackData, int eventData1, int eventData2);

The first parameter of the event function is reserved. timerId is the timer that caused the callback. The types of events generated are EVENT_TIMER_TICK and EVENT_DISCARD. eventData1 is a pointer to a double that represents the current time in seconds and is relative to the start of the first timer event. eventData2 is a pointer to a double that represents the time that has elapsed since the last call to the timer callback. The elapsed time is set to zero if the callback has not been called previously. Callback data defined by the user also is passed to the event function.



i hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 2
(2,623 Views)