‎06-04-2025 03:31 AM
It's impressive how much an Express VI can slow down data acquisition. With your solution, reading the data is so much faster!
I'm now writing using the "Write Binary File" block as you suggested, but when I process the data to make it readable, I get what seem like random values in the range of: 7.98E-157, 5.80601E+11, 1.75E-219, -3.43E-243, 1.97E-256, -1.65E-274.
However, the values should be oscillating between 0 and 1.
‎06-04-2025 04:02 AM
How do you process the data?
All you need is read from binary file:
Read from Binary File
By default, LabVIEW saves data with big-endian byte order as in Yamaedas example.
‎06-04-2025 10:33 AM
I'm just creating the file in LabVIEW, and then I use a Python script to read the binary file and write all the data into a CSV file. I'm not very confident with creating a binary file in LabVIEW, closing it, and then—after the while loop—reopening it to write all the binary data into an .xlsx
file. I tried doing it that way:
…but the .xlsx
file was always empty. (I also tried using the "Obtain queue")
When I use a TCP server written in C to receive data from the client and write it to a binary file, then use a Python script to convert the binary file into a CSV file, the values are in the correct range. But when I use LabVIEW… they are not.
I've attached my VI, my C-based TCP server (which does what I want to reproduce in LabVIEW), and my Python script.
‎06-04-2025 12:19 PM
I fixed some bugs, try this
- "string" was prepended to actual data with write to binary file
- file was read from the end. either set the file position to the beginning or close and then read
- read the exact amount of data you expect, at least in multiples of channels*sizeof double, otherwise data is not aligned (does not matter too much in this case but do it anyway.)
- wrong endianness (python script uses little endian)
‎06-05-2025 07:18 AM
@Ouinon wrote:
It's impressive how much an Express VI can slow down data acquisition. With your solution, reading the data is so much faster!
I'm now writing using the "Write Binary File" block as you suggested, but when I process the data to make it readable, I get what seem like random values in the range of: 7.98E-157, 5.80601E+11, 1.75E-219, -3.43E-243, 1.97E-256, -1.65E-274.
However, the values should be oscillating between 0 and 1.
The Express VI opens and closes the file between every write, by opening before the loop and closing after it keeps the reference open and the file position.
‎06-05-2025 07:23 AM - edited ‎06-05-2025 07:27 AM
@Ouinon wrote:
I'm just creating the file in LabVIEW, and then I use a Python script to read the binary file and write all the data into a CSV file. I'm not very confident with creating a binary file in LabVIEW, closing it, and then—after the while loop—reopening it to write all the binary data into an
.xlsx
file. I tried doing it that way:
You can't use a file reference after you've closed it ... Also, where do you think the File pointer is after having written all the values? That's where it'll start to read.
‎06-06-2025 08:30 AM
To familiarized myself with reading binary files, and I'm now writing a simple VI. I don't know what I'm doing wrong, but at the end, I get random values. However, I should be getting values between 0 and 1 for the first three values, and a value that represent the time passing for the fourth one.
My binary file is a 1D array of floats structured like this:[Value1 Value2 Value3 time Value1 Value2 Value3 time Value1 Value2 Value3 time ...]
I’ve attached my VI and the binary file I’m working on.
‎06-06-2025 09:09 AM
The actual structure is the following:
- 1 4-byte integer (= 256)
- 8192 8-byte double precision
- 1 4-byte integer (again = 256)
- 8192 8-byte double precision
...
and so on. All binary numbers are little endian.