LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert date and time into write to spreadsheet

Solved!
Go to solution

Easy question here

 

I need save 4 arrays of data and insert the date and time that it was taken (LV 8.6)

 

 

for example

 

 

9/4/09 10:00:01 AM  4  6  7  2

9/4/09 10:00:02 AM  4  6  7  2

9/4/09 10:00:03 AM  4  6  7  2

9/4/09 10:00:04 AM  4  6  7  2

 

Any ideas, I can't wire the timestamp or date/time string right into the create array

 

 

Thanks

Chris

0 Kudos
Message 1 of 19
(11,149 Views)

Just a heads up, my data are arrays of DBL

0 Kudos
Message 2 of 19
(11,144 Views)

Use the "array to speadsheet string" VI to convert the numerics to stirngs then put your time stamps and headers where you need them.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 19
(11,142 Views)

Thanks Ben

 

How can I save the file then, the write to spreadsheet will not accept the string?

 

Chris

0 Kudos
Message 4 of 19
(11,134 Views)

The "write to Spreadsheet.vi" in modern version of LV is polymorphic meaning, it will adapt to the dat type you pass to it. I just checked and it will accept a 2d array of strings.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 19
(11,122 Views)

Ben

 

I can get it all wired together, the only problem is that the file does not save in the correct order, I am sure that it is an easy fix, I just don't know how to do it.  I have attached screenshots of both the text file and my block diagram.

 

 

Thanks

Chris

Download All
0 Kudos
Message 6 of 19
(11,093 Views)

All of those shift registers and the creation of 1D Arrays and then the conversion to a 2D array is just a waste. Don't do that. Since you have single elements from the DAQ Assistant and a single date/time, just use a Build Array with all of the scalars as inputs and pass it to the 1D input of Write to Spreadsheet.

 

Since you did not post the actual VI, you'll have to make the modifications yourself.

Message 7 of 19
(11,084 Views)

Dennis

 

I think I may have been unclear in my intentions, I want to continuously be logging data to a single file.  This file would have the first column, date, then time, then four columns of data.  The VI that I wrote here stores all that I am looking for, but does not put them where they need to be (see the text file jpeg).  I need the columns to consist of the following, rather than a line of date, line of time, and four rows of columns.

 

Date   Time   Channel 1   Channel 2   Channel 3   Channel 4

 

Thanks

Chris

0 Kudos
Message 8 of 19
(11,071 Views)

Ok

the basic problem that I see is the the LabVIEW TimeStamp type is a cluster.  Converting it to a dbl gives you a value in seconds elapsed since 1904 Jan 1 12:00AM GMT and, your spreadsheet cannot interprate that (or display that) as a "TIME."   So, you want to convert it to a string (easy TS->String check the help for format options) BUT, you might want to pass all of your data as numbers into your spreadsheet so you can post-calculate or graph other outputs vs. TIME!  This little chunk of code .....

 

Time to XL.PNG
 
 

 converts a LV Timestamp to a number that Excel interperates as "the amount of days elapsed since 0 Jan 1900 @ 12:00AM LOCAL."  You will need to format the cell in Excel to display it as a date-time But it can be operated on and graphed against with only Excel's limitations (Excel followed the Lotus bug of erroneously assuming 1900 was a leap year, and Leap seconds are unrecognized)

 

Enjoy!

Message Edited by Jeff Bohrer on 08-06-2009 02:28 PM

"Should be" isn't "Is" -Jay
Message 9 of 19
(11,057 Views)
Solution
Accepted by topic author ctolson

Anyone out there trying to do the same thing I am, I got it to work with the attached VI.

Message 10 of 19
(11,048 Views)