Frequency Offset Calibration Transmitter Using USRP Embedded Series
This example shows how to use the USRP® Embedded Series Radio Support Package with MATLAB® to determine the frequency offset between SDR devices. The example comprises of two complementary scripts: one for the transmitter and one for the receiver. This is the help for the transmitter.
To transmit a 10 kHz sine wave, run this example by typing its script name in the MATLAB command window:
To receive the signal and to calculate the frequency offset, run the Frequency Offset Calibration Receiver Using USRP E3xx example by typing its script name in the MATLAB command window:
Refer to the Guided Host-Radio Hardware Setup documentation for details on configuring your host computer to work with the Support Package for USRP Embedded Series Radio.
This example uses a matched pair of scripts to determine the frequency offset between two SDR devices:
The transmit script is Frequency Offset Calibration Transmitter Using USRP Embedded Series
The receive script is Frequency Offset Calibration Receiver Using USRP Embedded Series
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 scripts 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 USRP Embedded Series 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 script Frequency Offset Calibration Transmitter Using USRP Embedded Series and the receiver script Frequency Offset Calibration Receiver Using USRP Embedded Series open, with each configured to run on its own SDR hardware in its own instance of MATLAB.
Running the Example
prmFreqCalibTx.SDRDeviceName = 'E3xx';
The transmitter is set to run for approximately 10 seconds. You can increase the transmission duration by changing the prmFreqCalibTx.RunTime variable. When the transmission starts, the message
will be shown in the MATLAB command window. Once the transmission is finished, the message
will be displayed. While the SDR hardware is transmitting, start the receiver script usrpe3xxFrequencyCalibrationReceiverML.m in its own instance of MATLAB and on its own SDR hardware. See the documentation for the Frequency Offset Calibration Receiver Using USRP E3xx example for more details.
Transmitter Design: System Architecture
The code below sets up the parameters used to control the transmitter.
% amount of time the transmission runs for in seconds prmFreqCalibTx.RunTime = 10; % SDR Transmitter parameters dev = sdrdev(prmFreqCalibTx.SDRDeviceName); prmFreqCalibTx.RadioIP = '192.168.3.2'; prmFreqCalibTx.RadioCenterFrequency = 2.4e9; prmFreqCalibTx.RadioFrontEndSampleRate = 520.841e3; % Sine wave generation parameters prmFreqCalibTx.Fs = prmFreqCalibTx.RadioFrontEndSampleRate; prmFreqCalibTx.SineAmplitude = 0.25; prmFreqCalibTx.SineFrequency = 10e3; % in Hertz prmFreqCalibTx.SineComplexOutput = true; prmFreqCalibTx.SineOutputDataType = 'double'; prmFreqCalibTx.SineFrameLength = 4096;
Using the parameters above, three System objects are created:
sineSource = dsp.SineWave (... 'Frequency', prmFreqCalibTx.SineFrequency, ... 'Amplitude', prmFreqCalibTx.SineAmplitude,... 'ComplexOutput', prmFreqCalibTx.SineComplexOutput, ... 'SampleRate', prmFreqCalibTx.Fs, ... 'SamplesPerFrame', prmFreqCalibTx.SineFrameLength, ... 'OutputDataType', prmFreqCalibTx.SineOutputDataType); sdrTransmitter = sdrtx( prmFreqCalibTx.SDRDeviceName,... 'IPAddress', prmFreqCalibTx.RadioIP, ... 'BasebandSampleRate', prmFreqCalibTx.RadioFrontEndSampleRate, ... 'CenterFrequency', prmFreqCalibTx.RadioCenterFrequency, ... 'ShowAdvancedProperties', true, ... 'BypassUserLogic', true); spectrumScope = dsp.SpectrumAnalyzer(... 'Name', 'Frequency of the transmit sine wave',... 'Title', 'Frequency of the transmit sine wave',... 'FrequencySpan', 'Full', ... 'SampleRate', prmFreqCalibTx.Fs, ... 'SpectralAverages', 50, ... 'YLimits', [-250 20]);
Baseband Signal Generation and Transmission
The transmitter is then run for the target amount of time. The sine wave generated by sineSource is displayed using spectrumScope before the loop. As the sine wave does not change inside the loop, to maximize transmitter performance, the spectrumScope is called only once.
prmFreqCalibTx.currentTime = 0; prmFreqCalibTx.timePerStep = (1 / prmFreqCalibTx.Fs) * ... prmFreqCalibTx.SineFrameLength; % generate the sine wave and display the spectrum sinwave = sineSource(); data = sinwave; spectrumScope(data); disp('Starting transmission') while prmFreqCalibTx.currentTime < prmFreqCalibTx.RunTime % send the baseband data to the SDR hardware for RF transmission sdrTransmitter(data); % generate the next sine wave baseband data block data = sineSource(); % Update the transmission timing loop control variable prmFreqCalibTx.currentTime = prmFreqCalibTx.currentTime + ... prmFreqCalibTx.timePerStep; end disp('Finished transmission') % Clean up the system objects and variables created, but leave the spectrum % analyzer open release(sineSource); release(sdrTransmitter); release(spectrumScope); clear sineSource sdrTransmitter prmFreqCalibTx data
Note that this example does not check for any dropped samples during the transmission.
This example describes the MATLAB implementation of a transmitter for performing frequency offset calibration between two SDR devices. The matched receiver is Frequency Offset Calibration Receiver Using USRP Embedded Series.
For a Simulink® implementation of these examples, see Frequency Offset Calibration Using USRP E3xx.