07-13-2016 03:32 PM
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
07-13-2016 03:39 PM
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.
07-13-2016 03:46 PM
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.
07-13-2016 03:48 PM
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!
07-13-2016 04:06 PM
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.
07-13-2016 04:09 PM
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.
07-13-2016 04:36 PM
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).
07-13-2016 05:07 PM
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.
07-13-2016 05:15 PM
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?
07-13-2016 05:55 PM
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