Example Program Drafts

Showing results for 
Search instead for 
Did you mean: 

Record and Playback Demo With NI USRP


This document describes how to construct an RF record and playback demonstration using the NI USRP™ (Universal Software Radio Peripheral) platform. NI has a broad spectrum of RF hardware and software for record and playback applications to meet both cost and quality needs. This tutorial specifically covers the use of NI USRP as an affordable small form factor solution. You can use higher fidelity NI PXI solutions for the same application to achieve wider bandwidths and significantly improve signal quality. The following examples include code specific to each section to help you integrate record and playback systems.

1. RF Record and Playback Systems

This tutorial highlights some specific software and hardware implementations to help you maximize the correlation between p(t) and s(t). Even if some of the parameters are applicable to many RF systems, this example refers to the following two systems:


1.jpgFigure 1. The NI USRP-2920 radio transceiver incorporates a direct conversion transmitter and receiver that operate from 50 MHz to 2.2 GHz and connects to a host PC via a 1 Gigabit Ethernet port. The theoretical maximum sampling rate of the system is 25 MS/s, producing a usable bandwidth of 20 MHz.


 Figure 2. The NI USRP-2921 radio transceiver incorporates a direct conversion transmitter and receiver that operate in the 2.4–2.5 GHz and 4.95.9 GHz ranges and connects to a host PC via a 1 Gigabit Ethernet port. The theoretical maximum sampling rate of the system is 25 MS/s, producing a usable bandwidth of 20 MHz. 


2. Background Reference

The ideal RF record and playback system is modeled by

        p(t) = r(t) = s(t)


        s(t) is the signal you are trying to record

        r(t) is the recorded signal

        p(t) is the playback signal

Because no system is perfect, the previous equation can be expressed as

        p(t) = r(t) + ns(t) = s(t) + n(t) + i(t)


        ns(t) is the system noise (acquisition and generation device)

        n(t) is the environment noise

        i(t) is the environment interference

Later in the tutorial, you will refer back to these relationships.


3.  Recording

Maximizing Dynamic Range

You can maximize the dynamic range of the NI USRP-292x series by applying gain or attenuation to ensure that the input signal uses all 14 bits of the analog-to-digital converter (ADC). The input range of the ADC is 1 Vpp. The input power to the ADC in the USRP receive chain is nonlinear and varies by frequency. The NI-USRP driver provides a gain setting of 0 dB to 30 dB of amplification.

When recording the signal, increase the gain as much as possible to use the full dynamic range of the ADC without clipping. Since I and Q are each scaled to 1 in the driver, the ideal scaling should result in a magnitude near 1. Calculate the complex magnitude using the equation form.gif. This is not a trivial task for modulated and burst signals because the power varies in time. Any prior knowledge of the input signal is helpful in adjusting the gain to optimize the dynamic range of the ADC. However, the target signal may be in the presence of other unwanted noise or nearby signals that can affect the recording. These signals are called n(t) for noise and i(t) for interference.


First, consider the bandwidth of the target signal s(t) and the target hardware. If the hardware bandwidth is exactly the bandwidth of s(t), then the signal-to-noise-and-distortion ratio (SINAD) is higher than the SINAD of hardware with a much larger bandwidth. This is further explained in Figure 3, which reviews the input path of the NI USRP-2920:



Figure 3. Path Followed by the Signal at Record Time (RX 2 RF Input)


The power of the input signal s(t) + n(t) + i(t) is limited by the fixed 40 MHz internal input bandwidth provided by the 20 MHz antialiasing lowpass filters on I and Q regardless of the user-requested bandwidth. 


Once the ADC digitizes the baseband signal, the onboard signal processor (OSP) in the internal field-programmable gate array (FPGA) filters the specified center frequency and downsamples the driver-requested I/Q rate to a rate between 200 kS/s and 25 MS/s. The output is transferred over the 1 Gigabit Ethernet cable and recorded by the host computer.

For example, examining 20 MHz of bandwidth, assume s(t) is an FM radio station signal at 91.5 MHz. By specification, this signal is 200 kHz wide. Also assume there are other radio stations across the 40 MHz bandwidth at varying power levels, as shown in Figure 4:



Figure 4. Example Spectrum of the FM Radio Band


The input power at the RF input on the NI USRP-2920 is the power of the entire 40 MHz band, extending beyond the 20 MHz spectrum shown, not just the power of s(t). This affects the dynamic range of the recording because these larger signals must be accounted for.




Figure 5. Using the Dynamic Range on the ADC Without Any Front-End Filtering


When an I/Q rate is specified, the front-end filters and ADC rate do not change from their fixed rate of about 100 MS/s. The OSP takes the full-rate-sampled signal, digitally filters it, and downsamples it to the requested I/Q rate before transferring the data over the 1 Gigabit Ethernet bus. The bandwidth and sampling rate are related as an I/Q rate of 200 kS/s has a bandwidth of approximately 200 kHz. Reducing the I/Q rate reduces the required data rate you need to transfer data back to the host PC over the Ethernet bus.

To improve performance in this situation, use an external bandpass filter to isolate the signal of interest, as shown in Figure 6:



Figure 6. Using the Dynamic Range on the Digitizer With Custom Front-End Filtering With the Full Dynamic Range of the Signal


Because it is challenging to predict unwanted signals in the spectrum, you need a thorough understanding of the signal and the surrounding 40 MHz. You can use RF measurement equipment, such as NI PXI RF solutions, to calculate the input power with precision and better predict the needed gain. A test application can also be helpful in visualizing these parameters to set the correct recording parameters. You can conduct a test by setting the gain of the NI USRP-2920 much higher than the power of the acquired signal and then decreasing the reference level until the ADC clips. Then increase the reference level by 2 dB to 3 dB to allow some headroom for small signal variations when recording. If the signal has a much higher peak-to-average ratio, increase the reference level even more.


Data Type of Recorded Signal

The recorded waveform is the baseband representation of the passband signal, also known as the complex envelope or I/Q data. You can save data in any format, but to stream the data to disk at high rates, you must minimize the amount of processing applied to the data during recording. For this reason, the examples store the data as an array of signed 16-bit integers. This is the format in which the data is transferred over the Ethernet bus and stored in the PC memory; the only processing is simply copying the data from PC memory to disk.


The I/Q data array is interleaved like this

I0, Q0, I1, Q1, I2, Q2….. In, Qn

Where n is the number of acquired samples.


Data type affects the size on disk, and 16-bit integers are 2 bytes each. Complex I/Q information is stored as 4 bytes per I/Q value. A data rate of 25 MS/s transfers information to the computer at 100 MB/s, which exceeds the sustainable write rate of most hard disk drives. For sustaining high data rates, redundant array of inexpensive disks (RAID) solutions are recommended such as the NI HDD-8265 RAID enclosure that can sustain up to 600 MB/s in 6, 12, and 24 TB configurations.


4. Playback

One of the biggest challenges in a record and playback system is reproducing the recorded signal at the same level it was recorded. This might be useful to test the unit under test (UUT) in the lab under the same conditions present in the field.

The following properties are needed to play back an RF signal using the NI-USRP driver:


  • I/Q rate [S/s]
  • Carrier frequency [Hz]
  • Gain [dB]

You need to record not just the specified value but also the coerced value because I/Q rates are derived from a 100 MS/s clock divided in discrete increments (not all I/Q rates are possible). If information about the settings is not available, you lack both sampling speed and power references, so you cannot accurately reproduce the recording.


Setting these parameters and recording the coerced values is straightforward using indicators on the NI USRP Configure Signal VI shown in Figure 7:



Figure 7. Obtaining the Coerced Parameters (Actual Parameters Used in Hardware)


National Instruments offers example code to help make the record and playback architecture easier to navigate. You should characterize the NI USRP-2920 for your specific frequency and operating conditions and reverify these regularly or whenever you question the output values. If you need a calibrated solution with guaranteed performance over frequency and temperature, NI PXI RF solutions may be a better alternative.



5. Best Practices


Frequency Accuracy

Different modulation schemes and standards have different tolerances with regard to frequency accuracy. In applications such as GPS, you need to conduct both record and playback. In such cases, you can attach an external 10 MHz clock source, such as an oven-controlled crystal oscillator (OCXO), to the Ref In port on the front of the NI USRP device and specify it in the driver. 


DC Offset/LO Leakage

In some instances, the local oscillator (LO) can leak through the mixer into the transmitted signal. This is sometimes the result of a DC offset in I and Q that comes through as a strong carrier signal. If the LO leakage is overpowering the RF waveform, you can frequency shift at baseband above or below the center frequency and then transmit the intended transmission waveform. For instance, if the I/Q rate is set to 5 MS/s (±2.5 MHz), a signal of about 1 MHz bandwidth (between ±500 kHz) can be frequency shifted up to 1.5 MHz (1 MHz to 2 MHz bandwidth). By using more shifting and external passive filters, you can transmit the transmit signal and attenuate the LO to minimize interference on the receiving UUT.


Record and Playback Accessories

Antennas, a DC bias tee (for powering active antennas), an external amplifier, filters, and attenuators are all common accessories for performing record and playback. Amplifiers are commonly used on the receiver to boost weak signals; however, adding gain can bring the noise floor up as well. A DC bias tee sends DC to an active antenna while receiving RF back through the same connection, blocking DC and passing RF. For example, you can implement GPS recording with an active antenna, a DC bias tee with power supply, and a powered 30 dB low-noise amplifier (LNA). Playback, on the other hand, requires only a few attenuators to the reduce output power to that of live GPS signals and a direct connection to a GPS.


6. Conclusion

This tutorial illustrates many of the concepts and parameters you need to successfully record and play back RF signals. You learned that low-signal power levels and out-of-band signals both pose challenges when you are trying to maximize the dynamic range of the acquisition. But you can use amplifiers and attenuators to modify signal power for more ideal record and playback results. Finally, an external clock, such as an OCXO, provides the additional stability and frequency accuracy you need for some standards such as GPS. Feel free to download and use these record and playback VIs as a starting point for your own applications.


7. Additional Resources