root / host / docs / sync.rst @ ae1ebd8a
History | View | Annotate | Download (8.15 KB)
| 1 |
======================================================================== |
|---|---|
| 2 |
UHD - Synchronization Application Notes |
| 3 |
======================================================================== |
| 4 |
|
| 5 |
.. contents:: Table of Contents |
| 6 |
|
| 7 |
The following application notes explain how to synchronize multiple USRPs |
| 8 |
with the goal of transmitting or receiving time-aligned samples for MIMO |
| 9 |
or other applications requiring multiple USRPs operating synchronously. |
| 10 |
|
| 11 |
**Note:** The following synchronization notes do not apply to USRP1, |
| 12 |
which does not support the advanced features available in newer products. |
| 13 |
|
| 14 |
------------------------------------------------------------------------ |
| 15 |
Common reference signals |
| 16 |
------------------------------------------------------------------------ |
| 17 |
USRPs take two reference signals in order to synchronize clocks and time: |
| 18 |
|
| 19 |
* A 10MHz reference to provide a single frequency reference for both devices. |
| 20 |
* A pulse-per-second (1PPS) to synchronize the sample time across devices. |
| 21 |
* Or, the MIMO cable transmits an encoded time message from one device to another. |
| 22 |
|
| 23 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 24 |
PPS and 10 MHz reference signals |
| 25 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 26 |
Connect the front panel SMA connectors to the reference sources. |
| 27 |
Typically, these signals are provided by an external GPSDO. |
| 28 |
However, some USRP models can provide these signals from an optional internal GPSDO. |
| 29 |
|
| 30 |
:: |
| 31 |
|
| 32 |
usrp->set_clock_source("external");
|
| 33 |
usrp->set_time_source("external");
|
| 34 |
|
| 35 |
**Note:** |
| 36 |
Sometimes the delay on the PPS signal will cause it to arrive inside the timing |
| 37 |
margin the FPGA sampling clock, causing PPS edges to be separated by less or |
| 38 |
more than 100 million cycles of the FPGA clock. If this is the case, |
| 39 |
you can change the edge reference of the PPS signal with this special parameter: |
| 40 |
|
| 41 |
:: |
| 42 |
|
| 43 |
usrp->set_time_source("_external_");
|
| 44 |
|
| 45 |
**Note2:** |
| 46 |
For users generating their own signals for the external SMA connectors, |
| 47 |
the pulse-per-second should be clocked from the 10MHz reference. |
| 48 |
See the application notes for your device for specific signal requirements. |
| 49 |
|
| 50 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 51 |
MIMO cable reference signals |
| 52 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 53 |
Use the MIMO expansion cable to share reference sources (USRP2 and N-Series). |
| 54 |
The MIMO cable can be used synchronize one device to another device. |
| 55 |
Users of the MIMO cable may use method 1 to synchronize multiple pairs of devices. |
| 56 |
|
| 57 |
:: |
| 58 |
|
| 59 |
usrp->set_clock_source("mimo");
|
| 60 |
usrp->set_time_source("mimo");
|
| 61 |
|
| 62 |
------------------------------------------------------------------------ |
| 63 |
Synchronizing the device time |
| 64 |
------------------------------------------------------------------------ |
| 65 |
The purpose of the PPS signal is to synchronously latch a time into the device. |
| 66 |
You can use the set_time_next_pps(...) function to either initialize the sample time to 0, |
| 67 |
or to an absolute time such as GPS time or UTC time. |
| 68 |
For the purposes of synchronizing devices, |
| 69 |
it doesn't matter what time you initialize to when using set_time_next_pps(...). |
| 70 |
|
| 71 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 72 |
Method 1 - poll the USRP time registers |
| 73 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 74 |
One way to initialize the PPS edge is to poll the "last PPS" time from the USRP device. |
| 75 |
When the last PPS time increments, the user can determine that a PPS has occurred: |
| 76 |
|
| 77 |
:: |
| 78 |
|
| 79 |
const uhd::time_spec_t last_pps_time = usrp->get_time_last_pps(); |
| 80 |
while (last_pps_time == usrp->get_time_last_pps()){
|
| 81 |
//sleep 100 milliseconds (give or take) |
| 82 |
} |
| 83 |
usrp->set_time_next_pps(uhd::time_spec_t(0.0)); |
| 84 |
|
| 85 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 86 |
Method 2 - query the GPSDO for seconds |
| 87 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 88 |
Most GPSDO can be configured to output a NMEA string over the serial port once every PPS. |
| 89 |
The user can wait for this string to determine the PPS edge, |
| 90 |
and the user can also parse this string to determine GPS time: |
| 91 |
|
| 92 |
:: |
| 93 |
|
| 94 |
//call user's function to wait for NMEA message... |
| 95 |
usrp->set_time_next_pps(uhd::time_spec_t(0.0)); |
| 96 |
|
| 97 |
-- OR -- |
| 98 |
|
| 99 |
//call user's function to wait for NMEA message... |
| 100 |
//call user's function to parse the NMEA message... |
| 101 |
usrp->set_time_next_pps(uhd::time_spec_t(gps_time+1)); |
| 102 |
|
| 103 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 104 |
Method 3 - internal GPSDO |
| 105 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 106 |
USRPs with internal GPSDOs properly configured will automatically |
| 107 |
configure themselves to set the VITA time to current UTC time. |
| 108 |
See the `GPSDO Application Notes <./gpsdo.html>`_ for more details. |
| 109 |
|
| 110 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 111 |
Method 4 - MIMO cable |
| 112 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 113 |
A USRP can synchronize its time to another USRP via the MIMO cable. |
| 114 |
Unlike the other methods, this does not use a real "pulse per second". |
| 115 |
Rather, the USRP sends an encoded time message over the MIMO cable. |
| 116 |
The slave device will automatically synchronize to the time on the master device. |
| 117 |
See the `MIMO Cable Application Notes <./usrp2.html#using-the-mimo-cable>`_ for more detail. |
| 118 |
|
| 119 |
------------------------------------------------------------------------ |
| 120 |
Synchronizing channel phase |
| 121 |
------------------------------------------------------------------------ |
| 122 |
|
| 123 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 124 |
Align CORDICs in the DSP |
| 125 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 126 |
In order to achieve phase alignment between USRPs, the CORDICS in both |
| 127 |
devices must be aligned with respect to each other. This is easily achieved |
| 128 |
by issuing stream commands with a time spec property, which instructs the |
| 129 |
streaming to begin at a specified time. Since the devices are already |
| 130 |
synchronized via the 10MHz and PPS inputs, the streaming will start at exactly |
| 131 |
the same time on both devices. The CORDICs are reset at each start-of-burst |
| 132 |
command, so users should ensure that every start-of-burst also has a time spec set. |
| 133 |
|
| 134 |
For receive, a burst is started when the user issues a stream command. This stream command should have a time spec set: |
| 135 |
:: |
| 136 |
|
| 137 |
uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); |
| 138 |
stream_cmd.num_samps = samps_to_recv; |
| 139 |
stream_cmd.stream_now = false; |
| 140 |
stream_cmd.time_spec = time_to_recv; |
| 141 |
usrp->issue_stream_cmd(stream_cmd); |
| 142 |
|
| 143 |
For transmit, a burst is started when the user calls send(). The metadata should have a time spec set: |
| 144 |
:: |
| 145 |
|
| 146 |
uhd::tx_metadata_t md; |
| 147 |
md.start_of_burst = true; |
| 148 |
md.end_of_burst = false; |
| 149 |
md.has_time_spec = true; |
| 150 |
md.time_spec = time_to_send; |
| 151 |
|
| 152 |
//send a single packet |
| 153 |
size_t num_tx_samps = tx_streamer->send(buffs, samps_to_send, md); |
| 154 |
|
| 155 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 156 |
Align LOs in the front-end (SBX/WBX + N-Series) |
| 157 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 158 |
Using timed commands, multiple frontends can be tuned at a specific time. |
| 159 |
This timed-tuning ensures that the phase offsets between VCO/PLL chains |
| 160 |
will remain constant after each re-tune. See notes below: |
| 161 |
|
| 162 |
* There is a random phase offset between any two frontends |
| 163 |
* This phase offset is different for different LO frequencies |
| 164 |
* This phase offset remains constant after retuning |
| 165 |
|
| 166 |
* Due to divider, WBX phase offset will be randomly +/- 180 deg after re-tune |
| 167 |
|
| 168 |
* This phase offset will drift over time due to thermal and other characteristics |
| 169 |
* Periodic calibration will be necessary for phase-coherent applications |
| 170 |
|
| 171 |
Code snippet example, tuning with timed commands: |
| 172 |
:: |
| 173 |
|
| 174 |
//we will tune the frontends in 100ms from now |
| 175 |
uhd::time_spec_t cmd_time = usrp->get_time_now() + uhd::time_spec_t(0.1); |
| 176 |
|
| 177 |
//sets command time on all devices |
| 178 |
//the next commands are all timed |
| 179 |
usrp->set_command_time(cmd_time); |
| 180 |
|
| 181 |
//tune channel 0 and channel 1 |
| 182 |
usrp->set_rx_freq(1.03e9, 0/*ch0*/); |
| 183 |
usrp->set_rx_freq(1.03e9, 1/*ch1*/); |
| 184 |
|
| 185 |
//end timed commands |
| 186 |
usrp->set_clear_time(); |
| 187 |
|
| 188 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 189 |
Align LOs in the front-end (others) |
| 190 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 191 |
After tuning the RF front-ends, |
| 192 |
each local oscillator may have a random phase offset due to the dividers |
| 193 |
in the VCO/PLL chains. This offset will remain constant after the device |
| 194 |
has been initialized, and will remain constant until the device is closed |
| 195 |
or re-tuned. This phase offset is typically removed by the user in MIMO |
| 196 |
applications, using a training sequence to estimate the offset. It will |
| 197 |
be necessary to re-align the LOs after each tune command. |