LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write 1D array to TDMS with multiple channels

Solved!
Go to solution

Hi, I need to write data to a TDMS file. The data is a single u8 1D array that I need to split into different data from two sensors, and then write them into the TDMS file. To accomplish this, I am using 2 random numbers with the "Build Array" function and attempting to write them to the TDMS file. However, my problem is that I am not sure how to save all the random numbers from each index and then write them as a 2D array in the TDMS file.

 

I have tried some of the examples that I found in the forum, but none of them worked the way I wanted. For example, my 1D array has 2 rows, where the first row contains values 10-20, and the second row contains values 50-70, and so on. In my TDMS file, I would like to see Channel 1 displaying the values 10-50, and Channel 2 displaying the values 20-70. I want to display the data in something like this:

ADaniel01_0-1683879479565.png

I know I need to use a for loop but I can't make it works, here is my vi that I'm using to try things:

ADaniel01_1-1683879558301.png

 

0 Kudos
Message 1 of 16
(1,289 Views)

Hi A.,

 


@A.Daniel01 wrote:

I want to display the data in something like this


Provide your data as a 2D array for TDMSWrite: each row will be data of one channel…

(Or use a 1D array of waveforms.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 16
(1,268 Views)

Check this out, Map Channel Names with Data.

 

WriteToTDMS.png

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 3 of 16
(1,265 Views)

That is what I want, but I don't know how to make my 1D array into that 2D array.

0 Kudos
Message 4 of 16
(1,244 Views)

@A.Daniel01 wrote:

That is what I want, but I don't know how to make my 1D array into that 2D array.


Then its better to start Learning basics of array functions.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 16
(1,238 Views)

I know how to use the array functions, I know how I can transform 1D array to 2D array, what I don't know is how to do what I asked in the first message, I don't know how to insert the 1D data to the 2D array and save it in new index.

0 Kudos
Message 6 of 16
(1,228 Views)

Hi A.,

 


@A.Daniel01 wrote:

I don't know how to insert the 1D data to the 2D array and save it in new index.


As I wrote: each row in a 2D array holds the samples of one channel.

Btw. you don't want to "insert" into an array, you want to build an array from your samples…

 

In your 1st message you wrote:


@A.Daniel01 wrote:

 For example, my 1D array has 2 rows, where the first row contains values 10-20, and the second row contains values 50-70, and so on.


In a 1D array there is exactly one "row" (or exactly one column)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 16
(1,217 Views)

Ok, next try, I did this, this is easy and it is what I need, the problem is, I dont know how many times the for loop needs to go, what can I do to have the same result using the same data input (the 2 random numbers in this case) and running the for loop until I stop getting data.

ADaniel01_0-1683892217899.png

 

0 Kudos
Message 8 of 16
(1,193 Views)

Hi A.,

 


@A.Daniel01 wrote:

the problem is, I dont know how many times the for loop needs to go, what can I do to have the same result using the same data input (the 2 random numbers in this case) and running the for loop until I stop getting data.


Generic programming rule: When you don't know the number of iterations before starting a loop then you should use a WHILE loop instead of a FOR loop…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 16
(1,187 Views)

Then what can I do to write the TDMS, I don't care if I need to use for, while or whatever, I just need to know how can I write each index of my u8 array in 1 different channel and keep writting.

0 Kudos
Message 10 of 16
(1,171 Views)