Compensate for frequency offset of PAM, PSK, or QAM signal
System object™ compensates for the frequency offset of received signals using an open-loop
To compensate for the frequency offset of a PAM, PSK, or QAM signal:
comm.CoarseFrequencyCompensatorobject and set its properties.
Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?
creates a coarse frequency offset compensator System object. This object uses an open-loop technique to estimate and compensate for the
carrier frequency offset in a received signal. For more information about the estimation
algorithm options, see Algorithms.
coarseFreqComp = comm.CoarseFrequencyCompensator
specifies properties using one or more name-value arguments. For example,
coarseFreqComp = comm.CoarseFrequencyCompensator(Name,Value)
Modulation='QPSK' specifies quadrature phase-shift keying
Unless otherwise indicated, properties are nontunable, which means you cannot change their
values after calling the object. Objects lock when you call them, and the
release function unlocks them.
If a property is tunable, you can change its value at any time.
For more information on changing property values, see System Design in MATLAB Using System Objects.
Modulation — Modulation type
'QAM' (default) |
Modulation type, specified as one of,
'BPSK'– Binary phase shift keying
'QPSK'– Quadrature phase shift keying
'OQPSK'– Offset quadrature phase shift keying
'8PSK'– 8-phase shift keying
'PAM'– Pulse amplitude modulation
'QAM'– Quadrature amplitude modulation
Algorithm — Algorithm used to estimate frequency offset
'FFT-based' (default) |
Algorithm used to estimate the frequency offset, specified as
To enable this property, set
'PAM'. This table shows the valid combinations of the modulation
type and the estimation algorithm.
|Modulation||FFT-Based Algorithm||Correlation-Based Algorithm|
Use the correlation-based algorithm for HDL implementations and for other situations in which you want to avoid using an FFT.
FrequencyResolution — Frequency resolution
0.001 (default) | positive scalar
Frequency resolution for the offset frequency estimation in hertz, specified as a positive scalar. This property establishes the FFT length used to perform spectral analysis and must be less than the sample rate.
MaximumFrequencyOffset — Maximum measurable frequency offset
0.05 (default) | positive scalar
SampleRate — Sample rate
1 (default) | positive scalar
Sample rate in samples per second, specified as a positive scalar.
SamplesPerSymbol — Samples per symbol
4 (default) | even integer, greater than or equal to
Samples per symbol, specified as an even positive integer greater than or equal to
To enable this property, set
x — Input signal
Input signal, specified as a column vector.
To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named
Compensate for Frequency Offset in QPSK Signal
Compensate for a 4 kHz frequency offset imposed on a noisy QPSK signal.
Set up the example parameters.
nSym = 2048; % Number of input symbols sps = 4; % Samples per symbol nSamp = nSym*sps; % Number of samples fs = 80000; % Sampling frequency (Hz)
Create a square root raised cosine transmit filter.
txfilter = comm.RaisedCosineTransmitFilter( ... RolloffFactor=0.2, ... FilterSpanInSymbols=8, ... OutputSamplesPerSymbol=sps);
Create a phase frequency offset object to introduce the 4 kHz frequency offset.
freqOffset = comm.PhaseFrequencyOffset( ... FrequencyOffset=-4000, ... SampleRate=fs);
Create a coarse frequency compensator object to compensate for the offset.
freqComp = comm.CoarseFrequencyCompensator( ... Modulation="qpsk", ... SampleRate=fs, ... FrequencyResolution=1);
Generate QPSK symbols, filter the modulated data, pass the signal through an AWGN channel, and apply the frequency offset.
data = randi([0 3],nSym,1); modData = pskmod(data,4,pi/4); txSig = txfilter(modData); rxSig = awgn(txSig,20,"measured"); offsetData = freqOffset(rxSig);
Compensate for the frequency offset using the coarse frequency compensator. When the frequency offset is high, applying coarse frequency compensation prior to receive filtering is benefitial because filtering suppresses energy in the useful spectrum.
[compensatedData,estFreqOffset] = freqComp(offsetData);
Display the estimate of the frequency offset.
estFreqOffset = -4.0001e+03
Return information about the coarse frequency compensator System object. To obtain the FFT length, you must call coarse frequency compensator System object prior to calling the
info object function.
freqCompInfo = info(freqComp)
freqCompInfo = struct with fields: FFTLength: 131072 Algorithm: 'FFT-based'
Create a spectrum analyzer object and plot the offset and compensated spectra. Verify that the compensated signal has a center frequency at 0 Hz and that the offset signal has a center frequency at -4 kHz.
sa = spectrumAnalyzer( ... SampleRate=fs, ... ShowLegend=true, ... ChannelNames=["Offset Signal","Compensated Signal"]); sa([offsetData compensatedData]) release(sa)
Compensate for Frequency Offset Using Coarse and Fine Compensation
Correct for a phase and frequency offset in a noisy QAM signal using a carrier synchronizer. Then correct for the offsets using both a carrier synchronizer and a coarse frequency compensator.
Set the example parameters.
fs = 10000; % Symbol rate (Hz) sps = 4; % Samples per symbol M = 16; % Modulation order k = log2(M); % Bits per symbol EbNo = 20; % Eb/No (dB) SNR = convertSNR(EbNo,"ebno",BitsPerSymbol=k,SamplesPerSymbol=sps);
Create a constellation diagram object to visualize the effects of the offset compensation techniques. Specify the constellation diagram to display only the last 4000 samples.
constdiagram = comm.ConstellationDiagram( ... 'ReferenceConstellation',qammod(0:M-1,M), ... 'SamplesPerSymbol',sps, ... 'SymbolsToDisplaySource','Property', ... 'SymbolsToDisplay',4000, ... 'XLimits',[-5 5], ... 'YLimits',[-5 5]);
Introduce a frequency offset of 400 Hz and a phase offset of 30 degrees.
phaseFreqOffset = comm.PhaseFrequencyOffset( ... 'FrequencyOffset',400, ... 'PhaseOffset',30, ... 'SampleRate',fs);
Generate random data symbols and apply 16-QAM modulation.
data = randi([0 M-1],10000,1); modSig = qammod(data,M);
Create a raised cosine filter object and filter the modulated signal.
txfilter = comm.RaisedCosineTransmitFilter( ... 'OutputSamplesPerSymbol',sps, ... 'Gain',sqrt(sps)); txSig = txfilter(modSig);
Apply the phase and frequency offset, and then pass the signal through the AWGN channel.
freqOffsetSig = phaseFreqOffset(txSig); rxSig = awgn(freqOffsetSig,SNR);
Apply fine frequency correction to the signal by using the carrier synchronizer.
fineSync = comm.CarrierSynchronizer( ... 'DampingFactor',0.7, ... 'NormalizedLoopBandwidth',0.005, ... 'SamplesPerSymbol',sps, ... 'Modulation','QAM'); rxData = fineSync(rxSig);
Display the constellation diagram of the last 4000 symbols.
Even with time to converge, the spiral nature of the plot shows that the carrier synchronizer has not yet compensated for the large frequency offset. The 400 Hz offset is 1% of the sample rate.
Repeat the process with a coarse frequency compensator inserted before the carrier synchronizer.
Create a coarse frequency compensator to reduce the frequency offset to a manageable level.
coarseSync = comm.CoarseFrequencyCompensator( ... 'Modulation','QAM', ... 'FrequencyResolution',1, ... 'SampleRate',fs*sps);
Pass the received signal to the coarse frequency compensator and then to the carrier synchronizer.
syncCoarse = coarseSync(rxSig); rxData = fineSync(syncCoarse);
Plot the constellation diagram of the signal after coarse and fine frequency compensation. The received data now aligns with the reference constellation.
Reference  describes the
correlation-based estimation algorithm used to estimate the frequency offset for PSK and
PAM signals. To determine the frequency offset, Δf, the algorithm
performs a maximum likelihood (ML) estimation of the complex-valued oscillation
exp(j2πΔft). The observed signal,
rk, is represented as
Ts is the sampling interval, θ is an unknown random phase, and N is the number of samples. The ML estimation of the frequency offset is equivalent to seeking the maximum of the likelihood function,
After simplifying, the problem is expressed as a discrete Fourier transform, weighted by a parabolic windowing function. It is expressed as
R(k) denotes the estimated autocorrelation of the sequence rk and is represented as
The term k(N–k) is the parabolic windowing function. In , it is shown that R(k) is a poor estimate of the autocorrelation of rk when k = 0 or when k is close to N. Consequently, the windowing function can be expressed as a rectangular sequence of 1s for k = 1, 2, ..., L, where L ≤ N – 1. The result is a modified ML estimation strategy in which
This equation results in an estimate of in which
The sampling frequency, fsamp, is the reciprocal of Ts. The number of elements used to compute the autocorrelation sequence, L, are determined as
fmax is the maximum expected frequency offset. and
round is the nearest integer function. The frequency offset
estimate improves when L ≥ 7 and leads to the recommendation that fmax ≤
FFT-based estimation algorithms can be used to estimate the frequency offset for various modulation types. The coarse frequency compensator implementation supports these modulation methods by using the algorithm noted.
QAMmodulation, the coarse frequency compensator uses the FFT-based algorithm described in . The algorithm estimates by using a periodogram of the mth power of the received signal and is given as
where m is the modulation order, r(k) is the received sequence, Rsym is the symbol rate, and N is the number of samples. The algorithm searches for a frequency that maximizes the time average of the mth power of the received signal multiplied by various frequencies in the range of [–Rsym/2, Rsym/2]. Because the form of the algorithm is the definition of the discrete Fourier transform of rm(t), searching for a frequency that maximizes the time average is equivalent to searching for a peak line in the spectrum of rm(t). The number of points required by the FFT is
where fr is the desired frequency resolution.
For OQPSK modulation, the coarse frequency compensator uses the FFT-based algorithm described in . The algorithm searches for spectral peaks at ±200 kHz around the symbol rate. This technique locates desired peaks in the presence of interference from spectral content around baseband frequencies due to filtering.
 Luise, M., and R. Reggiannini. “Carrier Frequency Recovery in All-Digital Modems for Burst-Mode Transmissions.” IEEE® Transactions on Communications, vol. 43, no. 2/3/4, Feb. 1995, pp. 1169–78.
 Wang, Y., et al. “Non-Data-Aided Feedforward Carrier Frequency Offset Estimators for QAM Constellations: A Nonlinear Least-Squares Approach.” EURASIP Journal on Advances in Signal Processing, vol. 2004, no. 13, Dec. 2004, p. 856139.
 Nakagawa, Tadao, et al. “Non-Data-Aided Wide-Range Frequency Offset Estimator for QAM Optical Coherent Receivers.” Optical Fiber Communication Conference/National Fiber Optic Engineers Conference 2011, OSA, 2011, p. OMJ1.
 Olds, Jonathan. Designing an OQPSK demodulator.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
See System Objects in MATLAB Code Generation (MATLAB Coder).
Introduced in R2015b