LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What's the structure of waveform file generated and read by LabVIEW

Solved!
Go to solution

Hello,

 

We need to generate some complex waveforms. Therefore, instead of using LabVIEW directly, we decide to use Python to generate these waveforms and export them into some files, which can be read by LabVIEW. We think that our waveform files should be similar to waveform files generated by LabVIEW. However, we do not find any description on the structure of waveform files. From a simple example waveform generated by LabVIEW, we only guess that it is a binary file and there are some descriptions at the beginning of files. Could someone show me the structure of waveform files in ASCII? Thanks a lot! 

0 Kudos
Message 1 of 14
(4,501 Views)

What waveform file are you referring to?  I have seen TDMS, CSV, text.

 

Personally, I would just save your data to a tab delimited text file and you can just use the Read Delimited Spreadsheet File to get your waveform data.


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
Message 2 of 14
(4,485 Views)

I guess you are talking about the read/write tools in the  "waveform file IO" palette. (If not, please be more specific ;))

 

A waveform datatypes is basically a 1D array (numeric, digital, etc.) with timing information (i.e. equally spaced in time as defined by t0 and dt) and you can have arrays of such waveforms.

 

You can open the waveform file VIs and look at the code. From that you can see that arrays of waveforms are stored as datalog files with an array of waveforms as "datalog record" type. (details)

 

For some perspective, here's what I wrote ~11 years ago about datalog files. I would recommend to save in plain files as Tim already suggested.

0 Kudos
Message 3 of 14
(4,466 Views)

Thanks for your reply. I do not know the file format exactly because there is no extension but it is not csv or TDMS. I just try to generate a waveform file with python which can be generated by "Write waveform to file" function of LabVIEW and can be read by "Read waveforms from file" function. (the waveform is too complex so it is a little bit difficult in LabVIEW)

0 Kudos
Message 4 of 14
(4,456 Views)

Yes, exactly. I just want to generate a waveform file with Python which can be read by the "Read waveforms from file" function of LabVIEW but I do not know what a waveform file should look like. I try to explore the file structure using a waveform file generated by "Write waveforms to file"  but it seems that it is a binary file. After I read it byte by byte, actually I do not see evident structure. If I write the waveforms into plain files, can it be read by LabVIEW?

0 Kudos
Message 5 of 14
(4,455 Views)

Hi KK,

 

If I write the waveforms into plain files, can it be read by LabVIEW?

When you know the data format of those "plain" files you can not only read them with LabVIEW, but even parse them…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 14
(4,445 Views)

@KK97 wrote:

If I write the waveforms into plain files, can it be read by LabVIEW?


LabVIEW is a full featured programming language and any file is nothing more than a linear sequence of bytes. Once you know the file structure, you can parse it into the desired data structure.

0 Kudos
Message 7 of 14
(4,441 Views)
Solution
Accepted by topic author KK97

As Altenbach mentioned, Write waveform end up in a Write Datalog, which is a raw binary of the waveform. So if you play around with Waveforms and Flatten to string it should become apparent. It writes an away of waveforms, and looking at it:

[array size, 4 bytes (int)]

[datetime 16 bytes]

[dT 8 bytes]

[data array size 4 bytes]

[data array, x doubles of 8 bytes]

[filler? 1 byte ]

[Variant, X bytes with attributes, "data string 6" with empty variant]

Waveform binary formatWaveform binary format

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 8 of 14
(4,436 Views)

@Yamaeda wrote:

As Altenbach mentioned, Write waveform end up in a Write Datalog, which is a raw binary of the waveform. So if you play around with Waveforms and Flatten to string it should become apparent. It writes an away of waveforms, and looking at it:

[array size, 4 bytes (int)]

[datetime 16 bytes]

[dT 8 bytes]

[data array size 4 bytes]

[data array, x doubles of 8 bytes]

[filler? 1 byte ]

[Variant, X bytes with attributes, "data string 6" with empty variant]


That's all nice and good but likely way over the head of the topic creator. While the 16 bytes datetime is actually sort of parsable (it's a 64 bit signed integer containing the seconds, and a 64 bit unsigned integer containing the fractional seconds), there are other difficulties in this such as the fact that the Variant memory layout never has been fully documented. And also that all these numbers are stored in big endian format in the data stream.

 

There are better things to do with your time than trying to parse binary files so unless you write such things as your job every day or just really really want to tinker with such difficulties for the fun of it, I would advice to use a different file format to share data between LabVIEW and non-LabVIEW applications.

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 14
(4,431 Views)

There is an example, where "Write Waveforms to File" is  used in NI Example Finder. According to that VI the extension of file is .dat. Write to waveform.JPG 

0 Kudos
Message 10 of 14
(4,417 Views)