This example shows how to use the RTL-SDR radio with MATLAB® and Simulink® to measure and calibrate for transmitter/receiver frequency offset at the receiver. Since the RTL-SDR radio is receive-only, you need to supply a signal source with a known center frequency to establish a baseline. If you do not have a signal generator available, you can use a low-cost Family Radio Service walkie-talkie as a source. Note that the signal source must be narrowband, with a sine wave being an ideal source.
This example is implemented in two versions:
The following text describes the Simulink version, but both versions have the same functionality.
|On this page…|
The model performs an FFT-based frequency offset calculation at complex baseband. It provides the following information:
The quantitative value of the frequency offset
A graphical view of the spur-free dynamic range of the receiver
A graphical view of the qualitative SNR level of the received signal
The following figure shows the receiver model:
The following figure shows the detailed structure of the Receiver subsystem:
The Find Peak Frequency block - uses an FFT to find the frequency with the maximum power in the received signal.
The Spectrum Analyzer block - computes and displays the power spectral density of the received signal.
The Find Peak Frequency subsystem finds the frequency with the maximum power in the received signal, which equals the frequency offset. The following diagram shows the subsystem. In this subsystem, the Periodogram block returns the PSD estimate of the received signal. The Probe block finds the frame size and the frame sample time. With this information, this subsystem finds the index of the maximum amplitude across the frequency band and converts the index to the frequency value according to
Foffset = IndexofMaxAmplitude * FrameSize / (FFTLength * FrameSampleTime)
The MATLAB function findpeakfreq.m performs this conversion.
The following figure shows the output of the Spectrum Analyzer on a frequency range of -100 kHz to 100 kHz. In the case shown below, the frequency with the maximum power of the received signal is about -17 kHz, and the spur-free dynamic range of the receiver is about 14 dB.
In order to calibrate the frequency offset of your RTL-SDR radio, begin transmitting with your known signal source, and then start the Frequency Offset Calibration (Rx) with RTL-SDR RadioFrequency Offset Calibration (Rx) with RTL-SDR Radio model on your RTL-SDR radio.
To run the receiver model, set the Center frequency parameter of the RTL-SDR Receiver block to the same value as your known transmitter. Then run the model. The frequency offset is calculated and displayed while the simulation is running.
To compensate for a transmitter/receiver frequency offset, specify the displayed PPM correction value as the Frequency correction (ppm) parameter of the RTL-SDR Receiver block. Be sure to use the sign of the offset in your specification. The spectrum displayed by the Spectrum Analyzer block should then have its maximum at 0 Hz.