LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get tdms Channel names in matlab

I'm having a similar problem. Although I can get the channel names to work right, I am unable to get DCC_GetFilePropertyNames to work. I have all the libpointers set, I think, but I either get a segmentation fault and Matlab crashes, or it seems to work fine, but no values were output. Here's what I've done:

Once I open the file and get the file handle using the loadTDM.m sample, I create a pointer to a cell array of strings

pstrings = libpointer('stringPtrPtr',{'','','',''});

I have tried it without making the empty strings, but it crashes every time. That there are 4 strings is only because in this instance, there are 4 properties. I can read the number of properties and scale that appropriately.
Then I try to read the names

calllib ('nilibddc','DDC_GetFilePropertyNames', pfile.Value, pstrings, 4);

Supposing it crash, if I then look at pstrings.value, I get
''
''
''
''

Can anyone see what I'm missing? All help is appreciated.
0 Kudos
Message 11 of 47
(3,542 Views)
Dear all,
 
I want to read my tdms files on MATLAB 7.5, (r2007b); when I tried using the script provided on "Reading TDM/TDMS Files with The MathWorks, Inc. MATLAB® Software" page, (Report Date: 05/22/2007,Last Updated: 05/30/2007,Document ID: 49L3K6FN)
 
 
 
running loadTDM (on the provided TDM file, only the examplePath was changed to the current directory), I got the following error:
 
 
>> loadTDM
??? There was an error loading the library "D:\MatLab TDM Example\bin\nilibddc.dll"
Error using ==> loaddefinedlibrary
The specified procedure could not be found.
 
Error in ==> loadTDM at 16
loadlibrary([examplePath '\nilibddc'], hfile);
>>
 
 
Anybody else notice this problem?
 
Any help would be gratefully appreciated!!
 
Thanks dearly,
 
Raphael
0 Kudos
Message 12 of 47
(3,459 Views)
Found to similar problem links - so example path or format of *.m file could be the problem
 
 

"Hi,
Did you ensure that you specified the following correctly?
"You can transfer the example code in the LoadTDM.m to any of your other M-script files. For example, if you copy the TDM dll and the header file into "C:\test\", you must specify the location in your m-script like this:
examplePath = 'C:\test';hfile = [examplePath '\nilibddc_m.h'];loadlibrary([examplePath '\nilibddc'], hfile);

Similar code can be found in lines 14 to 16 in the included m-script, which assumes that the TDM dll and the header file are in the same folder."
Also, which version of MATLAB® are you using? This example may only be used with version 6.5 or later. Are you using Windows XP?
MATLAB® is a registered trademark of The MathWorks, Inc.
 "

 

http://tolstoy.newcastle.edu.au/R/e2/help/07/04/14898.html

 

"Hi,

as already mentioned, do not save MAT files in ASCII format but save to binary formats, i.e. do *not...

     "From Matlab v7, _compressed_ MAT version 5 files are used by
     default [3]. These are not s...

You haven't told use what version of R you are using (neither what version of R.matlab), but from the error message I suspect you are using Matlab v7, correct? If so, try to save with

   save('test.mat', 'matrixM', '-ascii', '-V6')

and tell us if it works.

Cheers

Henrik "

 

 

0 Kudos
Message 13 of 47
(3,401 Views)
Hi!

How can I get the time channel correctly?
At first I added a new case in the case structure (pdatatype.Value=30) as a doublepointer. But this doesn't seem to be correct because the timevector is a aequidistant integer vector after running my script.
Are there any onther possibilities to get the time channel (full time stamp) or at least the sample rate of my tdms-data to build my own time vector?

Thanks a lot

Jens
0 Kudos
Message 14 of 47
(3,385 Views)
Jens,
the time channel is generally specified as float64 (double).
The equidistant vector is bad but useful to correlate the specific number, which is starting at 1, to compute a relative time stamp.
By reading the channel properties "Minimum" and "Maximum" you get two numbers which reflecting the amount of seconds since 01.01.1904.
The below attached syntax is adapted for Matlab, but I don't have tested it yet.
I have simply used the variables of the load_TDM.m file.
Multiplying the scalar variable "RelativeRecTime" with the time vector "pdata.Value" the relative time stamp is computed.

                minvalue = libpointer('doublePtr', 0);
                maxvalue = libpointer('doublePtr', 0);
                calllib('nilibddc', 'DDC_GetChannelProperty', pchannel.Value(chnindex), 'Minimum', minvalue,1);
                calllib('nilibddc', 'DDC_GetChannelProperty', pchannel.Value(chnindex), 'Maximum', maxvalue,1);
               
                disp ('******************');
                disp ('Min Value: ')
                minvalue.Value
                disp ('Max Value: ')
                maxvalue.Value
                disp ('Recording Time in seconds:')
                RelativeRecTime = maxvalue.Value - minvalue.Value
                disp ('******************');

ThSa

0 Kudos
Message 15 of 47
(3,344 Views)
Hey,
 
I also once asked about getting the timestamp of my recording; trying your code I got 0's in both minimum and maximum values. Here's what running the script lines you gave:
 
******************
Min Value:
ans =
     0
Max Value:
ans =
     0
Recording Time in seconds:
RelativeRecTime =
     0
******************
 
 
Thanks!
 
WildCherry
0 Kudos
Message 16 of 47
(3,334 Views)
Odd question but, have you checked the configuration of your time stamp?
Last time I worked with this stuff, I used an example of the NI Example Finder.

..\examples\file\plat-tdms.llb\TDMS - Express write data (time domain).vi

Generally this one is specified to log data in tdms format. By changing the file format you get a tdm output.

Attached please find a screenshot with my settings. Especially take care of "X Value Columns".


If you take another approach saving the timestamp, please post your tdm and tdx file.

Thanks,
ThSa
0 Kudos
Message 17 of 47
(3,328 Views)
ThSa,

thank you for your reply. I got the same result as 'wildcherry'. Both values (Minimum and maximum) are returned as '0'. I tried your labview example but using the file format 'tdms'. It returns '0' too. I think the problem with the time channel is only in tdms-files and not in tdm.
I can get the right number of the channel properties by using DDC_getNumProperties (it returns 5 properties) but the value of the property is always 0. Just to be sure that my measurement file is correct I opened the file with Diadem and it shows the correct channel properties so it has to be a problem with my matlab/ mat-lib.

But there is another point I'm wondering about. If I use my data from the DAQ board the "'DDC_GetDataType" returns  for the time channel  "30" (I added this into the case structure in your tdms-example as doublePtr as you said).
But using the Labview example with a simulated signal the datatype for time channel is returned as "10" (doublePtr). The result when reading it into matlab is the same! The time channel is a equidistant  Vector (int), the min and max value are returned as  0.

Is there another way to get the sampling rate? Something like getting the "dY" attribute in LabView...

Jens

0 Kudos
Message 18 of 47
(3,310 Views)
I just quiet confused why this stuff is not working on your site.
To get the dt of a signal use the express VI "convert from signal data" with the attribute "waveform" and afterwards you can use the function "get waveform components" to extract "dt" from the waveform.
This information can be stored as additional information (property) of one channel.

I've added an example VI, some example TDM files (with 1 time and 2 signal channels) and also the code  which should work in Matlab.



Probably the "if" statement isn't working for Matlab. I can't really remember how the syntax is in case of an M file...



Message Edited by ThSa on 01-24-2008 02:39 PM
0 Kudos
Message 19 of 47
(3,302 Views)

Dear ThSa,

Using your attached tdm files, and vi's, I got the correct time stamp in the minimum and maximum values, as you suggested!

The problem is, that using the same settings (X Value Columns etc.) on saving a _TDMS file_ rather than a TDM file, I get 0 values in both

minvalue and maxvalue on the MATLAB script

Do you have any idea why this occurs? Can you check it on your platform?

I may switch to using to TDM instead of TDMS, is there any advantage to using TDMS rather than TDM? I am recording just one channel at around 1000 Hz for about a 1000 seconds

 

Thanks dearly, WildCherry

0 Kudos
Message 20 of 47
(3,286 Views)