LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I decode flatenned waveform binary data?

I would like to decode exported binary data from labview so that I can use the data in other programs. I have been told it is flatenned waveform data and I have been given the document "LabVIEW Data Storage" for information on how to decode the data. However, I cannot make sense of the binary data. Can someone please help me get started?

The data was exported using version 6.1. It has a header which is easy to skip over, but I am having troubles with the actual binary data. I can't determine structure of the data (i.e. the type code, the descriptor, length, etc). The binary data starts like this (read left
to right, top to bottom).

0000 0004 0000 0003

41e7 7a0b bf8c 20c5

3ee4 f8b5 8000 0000

0001 d4c0 400b 3f00

0000 0000 4009 0a00

0000 0000 4009 6900

Any help would be greatly appreciated!
Thanks
Rich

0 Kudos
Message 1 of 6
(4,338 Views)
If it's a flattened waveform data type here's the decoding as far as I can see:

The first 16 bytes makes up the start time and date - t0.

The next 8 bytes is delta t (double)

The next 4 bytes is the number of signal values (0000 0064 means there are 100 Y values e.g.)

After that comes the Y values, they are 8 bytes each (double)...there's no separator between them. If the first two values are 0.34202 and 0.400349 the string will be:

3FD5 E3A8 748A 0BF5 3FD9 9F51 8C74 4B6B

At the end of the string the waveform attributes are appended.

In your example t0 is 01:00:00 01.01.2004 (0000 0004 0000 0003 41e7 7a0b bf8c 20c5), delta t is 1E-5 (3ee4 f8b5 8000 0000). There are 120 000 values (0001 d4c0) and the first value is 3.40576 (400b 3f00 000
0 0000), the next one is 3.12988 (4009 0a00 0000 0000)..etc.
Message 2 of 6
(4,338 Views)
Outstanding! This seems to work. However, I have follow-on questions that I hope you can answer too.

First, how is the time stamp coded? It doesn't make any sense to me. It's an aweful large number for seconds elapsed since 1/1/1904. I would like to figure out how the binary codes into the actual date.

Secondly, you stated that the waveform attributes are appended to the data. There is more than one waveform in this data and I would like to be able to get the rest of them. Hence, I need to know something about the appendages. Interestingly enough, I was able to visually scan the date for another timestamp (slightly different though) and I found where the next waveform began. I sucessfully extracted the next waveform, but I would like to under
stand what I am skipping over and how to skip over it (or use it).

For example, here is what the data looks like after the waveform:

0000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0c00 0400
0000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
0000 0000 000c 0004
0000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0c00
0400 0000 0000 0041
e77a 0bbf 8c20 c53e
f4f8 b580 0000 0000
00ea 6040 4157 571c
71ff e640 4159 0aaa
aaa7 ce40 4159 0aaa
aaa7 ce40 4159 0aaa
aaa7 ce40 4157 571c

(I noticed the next timestamp by the sequence 41e77a...etc but it is little b
it different as you can see)

Again, your help is appreciated!
-Rich
0 Kudos
Message 3 of 6
(4,338 Views)
I just wanted to add a quick note that a lot of the above depends on the LabVIEW version. The Timestamp datatype has changed between 6.1 and 7.0 so the headers will not be exactly the same.
0 Kudos
Message 4 of 6
(4,338 Views)
The time stamp (16 bytes) is the new data type introduced in LV7 (so if the data comes from an earlier version it will be different).

I haven't studied how it's encoded, it's obviously not just seconds since 1904 (gives the next Y2K bug...). Try wiring the data type to a flatten to string, show the string as hex...change the value and see how that translated into bytes. I't a bit too late here, too lazy to do it today:-)

Knowing when the waveform values have ended in the flattened data is done based on the length specifier in the header. After that there's the attributes which is a variant. The variant consist of the name of the control, the byte length of that name, the data and the byte length..plus plus...If you can't find a description of
it (haven't checked if it's in the document you mentioned earlier), build a waveform and change the data you wire to the attributes, observe how the flattened data change with it, and you'll decode it fairly simple.
0 Kudos
Message 5 of 6
(4,339 Views)
Hi everybody. Does anybody know the new waveform structure in LabVIEW 8.2? I need to build a waveform in my Java code. I have read this document: http://zone.ni.com/reference/en-XX/help/371361B-01/lvconcepts/flattened_data/. Although it says that "LabVIEW flattens waveforms like clusters", it's not true. There are some differences between them (9 bytes with zero value).  Thanks in advice.

My regards,
Vinicius
0 Kudos
Message 6 of 6
(4,124 Views)