LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timestamp Representation as SGL?

Solved!
Go to solution

Hi all,

 

I am saving binary data during a RT application and want to post-convert it into ascii. I am considering using sgl representation for the saved data to reduce file size. However, using sgl means that the timestamp gets "chopped" (i.e. one gets only up to minutes in time, no secs and millisecs). So, I was wondering if there is anyway to either

 

a) Get the full timestamp information from an sgl number (i.e. using the number to timestamp vi..) 

 

or

 

b) When saving a timestamp, is there any way to skip the date part (unnessecary in my case)? I ask that assuming that if I could skip the date part then an sgl representation would be enough to give me up to milliseconds..

 

Thanks for your time,

Harry

0 Kudos
Message 1 of 4
(3,198 Views)
Solution
Accepted by topic author charmand79

A timestamp uses 64 bits to hold the number of seconds since 1,1,1904 and another 64 bits to hold the fraction of the current second. You can't get anywhere near that with the 32 bits that SGL gives you and you can't "skip" the date, because it's an integral part of the number.

 

One thing you can do is create a new epoch instead of 1904, but if you take 10 bits to get the ms resoution, that would leave you with 22 bits for the seconds, which isn't very long.

 

What you can do is this:

 

  1. Take the timestamp and tick count value at a certain point in time before you start (t0).
  2. Have a VI which will give you the running ms value by subtracting the t0 tick count from the current tick count.
  3. Save the t0 timestamp in a header in your file.
  4. Save the actual time as the time you get in step 2 (which is a 32 bit integer). 
  5. When you want to calculate the actual timestamp, simply do t0 (from the header)+counter.

This should be good for roughly 50 days of measurements, after which the tick count rolls over.

 

There are probably also existing formats where you configure this, but I have no experience with that.


___________________
Try to take over the world!
0 Kudos
Message 2 of 4
(3,184 Views)

Hi,

 

SGL only contains a 23 bit matissa, so you will only have 13 bits for the seconds part, when using 10 bits for milliseconds. That will leave you with ~8000s or 2.3h...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 4
(3,178 Views)

Thanks tst,

 

nice trick there. I am sure it will give me what I want, and obviously 50 days of measurements is certainly enough...!!!

 

Cheers,

Harry

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