ModuleConnector DataReader: Read X4 Baseband data in Matlab

Discussion in 'Module Connector (MC)' started by Timo Lauteslager (IC), Oct 10, 2017.

  1. Hi!

    I have recorded a .DAT file using an X4M300 and ModuleConnector (Win64 1.4.2) in Matlab(2016b). Now, I want to read the baseband AP data in Matlab, and do subsequent processing. I tried using the ModuleConnector DataReader, but do not understand the output format. I found that if I plot every fourth sample in the returned 'data' field, I get something that resembles Amplitude BB data. But there is a strange quantization problem. And which is my phase data? Is there an example file for the ModuleConnector DataReader?

    Code:
    LIB = ModuleConnector.Library;
    
    metafilename = './Recordings/xethru_recording_20171010_111744_test_recording/xethru_recording_meta.dat';
    reader = ModuleConnector.DataReader();
    status = reader.open(metafilename);
    
    data_type = ModuleConnector.DataRecorderInterface.DataType_BasebandApDataType;
    reader.set_filter(data_type);
    
    d = reader.read_record();
    amp = d.data(4:4:end);
    figure
    plot(amp)
    
    baseband amplitude.png
    I have been able to access the raw data using Matlab function fread, but I am interested in using the ModuleConnector. Thanks for your help!

    Timo
     

    Attached Files:

  2. Charlie Shao

    Charlie Shao Moderator Staff Member

    Hi Timo,
    Please refer to XeThru File Formats page 3 for amplitude / phase baseband data in binary format.
     
  3. Stan

    Stan New Member

    Good morning,

    I have a similar request for support with MatLab. I'm recording baseband AP data and when using the DataPlayer, setting the rate to -1 causes it to skip frames so I decided to switch to the DataReader. I'm getting a byte array from Reader.read_record() and I would like to get it back as the two float arrays and a header like I was getting from app.read_message_baseband_ap.

    Can either of you help me here?

    I would also like to convert the data to normalized.

    Stan

    P.S. I'm currently hardcoding it like this, which isn't elegant at all:
    ctr = typecast(uint8(fileframe.data(1:4)), 'uint32');
    offset = 6*4+1; %FrameCounter uint32, NumOfBins uint32, BinLength float, SamplingFrequency float, CarrierFrequency float, RangeOffset float
    all_data = typecast(uint8(fileframe.data(offset:end)), 'single');

    I also manually read the parameter file for the normalization value and multiplied my data by it:
    NormalizationFactor = 1.0; %default
    fid = fopen(paramfilename);
    while (~feof(fid))
    line = fgetl(fid);
    [NormalizationFactor,n,errmsg] = sscanf(line, 'NormalizationFactor = %f');
    if n == 1
    break;
    end
    end
    fclose(fid);
     
    Last edited: Apr 23, 2018
  4. Charlie Shao

    Charlie Shao Moderator Staff Member

    Hi Stan,
    the data you get from reader.read_record() is one fram of radar data stored as uint8, please check the xethru file formats section 2.1 regarding how to parse baseband ap data, the data you got is already normalized.
    https://www.xethru.com/community/resources/xethru-file-formats.55/