Other Parts Discussed in Thread: TDA2
Tool/software:
I captured data with only 128 frames and used the following code to read the master_0000_data.bin
file. However, when I set the frame index beyond 128, the code still provides output, which is unexpected since I am sure there are only 128 frames in the file. Specifically, setting the frame index to 1524 results in an error message, while indices between 1 and 1524 do not produce any errors.
Could you please guide me on how to correctly read a single frame of data from the master_0000_data.bin
file? The code I am using is from the following location:
file:///C:/ti/mmwave_studio_02_01_01_00/mmWaveStudio/MatlabExamples/4chip_cascade_MIMO_example/utils/dataParse/read_ADC_bin_TDA2_separateFiles.m
% Define the parameters for reading the bin file
fileFullPath = '\master_0000_data.bin';
frameIdx = 1525; % Index of the frame you want to read
% Specify the radar setup parameters (adjust these values based on your system configuration)
numSamplePerChirp = 256; % Number of samples per chirp (replace with actual value)
numChirpPerLoop = 64; % Number of chirps per loop (replace with actual value)
numLoops = 1; % Number of loops per frame (replace with actual value)
numRXPerDevice = 4; % Number of receiving channels per device (replace with actual value)
numDevices = 1; % Number of devices in the cascade (adjust based on your setup)
% Call the function to read the bin file
[adcData1Complex] = readRadarBinFile(fileFullPath, frameIdx, numSamplePerChirp, numChirpPerLoop, numLoops, numRXPerDevice, numDevices);
% Display the output dimensions
disp('Output dimensions of adcData1Complex:');
disp(size(adcData1Complex));
function [adcData1Complex] = readRadarBinFile(fileFullPath, frameIdx, numSamplePerChirp, numChirpPerLoop, numLoops, numRXPerDevice, numDevices)
% Calculate expected number of samples per frame
Expected_Num_SamplesPerFrame = numSamplePerChirp * numChirpPerLoop * numLoops * numRXPerDevice * numDevices * 2; % Factor 2 for real and imaginary parts
% Open the file
fp = fopen(fileFullPath, 'r');
if fp == -1
error('Cannot open the file.');
end
% Set the file pointer to the start of the desired frame
fseek(fp, (frameIdx - 1) * Expected_Num_SamplesPerFrame * 2, 'bof'); % 2 bytes per sample
% Read the ADC data from the file
adcData1 = fread(fp, Expected_Num_SamplesPerFrame, 'uint16');
fclose(fp); % Close the file
% Convert unsigned data to signed format
neg = logical(bitget(adcData1, 16));
adcData1(neg) = adcData1(neg) - 2^16;
% Combine I and Q components to form complex samples
adcData1 = adcData1(1:2:end) + 1i * adcData1(2:2:end);
% Reshape the data to match the radar configuration
adcData1Complex = reshape(adcData1, numRXPerDevice * numDevices, numSamplePerChirp, numChirpPerLoop, numLoops);
% Permute to rearrange dimensions
adcData1Complex = permute(adcData1Complex, [2 4 1 3]); % Output: [SamplesPerChirp, Loops, RxChannels, Chirps]
% Display the dimensions of the output
disp('Dimensions of adcData1Complex:');
disp(adcData1Complex);
end