Hey all,
I'm having trouble reading the adc_data.bin with the MATLAB code provided in the user guide: mmwave Radar Device ADC Raw Data Capture. Here's the MATLAB code I run which is a direct copy from the user guide, section 9.1:
%%% This script is used to read the binary file produced by the DCA1000 %%% and Mmwave Studio %%% Command to run in Matlab GUI - readDCA1000('<ADC capture bin file>') function [retVal] = readDCA1000(fileName) %% global variables % change based on sensor config numADCBits = 16; % number of ADC bits per sample numLanes = 4; % do not change. number of lanes is always 4 even if only 1 lane is used. unused lanes isReal = 0; % set to 1 if real only data, 0 if complex dataare populated with 0 %% read file and convert to signed number % read .bin file fid = fopen(fileName,'r'); % DCA1000 should read in two's complement data adcData = fread(fid, 'int16'); % if 12 or 14 bits ADC per sample compensate for sign extensionnumLanes if numADCBits ~= 16 l_max = 2^(numADCBits-1)-1; adcData(adcData > l_max) = adcData(adcData > l_max) - 2^numADCBits; end fclose(fid); %% organize data by LVDS lane % for real only data if isReal % reshape data based on one samples per LVDS lane adcData = reshape(adcData, numLanes, []); %for complex data else % reshape and combine real and imaginary parts of complex number adcData = reshape(adcData, numLanes*2, []); adcData = adcData([1,2,3,4],:) + sqrt(-1)*adcData([5,6,7,8],:); end %% return receiver data retVal = adcData;
My IWR1443BOOST is ES3.0 and the mmWave Studio version is 2.0.0.2.
Here are the steps I followed:
1. Ran the procedure of the DataCapture Demo (I changed the chirp loop to be 128 and number of frames to 8). It ran from start to end no problem and gave the demo MATLAB Gui. Here's the Lua output after successfully completing the DataCapture Demo script:
GM: Constructor GM: Wed Apr 10 18:40:25 2019 RSTD.Transmit("/Settings") [18:40:25] [18:40:25] ### Running Startup script: "C:\ti\mmwave_studio_02_00_00_02\mmWaveStudio\Scripts\Startup.lua" ### [18:40:25] RSTD.SetAndTransmit ("/Settings/Scripter/Display DateTime" , "1") [18:40:25] RSTD.SetAndTransmit ("/Settings/Scripter/DateTime Format" , "HH:mm:ss") [18:40:25] Scripter ignored: Attempt to UnBuild() again or before Build. [18:40:25] RSTD.SetVar ("/Settings/Clients/Client 0/Dll" , "C:\\ti\\mmwave_studio_02_00_00_02\\mmWaveStudio\\Clients\\\\LabClient.dll") [18:40:25] RSTD.SetVar ("/Settings/Clients/Client 0/Use" , "TRUE") [18:40:25] RSTD.SetVar ("/Settings/Clients/Client 1/Use" , "FALSE") [18:40:25] RSTD.SetVar ("/Settings/Clients/Client 2/Use" , "FALSE") [18:40:25] RSTD.SetVar ("/Settings/Clients/Client 3/Use" , "FALSE") [18:40:25] RSTD.SetVar ("/Settings/Clients/Client 4/Use" , "FALSE") [18:40:25] RSTD.SetVar ("/Settings/AL Client/AL Dll" , "C:\\ti\\mmwave_studio_02_00_00_02\\mmWaveStudio\\RunTime\\SAL.dll") [18:40:25] RSTD.SetVar ("/Settings/Clients/Client 0/GuiDll" , "") [18:40:25] RSTD.SetVar ("/Settings/AutoUpdate/Enabled" , "TRUE") [18:40:25] RSTD.SetVar ("/Settings/AutoUpdate/Interval" , "1") [18:40:25] RSTD.SetVar ("/Settings/Monitors/UpdateDisplay" , "TRUE") [18:40:25] RSTD.SetVar ("/Settings/Monitors/OneClickStart" , "TRUE") [18:40:25] RSTD.SetVar ("/Settings/Automation/Automation Mode" , "false") [18:40:25] RSTD.Transmit("/") [18:40:25] RSTD.SaveSettings(): Settings saved to "C:\Users\S-Vec\AppData\Roaming\RSTD\config.xml" [18:40:25] RSTD.Build() [18:40:25] RSTD.SaveSettings(): Settings saved to "C:\Users\S-Vec\AppData\Roaming\RSTD\config.xml" [18:40:25] RSTD.Transmit("/") [18:40:25] RSTD.AL_Build() [18:40:25] RSTD.AL_LoadXml() [18:40:25] RSTD.Transmit("/") [18:40:25] RSTD.AL_Init() [18:40:25] RSTD.Clients_Build() [18:40:25] GM: Init [18:40:25] GM: Loaded 'C:\ti\mmwave_studio_02_00_00_02\mmWaveStudio\Clients\\LabClient.dll' [18:40:25] GM: 1 Guest (s) init [18:40:25] GM: 1 Module(s) init [18:40:25] GM: 2 Tab (s) init [18:40:25] RSTD.Client_LoadXml() [18:40:25] [RadarAPI]: Starting Matlab Engine.. [18:40:28] [RadarAPI]: Matlab Engine Started! [18:40:30] [RadarAPI]: ar1.LoadSettings('C:\Users\S-Vec\AppData\Roaming\RSTD\ar1gui.ini') [18:40:30] TESTING = false [18:40:30] [18:40:30] ***Script completed successfully.*** [18:40:33] [RadarAPI]: Opening Gpio Control Port() [18:40:33] [RadarAPI]: Status: Passed [18:40:34] [RadarAPI]: Opening Board Control Port() [18:40:34] [RadarAPI]: Status: Passed [18:40:35] [RadarAPI]: ar1.FullReset() [18:40:35] [RadarAPI]: Status: Passed [18:40:36] [RadarAPI]: Closing Board Control Port() [18:40:36] [RadarAPI]: Status: Passed [18:40:36] [RadarAPI]: Closing Gpio Control Port() [18:40:36] [RadarAPI]: Status: Passed [18:40:36] [RadarAPI]: ar1.SOPControl(2) [18:40:36] [RadarAPI]: Status: Passed [18:40:37] [RadarAPI]: ar1.frequencyBandSelection("77G") [18:40:39] [RadarAPI]: RS232 is not connected ..!!!! [18:40:49] [RadarAPI]: ar1.Connect(5,921600,1000) [18:40:51] [RadarAPI]: Warning: Connected with baudrate 115200 [18:40:52] [RadarAPI]: Warning: Disconnected existing BaudRate [18:40:53] [RadarAPI]: Warning: Trying to connect with baudrate 921600 [18:40:54] [RadarAPI]: ar1.Calling_IsConnected() [18:40:55] [RadarAPI]: ar1.SelectChipVersion("AR1243") [18:40:55] [RadarAPI]: Status: Passed [18:40:55] [RadarAPI]: ar1.SelectChipVersion("XWR1443") [18:40:55] [RadarAPI]: Status: Passed [18:40:55] Device Status : XWR1443/QM/SOP:2/ES:3 [18:40:56] [RadarAPI]: ar1.SelectChipVersion("AR1243") [18:40:56] [RadarAPI]: Status: Passed [18:40:56] [RadarAPI]: ar1.SelectChipVersion("XWR1443") [18:40:56] [RadarAPI]: Status: Passed [18:40:56] Device Status : XWR1443/QM/SOP:2/ES:3 [18:40:56] [RadarAPI]: ar1.SaveSettings('C:\Users\S-Vec\AppData\Roaming\RSTD\ar1gui.ini') [18:40:58] [RadarAPI]: ar1.ReadRegister(0xffffe214, 0, 31) [18:40:58] [RadarAPI]: ar1.ReadRegister(0xffffe210, 0, 31) [18:40:58] [RadarAPI]: ar1.ReadRegister(0xffffe218, 0, 31) [18:40:58] [RadarAPI]: ar1.DownloadBSSFw("C:\\ti\\mmwave_studio_02_00_00_02\\mmWaveStudio\\Scripts\\..\\..\\rf_eval_firmware\\radarss\\xwr12xx_xwr14xx_radarss.bin") [18:40:59] [RadarAPI]: Downloading BSS Patch RPRC Binary.. [18:41:00] [RadarAPI]: ar1.GetBSSFwVersion() [18:41:00] [RadarAPI]: BSSFwVersion:(02.00.00.01 (05/10/17)) [18:41:01] [RadarAPI]: ar1.GetBSSPatchFwVersion() [18:41:01] [RadarAPI]: BSSPatchFwVersion:(01.02.00.03 (24/10/18)) [18:41:01] BSS FW Download Success [18:41:03] [RadarAPI]: ar1.DownloadMSSFw("C:\\ti\\mmwave_studio_02_00_00_02\\mmWaveStudio\\Scripts\\..\\..\\rf_eval_firmware\\masterss\\xwr12xx_xwr14xx_masterss.bin") [18:41:04] [RadarAPI]: Downloading MSS RPRC Binary.. [18:41:07] MSS FW Download Success [18:41:09] [RadarAPI]: ar1.PowerOn(0, 1000, 0, 0) [18:41:09] [RadarAPI]: Status: Passed [18:41:09] MSS power up done async event received! [18:41:09] Power On Success [18:41:10] [RadarAPI]: ar1.RfEnable() [18:41:10] [RadarAPI]: Status: Passed [18:41:10] BSS power up done async event received! [18:41:11] [RadarAPI]: ar1.GetBSSFwVersion() [18:41:11] [RadarAPI]: BSSFwVersion:(02.00.00.01 (05/10/17)) [18:41:12] [RadarAPI]: ar1.GetBSSPatchFwVersion() [18:41:12] [RadarAPI]: BSSPatchFwVersion:(01.02.00.03 (24/10/18)) [18:41:12] RF Enable Success [18:41:13] [RadarAPI]: ar1.ChanNAdcConfig(1, 1, 0, 1, 1, 1, 1, 2, 1, 0) [18:41:13] [RadarAPI]: Status: Passed [18:41:13] ChanNAdcConfig Success [18:41:14] [RadarAPI]: ar1.LPModConfig(0, 0) [18:41:14] [RadarAPI]: Status: Passed [18:41:14] Regualar mode Cfg Success [18:41:16] [RadarAPI]: ar1.RfInit() [18:41:16] RF Init async event received! [18:41:16] [RadarAPI]: Time stamp, Temperture: 5972,30; APLL Status, Update: 1, 0; SynthVCO1 Status, Update: 1, 1; SynthVCO2 Status, Update: 1, 1; LODist Status, Update: 1, 1; RxADCDC Status, Update: 1, 1; HPFcutoff Status, Update: 1, 1; LPFcutoff Status, Update: 1, 1; PeakDetector Status, Update: 1, 1; TxPower Status, Update: 1, 1; RxGain Status, Update: 1, 1; TxPhase Status, Update: 0, 0; RxIQMM Status, Update: 1, 1; [18:41:16] [RadarAPI]: Status: Passed [18:41:16] RfInit Success [18:41:17] [RadarAPI]: ar1.DataPathConfig(1, 1, 0) [18:41:17] [RadarAPI]: Status: Passed [18:41:17] DataPathConfig Success [18:41:18] [RadarAPI]: ar1.LvdsClkConfig(1, 1) [18:41:18] [RadarAPI]: Status: Passed [18:41:18] LvdsClkConfig Success [18:41:19] [RadarAPI]: ar1.LVDSLaneConfig(0, 1, 1, 1, 1, 1, 0, 0) [18:41:19] [RadarAPI]: Status: Passed [18:41:19] LVDSLaneConfig Success [18:41:20] [RadarAPI]: ar1.ProfileConfig(0, 77, 100, 6, 60, 0, 0, 0, 0, 0, 0, 29.982, 0, 256, 10000, 0, 0, 30) [18:41:20] [RadarAPI]: Status: Passed [18:41:20] ProfileConfig Success [18:41:21] [RadarAPI]: ar1.ChirpConfig(0, 0, 0, 0, 0, 0, 0, 1, 1, 0) [18:41:21] [RadarAPI]: Status: Passed [18:41:21] ChirpConfig Success [18:41:22] Test Source Already Disabled...!!! [18:41:22] [RadarAPI]: Status: Passed [18:41:22] [RadarAPI]: ar1.FrameConfig(0, 0, 8, 128, 40, 0, 1) [18:41:22] [RadarAPI]: Status: Passed [18:41:22] FrameConfig Success [18:41:23] [RadarAPI]: ar1.SelectCaptureDevice("DCA1000") [18:41:24] [RadarAPI]: passed [18:41:24] SelectCaptureDevice Success [18:41:25] [RadarAPI]: StatusDCCard Event Registered [18:41:25] [RadarAPI]: Status: Passed [18:41:25] [RadarAPI]: ar1.CaptureCardConfig_EthInit("192.168.33.30", "192.168.33.180", "12:34:56:78:90:12", 4096, 4098) [18:41:25] [RadarAPI]: Status: Passed [18:41:25] [RadarAPI]: SYSTEM_CONNECT_CMD_CODE Async event recieved(9) [18:41:25] [RadarAPI]: ConnectRFDCCard Status: Passed [18:41:25] [RadarAPI]: Status: Passed [18:41:25] [RadarAPI]: READ_FPGA_VERSION_CMD_CODE event recieved(14) [18:41:25] [RadarAPI]: Status: Passed [18:41:25] CaptureCardConfig_EthInit Success [18:41:26] [RadarAPI]: ar1.ConfigureRFDCCardMode(1, 1, 1, 2, 3, 30) [18:41:26] [RadarAPI]: Status: Passed [18:41:26] [RadarAPI]: CONFIG_FPGA_GEN_CMD_CODE Async event recieved(3) [18:41:26] CaptureCardConfig_Mode Success [18:41:27] [RadarAPI]: ar1.CaptureCardConfig_PacketDelay(25) [18:41:27] [RadarAPI]: Status: Passed [18:41:27] [RadarAPI]: CONFIG_PACKET_DATA_CMD_CODE Async event recieved(11) [18:41:27] CaptureCardConfig_PacketDelay Success [18:41:28] [RadarAPI]: ar1.CaptureCardConfig_StartRecord("C:\\ti\\mmwave_studio_02_00_00_02\\mmWaveStudio\\Scripts\\..\\PostProc\\adc_data.bin", 1) [18:41:28] [RadarAPI]: Status: Passed [18:41:28] [RadarAPI]: RECORD_START_CMD_CODE Async event recieved(5) [18:41:29] [RadarAPI]: ar1.StartFrame() [18:41:29] [RadarAPI]: Status: Passed [18:41:29] Frame start async event received! [18:41:29] Frame End async event received! [18:41:29] [RadarAPI]: Frame Ended [18:41:31] Please wait for a few seconds for Packet reorder utility processing .....!!!! [18:41:31] [RadarAPI]: Packet Reorder Utility Started...please wait... [18:41:31] [RadarAPI]: ar1.PacketReorderZeroFill("C:\\ti\\mmwave_studio_02_00_00_02\\mmWaveStudio\\Scripts\\..\\PostProc\\adc_data_Raw_0.bin", "C:\\ti\\mmwave_studio_02_00_00_02\\mmWaveStudio\\Scripts\\..\\PostProc\\adc_data.bin", "C:\\ti\\mmwave_studio_02_00_00_02\\mmWaveStudio\\Scripts\\..\\PostProc\\pktlogfile.txt") [18:41:31] [RadarAPI]: STS_RECORD_COMPLETED Async event recieved(8) [18:41:31] [RadarAPI]: ar1.CaptureCardConfig_StopRecord() [18:41:31] [RadarAPI]: Status: Passed [18:41:31] [RadarAPI]: RECORD_STOP_CMD_CODE Async event recieved(6) [18:41:36] [RadarAPI]: Packet Reorder Utility process completed! [18:41:36] Reordering required : NO [18:41:36] Packet loss : NO [18:41:36] Number of packets received : 2879 [18:41:36] Number of zero filled packets : 0 [18:41:36] Number of zero filled bytes : 0 [18:41:46] Packet reorder utility processing done.....!!!! [18:41:46] Please wait for a few seconds for matlab post processing .....!!!! [18:41:46] [RadarAPI]: ar1.StartMatlabPostProc("C:\\ti\\mmwave_studio_02_00_00_02\\mmWaveStudio\\Scripts\\..\\PostProc\\adc_data.bin") [18:41:56] [18:41:56] ***Script completed successfully.***
2. Ran the MATLAB function provided by calling: readDCA1000("C:\ti\mmwave_studio_02_00_00_02\mmWaveStudio\PostProc\adc_data.bin") and got this error from MATLAB:
Error using reshape Product of known dimensions, 8, not divisible into total number of elements, 2095431. Error in readDCA1000 (line 30) adcData = reshape(adcData, numLanes*2, []); Error in cwins_process_adc (line 1) readDCA1000("C:\ti\mmwave_studio_02_00_00_02\mmWaveStudio\PostProc\adc_data.bin");
I put a breakpoint before the ''reshape' and here's the screenshot:
I know that if the function successfully returns, the number of ADC samples should be = 256 (samples/chirp) * 8 frames * 128 (chirps/frame). But the reshape call breaks everything before that happens, because the number of adcData is 2095431 which is not divisible by 8.
Do I need to change the parameters in the provided MATLAB function? I'm pretty sure that I'm using 16-bit ADC and the data is complex1x as you can see from Lua shell output.
I'm really at my wit's end on how to fix this. I would really appreciate some insight.
Many thanks in advance!
Ziheng