LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to data file with timestamp

Solved!
Go to solution

Hi all,

 

I'm trying to write data to a spreadsheet with column headers and a timestamp column without using Write to Measurement File.vi  I am able to do all of this, except label the column headers with the WMF express .vi, the problem i have with express anything is that you really don't know how any of it works.

 

Do any of you have an example or example code you could share?  I basically have (4) AI channels of data to save with a timestamp.

0 Kudos
Message 1 of 7
(3,941 Views)

In general here is what I do, instead of using any of the "prefab" vi's I use the low level file vi's that pass a REFERENCE once you open the file instead of a file path. This has the advantage of automatically locking the file so if you try to open it while LabVIEW has it locked it will inform you and give you the option to open a copy or open the file read only. This prevents your LabVIEW program from crashing with a sharing violation because you have the file open in another program when LabVIEW tried to write to it.

 

Your column headers have to be applied separately since they are text and your measurements are numerics. I usually write the headers at the same time I open the file.

OpenCapture.PNG

 

Then when I write my numeric data to the file I use this handy VI I created a long time ago that puts a time stamp on the data and writes it to the file.

 

WriteWithTimestamp.png
This VI will generate it's own timestamp if you do not wire one into it.

Don't forget to close the file reference when you exit your program

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 7
(3,913 Views)

Oh, great, another Timestamp Definition!  OLE, LabVIEW, Excel.  No wonder Timestamps are such a Pain Where You Sit.  Sigh.

 

Bob Schor

0 Kudos
Message 3 of 7
(3,881 Views)

@Bob_Schor wrote:

Oh, great, another Timestamp Definition!  OLE, LabVIEW, Excel.  No wonder Timestamps are such a Pain Where You Sit.  Sigh.

 

Bob Schor


I found that definition here after all...

 

Anyway modern versions of Excel may not need this, but I have found it very handy anyway as in cases where you have irregular data intervals or gaps in the data. It is easy to do the math on the timestamps to get elapsed time,

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 7
(3,860 Views)

i've been investigating this further and found that TDMS file generation is pretty easy, there is really only one function that the Save to measruement file express vi does that i haven't figured out yet and that is how to assign the timestamp to a column in the tdms file.  It's there i can see it from the probe, i have both time and dt, which i'd like to be columns (1) and (2) in the final file.

 

I tried just adding another instance of the TDMS write, see below, unortunately this creates a second sheet in the file with the timestamps.  I think i'm close i just need a bit of help to get it the rest of the way.

0 Kudos
Message 5 of 7
(3,837 Views)

Back on this topic...  Anyone at all have a solution to get the timestamp data with the measurement data in a single spreadsheet for TDMS?

 

What i'm doing now is peeling the timestamp from the 1D waveform from DAQmx read and putting it in a separate write to TDMS, which works in terms of capturing it but it shows up in a separate spreadsheet.  How can i place it in the spreadsheet with the measured data?

0 Kudos
Message 6 of 7
(3,738 Views)
Solution
Accepted by topic author coolhandLV7

@coolhandLV7 wrote:

What i'm doing now is peeling the timestamp from the 1D waveform from DAQmx read and putting it in a separate write to TDMS, which works in terms of capturing it but it shows up in a separate spreadsheet.  How can i place it in the spreadsheet with the measured data?


Make sure you are writing to the same group as your data.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 7
(3,732 Views)