You are on page 1of 4

# ELT-43007 DIGITAL COMMUNICATIONS

Matlab Exercise #3

## FIR Based Zero-Forcing (ZF) Linear Equalization

In this exercise, you are required to create a runnable m-file during the exercise. Always use correct figure
numbers, e.g., figure(3) for figure number 3, so the overall m-file will produces nice figures.
Be prepared to discuss with the teacher about the questions given in red text. Teacher might approach
you and start discussion, so think about them and try them beforehand with your freshly generated
Matlab m-file.

## 1 SYSTEM MODEL, GENERATION OF TRANSMITTED SYMBOLS

AND MODELING THE ISI CHANNEL

## 1.1 SYSTEM MODEL

In this exercise, we create a baseband equivalent 16-QAM transmission system. We use oversampling
factor of 1 for simplicity, so the model is working at symbol rate. We create symbols at the transmitter,
model a channel, and perform linear equalization of the channel at the receiver. The system model is
depicted in Figure 1. For simplicity, we consider noise-free system ( Z k = 0 ).

## 1.2 SYSTEM PARAMETERS AND TRANSMITTED SEQUENCE GENERATION

 Let’s first set the simulation parameters:
Rs = 20e6; %Let's define symbol rate for the plotting purposes

##  Then let’s create the transmitted symbols/samples (note 1/Rs=T):

%% Creation of the data
%16-QAM alphabet:
a = repmat(-3:2:3,1,4)-[repmat(-3j,1,4) repmat(-1j,1,4) repmat(1j,1,4) repmat(3j,1,4)];
Ak = a(randi(16,1000,1)); % 16-QAM sequence of 1000 samples
 Let’s also plot ideal constellation:
figure(1); plot(real(a),imag(a),'o'); title('16-QAM constellation'); grid; xlabel('RE');
ylabel('IM');

You should now see a pure 16-QAM constellation. Try to understand how the random data is
mapped to constellation points. The above way to create 16-QAM alphabets is short. Can you think
of other ways to create the alphabet?

## 1.3 BASEBAND EQUIVALENT SYSTEM MODEL

 We start by defining the channel:
%% Channel creation and channel modelling
p = [0.19+.56j .45-1.28j -.14-.53j -.19+.23j .33+.51j]; % Example complex channel model

This is just an example channel. It is a single realization of truncated version of actual channel used,
e.g., in 3GPP LTE radio link evaluations.
 Then we define L1 and L2 based on the above channel model. See lecture material p.317 how to
define these for any channel:
L1=1; L2=3; % Channel maximum tap is the second one, see p.317. we start with a pretty short
equalizer… later we increase the length also

 We then plot absolute values of the channel impulse response. Notice that the channel is
complex valued, so absolute value tells the relative strength of each of the channel taps. We use
subplot command here, because later we will plot additional subplots to this same figure(2):
figure(2); subplot(311); stem(-L1:L2,abs(p),'r');legend('ISI Channel');
title('Absolute values of impulse responses'); % Absolute values of channel impulse response

 Now we plot the amplitude response of the channel. Notice again the subplot command, we
will come back to figure(4) again, and plot some friends for the channel’s response:
%Plotting amplitude response of the channel:
figure(4); [H,f]=freqz(p,1,-Rs/2:Rs/200:Rs/2,Rs); plot(f/1e6,20*log10(abs(H)),'b'); grid on;
xlabel('Frequency [MHz]');ylabel('Amplitude response [dB]'); legend('ISI Channel');
title('Frequency Responses');

Notice that we computed the amplitude response of the channel with freqz function. How can you
do it with fft-function?

## 1.4 APPLYING THE ISI CHANNEL MODEL TO THE TRANSMITTED SEQUENCE

 Now we use filter function to apply the channel. We also get rid of the anti-causal delay:
Rk = filter(p,1,Ak); % Received signal
Rk = Rk(L1+1:end); % Discard the delay, if channel is anti-causal

 Now, we plot the constellation of the signal after the channel. ISI is now present in the
constellation
figure(6);plot(real(Rk),imag(Rk),'o'); grid on; xlabel('RE');ylabel('IM'); % Constellation
with ISI
2 CHANNEL EQUALIZATION WITH LEAST SQUARES BASED AND
INVERSION BASED ZF-FIR EQUALIZERS
Here we are cancelling the effect of the channel by using a filter that has approximately the
opposite effect to the signal as the channel. We are therefore trying to design a filter (equalizer)
that based on some design criterion minimizes the ISI. Here, we study least squares (LS) based
equalizer (see p.318-319) and channel inversing base equalizer (see p.320-321).

## 2.1 CHANNEL EQUALIZATION WITH LS BASED ZF-FIR EQUALIZER

 We are now cancelling the effect of the channel by using a filter c that tries to minimize the
squared error norm between the target equalized impulse response and realized equalized
impulse response:
%% FIR zero forcing equalizer (LS approach on p.318)
N1=2; N2=5; % Equalizer length is N1+N2+1
P=convmtx(p.',N1+N2+1); % Convolution matrix (see lecture material p. 318)
u_ZF=zeros(N1+N2+L1+L2+1,1); % u vector (zero forcing) (p.319)
u_ZF(L1+N1+1)=1; % Puts the one in the place corresponding to channel delay.
c_LS=((P'*P)\(P'))*u_ZF; % LS equalizer taps with pseudoinverse
Rk_LS=filter(c_LS,1,Rk); % Equalized data
Rk_LS=Rk_LS(L1+N1+1:end); % Discard the transient of the equalizer

You can see that we use so-called pseudo-inverse to solve the LS solution for the equalizer. Our
goal is to have Pc = uZF (we use zero forcing, i.e., try to force ICI to zero). With LS criterion we
- 1
can solve c = (PH P ) PH uZF . Notice that P is not square matrix, so we cannot solve traditional
inverse.

## 2.2 CHANNEL EQUALIZATION WITH INVERSION BASED ZF-FIR EQUALIZER

 We are now cancelling the effect of the channel by using a filter c that sets the N1 and N2 ISI
terms to zeros before and after the current symbol, respectively:
%% FIR zero forcing equalizer (alternative INV approach on p.320)
P_alt=P(N1+L1+1-N1:N1+L1+1+N2,:); % Picking the correct row of P (p.320)
u_alt=zeros(N1+N2+1,1); % u vector (zero forcing) (p.321)
u_alt(N1+1)=1; % Puts the one in the center.
c_INV=P_alt\u_alt; % INV equalizer taps with inverse
Rk_INV=filter(c_INV,1,Rk); % Equalized data
Rk_INV=Rk_INV(L1+N1+1:end); % Discard the transient of the equalizer

You can see that now instead of pseudo-inverse, we use actual inverse. We only pick up limited
amount of rows of P to get a square matrix (see p.320), so we can have solution Palt c = uZF ,alt .
Now since Palt is square matrix, we can solve c = Palt- 1uZF ,alt .

## 2.3 PLOTTING INTERESTING CURVES

 Here we plot interesting figures to help analyze the used equalizers. Please follow the
comments and the code, and try to understand why each figure indeed depicts what it claims to
depict:
Notice that some of the command add more data to previously created figures. If you already
deleted the figures that you created above, you can rerun the code.
%% Plotting absolute values of the impulse responses of the equalizers
figure(2);subplot(312);stem(-N1:N2,abs(c_LS)); legend('LS equalizer');
axis([-N1-L1 N2+L2 0 Inf]);
figure(2);subplot(313);stem(-N1:N2,abs(c_INV)); legend('INV equalizer');
axis([-N1-L1 N2+L2 0 Inf]);
figure(2); subplot(311); axis([-N1-L1 N2+L2 0 Inf]);

%% Plotting absolute values of the total impulse response of channel + LS/INV equalizers
figure(3);subplot(211);stem(-N1-L1:N2+L2,abs(conv(p,c_LS)));
legend('ISI Channel + LS equalizer'); axis([-N1-L1 N2+L2 0 Inf]);
figure(3);subplot(212);stem(-N1-L1:N2+L2,abs(conv(p,c_INV)));
legend('ISI Channel + INV equalizer'); axis([-N1-L1 N2+L2 0 Inf]);

## %% Plotting amplitude responses of the LS equalizer and the

%% product of channel and LS equalizer
figure(4); hold on; [H_LS,f]=freqz(c_LS,1,-Rs/2:Rs/200:Rs/2,Rs);
plot(f/1e6,20*log10(abs(H_LS)),'r'); % Amplitude response of the LS equalizer
figure(4); H_tot=H.*H_LS; plot(f/1e6,20*log10(abs(H_tot)),'k'); hold off;
legend('ISI Channel','LS equalizer','Total') % Amplitude response of the channel+LS equalizer

## %% Plotting amplitude responses of the channel, INV equalizer

%% and the product of channel and LS equalizer
figure(5); hold on; plot(f/1e6,20*log10(abs(H)),'r'); grid on; title('Frequency Responses');
[H_INV,f]=freqz(c_INV,1,-Rs/2:Rs/200:Rs/2,Rs); % Amplitude response of the INV equalizer
plot(f/1e6,20*log10(abs(H_INV)));
xlabel('Frequency [MHz]');ylabel('Amplitude response [dB]');
H_tot_inv=H.*H_INV; plot(f/1e6,20*log10(abs(H_tot_inv)),'k'); hold off;
legend('ISI Channel','INV equalizer','Total') % Amplitude response of the channel+INV
equalizer

## %% Plotting constellations (Comparing first method to non-equalized)

figure(6); hold on; plot(real(Rk_LS),imag(Rk_LS),'r.'); % Equalized constellation
plot(real(a),imag(a),'ko', 'MarkerSize',6, 'MarkerFaceColor','k'); hold off; %Ideal
constellation
grid on; legend('Data after ISI channel','Equalized data','Ideal constellation points');
axis equal;

## %% Plotting constellations (Comparing second method to first method)

figure(7); hold on;
plot(real(Rk_INV),imag(Rk_INV),'rx'); % LS equalized constellation
plot(real(Rk_LS),imag(Rk_LS),'g.'); % INV equalized constellation
plot(real(a),imag(a),'ko', 'MarkerSize',6, 'MarkerFaceColor','k'); hold off; %Ideal
constellation
grid on; legend('Equalized data (INV)','Equalized data (LS)','Ideal constellation points');
xlabel('RE');ylabel('IM'); axis equal;

## 3 USING THE CREATED CODE FOR FURTHER ANALYSIS

Use the above code to understand what is the difference between LS equalizer and inverse
based equalizer. The difference is explained above and in the lecture notes, but be prepared to
support this fact with the help of some of the figures generated above.

Does the equalizers work well? Are there any differences in performance of LS and INV
equalizers?

What happens if you change the equalizer tail lengths N1 and N2? Please evaluate the different
length equalizers.

Can you get it still work, if you change the channel? You can try, e.g., very simple lowpass
channel fir1(4,0.5). Try to set the parameters so that the equalizer work without using overly
high values of N1 and N2.