Main Content

Time Synchronize Operations on NI USRP Radios

Since R2025a

Wireless Testbench™ provides interfaces that allow you to control the precise timing of operations on NI™ USRP™ radios. These interfaces enable you to synchronize operations on a single radio, or across multiple radios.

To time synchronize operations on your radio, or across multiple radios, you need to understand the following concepts:

  • How the radio uses a reference clock and a time reference to keep time.

  • How to interact with the radio time.

  • How to use the radio time to schedule and synchronize commands and streaming operations.

This topic provides an overview of these concepts.

For information about phase synchronization, see Phase Synchronize Operations on NI USRP Radios.

Clock and Time References

NI USRP radios synchronize their clocks and time using a 10 MHz reference clock and a pulse per second (PPS) signal respectively. By default, the radio uses an internally generated clock reference and time reference signal. To time synchronize operations across multiple radios, you must first synchronize the clock and time references.

If the radios are physically close enough to connect cables between them, you can synchronize them by providing a single clock and time reference from a clock distribution module. Alternatively, some radios enable you to export the internally generated references, which you can provide to other radios.

To synchronize radios without using physical connections and your radio has an onboard GPS disciplined oscillator (GPSDO), you can use the GPSDO as the clock and time reference. The GPSDO must be locked to the GPS constellation to facilitate clock and time synchronization.

Synchronize Radios Using Clock Distribution Module

  1. Use SMA cables to provide a single clock and time reference to your radios. You can use a clock distribution module such as the OctoClock CDA-2990. The diagram shows an example.

  2. Use the Radio Setup wizard to connect, set up, and save a radio setup configuration for each of your radios. In the Configure Radio step, select the option that enables you to configure the synchronization options. Use the dropdown menus to set the clock and time sources to external. Save a radio setup configuration.

  3. Use the radioConfigurations function to create a radio object for your radio setup configuration.

  4. Use the referenceLockedStatus function to verify that your radios have locked to the shared reference clock.

Synchronize Radios by Exporting References

  1. Use SMA cables to connect the exported references from one radio to your other radios. The diagram shows an example.

  2. Use the Radio Setup wizard to connect, set up, and save a radio setup configuration for each of your radios. In the Configure Radio step, select the option that enables you to configure the synchronization options. For radios that are connected to external references, use the dropdown menus to set the clock and time sources to external. Save a radio setup configuration.

  3. Use the radioConfigurations function to create a radio object for your radio setup configuration.

  4. Use the referenceLockedStatus function to verify that your radios have locked to the shared reference clock.

Synchronize Radios using GPSDO

  1. Use the Radio Setup wizard to connect, set up, and save a radio setup configuration for each of your radios. In the Configure Radio step, select the option that enables you to configure the synchronization options. Use the dropdown menus to set the clock and time sources to GPSDO. Save a radio setup configuration.

  2. Use the radioConfigurations function to create a radio object for your radio setup configuration.

  3. Use the referenceLockedStatus function to verify that your radios have locked to the GPSDO reference clock.

  4. Use the gpsLockedStatus function to verify that the GPSDOs have locked to the GPS constellation.

Radio Time

To enable the precise timing of operations, NI USRP radios use their clock and time references to keep time, which they store in time registers. The current time in the time registers is referred to as the radio time.

To read the current radio time from the time registers, use the getRadioTime function with a radio object. To create a radio object, use the radioConfigurations function with a radio setup configuration you saved using the Radio Setup wizard.

Unless you set the radio time to a specific value by using the setTimeNextPPS function, or you take an action that causes the radio time to reset, the radio time is the elapsed time since you connected to your radio, which happens in one of the following scenarios:

  • You use a radio object function.

  • You create a baseband application object and specify the Preload name-value argument is true.

  • You use the capture or transmit function with a baseband or detector application object that you created without specifying the Preload name-value argument as true.

  • You call the setup function on a usrp System object™.

Note

Updating the following object properties causes the radio time to reset:

  • Properties that select radio antennas, such as Antennas, TransmitAntennas, ReceiveAntennas, DUTInputAntennas, or DUTOutputAntennas.

  • The SampleRate property, if the new sample rate is derived from a different master clock rate. For more information on how the baseband sample rate is derived, see Baseband Sample Rate in NI USRP Radios.

To ensure that any time values you set are relative to the current radio time, make changes to these properties only before you use the getRadioTime function to get the current radio time.

Synchronize Radio Time on Multiple Radios

Synchronize the radio time on two NI USRP radios that share a clock and time source.

Create Radio Objects

Create a radio object for each radio, specifying a radio setup configuration previously saved using the Radio Setup wizard.

radio1 = radioConfigurations("MyRadio")
radio1 = 
  N320 with properties:

           Name: "MyRadio"
       Hardware: "USRP N320"

      IPAddress: "192.168.20.2"

    ClockSource: "external"
     TimeSource: "external"

       LOSource: "internal"

radio2 = radioConfigurations("MyRadio2")
radio2 = 
  N321 with properties:

             Name: "MyRadio2"
         Hardware: "USRP N321"

        IPAddress: "192.168.21.2"

      ClockSource: "external"
       TimeSource: "external"

         LOSource: "internal"
       LOExported: 0
    LODistributed: 0

Create and Configure Application Object or usrp System Object

After you create your radio objects and before you synchronize the radio time, you should fully configure your radio. Connecting to the radio to load an application or update an RF property resets the radio time.

To configure one or both of your radios using a baseband or detector application object, use the corresponding radio object as the radio input argument when you create the object. Additionally, specify the Preload name-value argument as true and specify all RF properties using the PropertyName=Value syntax. The commented code shows an example.

% bbtrx = basebandTransceiver(radio, ...
%     Preload=true, ...
%     TransmitDataType="double", ...
%     TransmitAntennas="RFA:TX/RX", ...
%     TransmitCenterFrequency=2.4e9, ...
%     TransmitRadioGain=10, ...
%     CaptureAntennas="RFA:RX2", ...
%     CaptureCenterFrequency=2.4e9, ...
%     CaptureRadioGain=10);

To connect to and control one or both of your radios with a custom FPGA image that you created by using the Target NI USRP Radios Workflow, use the corresponding radio object as the radio input argument when you create a usrp System object. Then, run all the code required to configure your radio, your DUT, and the interfaces between them, up to the point where you call the setup function on your usrp System object. The commented code shows an example.

% device = usrp(radio, ...
%     SampleRate=250e6, ...
%     TransmitAntennas="DB0:RF0:TX/RX0", ...
%     TransmitDDRAllocation=1000);
% programFPGA(device,"myBitstream.bit","myDeviceTree.dts");
% describeFPGA(device,"ModelName_wthandoffinfo.mat"); 
% dut = fpga(device);
% addRFNoCRegisterInterface(dut, ...
%     "InterfaceID","DUTName", ...
%     "RFNoCBlock","0/DUTName#0");
% DUTPort_Read_Register = hdlcoder.DUTPort("Read_Register", ...
%     "Direction","OUT", ...
%     "DataType","int16", ...
%     "IsComplex",false, ...
%     "Dimension",[1 1], ...
%     "IOInterface","DUTName", ...
%     "IOInterfaceMapping",1);
% mapPort(dut,DUTPort_Read_Register);
% setup(device);

You can now proceed to synchronize the radio time.

Synchronize Radio Time

To synchronize both radios to use a common radio time, set the radio time on both radios to the same value on the next PPS signal. First, use the getTimeLastPPS function to get the time that the last PPS occurred.

tLastPPS = getTimeLastPPS(radio1);

When a PPS signal is detected, you have one second to set a new radio time. Check for a new signal every 0.1 seconds, then use the setTimeNextPPS function to set the radio time on both radios to zero.

while tLastPPS == getTimeLastPPS(radio1)
    pause(0.1)
end
setTimeNextPPS(radio1,0);
setTimeNextPPS(radio2,0);

To verify that the radio time is synchronized, verify that the last PPS signal occurred at the same time on both radios.

pause(1.1)
tLastPPS1 = getTimeLastPPS(radio1);
tLastPPS2 = getTimeLastPPS(radio2);
isequal(tLastPPS1,tLastPPS2)
ans = logical
   0

If the radio time synchronization is unsuccessful, try running this code section again.

Synchronize Streaming Operations

You can schedule and synchronize streaming operations using a baseband application object or a usrp System object by specifying the start time of the streaming operation.

Synchronize Streaming Operations using Baseband Application Objects

You can specify the start time of streaming operations that use a basebandReceiver, basebandTransceiver, or basebandTransmitter application object.

  1. Create a radio object by calling the radioConfigurations function with a radio setup configuration you saved using the Radio Setup wizard.

  2. Create the application object, specifying the Preload name-value argument as true and all RF property values during object creation.

  3. If you are synchronizing the streaming operations across multiple radios, synchronize the radio time using one of the methods outlined previously. If you are synchronizing operations on a single radio, proceed to the next step.

  4. Use the StartTime name-value argument when you call the transmit or capture function. Specify the start time relative to the current radio time, which you can read using the getRadioTime function.

For an example of how to schedule a single-shot transmission and a synchronized capture with a baseband transceiver, see the Transmit Once and Capture section in Loopback Transmit and Capture.

For an example of how to connect and time synchronize two radios and capture data, see Connect and Synchronize Multiple NI USRP Radios.

Synchronize Streaming Operations using usrp System object

You can specify the start time of streaming operations that use a usrp System object. First, create a radio object by calling the radioConfigurations function with a radio setup configuration you saved using the Radio Setup wizard.

  • To schedule a transmit operation, specify the StartTime name-value argument when you call the transmit function.

  • To schedule the start time for streaming samples from the radio, specify the StartTime name value argument when you call the System object as a function, or when you call the step function.

Specify the start time relative to the current radio time, which you can read using the getRadioTime function.

Synchronize RF Property Updates

Some NI USRP radios enable you to schedule changes to RF properties by setting the command time:

  1. Use the getRadioTime function to query the current radio time.

  2. Use the setCommandTime function to schedule a future time for updating RF properties on the radio.

  3. Make changes to any RF properties on your Wireless Testbench object or System object. For example, update the TransmitCenterFrequency and ReceiveCenterFrequency property on your basebandTransceiver object.

  4. Use the clearCommandTime function to clear the currently set command time.

When you set the command time to a future time and update an RF property on your object, the command is issued to the radio and added to the command queue. The radio executes the commands in the queue in a first in, first out order:

  • When a command arrives at the front of the queue, the radio executes the command at the specified command time.

  • If multiple commands in the queue carry the same command time, the radio executes the commands serially in the order that they were placed.

  • If a command arrives at the front of the queue with a command time that is in the past, the radio executes the command immediately.

Note

To capture data with a baseband application object when there are property updates scheduled in the command queue, specify the Background name-value argument as true when you call the capture function. When you capture data in the foreground, you block the queue.

To query the command time set on the radio, use the getCommandTime function.

To clear the command time set on the radio, use the clearCommandTime function. If no command time is set, the radio executes commands that set RF properties when they reach the front of the command queue.

For an example, see Schedule Synchronized Property Updates on Baseband Transceiver.

See Also

Tools

Functions

Objects

Topics