LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I create a time stamp of 2ms or 1ms resolution in a text file

I have trouble creating time stamps in text files that have 2ms resolution. Although my timed loop in LV 7.1 is running the code at 500 Hz without any late iterations, and I record all the data points in the data file, the time stamps are the same in ms range for 5 consecutive points, i.e 10ms resolution. I would like the time stamps to have a 2ms resolution, where each data points every 2ms should show a different milisecond time stamp.
I am trying to do this to be able to show exact 2ms-time stamps for each data sample from 1 digital input line sampled at 500 Hz using NI-DAQmx 7.2. So far I have been using "Get/Date Time in Seconds" and "Format Date/Time String" to display the time stamp in the milis
econd range.
0 Kudos
Message 1 of 3
(2,799 Views)
Use the Tick Count (ms) function. Call Get Date/Time in Seconds when you start to get time of day. Also call the Tick Count (ms). After acquiring each point call Tick Count (ms) again and subtract from the starting tick count. Then add this to the starting Time in Seconds value (with appropriate scaling). The result is your timestamp.

Another approach: If you are using hardware timing for the 500 Hz acquisition, each sample is automatically 2 ms after the previous one. Record the start time and add 2 ms for each sample.

Lynn
Message 2 of 3
(2,799 Views)
Yes, I am using hardware timing. Actually, I am using the counter clock as the timing source for my Timed Loop to make sure I get as close to real-time as I can. I also have a fast computer, and so far I haven't had any late iterations of the loop. I think this second approach is probably the best since I know the starting time, and I can add 2ms for each sample. Thank you.
0 Kudos
Message 3 of 3
(2,799 Views)