LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading binary files, unflatten binary string

I am reading a binary file in LabVIEW and would like to convert the data to numbers. The binary file is a report from an external datalogger, WebDAQ/100 which ftps the report in binary format to a file. LabVIEW reads this file (which is a .dat-file right now. Anything else better?)
I've tried several Read file functions. One of them gives me a binary string. Using the Unflatten from string from there causes problems... I've tried different options for the TYPE-input, and they give different answers, but none of them give the data which the datlgooger i sending. How do I know that to put in the cluster on the type-input? Or if it shouldn't be a cluster at all, what should it be? I really hope someone can help me, because I'm
feeling really desperate!!

-Frustrated student...
0 Kudos
Message 1 of 5
(3,544 Views)
You need to read and decode the binary data based on a description of the binary format. I have not used WebDaq myself, but I found a partial description at:

http://www.microdaq.com/product/data-aquisition/webdaqHELPmanual/index.htm

The easiest would probably be to select the text format instead, then the decoding would be more or less self-explanatory.

On the same site it is stated that there are examples on how to retrieve report data into LabVIEW in the /prog/lv directory , you might find info there on how to read the binary format.

See:

http://www.microdaq.com/product/data-aquisition/webdaqHELPmanual/prog.htm

If you save a report in both text and binary format you can compair their contents and figure out the format. Uploading such a pair of fil
es here might enable some of us to help you.
0 Kudos
Message 2 of 5
(3,544 Views)
Hei Mads 😉

Thanks a bunch for answering my question 🙂

I've looked through the webDAQ's website more than once, but I just can't find anything there that can help me now....

You're saying that I could just use the text format instead, and that's what i did originally. I'm only trying to use the binary format instead because I thought that everything would run faster. Do you think that would help?

I've saved two files holding reports from the webDAQ. They are both generated by one channel and the scannumbers and each of the file contains 100scans. (Giving 200 numbers.) Does these files tell you anything??

-Hope you can help me 🙂

Hilsen Margrete
Download All
0 Kudos
Message 3 of 5
(3,544 Views)
The binary file looks like this:

B004 2020 2701 2020 2020 2020 2080 A643 2801 2020 2020 2020 2080 A643 2901 2020 2020 2020 2080 A643 2A01 2020 2020 2020 2080 A643 2B01 2020 2020 2020 2080 A643 2C01 2020 2020 2020 2080 A643 2D01 2020 2020 2020 2080 A643 2E01 2020 2020 2020 2080 A643 2F01 2020 2020 2020 2080 A643 3001 2020 2020 2020 2080 A643 3101 2020 2020 2020 2080 A643 3201 2020 2020 2020 2080 A643 3301 2020 2020 2020 2080 A643 3401 2020 2020 2020 2080 A643 3501 2020 2020 2020 2080 A643 3601 2020 2020 2020 2080 A643 3701 2020 2020 2020 2080 A643 3801 2020 2020 2020 2080 A643 3901 2020
Etc�..

The section 2020202020202080A643 is repeated throughout the file, all or parts of it is probably a delimiter. 20202020202020 equals 7 space characters�.so
that is very likely a delimiter.

Now the numbers between the delimiter is:

2801
2901
2A01
2B01
2C01
etc�

From the text file we saw that the log contains a scan number, a number that increments by 1 for each new line�

If the byte order is LSB first then the numbers above equals:

0128h = 296d
0129h = 297d
012Ah = 298d

etc�.so this is probably the scan number.

In the text report the recorded value is constantly 333.

Perhaps this is the A643 part of the repeating string? If it has the least significant bit first as well then the recorded value equals 43A6h = 17318. Could that be correct, or should the answer be 333 just like in the text file?

It might be easier to decode the file if it contains samples of different values.
0 Kudos
Message 4 of 5
(3,544 Views)
Hi 🙂 Thanks again!!!!!

Both files are supposed to be identical. With the constant value of 333 in addition to a scan number. (The scan numbers might vary between the files, but it's the same amount of data in both of them.) I actually thought it would be easier to decode the file with constant values because that way I know what I'm looking for...

However, I've actually kind of given up this option now and I'm trying to solve my problem from the HW side. (Meaning that I won't need to use the binary format, which makes evereything easier.)

Thank you very much for being such a big help! You're the best 😄
0 Kudos
Message 5 of 5
(3,544 Views)