LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

time stamp dropping seconds

Solved!
Go to solution

I figure someone has had this problem before but didn't see it in the forum anywhere.  I'm adding a time stamp to a file so I've used the "Get Time/Date in Seconds" and wired that to a "Convert to DBL".  This then wires both into an indicator on the Front Panel and into the "Write to Measurement File" Express VI.

 

The indicator displays the time stamp just fine but in the file it puts it into scientific notation and cuts off the last 4 digits as well as any fractional seconds.  The time stamp writes to the file every 5 seconds so it is important to have the rest of the time stamp included.  I've tried using probes on the wires to see where things go weird but I get the same truncated value in the wire before and after the indicator.  I thought it had something to do with the Express VI first since the indicator is fine but with it truncated in the wire it seems that the Express VI is indeed saving exactly what is handed to it...but then again the indicator...you can see I've been running in circles over this!  Does anybody know the reason it is doing this and a possible solution?

 

Thanks a lot!

0 Kudos
Message 1 of 16
(3,316 Views)

Can you post your code?

0 Kudos
Message 2 of 16
(3,312 Views)

I can't post the exact code because it is being developed for use outside our lab but I've recreated the basics of the problem.  The array would be the collected data and except some filename details and things like that everything relevant to the time and saving is included.  Also settings in the express VI are the same.  Not sure if it will help out.

0 Kudos
Message 3 of 16
(3,305 Views)

Right click on the numeric display and select Display Format.  Set the number of significant digits to 10.  You will see the rest of the number.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 16
(3,292 Views)

Right sorry, in making the example I forgot to do that.  The problem I'm having is that it displays fine...but it saves the scientific notation into the file which cuts off the last 4 digits and everthing after the decimal.  Not sure how to make it save correctly.

0 Kudos
Message 5 of 16
(3,287 Views)

What you are seeing is a behavior of the TDMS Write functions. The only way to fix it is to not use them, and use, for example the Write to Spreadsheet File VI.

0 Kudos
Message 6 of 16
(3,281 Views)

What you should probably be doing is modifying the dynamic data to include the timestamp instead of adding another column. I would avoid dynamic data at all costs but you can convert your 2D DBL to 1D Waveforms with the Build Waveform function. Place this in a for loop to add the t0 and dt. The 1D waveform array can be wired directly to the file write. Trying to make the Write to Measurement File (or any Express VI) adapt to your custom data is usually a mistake. There is just no way that an Express VI can adapt to an infinite number of datatypes. Better to adapt to the data that it was designed for.

0 Kudos
Message 7 of 16
(3,278 Views)

Its situations like this that makes Express VIs undesirable.  I understand why NI created express VIs, a great selling tool in that you can create a data collection program very quickly.  But the user gets blind sided by using Express VIs, and does not learn real programming.  My advice is to avoid Express VIs and write the code yourself.  The only Express VI I ever use is the Elapsed Time vi.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 16
(3,263 Views)

Hi Dennis,

 

Not sure I see what you mean when you say "place this in a for loop to add the t0 and dt".  Are you saying the for loop will automatically add these somehow?  The 2-D array is a collection of 5 seconds worth of data while the time stamp (as it is now) is the time at the start of the collection time.  So should I be using the time stamp as the t0 and using the sampling rate to find the dt?  This seems to make sense to me but I'm sure if I'm misunderstanding.

0 Kudos
Message 9 of 16
(3,262 Views)

I agree.  I don't really like the Express VI's but I'm picking this project up halfway and they are imbedding throughout the program.  We are doing some relatively complicated things at save time so I've been hesitant to remove them.  Thought I think I've almost gotten it to the point that I could be taken out.

0 Kudos
Message 10 of 16
(3,260 Views)