Main Content

getRadioTime

Current radio time

Since R2025a

Add-On Required: This feature requires the Wireless Testbench™ Support Package for NI™ USRP™ Radios add-on.

Description

time = getRadioTime(radio) returns the current time time in the time registers of the radio associated with the radio object radio.

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.

example

Examples

collapse all

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.

time = getRadioTime(radio)
time = 
0.0429

Since the call to the getRadioTime function is the first time you have connected to your radio, the radio time value is very small. Call the function again after 1 second.

pause(1)
time2 = getRadioTime(radio)
time2 = 
1.0656

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.

Input Arguments

collapse all

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

collapse all

The current radio time in seconds, returned as a positive numeric scalar.

Data Types: double

Version History

Introduced in R2025a