LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

event data from asynchronous timer

Solved!
Go to solution

My application uses an asynchronous timer to read analogue and digital signals which are then loaded to a thread safe queue. The main part of the application unloads the queue, displays values and updates graph plots and also writes data to a file on disc.

The async timer runs every 40 millisecs, various display updates run 5 times a second and data is written to a file every second.

One of the data items is an SSI input of a hoist height, which at this data rate should be increasing at 25mm per second, or 1mm every scan. I get quite a variation in this reading, ranging from 0.3mm to 1.7mm and these large variations seem to occur when the display updates occur or the data file is being written. I thought that by using the async timer I would be immune from Windows update problems, as it runs in a separate thread.

An earlier version used a panel timer in which I was able to use the event data to show that the timer interrupt was indeed being affected by display activity. The async timer event data appears to hold zeroes, whereas the panel timer event data held a version of the current time and the time elapsed since the last timer interrupt. How can I check that the async timer is interrupting at the correct time?

0 Kudos
Message 1 of 4
(4,208 Views)
Solution
Accepted by topic author Humph

Asyncronus timer callback has the exact same structure of UIR timers one, with the only exception of the first parameter, an integer which in the UIR timer callback holds the handle of the panel the timer while it is reserved in the async timer callback. This means that eventData parameters holds the informations on the time elapsed in th eprogram, passed as pointers to double values. To read back these informations you must operate this way:

 

double     totalTime, timeFromLastTimer;

 

totalTime = *(double *)eventData1;      // Time from program start

timeFromLastTimer = *(double *)eventData2;     // Time from last timer callback

 



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 2 of 4
(4,196 Views)
Thanks Roberto, that is the code that I used to get the data for the Panel Timer. I have just re-run the app on my laptop and the elapsed time data is there OK! Must have done something silly on the test rig which made me think that the two timers were different. Sorry for wasting your time.
0 Kudos
Message 3 of 4
(4,183 Views)

Roberto,

 

Thanks for the example on getting valid data from the eventData1 & eventData2 parameters. 

My 'c' is very rusty

 

Thanks

Walleye

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