06-10-2010 12:21 AM
The aim of this post is to read a binary file, extract bit informations, and plot waveforms of multichannel data.
I have a binary file that contains 8 channel 16 bit ADC data, which was orininally acquired through ADS1178 ADC IC. Each sample (for all 8 channels) is stored in 16 bytes format (byte 0 to byte 15). D0s' of these 16 bytes, combined together, form a 16 bit data of channel 0. Similarly all D1s' of the same 16 bytes form channel1 data. Similarly for other channels, upto channel 7. The next 16 bytes contain the next sampled value in the same format. In other words, all MSbs are stored in byte0, and all LSbs in byte 15. This might be something similar to bit extraction and rejoin problem. Kindly refer to the attached code.
06-10-2010 11:58 AM
06-11-2010 07:37 AM
Thanks for your interest. I am attaching the sample data files and another version of the code that plots only till 15th sample point, although the data may be larger.
'SN_IITB4.dat' contains ADC generated data, where Ch3 must be having a sine wave of 1Vpp 5KHz, 'SN_IITB4.dat' is manually generated triangular wave data.
06-11-2010 09:21 AM
What you might be able to do is read your 16 bytes from your file and put them into a byte array. Use the Number To Boolean Array function in a for-loop to build up a boolean array with each boolean representing one bit of your data. Now, I think you could use the Decimate Array function to pull your data from your boolean array.
I don't have an example at the moment, but I might be able to put one together if I remember to do so.