Anda di halaman 1dari 60

HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

1.a.Channel equalizer design using MATLAB (LMS, RLS)


LMS Algorithm:
Aim:
To minimize the error coefficients in the channel using LMS algorithm.
Software Used:
MATLAB Package
Theory
In a communication system ,the transmitter sends the information over an RF channel.
The channel distorts the transmitted signal before it reaches the receiver .The receivers task is
to figure out what signal is transmitted and turn the received in understandable information.
Unfortunately, often the digital transmission of information is accompanied with a phenomenon
known as Inter Symbol Interference(ISI). This means that transmitted pulses are smeared out so
that the pulses that corresponds to different signals are not seperable. Traditionally, ISI pattern is
resolved by channel equalization in which aim is to construct an equalizer such that the impulse
response of channel equalizers combination is as close to z^-d as possible. Where d is the delay.
LMS ALGORITHM:
Least mean square algorithm are used in adaptive filters and find filter coefficient that
relate to producing the least mean squares of error signal. It is stochastic gradient descent method
in that filter is only adapted based on error at correct time. It is implemented using FIR for
adjusting the coefficients. There are different modes in which they work
1) Training: The channel equalizer identifies the channel characteristics and work with
known training sequences.
2) Tracking: The equalizer operates in so called direction fashion.
ADVANTAGES:
1) Simplicity in implementation
2) State and robust performance against different signal condition.
.
Algorithm:
Get the value for length of filter,channel order,iteration step size.
Get the Gaussian input signal
OUTPUT:

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Choose the channel to be random uniform


Normalize the channel
Convolve channel with the input
Take the co-efficient of the filter
Initialize the variables that are stored in array.
LMS Adaptation
Select part of training input
Compute the errors
Get the values and output is plotted for those values.

Program:

clc;
clear all;
numpoints=5000;
numtaps=10;
u=0.01;
count=0;
ber=[];
c=[1 0 8];
x=randn(numpoints,1);
y=conv(x,c);
y=y+0.01;
w=zeros(numtaps,1)+i*zeros(numtaps,1);
for n=numtaps:numpoints
inp=y(n:-1:n-numtaps+1);
yi(n)=w'*inp;
e(n)=y(n)-yi(n);

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

e2(n)=e(n).^2;

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

wi=w+u*(real(e(n)*conj(inp))+i*imag(e(n)*conj(inp)));
if yi>=0
yi=1;
else
yi=-1;
end
if wi~=yi
count=count+1;
end
ber1=count/n;
ber=[ber,ber1];
end
figure(1),plot(e);
xlabel('No.of.iterations');
ylabel('Estimation of output error');
title('Error VS No.of iterations');
figure(2),plot(ber);
xlabel('No.of.iterations');
ylabel('BER');
title('BER VS No.of iterations');
Result:

Thus the minimizing error coefficients in the channel using LMS algorithm was verified
and the output was plotted.

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

1.b RLS Algorithm

Aim:

To minimize the error co-efficient in the channel using RLS Algorithm.

Software Used:

MATLAB Package.

Theory
In a communication system ,the transmitter sends the information over an RF channel.
The channel distorts the transmitted signal before it reaches the receiver .The receivers task is
to figure out what signal is transmitted and turn the received in understandable information.
Unfortunately, often the digital transmission of information is accompanied with a phenomenon
known as Inter Symbol Interference(ISI). This means that transmitted pulses are smeared out so
that the pulses that corresponds to different signals are not seperable. Traditionally, ISI pattern is
resolved by channel equalization in which aim is to construct an equalizer such that the impulse
response of channel equalizers combination is as close to z^-d as possible. Where d is the delay.

RLS ALGORITHM:
Recursive least square algorithm is used in adaptive filter to find filter coefficient that
relate to recursively producing the least squares of error occurs in signal. This is contrast to other
algorithm that aim to reduce the mean square error. The difference is that RLS filters are
dependent on signals themselves where as MSE filters are dependent on the statistics are known
as MSE filter with fixed coefficient can be built.
Compared to LMS, RLS approach faster convergence and smaller error with
respect to unknown system. When the LMS algorithm looks at the error to minimize it and
considers only the current error value. In RLS method, the error consider is the total error from
the beginning to the current data point. RLS also has infinite memory. LMS represent most
simplest and RLS representation will increase the complexity.

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

OUTPUT:

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Algorithm:
Get the value for length of filter,channel order,iteration step size.
Get the Gaussian input signal
Choose the channel to be random uniform
Normalize the channel
Convolve channel with the input
Take the co-efficient of the filter
Initialize the variables that are stored in array.
RLS Adaptation
Select part of training input
Compute the errors
Get the values and output is plotted for those values.
Program:

clc;
clear all;

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

numpoints=2100;
numtaps=10;
lamda=0.99;
count=0;
delta=1;
ber=[];
c=[1 0 8];
x=randn(numpoints,1)+i*randn(numpoints,1);
h=conv(x,c);
d=h+0.01;
w=zeros(numtaps,1)+i*zeros(numtaps,1);
p=diag(ones(numtaps,1)*delta);
for n=numtaps:numpoints

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

inp=d(n:-1:n-numtaps+1);
yi(n)= w'*inp;
e(n)=d(n)-yi(n);
z=inp'*p;
g=z'/(lamda+z*inp);
w=w+(real(e(n)*conj(g))-i*imag(e(n)*conj(g)));
p=(p-g*z)/lamda;
if yi>=0
yi=1;
else
yi=-1;
end
if w~=yi
count=count+1;

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

end
ber1=count/n;
ber=[ber,ber1];
end
figure(1),semilogy(abs(e));
xlabel('No.of iterations');
ylabel('Estimation of output error');
title('Error VS No.of iterations');
figure(2),plot(ber);
xlabel('No.of iterations'); ylabel('BER'); title('BER VS No.of iterations');
Result:

Thus the minimizing error coefficients in the channel using RLS algorithm was verified and the
output was plotted.

2a.Performance Evaluation of digital modulation schemes

a.BFSK:

Aim:

To analyze the system error rate and bit error rate using BFSK.

Apparatus Required:

MATLAB 7.5

Theory:

Frequency shift keying (FSK) is a relatively simple, low-performance form of digital


modulation. Binary FSK is a form of FSK where the input signal can have only two different
values (hence the name binary). Binary FSK is a constant-envelope form of angle modulation
similar to conventional frequency modulation except that the modulating signal varies between
two discrete voltage levels (i.e., 1s and 0s) rather than with a continuously changing value, such
as a sine wave. Binary FSK is the most common form of FSK. With Binary FSK, the center or

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

carrier frequency is shifted by the binary input signal. Consequently, the output from an FSK
modulator is a step function in the frequency domain. As the binary input signal changes from a
logic 0 to logic 1 and vice versa, the FSK output signal shifts between two frequencies; a mark or
logic 1 frequency and a space or logic 0 frequency.

Procedure:

Get the random binary input signal.

Encoded the input signal using FSK modulation.

The noise is added with the signal.

The modulated signal is transmitted.

The signal is received and detected.

The BER and SER are computed and the output is plotted for those values.

OUTPUT:

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Program:

clear

N = 10^5 % number of bits or symbols

T = 8; % symbol duration

t = [0:1/T:0.99]; % sampling instants

tR = kron(ones(1,N),t); % repeating the sampling instants

Eb_N0_dB = [0:11]; % multiple Eb/N0 values

for ii = 1:length(Eb_N0_dB)

% generating the bits

ip = rand(1,N)>0.5; % generating 0,1 with equal probability

freqM = ip+1; % converting the bits into frequency, bit0 -> frequency of 1, bit1 -> frequency
of 2

freqR = kron(freqM,ones(1,T)); % repeating

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

x = (sqrt(2)/sqrt(T))*cos(2*pi*freqR.*tR); %generating the FSK modulated signal

% noise

n = 1/sqrt(2)*[randn(1,N*T) + j*randn(1,N*T)]; % white gaussian noise, 0dB variance

% coherent receiver

y = x + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise

op1 = conv(y, sqrt(2/T)*cos(2*pi*1*t)); % correlating with frequency 1

op2 = conv(y, sqrt(2/T)*cos(2*pi*2*t)); % correlating with frequency 2

% demodulation

ipHat = [real(op1(T+1:T:end)) < real(op2(T+1:T:end))]; %

nErr(ii) = size(find([ip - ipHat]),2); % counting the number of errors

end

simBer = nErr/N;

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

theoryBer = 0.5*erfc(sqrt((10.^(Eb_N0_dB/10))/2)); %theoretical BER

figure

semilogy(Eb_N0_dB,theoryBer,'b-');

hold on

semilogy(Eb_N0_dB,simBer,'mx-');

axis([0 11 10^-4 0.5])

grid on

legend('theory:fsk-coh', 'sim:fsk-coh');

xlabel('Eb/No, dB')

ylabel('Bit Error Rate')

title('Bit error probability curve')

Result:

Thus the analysis of SER and BER using BFSK modulation technique was performed.

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

2b.BPSK

Aim:

To analyze the system error rate and bit error rate using BPSK.

Apparatus Required:

MATLAB 7.5

Theory:

Binary Phase Shift Keying (BPSK) is a type of phase modulation using 2 distinct carrier
phases to signal ones and zeros. BPSK is the simplest form of PSK. It uses two phases which are
separated by 180 and so can also be termed 2-PSK. It does not particularly matter exactly where
the constellation points are positioned, and, in this figure, they are shown on the real axis, at 0
and 180. This modulation is the most robust of all the PSKs since it takes serious distortion to
make the demodulator reach an incorrect decision. It is, however, only able to modulate at
1bit/symbol (as seen in the figure) and so is unsuitable for high data-rate applications.

Procedure:

Get the random binary input signal.

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Encoded the input signal using BPSK modulation.

The noise is added with the signal.

The modulated signal is transmitted.

The signal is received and detected.

The BER and SER are computed and the output is plotted.

Program:

Clear;N = 10^6 % number of bits or symbols

rand('state',100); % initializing the rand() function

randn('state',200); % initializing the randn() function

% % Transmitter

ip = rand(1,N)>0.5; % generating 0,1 with equal probability

s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 1

OUTPUT:

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white gaussian noise, 0dB variance

Eb_N0_dB = [-3:10]; % multiple Eb/N0 values

for ii = 1:length(Eb_N0_dB)

% Noise addition

y = s + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise

% receiver - hard decision decoding

ipHat = real(y)>0;

% counting the errors

nErr(ii) = size(find([ip- ipHat]),2);

end

simBer = nErr/N; % simulated ber

theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber

close all

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

figure

semilogy(Eb_N0_dB,theoryBer,'b.-');

hold on

semilogy(Eb_N0_dB,simBer,'mx-');

axis([-3 10 10^-5 0.5])

grid on

legend('theory', 'simulation');

xlabel('Eb/No, dB');

ylabel('Bit Error Rate');

title('Bit error probability curve for BPSK modulation');

Result:

Thus the analysis of SER and BER using BPSK modulation technique was performed.

3.OFDM transceiver design using MATLAB


Aim:

To generate OFDM transmit waveform closely based on IEEE


802.11a specification.

Software Used:

MATLAB Package.

Theory:

The basic principle of OFDM is to split a high-rate datastream into a number of lower
rate streams that are transmitted simultaneously over a number of subcarriers. Because the
symbol duration increases for lower rate parallel subcarriers, the relative amount of dispersion in
time caused by multipath delay spread is decreased. Intersymbol interference is eliminated
almost completely by introducing a guard time in every OFDM symbol. In the guard time , the
symbol is cyclically extended to avoid intercarrier interference. In OFDM design, a number of
parameters are up for consideration, such as the number of subcarriers, guard time, symbol
duration, subcarrier spacing, modulation type per subcarrier. The choice of parameters is

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

influenced by system requirements such as available bandwidth, required bit rate, tolerable delay
spread, and Doppler values. Some requirement are conflicting. For instance, to get a good delay
spread tolerance, a large number of subcarriers with small subcarrier spacing is desirable, but the
opposite is true for a good tolerance against Doppler spread and phase noise.
Procedure:

To open matlab package click start-All programs-matlab.

Now click file new matlab editor window appeared.

Type the matlab code.

To run the program click debug-run.

Correct the errors in the main MATLAB and display the results.

Program:

close all;clear all;clc

t_data=randint(9600,1)';

OUTPUT:

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

x=1;

si=1; %for BER rows

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

%%

for d=1:100;

data=t_data(x:x+95);

x=x+96;

k=3;

n=6;

s1=size(data,2); % Size of input matrix

j=s1/k;

% Convolutionally encoding data

constlen=7;

codegen = [171 133]; % Polynomial

trellis = poly2trellis(constlen, codegen);

codedata = convenc(data, trellis);

%Interleaving coded data

s2=size(codedata,2);

j=s2/4;

matrix=reshape(codedata,j,4);

intlvddata = matintrlv(matrix',2,2)'; % Interleave.

intlvddata=intlvddata';

% Binary to decimal conversion

dec=bi2de(intlvddata','left-msb');

%16-QAM Modulation

M=16;

y = qammod(dec,M);

% scatterplot(y);

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

% Pilot insertion

lendata=length(y);

pilt=3+3j;

nofpits=4;

k=1;

for i=(1:13:52)

pilt_data1(i)=pilt;

for j=(i+1:i+12);

pilt_data1(j)=y(k);

k=k+1;

end

end

pilt_data1=pilt_data1'; % size of pilt_data =52

pilt_data(1:52)=pilt_data1(1:52); % upsizing to 64

pilt_data(13:64)=pilt_data1(1:52); % upsizing to 64

for i=1:52

pilt_data(i+6)=pilt_data1(i);

end

% IFFT

ifft_sig=ifft(pilt_data',64);

% Adding Cyclic Extension

st=[]

% cext_data=zeros(80,1);

cext_data(1:16)=ifft_sig(49:64);

for i=1:64

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

cext_data(i+16)=ifft_sig(i);

st=[st cext_data];

end

fMHZ=20;

[Pxx,W]=pwelch(st,[],[],4096,20);

figure(1),plot([-2048:2047]*fMHZ/4096,10*log10(fftshift(Pxx)));

xlabel('frequency,MHz')

ylabel('power spectral density')

title('Transmit Spectrum OFDM')

% Channel

% SNR

o=1;

for snr=0:2:50

ofdm_sig=awgn(cext_data,snr,'measured'); % Adding white Gaussian Noise

% figure;

% index=1:80;

% plot(index,cext_data,'b',index,ofdm_sig,'r'); %plot both signals

% legend('Original Signal to be Transmitted','Signal with AWGN');

% RECEIVER

%Removing Cyclic Extension

for i=1:64

rxed_sig(i)=ofdm_sig(i+16);

end

% FFT

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

ff_sig=fft(rxed_sig,64);

% Pilot Synch%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i=1:52

synched_sig1(i)=ff_sig(i+6);

end

k=1;

for i=(1:13:52)

for j=(i+1:i+12);

synched_sig(k)=synched_sig1(j);

k=k+1;

end

end

% scatterplot(synched_sig)

% Demodulation

dem_data= qamdemod(synched_sig,16);

% Decimal to binary conversion

bin=de2bi(dem_data','left-msb');

bin=bin';

% De-Interleaving

deintlvddata = matdeintrlv(bin,2,2); % De-Interleave

deintlvddata=deintlvddata';

deintlvddata=deintlvddata(:)';

%Decoding data

n=6;

k=3;

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

decodedata =vitdec(deintlvddata,trellis,5,'trunc','hard'); % decoding datausing veterbi


decoder

rxed_data=decodedata;

% Calculating BER

rxed_data=rxed_data(:)';

errors=0;

c=xor(data,rxed_data);

errors=nnz(c);

% for i=1:length(data)

% if rxed_data(i)~=data(i);

% errors=errors+1;

% end

% end

BER(si,o)=errors/length(data);

o=o+1;

end % SNR loop ends here

si=si+1;

end % main data loop

% Time averaging for optimum results

for col=1:25; %%%change if SNR loop Changed

ber(1,col)=0;

for row=1:100;

ber(1,col)=ber(1,col)+BER(row,col);

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

end

end

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

ber=ber./100;

figure

i=0:2:48;

semilogy(i,ber);

title('BER vs SNR');

ylabel('BER');

xlabel('SNR (dB)');

grid on

Result:

Thus the required OFDM transceiver waveform was generated and


the output was verified using BER and SNR.

4.SIMULATION OF MICROSTRIP ANTENNAS

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

AIM:
To simulate the design of the micro strip antennas using MATLAB.

SOFTWARE REQUIRED:
Matlab 7.0
Windows XP

THEORY:
In high performance aircraft, space craft, satellite and missile applications whose size,
weight, cost, performance, ease of installation and aerodynamic profiler constraints and low
profile antennas may be required. Presently there are many other governments and commercial
applications such as mobile radio and wireless communications that have similar specification.

To meet these requirements micro strip antennas can be used. These antennas are low
profile, conformable to planar and non planar surfaces, simple and in expensive to manufacture
using modern printed circuit technology, mechanically robust when mounted on rigid surfaces,
compatible with MMIC design and when the particular patch shape and mode are selected they
are very versatile in terms of resonant frequency, polarization, pattern and impedance.

Often micro strip antennas are also referred to as patch antennas. The radiating elements and
the feed lines are usually photo etched on dielectric substrate. The radiating patch may be
square, rectangular, thin strip, circular, elliptical, triangular or any other configuration. There are
many configurations that can be used to feed micro strip antennas. The four most popular are the
micro strip lines, coaxial probe, aperture coupling and proximity coupling.

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

DESIGN:

specify:
er, fr (in GHz) and h

Determine:
W, L

Where,

W - Width (in cm)

L - Length (in cm)

0 free space velocity

h - Height of the dielectric substrate ? L

er Dielectric constant

PROCEDURE:
1. For an efficient radiation, a practical width that leads to good radiation efficiencies is
W=(1/2frv 0e0)(v2/er+1)
2. Determine the effective dielectric constant of the micro strip antennas. ereff=((er+1)/2)+
((er-1)/2)[1+12(h/W)]^(1/2)
3. Once W is found, determine the expression of length ?L using equation (?
L/h)=0.412[ereff+0.3/ereff-0.258][(W/h)+0.264/(W/h)+0.813]
4. The actual length of patch can be determined as below L=(1/
(2frv 0e0vereff))-2?L

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

FLOWCHART:

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

PROGRAM:
clc;
clear all;
close all;
display('SIMULATION OF MICROSTRIP PATCH ANTENNA');
er=input('enter the dielectric constant of the substrate');
fr=input('enter the resonant frequency(GHz)');
h=input('enter the height of the substrate');
c=sqrt((2/(er+1)));
d=30/(2*fr);
w=c*d;
display('width of the patch');
display(w);
a1=(er+1)/2;
b1=(er-1)/2;
c1=power((1+12*(h/w)),-0.5);
ereff=a1+(b1*c1);
display ('effective dielectric constant of the patch');
display (ereff);
a2=(ereff+0.3)*((w/h)+0.264);
b2=(ereff-0.258)*((w/h)+0.8);
deil=h*0.421*(a2/b2);
display('extented incremental length of the patch');
display(deil);
L=(30/(2*fr*sqrt(ereff)))-(2*deil);
display('the actual length of the patch');
display(L);
Le=L+(2*deil);
display('the effective length of the patch');
display(Le);

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

OUTPUT:
SIMULATION OF MICROSTRIP PATCH ANTENNA
enter the dielectric constant of the substrate2
enter the resonant frequency(GHz)400
enter the height of the substrate6
width of the patch

w=

0.0306

effective dielectric constant of the patch

ereff =

1.5103

extented incremental length of the patch

deil =

1.2205

the actual length of the patch

L=

-2.4105

the effective length of the patch

Le =

0.0305

RESULT:
The simulation of micro strip antenna was done using MATLAB 7.0. The parameters such
as width and length of the patch, effective dielectric constant of the micro strip antenna,
extension length of the patch was found using empirical formulas for the specified dielectric
constant and resonant frequency.

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Lab:5 linear block codes and cyclic codes


AIM
To simulate linear block coding techniques for hamming and cyclic code using MATLAB.
THEORY
HAMMING CODES
Consider a family of (n,k) linear block codes that have the following parameters.
Block length,n=2m-1
No.of.message bits k=2m-m-1
No. of parity bits, n-k=m, where m>=3.
These are so called Hamming codes. To illustrate the relations between the minimum
distance dmin and the structure of the parity check matrix H. Consider the codeword 0110100,In
the matrix multiplication is done, and the non-zero elements of this codeword shift out the
second, third and fifth column of the matrix if yielding. An important property of hamming codes
is that they satisfy the condition. t=1.This means that hamming codes are single error correcting
binary perfect codes.
CYCLIC CODES
Cyclic codes form a sub class of linear block codes.A binary code is said to be cyclic code,if it
exhibits two fundamental properties.

1. LINEARITY PROPERTY

The sum of two codeword is also a codeword.

2. CYCLIC PROPERTY

Any cyclic shift of codeword is also called a codeword.

ALGORITHM
HAMMING CODE
STEP 1: Start the program
STEP 2: Assign the number of parity bits m=4
STEP 3: Calculate the block length n from m=2m-1
STEP 4: Assign the number of message bits k such that n-k=m so k=11

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

STEP 5: The hamming code is (5,11)


STEP 6: Obtain the input signal message randomly the input message is in binary format
STEP 7: The parity bits are calculated for input message taken.
STEP 8: The parity bits are appended along the message bit to form the codeword.
STEP 9: The codeword formed is transmitted through AWGN channel
STEP10: The received signal is then decoded to retrieve the message
STEP 11: The BER is calculated for the retrieved message
STEP 12: For the various values of the SNR and its corresponding BER,the graph is
Plotted.
CYCLIC CODE
STEP 1: Start the program.
STEP 2: Assign the block length n=7.
STEP 3: Assign the message bits,k=4.
STEP 4: The cyclic code is (7,4)
STEP 5:Generate the polynomial.
STEP 6: Obtain the input message randomly.
STEP 7: The input message is in binary format.
STEP 8: The codeword is formed by appending the parity bits with the message bits.
STEP 9: The parity bits are calculated from the generation polynomial.
STEP10: The codeword formed is transmitted through AWGN channel.
STEP11: The received signal is then decoded with the help of generator polynomial

Knowledge to retrieve the message.

PROGRAM

HAMMING CODE

####################################

clc;

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

clear all;

close all;

m=4;

n=2^m-1;

k=11;

berf=[];

for i=1:10

b=0;

for j=1:50

msg=randint(500,k,[0,1]);

code=encode(msg,n,k,'hamming/binary');

t=0:0.1:10;

snr=0;

y=awgn(code,i);

y(find(y>0))=1;

y(find(y<0))=0;

msgop=decode(y,n,k,'hamming/binary');

[number,b1]=biterr(msgop,msg);

b=b+b1;

end

berf(i)=b/50;

end

semilogy(1:10,berf);

title('performance analysis in awgn for hamming codes');

xlabel('snr(db)');

ylabel('BER');

#######################################################################
CYCLIC CODES

clc;
clear all;
close all;
n=7;
k=4;
genpoly=cyclpoly(n,k,'max');
berf=[];
for i=1:10
b=0;
for j=1:50
msg=randint(500,k,[0,1]);
code=encode(msg,n,k,'cyclic/binary',genpoly);

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

t=0:0.1:10;
snr=0;
y=awgn(code,i);
y(find(y>0))=1;
y(find(y<0))=1;
msgop=decode(y,n,k,'cyclic/binary',genpoly);
[number,b1]=biterr(msgop,msg);
b=b+b1;
end
berf(i)=b/50;
end
semilogy(1:10,berf);
title('performance analysis in awgn for cyclic codes');
xlabel ('snr (db)');
ylabel ('BER');

#########################################################

RESULT
Thus the linear block coding technique for hamming code and cyclic code has been simulated
using MATLAB

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Lab 6a.ANALOG HIGH PASS FILTER

AIM: - TO write a MATLAB program to plot magnitude response of analog

High pass filter..

PROCEDURE:-

Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window

PROGRAM:-

clc;

close all;

clear all;

f=100:20:8000;

fl=400;

k=length(f);

for i=1:k;

m(i)=1/sqrt(1+(fl/f(i))^2);

mag(i)=20*log10(m(i));

end;

figure;

semilogx(f,mag);

title('magnitude response of analog of high pass filter');

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

xlabel('frequency----->');

ylabel('magnitude in db');

grid on;

RESULTS:- Thus the MATLAB program for analog high pass filter was
written and magnitude response was plotted.

OUTPUT:

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

ANALOG LOW PASS FILTER

AIM: - To write a MATLAB program to plot magnitude response of analog

Low pass filter.

PROCEDURE:-

Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window

PROGRAM:-

clc;

close all;

clear all;

f=100:20:8000;

fh=900;

k=length(f);

for i=1:k;

m(i)=1/sqrt(1+(f(i)/fh)^2);

mag(i)=20*log10(m(i));

end;

figure;

semilogx(f,mag);

title('magnitude response of analog of low pass filter')

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

xlabel('frequency----->');

ylabel('magnitude in db');

grid on;

RESULTS:-

Thus the MATLAB program for analog Low pass filter was written and
magnitude response was plotted.

OUTPUT:-

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Lab 6b.DESIGN OF DIGITAL FIR FILTERS

Aim:

To write MATLAB programs for the following FIR filters:

1 Low pass filter


2 High pass filter
3 Band pass filter
4 Band stop filter

Essentials required:

Hardware: IBM PC or compatible

Software : MATLAB v5.1 or higher

Theory:

A filter is defined as a system that selectively changes the frequency


characteristics of a signal. It is used to improve the quality of the signal by reducing
the amount of noise present in the signal.

Impulse response of a system is defined as the response of the system when


an impulse sequence is given as the input. We can therefore divide the class of
linear time invariant systems into two types, those that have a finite duration
impulse response and those that have an infinite duration impulse response. Those
that belong to the first category are known as finite impulse response or FIR
system. Thus an FIR system has an impulse response that is zero outside of some
finite time interval. An FIR filter is defined by the equation

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

M 1
y (n) bk x (n k )
k 0

Digital filters play a very important role in DSP. Compared to analog filters, they are
preferred in a number of applications because of the advantages it provides over
the analog counterpart. Some of the typical advantages are

Digital filters have characteristics that are not possible with analog filters
such as true linear phase.
Unlike the analog filters the performance of the digital filters does not vary
with environmental changes for example thermal variations.
Several input signals or channels can be filtered by one digital filter without
the need to replicate the hardware.
Both the filtered and unfiltered data can be saved for further use.
Digital filters can be used at very low frequencies. Hence they find very wide
use in biomedical applications.

An FIR filter has only zeros and no poles. Hence the system is always stable.
Another important characteristic is that they provide linear phase. Thus the FIR
filters are the ones widely used. Different methods for design of FIR filters include
the window method, frequency sampling method and the minimax method.

Program:

% fir filter

clc;

clear all;

close all;

%low pass filter

n=50;

wn=0.5;

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

b=fir1(n,wn);

fvtool(b,1);

%high pass filter

n=50;

wn=0.5;

b=fir1(n,wn,'high');

fvtool(b,1);

% band pass filter

n=50;

wn1=0.4;

wn2=0.8;

b=fir1(n,[wn1,wn2]);

fvtool(b,1);

% band stop filter

n=50;

wn1=0.4;

wn2=0.8;

b=fir1(n,[wn1,wn2],'stop');

fvtool(b,1);

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Graph:

Low pass filter:

Magnitude Response in dB
20

-20

-40
Magnitude (dB)

-60

-80

-100

-120

-140
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
Normalized Frequency ( rad/sample)

High Pass Filter:

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Magnitude Response in dB
20

-20
M a g n itu d e ( d B )

-40

-60

-80

-100

-120

-140
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
Normalized Frequency ( rad/sample)

Band Pass Filter:

Magnitude Response in dB
0

-20

-40
M a g n itu d e ( d B )

-60

-80

-100

-120

-140
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
Normalized Frequency ( rad/sample)

Band Stop Filter:

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Magnitude Response in dB
20

-20
M agnitude (dB)

-40

-60

-80

-100

-120
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
Normalized Frequency ( rad/sample)

RESULT:

The MATLAB programs to implement FIR filters are written and the results are
plotted.

7.a.RADIATION PATTERN OF FOLDED DIPOLE ANTENNA

AIM

To plot the radiation pattern of folded dipole antenna (E-plane).

APPARATUS REQUIRED

1. Antenna transmitter, receiver and stepper motor controller


2. Folded Dipole antenna, half wave dipole antenna
3. Antenna tripod and stepper pod with connecting cables.
THEORY

Antenna or areal is defined as a metallic device for radiating radio waves. In other words,
the antenna is transitional structure between free space wave and a guiding device. The guiding

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

device or transmission line may take the form of a co axial line or a wave guide and it is used to
transport electromagnetic energy from the transmitting source to the antenna or from the antenna
to the receiver.

An antenna radiation pattern or antenna pattern is defined as a mathematical function or a


graphical representation of the variation of field or power as a function of spherical co ordinates.

FORMULA USED

1. 3 dB beam width
Select the 3 dB signal strength in polar plot and mark the intersection points of the beam
in that circle. And find the angle between the intersection points

2. Front to back ratio


It is the ratio of maximum signal strength in the intended direction to the signal strength
in the opposite direction

FBR=Maximum signal strength in the intended medium

Signal strength in the opposite direction

220

230

240

250

260

270

280

290

300

310

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

320

330

340

350

360

PROCEDURE

1. Connect the dipole antenna to the tripod and set the transmitter frequency to 600MHz.
Keep the antenna in horizontal plane.
2. Now connect folded dipole antenna to the stepper tripod and set the receiver to 600MHz
3. Set the distance between two antennas is around 1m.Any Stray objects around the
antenna is removed.
4. The antenna under sight is located at the receiver side around the axis is the step at 5
degree using stepper motor and the level reading of the receiver at each step is noted.
5. The maximum reading out of the whole set of reading and it is set as 0dB reference
reading. The reference readings are subtracted from all other reading.
6. The antenna readings are plotted on the polar sheet.
7. The 3 dB signal in polar chart is selected and the intersection point at the beam circle is
marked.
8. The angle between these two intersection points is noted and it is the 3dB beam width
9. The front to back ratio is the measure of the ability of directional antenna to concentrate
the beam and is required forward direction.
Result:

Thus the radiation pattern of folded dipole was obtained.

7.b.RADIATION PATTERN OF BROADSIDE ARRAY ANTENNA

AIM

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

To plot the radiation pattern of Broadside array antenna (E-plane).

APPARATUS REQUIRED

Antenna transmitter, receiver and stepper motor controller


Folded Dipole antenna, half wave dipole antenna
Antenna tripod and stepper pod with connecting cables.
THEORY

Antenna or areal is defined as a metallic device for radiating radio waves. In other words,
the antenna is transitional structure between free space wave and a guiding device. The guiding
device or transmission line may take the form of a co axial line or a wave guide and it is used to
transport electromagnetic energy from the transmitting source to the antenna or from the antenna
to the receiver.

An antenna radiation pattern or antenna pattern is defined as a mathematical function or a


graphical representation of the variation of field or power as a function of spherical co ordinates.

FORMULA USED

1. 3 dB beam width
a. Select the 3 dB signal strength in polar plot and mark the intersection points of the
beam in that circle. And find the angle between the intersection points.

2. Front to back ratio


a. It is the ratio of maximum signal strength in the intended direction to the signal
strength in the opposite direction

FBR=Maximum signal strength in the intended medium

Signal strength in the opposite direction

TABULATION:

Angle in Radiation intensity Normalized Value


Degree

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

10

20

30

40

50

60

70

80

90

100

110

120

130

140

150

160

170

180

190

200

210

220

230

240

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

250

260

270

280

290

300

310

320

330

340

350

360

PROCEDURE

1. Connect the dipole antenna to the tripod and set the transmitter frequency to 600MHz.
Keep the antenna in horizontal plane.
2. Now connect Broadside array antenna to the stepper tripod and set the receiver to
600MHz
3. Set the distance between two antennas is around 1m.Any Stray objects around the
antenna is removed.
4. The antenna under sight is located at the receiver side around the axis is the step at 5
degree using stepper motor and the level reading of the receiver at each step is noted.
5. The maximum reading out of the whole set of reading and it is set as 0dB reference
reading. The reference readings are subtracted from all other reading.
6. The antenna readings are plotted on the polar sheet.
7. The 3 dB signal in polar chart is selected and the intersection point at the beam circle is
marked.
8. The angle between these two intersection points is noted and it is the 3dB beam width

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

9. The front to back ratio is the measure of the ability of directional antenna to concentrate
the beam and is required forward direction.

Result:

Thus the radiation pattern of Broadside array was obtained.

8.CHARACTERISTICS OF TRANSMISSION LINES

AIM:

To determine the characteristics of transmission lines.

APPARATUS REQUIRED:

1. Transmission line trainer


2. CRO
3. Multimeter

THEORY:

A transmission line is a material medium or structure that forms a path for directing the
transmission of energy from one place to another, such as electromagnetic waves or acoustic
waves, as well as electric power transmission. Transmission lines are used for purposes such as
connecting radio transmitters and receivers with their antennas, distributing cable
television signals, and computer network connections. Transmission lines use specialized
construction such as precise conductor dimensions and spacing, and impedance matching, to

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

carry electromagnetic signals with minimal reflections and power losses. Types of transmission
line include ladder line, coaxial cable, dielectric slabs, stripline, optical fiber, and waveguides.
The higher the frequency, the shorter are the waves in a transmission medium.

The characteristic impedance Z0 of a transmission line is the ratio of the amplitude of


a single voltage wave to its current wave. Since most transmission lines also have a reflected
wave, the characteristic impedance is generally not the impedance that is measured on the line.
For a lossless transmission line, it can be shown that the impedance measured at a given
position l from the load impedance ZL is

where is the wave number.

Half wave length:

For the special case where l = n where n is an integer (meaning that the length of the line is a
multiple of half a wavelength), the expression reduces to the load impedance so that

for all n. This includes the case when n = 0, meaning that the length of the transmission line is
negligibly small compared to the wavelength.

Quarter wave length:

For the case where the length of the line is one quarter wavelength long, or an odd multiple of a
quarter wavelength long, the input impedance becomes

PROCEDURE:

1. Make connections as shown in Block diagram


2. Connect the CRO to the transmission line trainer and set the input signal.
3. The ohmic resistance of the line is measured in series by short circuiting end of the line
and connecting the measuring instruments to the start of the line.
4. Find the resistance value for full wavelength, half wavelength and quarter wavelength.
5. Tabulate the readings

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

RESULT:

Thus the characteristics of transmission lines were determined.

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

9.DESIGN AND TESTING OF A DIRECTIONAL COUPLER

Aim:
To design and test the directional coupler.

Apparatus Required:
1. Microstrip component training system.
2. Cables.
3. Accessories for training.
4. Directional coupler.
5. 2 way 3dB power divider or combiner.
6. Ring Resonator.

Theory :
Directional coupler
Directional couplers are passive devices that couple part of the transmission power in a
transmission line. These directional RF couplers change by a known amount out through another
port. A typical RF directional coupler often uses two transmission lines set close enough together
such that energy passing through one is coupled to the other.

2 way 3dB power divider or combiner


A power divider or a power combiner is a device for dividing and/or combining the
wireless signals. A power divider is an interdependent device calculating a vector sum total of at
least two signals. Power dividers divide power in an input path into two or more output paths.
When energy flows in an opposite direction through a power divider, the power divider acts as a
power combiner. Power divider circuits are used in radio frequency applications to split an input
signal over two or more outputs so that the input signal can be processed in parallel in
subsequent stages.

Optical ring resonator

It consist of a waveguide in a closed loop coupled to one or more input/output (or bus)
waveguides. When light of the appropriate wavelength is coupled to the loop by the input
waveguide, it builds up in intensity over multiple round-trips due to constructive interference. It
can then be picked up by a detector waveguide. Since only some wavelengths resonate within the
loop, it functions as a filter.

Procedure:

Compiled by k.mariyappan
HAWASSA UNIVERSITY ,ADVANCED COMMUNICATION LAB 1(MSC)

1. First determine the frequencies that are going to use for measurement in experiments.
2. Connect the Microstrip component training system with one cable to the output and the
other is to be connected via the attenuator pad to the input.
3. Directly connect the input and output via the SMA adapater.
4. Take readings from 850MHz to 1300MHz for every 20 MHz. These readings are used for
normalizing the readings obtained from the microstrip component under test.
5. Now replace the SMA adapter by microstrip coupler ((or) 2 way 3dB power divider or
combiner (or) ring resonator).
6. Now take the readings same as the reference.
7. Subtract the readings from the reference and plot the readings.

Result:
Thus the directional coupler was designed and tested.

mariwithgold@gmail.com

Compiled by k.mariyappan

Anda mungkin juga menyukai