11-10-2008 04:42 PM
I have a Labview generated tdms data file that has the computer clock time stamp written to the file as a string. When I add this tdms file to the data portal in DIadem it imports this time channel as a string, and I cant plot this as x-axis data. I would like to easily import this time string from the tdms file as a time channel. Is this possible?
The work around I have found is to import the tdms file into excel, and then to save as an excel file. I can then import this channel from the excel file using the Excel import wizard and specifying that the time stamp column is a time channel. Surely, there must be a better way.
thanks.
Solved! Go to Solution.
11-11-2008 07:55 AM - edited 11-11-2008 07:56 AM
Hi,
I wrote a little script to convert a string to timeformat and then add the data to a new channel:
dim T
T = "11/11/2008 15:30:22" 'Example date
T = ttr(T, "#dd/mm/yyyy hh:nn:ss" ) 'Convert string into Timeformat
call MsgBox(T)
Call ChnAlloc("Time",1024,1,DataTypeFloat64,"Time",4,4) 'Create Timechannel
CL("Time" )= 1 'Set ChnLength
Chdx(1,1)=T 'Set single Value
If you have a lot of values you can just loop over them. This will do it!
Salud, Mona
11-11-2008 09:19 AM
Hi PRinOR,
If you want to send DateTime information from LabVIEW to TDMS and then to DIAdem, I would strongly recommend changing your LabVIEW program to write a brown datetime array wire to the TDMS Write.vi, either instead of or in addition to the datetime string array that you are currently writing.
Still, we can convert the datetime string channel in DIAdem into a new datetime channel, as suggested by the other poster. I would recommend, however, that you do so with a VBScript that uses tthe Channel Calculator instead of a tight VBScript loop over every value. If you will post one of these TDMS file, I will be happy to provide you with such a VBScript.
What version of DIAdem are you using? The Channel Calculator first became able to handle string channels in DIAdem 10.1.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
11-11-2008 12:59 PM
Brad,
I have DIAdem version 11. I am new to the program and havent used scripts yet, so I'm not sure what you mean by scripts using the "Channel Calculator instead of a tight VBScript loop".
I didn't write the labview program that is writing the string, and don't have access to the code. I may be able to have them change it to the brown time stamp though. The only issue would be how this channel would open for others in the group who are using Excel. Do you know if opening a brown time stamp in excel displays the date and time as it does now or would it show a large number representing seconds after 1900?
The other option I suppose is to add the time stamp string conversion to the VI I am using to concacenate multiple tdms files. This is also the first time I have dealt with a tdms file-and it does seem more complicated to manipulate the data in a VI compared to say a lvm file.
Here is one tdms segment. The time stamp is in each of the four channel groups.
thanks
11-12-2008 09:34 AM
Hi PRinOR,
Here is a VBScript that converts each "Time Stamp" text channel in the Data Portal into a "Time Stamp" datetime channel. You can run this VBScript manually each time you load one of these TDMS files into the Data Portal, or we could set it up to run automatically on your computer as a custom NAVIGATOR load event.
If you convince the LV programmer to include a brown datetime wire write to the TDMS file, then that new data channel will show up as a column of correctly recognized datetime values in Excel, though the display in Excel will be different than the datetime string in your TDMS file because Excel does not have that format as a default display type (I believe it's possible with a custom Excel datetime display type).
Brad Turpin
DIAdem Product Support Engineer
National Instruments
11-12-2008 05:29 PM
Brad,
Thanks for the script, it worked perfectly the first time. It also appears to be independent of the number of channels or groups in the tdms file. Well done.
For anyone that also encounters this problem and wants to use the script it looks like you might have to modify two things: the name of the time channel string, and the format of the string. In my file this was "time stamp" and "#yyyy-mm-dd hh:nn:ss.ffff" respectively. Brad, please correct me if I'm wrong.
thanks again.
11-10-2009 08:51 AM
11-11-2009 05:33 PM
Hi chandler,
Are you using two different TDMS Write.vi calls, one for the datetime wire and another for the DBL wire? Are you wiring an array of values or just a scalar constant? You need to wire a 1D or 2D array of all the same data type to the TDMS Write.vi. Feel free to post a screenshot of you problematic VI or just the non-working vi for our review.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
11-12-2009 09:49 AM
Thanks Brad,
I just figured it out. I used another write command and converted the timestamp into an array
03-09-2011 11:31 AM