Frequency offset estimation with linearly modulated sequence of symbols and matlab
From Tools4SDR
Tutorial: Digital communication with linearly modulated sequence of symbols
|
| 1. General introduction |
| 2. Frequency offset estimation |
| 3. Channel impulse response estimation |
| 4. Synchronisation |
| 5. A simple receiver |
| 6. The complete scheme |
This tutorial is about the frequency offset estimation between the 2 USRPs with a linearly modulated sequence of symbols. This tutorial uses the Matlab part of the toolbox.
Contents |
Requirements
To do this tutorial, you need:
- A computer with Matlab
- 2 USRPs with 2 FLEX 2400 daughterboards
- The SDR4All toolbox v1.0.2
Theoretical part
Frequency offset
The frequency offset is a RF impairments which is due to modulation frequency mismatch between transmitter and receiver. If the complex envelop of the signal to transmit writes:
$x(t) = x_I(t) + i x_Q(t)$
the transmitter radio generates the following signal where $f_0$ is the modulation frequency:
$z(t) = x_I(t)\sqrt{2}\cos(2\pi f_0t) - \sqrt{2} x_Q(t)\sin(2\pi f_0t)$
At the receiver, the inphase and inquadrature signals are estimated with the above formula:
$y_I(t) = LP\{z(t)\sqrt{2}\cos(2\pi f_1t)\}$
$y_Q(t) = LP\{-z(t)\sqrt{2}\sin(2\pi f_1t)\}$
Where $f_1$ is the demodulation frequency, and the LP operator stands for an ad-hoc low-pass filter. These relations simplify to:
$y_I(t) = x_I(t) \cos(2\pi (f_0-f_1)t) - x_Q(t)\sin(2\pi (f_0-f_1)t)$
$y_Q(t) = x_I(t) \sin(2\pi (f_0-f_1)t) + x_Q(t)\cos(2\pi (f_0-f_1)t)$
The received complex envelop writes hence:
$y(t) = y_I(t)+iy_Q(t) = x(t)e^{2i\pi (f_0-f_1)t}
Without frequency offset, i.e. $f_0=f_1$, it simplifies to:
$y(t) = x(t)$
Otherwise, if $f_0 = f_1 + \Delta f$, we get:
$y(t) = x(t)e^{2i\pi \Delta f t}$
The purpose of this tutorial is to estimate this frequency offset. Once known, it can be easily be corrected:
$y_2(t) = y(t) e^{-2i\pi \Delta f t}$
Linearly modulated sequence of symbols and frequency offset estimation
If $x(t)$ is a linearly modulated sequence of real symbols (BPSK for example), this signal writes:
$x(t) = \sum_{n} a_n g(t-nT)$
Where $a_n$ is a sequence of real symbols assumed i.i.d. and $g(t)$ is the shaping filter. The received complex envelop writes then:
$y(t) = \sum_{n} a_n h(t-nT) e^{-2i\pi \Delta f t} + b(t)$
where $h(t)$ stands for the convolution product between the shaping filter $g(t)$ and the channel impulse response, and $b(t)$ for the additive Gaussian noise, assumed circular (i.e. $E\{b(t)^2\} = 0$).
The non-conjugate autocorrelation of the received signal $E\{y(t)^2\}$ writes then:
$E\{y(t)^2\} = E\{a_n^2\} \sum_{n} (h(t-nT))^2 e^{-4i\pi \Delta f t} $
This function is a periodic function which can be written as a Fourier series. It can be proven that its major coefficient stands at the frequency $2 \Delta f$.
The algorithm works then as follows:
- Compute the signal $y(t)^2$
- Compute its Fourier transform and find its maxima
- Estimate $2\Delta f$ as the point for which this maxima is reached.
Note that this technique can be straigthforward adapted to the case where the transmitted signal is a linearly modulated sequence of QAM symbols. The algorithm is modified as follows: The algorithm works then as follows:
- Compute the signal $y(t)^4$
- Compute its Fourier transform and find its maxima
- Estimate $4\Delta f$ as the point for which this maxima is reached.
Practical part
The estimation of the frequency offset is done with Matlab and SDR4All server. You have too use two instance of matlab:
- One to control an USRP in RX
- Another to control the other USRP in TX
The matlab code is available for downloading:
Signal to transmit
You have first to generate the signal to transmit:
[t,y] = GenerateSignal(); Vide = zeros(length(y),1); y = y.'; Sig = kron(ones(20,1),[y;Vide]);
The signal is duplicated several times so that you can get an complete version at the receiver.
The USRP is then set up in TX:
sock=SDR4All_Connect(1,'SlotA','TX'); SDR4All_SetGain(sock,20); % Maximal TX gain SDR4All_SetFreq(sock,2422e6); SDR4All_SetInterpRate(sock,256);
And when the receiver would be ready, use the sending data:
SDR4All_SendData(sock,Sig);
Signal reception and processing
You need to first set up the USRP in RX:
sock=SDR4All_Connect(0,'SlotA','RX'); [gain_min,gain_max,gain_step] = SDR4All_GetGain(sock); SDR4All_SetGain(sock,(gain_max+gain_min)/2); SDR4All_SetFreq(sock,2422e6); SDR4All_SetDecimRate(sock,128);
And when you are ready, get the transmitted data:
[Data] = SDR4All_GetData(sock,2*1000*500);
You should get a signal like the following one:
You can then estimate the frequency offset with the following commands:
[t2,y2] = SelectUsefulPart(Te,Data); % Select a burst of data y2 = y2.'; y2 = y2./max(abs(y2)); [z,offset] = CorrectFrequencyOffset(y2,ones(1,2000),5);
Note that this tutorial works only if you select the signal close enough of the beginning of the signal of interest. A tutorial with automatic synchronisation is also online.
Results
The results are the following ones:
As expected, you have a peak in the correlation function which correspond to the frequency 2 $\Delta f$.
