LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing a number to TDMS

Solved!
Go to solution

Hello everyone! I have a task to implement some of the advanced I/O techniques in my code, so I decided to make a reading/writing subVI with TDMS. The data I need to write in is a number, type of double. The problem is that TDMS accepts type of waveform, and when I convert my number to data type,which TDMS accepts, it doesn't write my data into file.It only writes the time of execution and other irrelevant data. Is there any possibility to write a data of double type?

0 Kudos
Message 1 of 28
(5,136 Views)

If you look at the help for TDMS write you will see that numeric data needs to be in a 1D or 2D array.

PaulG.

LabVIEW versions 5.0 - 2023

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 2 of 28
(5,117 Views)

Are you trying to write a single value to a channel?  TDMS is setup to stream data to the disk.  This means it wants many data points to write at a time.  If you are only writing a single value to a channel, you should write the value to a property instead.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 28
(5,110 Views)

I need to write a single data,yes. I used a conversion "double to data", but TDMS didn't write it. It's not 1-D array, but 1-D waveform array, and a type mismatch is indicated.

0 Kudos
Message 4 of 28
(5,104 Views)

Can you post your code?  I'd just be shooting in the dark without it.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 28
(5,098 Views)

@miki90 wrote:

I need to write a single data,yes. I used a conversion "double to data", but TDMS didn't write it. It's not 1-D array, but 1-D waveform array, and a type mismatch is indicated.


Just try to wire a 1D array of Double to the write terminal.  The terminal is polymorphic and will change to the data type you wire to it, but the default is a 1D array of waveform.  If you only one have one element you want to write (not an array) then use the build array to turn your scalar double into an array of double with just one value.

 

TDMS works best when you are writing a chunk of data at once.  So a better option is to collect a bunch of these scalar values builing the array your self then writing them all at once.  Writing one element all the time in a loop can cause very large index files, and performing a close and defrag will fix this, but the better solution is to write more than one element at a time.

0 Kudos
Message 6 of 28
(5,094 Views)

TDMS is in Read/Write subVI on the right.

Download All
0 Kudos
Message 7 of 28
(5,091 Views)

@miki90 wrote:

TDMS is in Read/Write subVI on the right.


There is alot of scary going on there.

 

You take a scalar value, then insert it into a blank array, then convert it to Dynamic Data type then try to wire that into a sub VI that has a 1D array of waveform, then you build an array (making it a 2D array of waveform) then try to write that...just write the single scalar double to TDMS by using a build array (making it a 1D array of double).

 

Holy Cow.  Few other things (sorry if I come across as judgemental just trying to help)

 

You obviously are running this VI after setting some values and that's not how programs work (or should work)  When I open Excel I don't have to click the Run button first.  You run the program then change the controls as it's running.

 

You are looking to figure out which button was pressed, if your VI was running you could just have an event structure that tells you what was pressed.  

 

You also have no groups or channel names in the TDMS write.  Doesn't this generate an error every time?

0 Kudos
Message 8 of 28
(5,088 Views)

Hooovahh, it cannot accept an array of double, I tried it. It only accepts a waveform 1D array.

0 Kudos
Message 9 of 28
(5,087 Views)

@miki90 wrote:

Hooovahh, it cannot accept an array of double, I tried it. It only accepts a waveform 1D array.


The "TDMS Write" function accepts a 1D array of double.  Your subVI that has the write in it, doesn't.  Change the subVI.

0 Kudos
Message 10 of 28
(5,083 Views)