NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
FJSanchez
Posts: 2
0 Kudos

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

Member
JD_war_eagle
Posts: 126
0 Kudos

Re: GetLocalTime vs gettimeofday

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/
Member
hendra@ngms
Posts: 191
0 Kudos

Re: GetLocalTime vs gettimeofday

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.

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page