LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting Graph in Excel with Asynchronous Timestamps

Hi,
I'm reading from an instrument t over ethernet to log data around every hour (though this time can change). The data I get from the instrument is a single double, I assign this a timestamp from the machine that reads it (I know this isn't perfect but timing within a minute is fine for this application).


To plot the data in labview  I build an array of clusters of the data timestamp and value and show this on an XY graph.

 

I wish to save this graph in excel but I'm struggling to show the time in a readable format -  when I plot the graph in excel the time reads in exact values rather than as a date formatted number, so it shows a value of around 42,000 rather than todays date. I can save the XY graph but this isnt really what I want as it doesn't look very good.

I've hopefully attached a VI that indicates my problem,

Kind Regards,

Joe

0 Kudos
Message 1 of 3
(4,448 Views)

You are running into the differences between the way LabVIEW and Excel express time.  For both, time is a number.  For Excel, it is the number of days since 1 Jan 1900, while LabVIEW save seconds since 1 Jan 1904.

 

I have a few suggestions.  First, in LabVIEW, I would create the XY data type as a cluster of TimeStamp and Dbl (that is, I wouldn't convert the LabVIEW Time to a Float).  This makes the LabVIEW XY graph show "natural" coordinates (once you change the format of the X Axis to Absolute Time).  For Excel, think about what data you really want.  I'd think that you would want "Elapsed Time" as the X Axis, with the first point having the value 0, with a possible entry for the Starting Time.  

 

Suppose you have an array of Time/Value points in LabVIEW.  To get Starting Time, this is simply the Time component of the first point in the Array.  Next, convert the Array to Delta-Time/Value by subtracting TimeZero from the Time component of the data.  Now you need to remember that the LabVIEW values will be in seconds -- if your points are taken once per hour, these values (being sent to Excel) will be 0, 3600, 7200, ... .  You should consider if you want to send Excel time points in seconds, in minutes, or hours -- you can convert in LabVIEW, or wait and convert in Excel (it's your choice).

 

So I'd create my Excel sheet with three columns (or three rows -- your choice).  The first would be Starting Time.  To avoid the Excel/LabVIEW conversion issue, change the LabVIEW time to a String Representation using Get Date/Time String (put Starting Time as the input, and create the output format that you want for Excel).  Write a single text cell with this number.  Take your array, rearranged for Excel as an cluster of two Dbls, and write these as a Table, which you'll also use to build your Excel Graph.

 

Bob Schor

0 Kudos
Message 2 of 3
(4,304 Views)

Hi, sorry for the slow reply - I've been without a proper internet connection for a while.


I had already thought of the time difference - it's fairly easy to solve by dividing by the number of seconds in a year and then taking off the number of days difference.

 

Unfortunatley your soludtions won't work due to the actual process being asynchronous - the readings can be up to a few minutes off per hour.

 

I've managed to solve my problem a dufferent way, if i convert labview time into a string and label the columns with the array of string timestamps this works perfectly.

 

 

Thanks for your help,

Kind Regards,
Joe

 

Edit - I've somehow logged onto this old account that I have on an old computer.

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