原厂程序为:
function [radar_data_Rxchain] = read_ADC_bin_TDA2_separateFiles(fileNameCascade,frameIdx,numSamplePerChirp,numChirpPerLoop,numLoops, numRXPerDevice, numDevices)
dataFolder =fileNameCascade.dataFolderName;
fileFullPath_master = fullfile(dataFolder,fileNameCascade.master);
fileFullPath_slave1 = fullfile(dataFolder,fileNameCascade.slave1);
fileFullPath_slave2 = fullfile(dataFolder,fileNameCascade.slave2);
fileFullPath_slave3 = fullfile(dataFolder,fileNameCascade.slave3);
[radar_data_Rxchain_master] = readBinFile(fileFullPath_master, frameIdx,numSamplePerChirp,numChirpPerLoop,numLoops, numRXPerDevice, numDevices);
[radar_data_Rxchain_slave1] = readBinFile(fileFullPath_slave1, frameIdx,numSamplePerChirp,numChirpPerLoop,numLoops, numRXPerDevice, numDevices);
[radar_data_Rxchain_slave2] = readBinFile(fileFullPath_slave2, frameIdx,numSamplePerChirp,numChirpPerLoop,numLoops, numRXPerDevice, numDevices);
[radar_data_Rxchain_slave3] = readBinFile(fileFullPath_slave3, frameIdx,numSamplePerChirp,numChirpPerLoop,numLoops, numRXPerDevice, numDevices);
radar_data_Rxchain(:,:,1:4,:) = radar_data_Rxchain_master;
radar_data_Rxchain(:,:,5:8,:) = radar_data_Rxchain_slave1;
radar_data_Rxchain(:,:,9:12,:) = radar_data_Rxchain_slave2;
radar_data_Rxchain(:,:,13:16,:) = radar_data_Rxchain_slave3;
end
function [adcData1Complex] = readBinFile(fileFullPath, frameIdx,numSamplePerChirp,numChirpPerLoop,numLoops, numRXPerDevice, numDevices)
% 每帧预期的采样数
Expected_Num_SamplesPerFrame = numSamplePerChirp*numChirpPerLoop*numLoops*numRXPerDevice*2;
fp = fopen(fileFullPath, 'r');
fseek(fp,(frameIdx-1)*Expected_Num_SamplesPerFrame*2, 'bof'); % fseek移至文件中的指定位置
adcData1 = fread(fp,Expected_Num_SamplesPerFrame,'uint16');
neg = logical(bitget(adcData1, 16)); % logical将数值转换为逻辑值 bitget获取指定位置的位
adcData1(neg) = adcData1(neg) - 2^16;
%%
adcData2 = adcData1(1:2:end) + sqrt(-1)*adcData1(2:2:end); % 实部加虚部
adcData1Complex = reshape(adcData2, numRXPerDevice, numSamplePerChirp, numChirpPerLoop, numLoops);
adcData1Complex = permute(adcData1Complex, [2 4 1 3]); % 置换数组维度
fclose(fp);
end
程序输入依次为,
fileNameCascade :二进制文件名
frameIdx, 帧编号,
numSamplePerChirp, 采样点数 ,原厂为256
numChirpPerLoop, 每循环调频数,原厂为12
numLoops, 循环数,原厂为64
numRXPerDevice, 每个芯片的接收天线个数,原厂为4
numDevices,芯片数 为 1。每个芯片对应一个存储的二进制文件
程序依次读取四个二进制文件,计算每帧的采样数,在二进制文件中读取相应的字节数,将读取到的字节通过 实部,虚部 相加。得到整个周期的调频信号。
调频信号为 一个 4 X 256 X 12 X 64 的矩阵。 12根天线依次发射,4根天线同时接收,每根天线采样点为256,循环64次。
重组矩阵,调整为 256 X 64 X 4 X 12。 方便进行后期处理。