From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.bin File Format

Hello,

 

I am sure that there have been other questions similar to this, but I have not been able to find a good description of the format of .bin files. Does anyone know where I could find a description of Binary files? I am looking to perform data analysis on DAQmx aquired data. I am using python to code the script and haven't been able to import the binary files, made with labview, correctly.

 

Thanks,

 

Mmoon

0 Kudos
Message 1 of 17
(5,270 Views)

There is no set format for a Binary File.  It is just whatever data you need to store in it saved in a binary (machine readable) format.


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 2 of 17
(5,263 Views)

There's no standard. ".bin" usually indicates a binary file of some type without telling you anything about the data inside it. You need to find out how the data inside the file is written from somewhere else, for example by examining the LabVIEW code that creates those files. If you post the VI, or at least an image of the part of the code that writes the files, we might be able to help you understand the data.

0 Kudos
Message 3 of 17
(5,259 Views)

Thanks for clarifying, I have attached my VI that I am working with. Please let me know if you see any mistakes with how I have my VI formatted.

 

Thanks!

0 Kudos
Message 4 of 17
(5,255 Views)

What you're writing now to the file is a mess. You are taking a 2D array of waveforms (out of the DAQmx Read), using Convert from Dynamic Data to extract a single channel where you should be using Index Array, and then oddly reshaping the single waveform into a single-element array of waveforms. This is a lot of unnecessary code that is going to make it difficult to interpret the data in the file.

 

What are you reading from the DAQmx Task? What data do you want in the file, and how would you like it to be formatted or arranged?

 

Have you considered TDMS instead of a binary file? There are python libraries for reading TDMS files, and you might find that easier to work with.

0 Kudos
Message 5 of 17
(5,246 Views)

I am reading 2 voltage values from two channels from the DAQmx task. Id like to have these two sets of data as well as a time stamp of the elapsed time that passed during the test all to be in the file in separate columns of an array.

I remember reading that Python cannot manipulate TDMS files, but if I am mistake I would be open to switching the formatting.

0 Kudos
Message 6 of 17
(5,242 Views)

I haven't used any Python TDMS libraries, but a quick Google search turns up several, so that might be worth a try.

 

Perhaps you should start by logging all your data to a text file, rather than binary, so you could open it in Excel or a text editor and see whether you're even capturing the data you want. For example, the "Elapsed Time" function isn't doing what you want, because it resets after 100000 seconds. Instead, you should get the date and time before the while loop starts, then get it again after the while loop ends (one easy way to do this is to put a Get Date/Time in Seconds function inside the while loop, wired to the while loop border, so you get the value from the last iteration of the while loop) and subtract to get the elapsed time.

 

There is no need for a sequence structure in your VI.

 

There is no such thing as "columns," or for that matter an array, in a binary file. It all depends on how you interpret the data when you read it.

 

Instead of reading the data as a waveform, read it as a 2D array of DBL. You could simply write that array directly to the binary file, without any of the dynamic data and waveform manipulation. What you'll get in the file is 512 samples of the first channel, followed by 512 samples of the second channel, repeating. You could transpose the array first, so that the data would alternate between samples of the two channels, on sample at a time (instead of in blocks of 512).

0 Kudos
Message 7 of 17
(5,234 Views)

I rewrote my script, using TDMS files. I attached the new version. Does this seem more reasonable?

 

One of the stipulations for my script is that it needs to include a running display of elapsed time.

0 Kudos
Message 8 of 17
(5,225 Views)

Again, there's no need for a sequence structure. Remove it!

 

Also, as I wrote before, the Elapsed Time function is configured to reset after 100000 seconds. That might be longer than you ever expect your code to run, but the Elapsed Time function is still the wrong function to use. That function is designed to tell you when a certain amount of time has elapsed. All you need is a Get Date/Time in Seconds function outside the while loop, a second one inside the loop, and a Subtract.

 

Other than that, it looks OK to me. Does it work?

0 Kudos
Message 9 of 17
(5,219 Views)

Ok I removed the elapsed time function and replaced it with the get date/time vi.

 

I am currently running into an error that says: "A Case structure must have a case corresponding to every possible value of the selector.  An easy way to fill this requirement is to specify a default case or cases whose selector values include ranges to or from infinity."

 

I am not sure why this is an issue but I have attached my new script to this. Can someone tell me where my issue is?

 

Thanks

0 Kudos
Message 10 of 17
(5,213 Views)