Frequency Offset Calibration Transmitter with SDR Hardware

This example shows how to use the SDR (Software Defined Radio) System objects to measure and calibrate for transmitter/receiver frequency offset at the receiver using MATLAB®.


The example provides the following information about the SDR Transmitter/Receiver link:

  • 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 example is a complementary pair of scripts: the transmitter sdrfFrequencyCalibrationTransmitter.m and the receiver sdrfFrequencyCalibrationReceiver.m.

The SDR Transmitter sends a sine wave at 100Hz to the SDR Receiver. The SDR Receiver monitors the received signal, calculates the transmitter/receiver frequency offset and displays it in the MATLAB command window. The calculated offset can be used to compensate for the frequency offset between the transmitter and the receiver.

Calibrating for Frequency Offset

To calibrate the frequency offset between two SDR devices, run sdrfFrequencyCalibrationTransmitter.m on one SDR radio, while simultaneously running sdrfFrequencyCalibrationReceiver.m on another SDR radio. The CenterFrequency property of the SDR Transmitter and Receiver System objects should have the same value.

To compensate for a transmitter/receiver frequency offset, add the displayed frequency offset value to the Center Frequency of the SDR Receiver System object. Be sure to use the sign of the offset in your addition. Once you've done that, the spectrum displayed by the receiver's spectrum analyzer System object should have its maximum amplitude at roughly 0 Hz.

Refer to the Simulink® model sdrffreqcalib for a block diagram view of the system.

Hardware Requirements

To run this example, make sure that the center frequency of the SDR Transmitter and Receiver System objects is within the acceptable range of the SDR daughter board and the antennas being used. Refer to documentation for details on configuring your host computer to work with the SDR Transmitter and Receiver System objects.


Set the properties of the sine wave source, the SDR transmitter, and the spectrum analyzer System object.

bbTxFreq = 100;    % Transmitted baseband frequency
rfTxFreq = 1.85e9; % Nominal RF transmit center frequency

prmFreqCalibTx = sdrfConfigureFreqCalibTx(rfTxFreq, bbTxFreq);

hSineSource = dsp.SineWave (...
    'Frequency',           prmFreqCalibTx.SineFrequency, ...
    'Amplitude',           prmFreqCalibTx.SineAmplitude,...
    'ComplexOutput',       prmFreqCalibTx.SineComplexOutput, ...
    'SampleRate',          prmFreqCalibTx.Fs, ...
    'SamplesPerFrame',     prmFreqCalibTx.SineFrameLength, ...
    'OutputDataType',      prmFreqCalibTx.SineOutputDataType);

The host computer communicates with the SDR radio using the SDR Transmitter System object. The IP address of the SDR radio can be supplied as an argument when you construct the object. The IP address can be any address within the same subnet as your host computer. The parameter structure, prmFreqCalibTx, sets the CenterFrequency and InterpolationFactor arguments.

hSDRTx = comm.SDRADIFMCOMMSTransmitter( ...
    'IPAddress',            '', ...
    'CenterFrequency',      prmFreqCalibTx.RadioTxCenterFrequency, ...
    'InterpolationFactor',  prmFreqCalibTx.RadioInterpolationFactor)

Use dsp.SpectrumAnalyzer to display the spectrum of the transmitted signal.

hSpectrumAnalyzer = dsp.SpectrumAnalyzer(...
    'Name',                'Frequency of the Sine waveform sent out',...
    'Title',               'Frequency of the Sine waveform sent out',...
    'FrequencySpan',       'Full', ...
    'SampleRate',           prmFreqCalibTx.Fs, ...
    'YLimits',              [-70,30],...
    'SpectralAverages',     50, ...
    'FrequencySpan',        'Start and stop frequencies', ...
    'StartFrequency',       -100e3, ...
    'StopFrequency',        100e3,...
    'Position',             figposition([50 30 30 40]));

Stream Processing

Loop until the example reaches the target number of frames.
radio = sdrinfo(hSDRTx.IPAddress);
    for iFrame = 1: prmFreqCalibTx.TotalFrames
        sinewave =  step(hSineSource); % generate sine wave
        step(hSDRTx, sinewave); % transmit to SDR radio
    % Display the spectrum after the simulation.
    step(hSpectrumAnalyzer, sinewave);

Release System Objects

release (hSineSource);
release (hSDRTx);
clear hSDRTx


In this example, System objects were used to build, visualize and transmit a 100 Hz tone using SDR hardware. This signal is to be used to calculate the frequency offset between the transmitter and a receiver.


The following helper functions are used in this example.

Was this topic helpful?