03-12-2010 02:33 PM
This seems like it should be rather simple, but I'm having a tough time figuring out a solution....
I'd like to be able to have 2 timers on my user interface. One timer will display the total time since the application was started, and the second timer will show the total time that a device is enabled (device will be enabled and disabled numerous times). Determining the total time since the application was started is a simple task:
startTime = Timer();
CVICALLBACK tlmTimerCallback() {
totalTime = Timer() - startTime; // Elapse time (mS)
}
However, I'm having a difficult time figuring out how to get a new start time when the device is re-enabled so that I can then add the new elapsed enable time to the previous enable time. Millisecond accuracy is nice, but 1 second accuracy would be fine too.
Any help would greatly appreciated.
THANKS!!
Solved! Go to Solution.
03-12-2010 07:02 PM
I made a small application with CVI 8.5.1 for this purpose.
Please check the attached project and see if it answers your question.
03-12-2010 08:24 PM
Thanks for the example. Unfotunately, it doesn't seem to want to run on my computer. When I try to build the project, I get link errors (undefined symbol, one each for NewAsyncTimer, DiscardAsyncTimer, and SetAsyncTimerAttribute). I'm running LabWindows/CVI 8.1 (base package). At first I got an error when opening the uir file as well, but I saved it as an 8.1 file, and that seemed to help. The asynchronous timer help files as well as asynctmr.h seem to be a part of my CVI install, so it appears that the functions should be supported by 8.1. I'm not sure how the solve the error though.
I'm hoping I can get this running. After seeing them mentioned a number of times, I still am not overly clear on what the advantage of asynchronous timers are. This will be a good example to get a little experience using them.
03-12-2010 09:29 PM
03-15-2010 09:03 AM
Thanks ebalci! I integrated parts of your example into my project over the weekend, and it works great. I have another project that I'm working on that sends commands and recieves telemetry to a number of devices (8 to 10) via TCPIP. The user interface tends to be slow while all the TCPIP connections are being maintained. I think the Asychronous timers might help with that project as well. That leads to some other questions, but I'll save those for another post after I do some more reading on the subject. Looks like there are some good articles in the NI Developer Zone.
Thanks again!
03-15-2010 01:45 PM
You are welcome..
I'm glad it helped you figure things out a little.
Take care,