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 SDR Transmitter sends a sine wave at 100Hz with the MATLAB script, sdrfFrequencyCalibrationTransmitter.msdrfFrequencyCalibrationTransmitter.m, to the SDR receiver. The SDR Receiver monitors received signals, calculates the transmitter/receiver frequency offset and displays it in the MATLAB command window for calibration with the MATLAB script, sdrfFrequencyCalibrationReceiver.msdrfFrequencyCalibrationReceiver.m.
|On this page…|
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
To calibrate the frequency offset between two SDR devices, run sdrfFrequencyCalibrationTransmitter.msdrfFrequencyCalibrationTransmitter.m on one SDR radio, while simultaneously running sdrfFrequencyCalibrationReceiver.msdrfFrequencyCalibrationReceiver.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.
To run this example, ensure that the center frequency of the SDR Transmitter and Receiver System objects is within the acceptable range of your SDR daughter board and the antennas you are using. Please refer to documentationdocumentation 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. You can supply the IP address of the SDR radio 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', '192.168.2.2', ... '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', ... 'FFTLengthSource', 'Property',... 'FFTLength', prmFreqCalibTx.SpeAnaFFTLength,... 'SampleRate', prmFreqCalibTx.Fs, ... 'YLimits', [-70,30],... 'SpectralAverages', 50, ... 'FrequencySpan', 'Start and stop frequencies', ... 'StartFrequency', -100e3, ... 'StopFrequency', 100e3,... 'Position', figposition([50 30 30 40]));
Loop until the example reaches the target number of frames.
radio = sdrinfo(hSDRTx.IPAddress); if(~isempty(radio)) for iFrame = 1: prmFreqCalibTx.TotalFrames sinewave = step(hSineSource); % generate sine wave step(hSDRTx, sinewave); % transmit to SDR radio end % Display the spectrum after the simulation. step(hSpectrumAnalyzer, sinewave); else warning(message('SDR:sysobjdemos:MainLoop')) end
release (hSineSource); release (hSDRTx); clear hSDRTx
In this example, you used Communications System Toolbox™ System objects to build a signal source to send a reference tone at 100 Hz. This signal is to be used as a calibration signal for a SDR receiver.
The following scripts are used in this example.