LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing multiple tdms file channels with different data types using TDMS Advanced Asynchronous Write priodically and Overwriting the same file.

Hello Experts,

 

I am facing two problems:

1. Writing data to multiple channels of the same group of a tdms file with different data types. I have cluster of arrays generated periodically of four data types to be stored in a TDMS file viz. TimeStamp, Boolean, Double, Integer. When I try to configure each channel for every data type serially and then writing the data to it similarly (serially), I don't get any error but along with the raw data I am passing some abrupt values are also added to each channel every iteration. Configuration is done onlyduring the first iteration.

2. After certain no of writes I am overwriting that file using the function Set next write Position and I am not able to achieve it when I am trying to reset the position counter of multiple channels with different data types. I expected that, calling the function name mentioned above once with the first channel name as the input will automatically reset position of other channels also but their position is not reset. 

 

Therefore, Can any expert Please give me the example for writing to a tdms file asynchronously to multiple tdms file channels with different data types and overwriting the same?

 

 

Thank You !!!

0 Kudos
Message 1 of 5
(5,687 Views)

Hi,

 

Since you want to write your file with Advanced Asynchronous Write, you must be carful that the data size for each channel should be multiple of sector size(usually 512 bytes). And for this reason, if the overwriting size is not multiple of sector size, then we should use Advanced Synchronous Write for overwriting.

 

Please see the attachment VI for example.

 

- Tianbin

Message 2 of 5
(5,651 Views)

Thank You very much for your reply....I will try your solution and suggestions and let you know....I will mark it as solution soon if I get my answer....!!!

Thanks once agin....!!! 

0 Kudos
Message 3 of 5
(5,641 Views)

Hello Tianbin,

         Thank You very much, I had exactly the similar design but i had set the 'disable buffering' to False and I was making mistakes in assigning no of samples per channel. Now, to get rid of multiple of sector size data writing, I am using TDMS Synchronous write. When I am writing a constant data to the file periodically, it writes the data correctly and even the overwriting is executed successfully (even when I have 'disable buffering' as False) but, when I provide variable data, The file shows me some abrupt values along with the actual data i am providing. Can you please analyse this issue?

Thank You !!!

0 Kudos
Message 4 of 5
(5,619 Views)

Hi,

 

I think the problem is not in writing constant data/variable data, the root cause of your problem is in the overwriting part of the VI. We should be very careful when using the TDMS Set Next Write Position function, and user should know clearly about how the logged data are stored in the TDMS file. Otherwise, incorrect use of the Set Next Write Position might result in corrupted files as you have encountered.

 

For example, if you write four channels, in each loop you write 100 samples to each of the channels(e.g, channel1, channel2, channel3 and channel4) sequentially, and the loop executes 10 times. The 1000 samples of each channel are stored in 10 data blocks separately, with each block contains 100 samples. And the Set Next Write Position + Advanced Sync Write are not "smart" enough to handle this in once overwriting operation, user need some extra efforts to achieve this.

 

If you want to overwrite 100 samples(e.g, start from 50th to 149th samples) of channel3, since the samples #0 to #99 are in the first data block and the samples #100 to #199 are in the second data block, so the overwriting operation has to be completed within two Set Next Write Position + Advanced Sync Write calls. First, Set Next Write Position to offset #50, overwrite 50 samples; then Set Next Write Position to offset #100, overwite 50 sampes(this overwrites samples #100 to #149).

 

Please refer to the attachment for details.

 

 

Message 5 of 5
(5,582 Views)