Most USRPs support timed commands, which allow execution of commands at a specific time. Timed commands fall into one of two categories: Stream Commands and General Timed Commands.
All USRPs (with the exception of the USRP1) allow specifying times for stream commands. This allows capturing/receiving and transmitting samples at specific times.
For receiving samples, simply provide a time specification to the stream command. Example:
For transmitting samples, simply attach a timestamp to the outgoing data. The USRP will buffer the data until the requested time has been reached. Example:
There are other commands that can also be executed in a timed fashion, including, but not limited to:
This can be used to implement features such as frequency hopping, AGC (automatic gain control) loops, bit-banging serial protocols over GPIO lines, etc.
Unlike timed stream commands, these timed commands are not atomic with respect to setting the command time. Instead, the command time needs to be set for all subsequent commands. Example:
Every command that is submitted to the USRP is placed into a command queue, and commands in such a queue are always executed in the order they are received.
When a command has a command time attached to it, the command is held in the queue until the desired time has been reached. This has consequences:
Because of this mode of operation, "late" commands (commands with a command time that is in the past) are executed immediately.
In RFNoC devices, each RFNoC block has its own command queue. Older devices have fewer (or only one command queue).
When the command queue is full, UHD will block until the USRP has signaled that there is space for more commands. That can cause timed commands to reach the FPGA after their desired execution time.
The choice of timed commands which can be executed in a timed fashion depend entirely on the underlying device, and for RFNoC devices, depend also on the RFNoC blocks receiving the commands. Typical RF configuration commands, such as setting gain, frequency, or antenna ports are often capable of being timed, but not for all devices. Refer to the individual device manual pages for more details.
When a command time is requested in software, the command time (stored as a uhd::time_spec_t) will be converted into an integer value (a 64-bit tick count value). This conversion will quantize the command time, potentially causing an offset from the desired value.
UHD will quantize the command time according to the tick rate of the RFNoC block or device (in case of pre-RFNoC USRPs). For radio blocks, and commands that affect the radio (including stream commands, and RF controls) this tick rate is equal to the master clock rate. For example, if a USRP X310 is operating at a 200 MHz master clock rate, then the timing resolution of the timed commands is \( 1/200 MHz = 5 ns \). Specifying a command time at 2.000000001 s in this case would be rounded to a command time at 2s.
Additionally, devices may physically operate at a lower clock frequency. For example, the USRP X440, when operating at a master clock rate of 500 MHz, internally uses a 62.5 MHz clock (operating at 8 samples per clock edge). The command processor can only compare the command time with the current time every 16 ns, resulting in a further quantization of effective command times.