MATLAB: How to set the clock and time references of USRP to external reference or to MIMO cable for the slave USRP

Communications Toolbox

I am using USRP2 and USRP N210 SDRs to build a MIMO system. Specifically, I am building an Rx antenna array for indoor wireless positioning using directional of arrival concept and USRP2 or USRP210 devices (Daughter board XCVR2450). I perform parallel computing as follows:
 
matlabpool open 2
pctRunOnAll('setupsdru')
spmd
switch (labindex)
case 1
[RxData1_temp_cell]=USRPRX1();
case 2
[RxData2_temp_cell]=USRPRX2();
end
end
Now, I want to configure the clock and time reference of USRP to external GPS source because all USRPs in the array should be synchronized. I want the USRP to get its references externally, or in case of using two USRPs, from MIMO cable (one master and one slave).

Best Answer

External clock reference for USRP radios is not directly supported. Also, data stream synchronization via the MIMO cable is not supported.
The following workaround may be useful to program both the Reference clock source and PPS clock source to be external. Please note that this is an undocumented workaround, and it may not work starting in R2014b.
Please note that R2013a onwards steps 1 and 5 are not required.
1) Edit the 'UsrpMaskMapiT.m' file. This file resides under the
'commusrp/usrp_uhd_mapi' directory in the USRP Support Package installation directory.
Edit line 55 to change 'setClockConfig' to 'setClockConfigFull'
2) Power up the USRP radio.
3) Connect the 10 MHz reference clock to the Reference Clock input (eg. +7dBm since wave).
4) Start MATLAB.
5) Click the "Add SDRu" shortcut which should be present in the root MATLAB window after installing the USRP Support Package.
If you are not using Simulink blocks, and are working from the MATLAB Command Window or writing a MATLAB script or function, you may skip steps 6 and 7.
6) Build or load the Simulink model with the USRP block.
7) Open the USRP block mask by double-clicking on the block. Then close the mask.
8) At the MATLAB Command Window, please enter the following commands:
 
h = UsrpMaskMapiT('192.168.10.2', BoardIdCapiEnumT.MboardId)
h.setClockConfig(CannedClockConfigCapiEnumT.External);
9) At this point the E LED on USRP2 should light steadily, indicating the
USRP2 has locked to the reference clock. If it flickers or is not lit,
check your reference. It may be off frequency or at an incorrect level.
10) Now, you can run your model, function or script. Note that, if you disconnect or power down the USRP radio, you must repeat steps 7 and 8.
If you skip step 7, the E LED may light up but you may not receive any data. If you would like to see the options or mix internal/external for ref/pps, modify step (8) to be:
 
h = UsrpMaskMapiT('192.168.10.2', BoardIdCapiEnumT.MboardId)
c = ClockConfigCapiT
c.refSource = RefSourceCapiEnumT.External
c.ppsSource = PPSSourceCapiEnumT.External
c.ppsPolarity = PPSPolarityCapiEnumT.Positive
h.setClockConfigFull(c);
You should be able to change from external clocking to internal clocking by shutting down MATLAB and restart it.
Related Question