LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

chronometer

Hello,

I work on CVI8.1 and I have a question. How can I show the time elapsed on a "edit numeric" control on my panel.
I make an AI acquisition and when I start this acquisition, I'd like that time of acquisition start too.

Have you some examples?

Thanks

Julien
0 Kudos
Message 1 of 7
(3,948 Views)
There can be at least 2 ways of accomplish this task: the first one is to use a timer that fires say 2 times per seconds and accumulates eventData2 parameter (seconds from last timer call) showing it on the numeric indicator.
 
Assuming an external variable holds the elapsed time, you could put this variable to 0 before acquisition starts, next start your acquisition and enable the timer. Inside the timer callback put someting like this:
 elapsedTime += *(double *)eventData2;
 SetCtrlVal (panelHandle, PANEL_CHRONO, tn);
Another way is to intercept your acquisition process results and calculate the elapsed time: taking as an example ContAcq-IntClk example (samples\daqmx\analog in\measure voltage folder) in the acquisition loop you could use "Samples per channel read" value returned from DAQmxReadAnalogF64 to calculate the elapsed time based on samples-per-seconds acquisition rate.


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 7
(3,941 Views)
Thanks a lot! 🙂
I tryed your timer solution and it works !

Julien
0 Kudos
Message 3 of 7
(3,933 Views)

For a more precise timer you can use the asynchronous timer library, asynctmr.fp in toolslib\toolbox folder.

While the Timer control placed on the UIR can be affected from mouse events like drag&drop the async timer is immune to most of such problems and it will give you a smoother chronometer count. In this case you specify a function for the timer to call at each interval and this function has similar parameters like time passed so you can still use Roberto's piece of code.

You can have a look at the sample projects for detail.

S. Eren BALCI
IMESTEK
Message 4 of 7
(3,915 Views)
Thanks for precision! I'll see on this way.
0 Kudos
Message 5 of 7
(3,889 Views)
> For a more precise timer you can use the asynchronous timer library,
> asynctmr.fp in

I've used it in the past on Windows, but does anyone know if this works on
Linux ?
--
Guillaume Dargaud
http://www.gdargaud.net/



0 Kudos
Message 6 of 7
(3,887 Views)
Hi Guillaume, it was my opinion that asyncronous timers were too strictly related to Windows to be ported to Linux, but according to AlexD response in this thread you can use it without problems.


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?
0 Kudos
Message 7 of 7
(3,875 Views)