LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing a binary timestamp to a file.

Hello, I am using the "Write to SGL File" VI to save some acquired data to a binary file, for later analysis in LabVIEW. I would also like to save a timestamp with each set of measurements. What is the best way to do this without losing too much precision?

Can I use the "Get Time / Date in Seconds" VI and then convert that to a DBL, and then somehow split that up and write it to a file? It won't let me convert the Time / Date in seconds directly to SGL. Any help would be greatly appreciated! Thanks.
0 Kudos
Message 1 of 2
(3,249 Views)
1... Define your own cluster, consisting of a U32 (or a DBL) for the TimeStamp, and an array of SGL. Create the file as a datalog file, write the cluster to it, and close the file. No need for the high-level stuff. When you want to read it, open the file as a datalog file, read the cluster, close it.

2... Get the current date/time as a DBL. Use the QUOTIENT / REMAINDER function to divide it by 86400.0 (Seconds per day). Convert the two numbers to SGLs, and store them in the SGL array as the 0 and 1 items (or last and next-to-last, whatever). When reading, extract those two SGLs, multiply the quotient by 86400.0 (DBL), and add the remainder. There's your original number.

There's nothing magical about 86400, it's just an easy-to-remember (for me) number
. You could use any other number in the same vicinity (like 100,000) if you'd rather - just use the same number on both ends.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 2
(3,249 Views)