01-26-2009 10:30 AM
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?
Solved! Go to Solution.
01-26-2009 11:59 PM
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
01-27-2009 05:25 AM
07-08-2010 07:06 PM
Roberto,
Thanks for the example on getting valid data from the eventData1 & eventData2 parameters.
My 'c' is very rusty
Thanks
Walleye