LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Down sample

Solved!
Go to solution

Hi all,

 

I need to down-sample a tdms file from 1MH to 1KH,it seems it is possible with using of "Sample Compression" but the point is the input of this block is a single signal and my tdms file consists of some different channels a beginner I do not know how can I get signals from my tdms file and connect them as inputs to "Sample Compression" block!

I would really appreciate if someone help me with some tips.

 

Many thanks,

Navid

0 Kudos
Message 1 of 10
(3,925 Views)
Solution
Accepted by topic author Navid777

Read your TDMS file using the Open then Read TDMS functions.  Here you can specify the offset and length of the read.  You can then put this in a while loop getting 1000 samples at a time, stopping when there is an end of file error, or your read returns less then 1000 samples.  Take these 1000 samples, and get the mean of them.  Then write this single data point to the TDMS file as a new group.  Then close the TDMS file after all 1000 chunks have been processed.  Then you will have one file with the raw data in the existing group, and the decimated data in the new.  You can also choose to save them as a new TDMS file but I find it convient to do it this way since it would all be in one file.

Message 2 of 10
(3,917 Views)

Hi Hooovahh,

 

Firstly many thanks for your answer,my new TDMS file is kind of DAQ! And it has some difference compare to regular TDMS file,I just wanted to ask is there any way to down sample the content of these files without making loop?

 

Best,

Navid

 

 

0 Kudos
Message 3 of 10
(3,853 Views)

@Navid777 wrote:

 

Firstly many thanks for your answer,my new TDMS file is kind of DAQ! And it has some difference compare to regular TDMS file,I just wanted to ask is there any way to down sample the content of these files without making loop?

 


No you must make a loop to iterate over data.  Don't be afraid of loops, loops are your friend.

0 Kudos
Message 4 of 10
(3,839 Views)

ya it seems we have to be friend,and with your link it's gonna be easier.

 

Thanks,

0 Kudos
Message 5 of 10
(3,836 Views)

Hi Hooovahh,

 

could you do a favor please and tell me how can I get the number of samples from Read TDMS function,I need to check whether the number of samples is bigger than 1000 or not for loop condition.The data output of my Read TDMS function is waveform,should I change the form for getting the number of samples?

 

Many thanks for your helps,

Navid

0 Kudos
Message 6 of 10
(3,805 Views)

Glad to hear you are making progress.  If you want to know the number of data points in a Channel, in a Group use the Get Properties function.

 

TDMS Get Properties, with the Group, and Channel you want to read, then read the property Length (string constant).  It will return a number which records the number of data points you would get if you selected to read all data points (when count is -1).

0 Kudos
Message 7 of 10
(3,791 Views)

I truly appreciate you for being supportive,

 

I have one more question and hopefully it would be the last one!:)

at the first iteration I read the first 1,000,000 samples of each channel and down sample them to 1000 samples,but at the next iteration I need to read the second 1,000,000 samples of each channel and down sample them.my question is that,how can I increase the offset in each iteration?

The VI has been attached,maybe it could help to be more understandable.

 

Thanks,

Navid

0 Kudos
Message 8 of 10
(3,768 Views)

You may not have noticed but there is actually an "Offset" terminal in the read function and by default it is set to 0.  Set it to (1000000*i) where i is the iteration terminal (in the lower left corner of the while loop).  i starts at 0 and increases by 1 each loop, so the first time the offset will be (1000000*0)=0 the next time it will be (1000000*1)=1000000

0 Kudos
Message 9 of 10
(3,752 Views)

Dear Hooovahh,

 

Many thanks for all your tips.

The problem solved.

 

Best,

Navid

0 Kudos
Message 10 of 10
(3,746 Views)