LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetLocalTime vs gettimeofday

Hi all:

 

I am using CVI to save the data of some sensors with time stamp, for this I am using the GetLocalTime Function. The problem of this function is that a very fast acquisitions speed the time stamp look like this:

 

Hour Minute Second Millisecond

 10      10          00          000

 10      10          00          000

 10      10          00          000

 10      10          00          015

 10      10          00          015

 10      10          00          015

 

The get local time resolution is not very good. I read that gettimeofday is better for printing the time stamp in milliseconds but LabWindows cvi doesn't use sys/time.h. Any Idea of how to add sys/time.h or do you know of a more precise function than the GetLocalTime?

Thanks

Francisco

Francisco J. Sanchez, Ph.D., MCIC
0 Kudos
Message 1 of 3
(4,599 Views)

Hi FJSanchez,

 

You can use functions defined in external libraries within CVI by including the header files and the link libraries (LIBs) in your CVI project.  This link has some info on which ones you will need for the Windows GetSystemTime function.  Since CVI defines its own version of GetSystemTime, follow the directions in this article to successfully call the Windows version of the function.

Justin D
Applications Engineer
National Instruments
http://www.ni.com/support/
0 Kudos
Message 2 of 3
(4,588 Views)

One thing to consider is whether you want absolute time or relative time.  If you think you are obtaining absolute time withing an interrupt handler with which to time-tag a data record going to disk, as an example, you need to consider that there is jitter due to operating system latency.  You might want 1 millisecond accuracy, but jitter will give you some record to record skew, that might be observed as a small number of milliseconds difference, record to record.

 

If you are doing a short data capture, consider tagging your records either with an incrementing count, or get the start time and add a number representing your time interval to each recrod time stamp.  I your sample timing is accurate, FIFO filling is accurate, and FIFO buffer interrupts are not lost, this method will produce very good time stamps without the jitter.

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