This example shows how to use the Xilinx® Zynq-Based Radio Support Package with Simulink® to determine the frequency offset between SDR devices. The transmitter model configures the hardware and sends a 10kHz sine wave. The receiver model receives the signal, calculates the frequency offset and displays the offset.
Refer to the Guided Host-Radio Hardware Setup documentation for details on configuring your host computer to work with the Support Package for Xilinx® Zynq-Based Radio.
This example uses a matched pair of models to determine the frequency offset between two SDR devices:
The transmitter sends a 10 kHz tone. The receiver detects the transmitted tone using an FFT-based detection method. The offset between the transmitted 10 kHz tone and the received tone can then be calculated and used to compensate for the offset at the receiver. The pair of models provides the following information:
A 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
Before running the example, make sure you have performed the following steps:
1. Configure your host computer to work with the Support Package for Xilinx® Zynq-Based Radio. See Guided Host-Radio Hardware Setup for help.
Some additional steps may be required if you want to run two radios from a single host computer. See Setup for Two Radios Connecting to One Host for help.
2. Make sure that you have both the transmitter model and the receiver model open, with each configured to run on its own SDR hardware in its own instance of Simulink.
3. Make sure that the model uses the correct block for your hardware. By default, the model uses an AD936x Transmitter block. If you are using an FMCOMMS5 RF Card, replace the AD936x Transmitter block with the FMCOMMS5 Transmitter block.
Start the transmitter model running, and then start the receiver model.
The calculated frequency offset is shown by the Frequency Offset Display block in the receiver model. The Spectrum Analyzer block in the Receiver subsystem shows the spectrum of the received signal. A sample spectrum is shown below.
In this case, the frequency with the maximum received signal power is at about 2.86kHz. Since the transmitter is sending a tone at 10 kHz, this means the frequency offset is about 7.14kHz. The spurious free dynamic range of the signal is about 44.5 dB.
To compensate for a transmitter/receiver frequency offset, add the displayed frequency offset value to the Center frequency parameter of the
comm.SDRRxAD936x block. Make sure to use the sign of the offset in your addition. Rerun the receiver with the applied frequency offset compensation. The calculated offset frequency displayed should now be close to zero, and the peak in the spectrum should be close to 10 kHz.
It is important to note that the frequency offset value is only valid for the center frequency used to run the calibration.
The following figure shows the transmitter model:
The transmitter sends a 10 kHz tone at a default center frequency of 2.4 GHz i.e. the tone is transmitted at 2.4 GHz + 10 kHz.
The following figure shows the receiver model:
The following figure shows the detailed structure of the Receiver subsystem:
The Spectrum Analyzer block computes and displays the power spectral density of the received signal.
The Find Peak Frequency subsystem uses an FFT to find the frequency with the maximum power in the received signal.
The Find Peak Frequency subsystem finds the frequency with the maximum power in the received signal. The subsystem is shown below:
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, the MATLAB® function block findpeakfreq finds the index of the maximum amplitude across the frequency band and converts the index to a frequency value according to the following calculation:
Foffset = IndexofMaxAmplitude * FrameSize / (FFTLength * FrameSampleTime)
Note that the FFT performed by the Periodogram uses 4096 samples. This means that the frequency offset calculated is limited to a resolution of 48 Hz.
This example describes the Simulink implementation of a pair of models for performing frequency offset calibration between two SDR devices. You can also view a MATLAB implementation of these models in Frequency Offset Calibration Transmitter Using Analog Devices AD9361/AD9364 and Frequency Offset Calibration Receiver Using Analog Devices AD9361/AD9364.
If the received signal is very weak, you can try increasing the receiver gain by changing the Source of gain variable to Input port for the manual gain control mode or by changing it to 'AGC Fast Attack' or 'AGC Slow Attack'.
If you run the example as described but fail to see a signal like the one shown (e.g. you only receive noise or the spectrum display is never updated), see Common Problems and Fixes.