This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HSDC Raw Data File Confusion

Other Parts Discussed in Thread: ADC12J4000EVM, ADC12J4000

I'm collecting data on the ADC12J4000EVM using the TSW14J56EVM and the High Speed Data Converter (HSDC) Pro software and ADC12J4000EVM GUI. Trying to capture raw time domain data to a binary file so I can post-process the data in MATLAB.

Following the HSDC User's Guide, in the HSDC GUI I save data using File-->Save Raw ADC Codes as Binary File. I'm having trouble figuring out the correct way to parse the data, which is apparently stored as ADC Codes rather than voltage levels.  I've seen a few similar posts, but I would like an explicit explanation on how to parse the data, and if MATLAB code could be provided, it would be much appreciated. Some posts say the data is stored in two's complement. Is this only for the CSV, not the binary file? What is the format of the binary file?

Here's my MATLAB code thus far, assuming the binary data is stored as 32-bit integers, non-2's complement. N is the number of bits, Vfs is the peak-to-peak voltage from the Analog Input Characteristics section of the ADC12J4000 online datasheet.

function Data = ReadTiAdcData(filename)
fid = fopen(filename,'r');
Data = fread(fid,'int32');
fclose(fid);
N = 12;
Vfs = 0.95;
Data = Vfs*Data/2^(N-1);

If I use this code and take an FFT of the data, the spectrum looks nothing like what's recorded in the HSDC GUI. It's not just a scaling issue (fundamental shows up in the wrong location, there's very high spurs, etc.).

Also, should I be grabbing Vfs from control tab of the ADC12J4000EVM GUI?  For instance, "Gain Full Scale" is set by default to 612.5 mV Vpp with an offset of -37.4999 mV.  Should these values be used in the conversion from ADC Code to voltage?


Also note that the User's Guide says that if the Single Tone FFT test is active, the FFT plot is saved along with statistics and setup information, and if the Time Domain test is active, the Time Domain plot is saved along with statistics. HSDC simply does not work as described here. No matter which test is active, I get the same CSV and Binary output files, which contain raw data only without statistics or setup information.

  • Hi Chris

    You're on the right track but you need to load the data from the binary file differently. The 12 bit samples are stored in a two byte format in the data file, with the upper nibble all 0's.

    Here is what the format looks like:

    LowByte HighByte LowByte HighByte LowByte HighByte LowByte HighByte LowByte HighByte LowByte HighByte LowByte HighByte LowByte HighByte

    In the binary file format the ADC codes are from 0000H to 0FFFH or 0b to 4095b. You can convert this to signed by subtracting 2048 from the decimal values. Then the codes will go from -2048 to +2047. This is the data format used when exporting from the time domain sample plot (right click on plot and select Export>Export data to Excel). You can then scale and multiply these signed values by the full scale range of the ADC to give the approx. --362.5mV to +362.5mV differential signal amplitude (for the default FSR setting).

    Best regards,

    Jim B

  • Chris,

    Do you need the binary bits? Or would a CSV of the signed integer 2s complement values be ok? If you select to save the data as a CVS it may be easier to read this into matlab without having to parse the bin file. However the bin file does give you a more size optimized file so may be better for really large capture depths.

    I will look into the saving statistics that you mentioned.

    Ken.
  • Thanks for your reply, Jim.  I assume the +/- 362.5 mV (or 725 mV) comes from the datasheet? Why do we see 612.5 mV as the default setting for Gain Full Scale in the ADC12J4000EVM GUI?

  • Ok, here's my latest code. This gets me the correct spectrum with the fundamental at the correct frequency, but the scaling is still off. The HSDC GUI shows the fundamental at -1.00 dBFS, but post-processing in MATLAB returns a -3.98 dBFS fundamental.

    function X = ReadTiAdcData(filename)
    fid = fopen(filename,'r');
    X = fread(fid,'int16');
    fclose(fid);
    X = X-2^(N-1);
    N = 12;
    Vfs = 725e-3;
    X = Vfs *X/2^(N-1);

    Thanks so much Ken and Jim for helping! To answer your question Ken, I am not opposed to using the .csv, but I'd like to understand how to parse both output formats.
  • Chris,

    Just an update on the signal statistics.  That is in reference to the "File>Save Screen Shot as" option which not only saves the selected screen (time or frequency) but it saves the entire window which includes the signal statistics on the left side of the HSDC Pro window.  Here is an example with an ideal signal.

    Ken

  • Thanks Ken. I am aware that the screenshot saves statistics. However the HSDC User's Guide states that statistics are also saved in the binary and csv files, which is not true.
  • Chris,

    Sorry for the confusion in the users guide. We will fix the text in the next release - it doesn't save these parameter in a separate file, just part of the screen shot. If you want access to the actual parameters you can control HSDC Pro from within Matlab and extract these parameters from HSDC Pro directly. Please look at the automation examples and users manual (sections 23, 24, 25):

    C:\Program Files (x86)\Texas Instruments\High Speed Data Converter Pro\HSDCPro Automation DLL\Manual and Examples

    This isn't an officially supported mode of HSDC Pro and we do not provide much support for it, but we have provided some examples as some customers have found this useful.

    Ken.
  • Thanks Ken. If you or Jim have more feedback on the ADC data file scaling problem I'm having, please let me know. I posted my latest MATLAB code a few posts above.