getTimeLastPPS
Add-On Required: This feature requires the Wireless Testbench™ Support Package for NI™ USRP™ Radios add-on.
Description
Examples
Create a radio object, specifying a radio setup configuration previously saved using the Radio Setup wizard.
radio = radioConfigurations("MyRadio");
Get the current radio time in seconds from the time registers on the radio. This function connects to the radio and resets the radio time.
getRadioTime(radio)
ans = 0.0423
Wait 5 seconds, then get the time that the last PPS signal occurred.
pause(5) tLastPPS = getTimeLastPPS(radio)
tLastPPS = 4.4874
When a PPS signal occurs, reset the radio time to zero.
setTimeNextPPS(radio,0);
Wait 1 second, then get the current radio time to confirm that the radio time has been reset.
pause(1) getRadioTime(radio)
ans = 0.6839
Since the radio time is less than 1 second, the radio time has been successfully reset.
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.
Input Arguments
Radio object, specified as a radio object that corresponds to a radio setup configuration you saved using the Radio Setup wizard.
To create a radio object, call the radioConfigurations
function with the name of your radio setup
configuration. For example, for a radio setup configuration named
MyRadio
, call radio =
radioConfigurations("MyRadio")
.
Output Arguments
The radio time that the last PPS signal occurred in seconds, returned as a positive numeric scalar.
For more information about radio time, see Radio Time.
Data Types: double
Version History
Introduced in R2025a
See Also
Functions
Objects
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)