Main Content

Frequency Offset Calibration Receiver Using USRP E3xx

This example shows how to use the USRP™ Embedded Series Radio Support Package with MATLAB® to determine the frequency offset between SDR devices using USRP E3xx. The example comprises of two complementary scripts: one for the transmitter and another for the receiver.

要传输10 kHz的正弦波,请运行Frequency Offset Calibration Transmitter Using USRP Embedded Seriesexample by typing its script name in the MATLAB command window:

usrpe3xxFrequencyCalibrationTransmitterML

To receive the signal and to calculate the frequency offset, run this example by typing the script name of this example in the MATLAB command window:

Usrpe3xxFrequencyCalibrationReceiverMl.

Refer to theGuided Host-Radio Hardware Setup有关配置主计算机的详细信息,请使用USRP®嵌入式系列收音机的支持包。金宝app

Introduction

This example uses a matched pair of scripts to determine the frequency offset between two SDR devices:

这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:

  • 频率偏移的定量值

  • 接收器的无旋转动态范围的图形视图

  • 接收信号的定性SNR水平的图形视图

设置

在运行示例之前,请确保已执行以下步骤:

1. Configure your host computer to work with the Support Package for USRP Embedded Series Radio. SeeGuided Host-Radio Hardware Setup求助。

2.确保您拥有发射机脚本频率偏移校准发射机使用USRP E3xxand the receiver scriptFrequency Offset Calibration Receiver Using USRP E3xxopen, with each configured to run on its own SDR hardware in its own instance of MATLAB.

运行该示例

该示例配置为使用USRP E3xx硬件运行。

prmFreqCalibRx。SDRDeviceName ='e3xx';

确保发送器正在发送10 kHz音调,然后启动接收器脚本。看Frequency Offset Calibration Transmitter Using USRP Embedded Seriesfor help with the transmitter.

这calculated frequency offset is displayed in the MATLAB command window. Adsp.spectrumanalyzer.对象用于可视化接收信号的频谱。A sample of a received spectrum is shown below.

在这种情况下,具有最大接收信号功率的频率约为2.85kHz。由于发射机在10 kHz处发送音调,这意味着频率偏移量约为7.15kHz。信号的虚假自由动态范围约为46 dB。

要补偿发射器/接收器频率偏移,请设置prmFreqCalibRx。OffsetCompensation变量到命令窗口中显示的值。此值被添加到中心频率SDR接收器对象。请务必在添加中使用偏移量的标志。通过施加的频率偏移补偿重新运行接收器。所显示的计算偏移频率现在应该接近零,并且频谱中的峰值应接近10kHz。

It is important to note that the frequency offset value is only valid for the center frequency used to run the calibration.

接收器设计:系统架构

Initialization

下面的代码设置了用于控制接收器的参数。

%接收者以秒为单位运行的近似时间长度prmFreqCalibRx。RunTime = 10;% Set the offset value to compensate byprmFreqCalibRx。OffsetCompensation = 0;% SDR Receiver parametersradio = sdrdev(prmFreqCalibRx.SDRDeviceName); prmFreqCalibRx.RadioIP ='192.168.3.2';prmfreqcalibrx.radiooutputdatatype ='double';prmFreqCalibRx。RadioSamplesPerFrame = 4096;prmFreqCalibRx。RadioChannelMapping = 1; prmFreqCalibRx.DesiredRadioCenterFrequency = 2.4e9; prmFreqCalibRx.RadioBasebandSampleRate = 520.841e3; prmFreqCalibRx.RadioCenterFrequency =......prmfreqcalibrx.desivedradiocenterfrequency +.......prmFreqCalibRx。OffsetCompensation; prmFreqCalibRx.RadioGainControlMode ='AGC快速攻击';% Expected sine wave parametersprmFreqCalibRx。RxSineFrequency = 10e3;% in Hertzprmfreqcalibrx.fs = prmfreqcalibrx.radiobaseBandSamplerate;% FFT length for calculating the frequency offsetprmFreqCalibRx。FocFFTSize = 4096;

使用上面的参数,创建了三个系统对象:

  1. Use acomm.SDRRxE3xxSystem object to receive the baseband sine wave from the SDR hardware.

  2. usrpe3xxCoarseFrequencyOffsetobject performs an FFT and returns the frequency of maximum power

  3. dsp.spectrumanalyzer.对象用于可视化接收信号的频谱

prmFreqCalibRx。FocFFTSizevariable sets the size of the FFT used to calculate the frequency offset. The default value of 4096 means that the frequency offset calculated is limited to a resolution of 48 Hz.

sdreceiver = sdrrx(prmfreqcalibrx.sdrevicename,......'IP地址'那prmFreqCalibRx。RadioIP,......'CenterFrequency',prmfreqcalibrx.radiocenterfrequency,......'gainsource',prmfreqcalibrx.radiogainControlMode,......'SamplesPerFrame'那prmFreqCalibRx。RadioSamplesPerFrame,......'BasebandSampleRate',prmfreqcalibrx.radiobaseBandSamplerate,......'OutputDataType',prmfreqcalibrx.radioOutputDattype,......'ChannelMapping',prmfreqcalibrx.radiochannelmapping,......'ShowAdvancedProperties'那true,......'bypassuserlogic'那true); coarseFrequencyOffset = usrpe3xxCoarseFrequencyOffset(......'FFTSize'那prmFreqCalibRx。FocFFTSize ,......'采样率'prmfreqcalibrx.fs);SpectrumScope = DSP.SpectRumanalyzer(......'SpectrumType''Power'......'FrequencySpan''Full'......'FrequencyResolutionMethod''RBW'......'rbwsource''Property'......'RBW',48,......'采样率',prmfreqcalibrx.fs,......'ylimits'那[-120, 20],......'SpectralAverages'那10);

接收和基带信号处理

这receiver is then run for the target amount of time.

prmfreqcalibrx.currenttime = 0;prmfreqcalibrx.timeperstep =(1 / prmfreqcalibrx.fs)*......prmfreqcalibrx.radiosamplesperframe;有效= false;whileprmFreqCalibRx。currentTime < prmFreqCalibRx.RunTime% Keep calling the Receiver until there is data availablewhile~valid [rxSig, valid] = sdrReceiver();结尾%显示接收频谱。spectrumScope(rxSig);% Compute the frequency offset. Since the SDRCoarseFrequencyOffset% object returns the frequency of the peak power, we need to compensate% for the fact we are transmitting at prmFreqCalibRx.RxSineFrequency.% The value 'offset' represents the frequency shift that needs to be%施加到中心频率。offset = coarsefrequencyOffset(rxsig)+ prmfreqcalibrx.rxsinefryquency;% Print the frequency offset compensation value in MATLAB command% window.commanationvalue = -offset.%#OK prmfreqcalibrx.currentime = prmfreqcalibrx.currenttime +......prmfreqcalibrx.timeperstep;%重置有效所以我们可以等待新数据有效= false;结尾% Release all system objectsrelease(sdrReceiver); release(coarseFrequencyOffset); release(spectrumScope); clearSDRReceiver.coarseFrequencyOffsetprmfreqcalibrx.

替代实施方式

This example describes the MATLAB implementation of a receiver for performing frequency offset calibration between two SDR devices using the USRP E3xx. For the transmitter counterpart, seeFrequency Offset Calibration Transmitter Using USRP Embedded Series

For a Simulink® implementation of these examples, seeFrequency Offset Calibration Using USRP E3xx

Troubleshooting the Example

如果收到的信号非常弱,则可以尝试通过更改的通过提高接收器增益prmFreqCalibRx。RadioGainvariable with the manual gain control mode or by changing theprmFreqCalibRx。RadioGainControlMode“AGC快速攻击”或“AGC缓慢攻击”。

如果按照所描述的示例运行示例,但未能看到如图所示的信号(例如,您只接收噪音或从未显示过频谱显示),请参阅Common Problems and Fixes

附录

此示例使用以下帮助文件: