From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Import time channel into DIadem from a tdms file

Solved!
Go to solution

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.

0 Kudos
Message 1 of 23
(8,126 Views)

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

Message Edited by RMathews on 11-11-2008 02:56 PM
Ramona Lombardo
Applications Engineer, NI Germany
Certified LabVIEW Developer
Message 2 of 23
(8,112 Views)

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

 

 

0 Kudos
Message 3 of 23
(8,107 Views)

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

 

0 Kudos
Message 4 of 23
(8,093 Views)
Solution
Accepted by topic author PRinOR

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

 

Message 5 of 23
(8,071 Views)

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.

 

0 Kudos
Message 6 of 23
(8,053 Views)
I am having the same issue and I want to use the brown datetime wire but I can't seem to get the write tdms vi to accept the timestamp wire. I would like the timestamp and my 1D double array of data to be written to the tdms file
0 Kudos
Message 7 of 23
(7,131 Views)

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

Message 8 of 23
(7,112 Views)

Thanks Brad,

I just figured it out. I used another write command and converted the timestamp into an array

 

 

0 Kudos
Message 9 of 23
(7,104 Views)

 

Hello Brad,
it's the first time that i post something on this forum but anyway I've red a lot of different thread about DIADEM and how to save time channels and now i'm dealing with it.
Following your suggestion i'm able to write a TDMS file with a timestamp channel and an array of 5 DBL and i can also load this file into DIADEM data portal correctly, but now i noticed that using two different TDMS Write.vi calls the file size is very big and also the index file is very big.
Example:
A file with 6 channels(1timestamp + 5 DBL) and 86400 rows is 25.5 MB with the index file of 20.9MB
Instead a file with an array of 6DBL with only one TDMS Write.vi call is only 3.95MB and the index file is 1KB.
The problem is that in my real application I will have 20 channels and about 1 million rows, so it will be a huge file.
Thanks

 

0 Kudos
Message 10 of 23
(5,707 Views)