LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

way to determine time a device in enabled?

Solved!
Go to solution

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!!

0 Kudos
Message 1 of 6
(3,465 Views)
Solution
Accepted by topic author byrd01

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. 

S. Eren BALCI
IMESTEK
Message 2 of 6
(3,453 Views)

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.

0 Kudos
Message 3 of 6
(3,449 Views)
I solved my link problems.  I had to add the asynctmr.fp instrument driver to the project.  Now it runs, and seems to work fine with my newly created (8.1) uir file.  Thanks again.  I'll go take a look at the example now and let you know how it works out.
0 Kudos
Message 4 of 6
(3,439 Views)

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!

0 Kudos
Message 5 of 6
(3,404 Views)

You are welcome..

 

I'm glad it helped you figure things out a little. 

 

Take care, 

S. Eren BALCI
IMESTEK
0 Kudos
Message 6 of 6
(3,389 Views)