Communication Systems Lab Manual
Communication Systems Lab Manual
LABORATORY RECORD
NAME:
CLASS:
BRANCH:
SUBJECT CODE:
SUBJECT NAME:
TO CERTIFY THAT THIS IS A BONAFIDE RECORD OF WORK DONE BY THE ABOVE STUDENT IN
LABORATORY DURING THE ACADEMIC YEAR / SEMESTER
AIM:
To sample a signal with different sampling frequencies and to reconstruct the same.
COMPONENTS REQUIRED:
THEORY:
The analog signal can be converted to a discrete time signal by aprocess called sampling.
The sampling theorem for a band limited signal of finite energy can be stated as,” A band
limited signal of finite energy, which has no frequency component higher than W Hz is
separatedby1/2Wseconds.‟‟Itcanberecoveredfromknowledgeofsamplestakenatthe rate of
2W persecond.
Sampling is the process of splitting the given analog signal into different samples of
equal amplitudes with respect to time. There are two types of sampling namely natural
sampling, flat top sampling. Sampling should follow strictly the Nyquist Criterion i.e. the
sampling frequency should be twice higher than that of the highest frequency signal.
fs 2 fmWhere,
2
TABULATION:
TIME PERIOD
AMPLITUDE
TON TOFF
MESSAGE SIGNAL
PULSE INPUT
RECONSTRUCTED
SIGNAL
MODEL GRAPH:
3
PROCEDURE:
1. Give the connections as per the blockdiagram.
2. Apply the modulating signal and measure its amplitude and timeperiod.
RESULT:
Thus the given signal is sampled with different sampling frequencies
and the waveforms are plotted.
4
BLOCKDIAGRAM
5
EXPT.NO.2 TIME DIVISION MULTIPLEXING
AIM:
COMPONENTS REQUIRED:
THEORY:
While sampling the pulse is present for a short duration and the channel is idle for the
most of the time. This free space between the pulses can be occupied by pulses from other
signals. This is known as Time Division Multiplexing. Thus, time division multiplexing
passed through the low pass filter. The outputs of the low pass filters are connected to the
rotating sampling switch (or) commutator.It takes the sample from each message per
revolution and rotates at the rate of f s. Thus the multiplexed signal contains samples from
four messages. The multiplexed signal is passed through the pulse amplitude modulator and
then sent through the channel. At the receiver side the signal is demodulated then passed
through low pass reconstruction filters. If the highest signal frequency present is fm, then by
sampling theorem, the sampling frequency fs must be such that fs≥2fm. Therefore, the time
Time Time
Amplitude Frequency Amplitude Frequency
Channel period Channel period
(V) (KHz) (V) (KHz)
(ms) (ms)
MODEL GRAPH:
7
PROCEDURE:
RESULT:
Thus the Time division multiplexing and demultiplexing waveforms are obtained.
8
BLOCK DIAGRAM
MODEL GRAPH
9
EXPT.NO.3 PULSE CODE MODULATION
AIM:
COMPONENTS REQUIRED:
THEORY:
Pulse code modulation is used to convert an analog signal into digital signal. The
essential operators in PCM system are sampling, quantization and encoding. First the message
wave is sampled with a train of pulses to convert the continuous time signal into discrete time
signal. The sampling rate must be greater than twice the highest frequency component of
message signal. Quantization converts sampled signal which has continuous amplitude into
discrete amplitude. The difference between the output and input of the quantizer is known as
quantization noise. So the Quantizationprocess introduces a signal distortion.Encoding process
assign code for each sampled and quantized signal. No of bits assigned for each sample depends
on number of levels available in quantization.
10
PCM OUTPUT:
11
PROCEDURE:
1. Give the connections as per the blockdiagram.
4. Apply the input signal to the PCM kit and observe and measure the
PCMoutput.
RESULT:
Thus the Pulse Code Modulated signals are obtained and the waveforms are
plotted.
12
CIRCUIT DIAGRAM
AMPLITUDEMODULATION
DEMODULATION
13
EXPT.NO.4 AMPLITUDE MODULATION
AIM:
To construct amplitude modulator and demodulator circuit and plot the waveforms.
COMPONENTS REQUIRED:
1 Transistor BC 107 1
2 Diode 1N4001 1
3 Capacitors 0.1µF, 0.01µF 2,1
100K,22K,500Ω,20
4 Resistors 2, 1each
0K,10Ω
5 Decade Inductance Box 10 mH 1
6 Function Generators 1 MHz 2
7 CRO 20MHz 1
8 Regulated Power supply 0-30V 1
THEORY :
Modulation is defined as the process in which the characteristics of carrier wave are
varied in accordance with the modulating signal.
Need for modulation is as follows:
Avoid mixing ofsignals
Reduction in antennaheight
long distancecommunication
Multiplexing
Improve the quality ofreception
Ease ofradiation.
Amplitude Modulation is the process of changing the amplitude of a relatively high
frequency carrier signal in proportion with the instantaneous value of the modulating signal.
The output waveform contains all the frequencies that make up the AM signal and is used to
14
TABULATION:
Time period
Signals Amplitude (V) Frequency (KHz)
(ms)
Modulating signal
Carrier signal
Demodulated
signal
15
transport the information through the system. Therefore the shape of the modulated wave is
called the AM envelope. With no modulating signal the output waveform is simply the
carrier signal. Coefficient of modulation is a term used to describe the amount of amplitude
change present in an AM waveform. There are three degrees of modulation available based
on value of modulationindex.
1) Undermodulation : m<1, Em<Ec
2) Criticalmodulation: m-1, Em =Ec
3) Overmodulation: m>1, Em>Ec
Demodulation is the reverse process of modulation and converts the modulated carrier
back to the original information. Demodulation is performed in a carrier by a circuit called a
demodulator.
PROCEDURE:
1. Rig up the circuit as per the circuitdiagram.
2. Set the carrier signal using function generator and measure the
amplitude and time period.
3. Set the modulating signal and measure the amplitude and timeperiod.
4. Vary the amplitude around the carriervoltage.
5. Note down the maximum (Emax) and minimum (Emin) voltages from theCRO.
6. Calculate the modulation index using theformula.
7. Apply the AM signal to the detectorcircuit.
8. Observe the amplitude demodulated output on theCRO.
9. Compare the demodulated signal with the original modulating
signal (Both must be same in all parameters). Plot the
observedwaveforms.
RESULT:
16
PROGRAM
clc;
clear all;
close all;
x=[ 1 0 0 1 1 0 1]; % Binary Information
bp=.000001; % bit period
disp(' Binary information at Transmitter :');
disp(x);
%XX representation of transmitting binary information as digital signal XXX
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=ones(1,100);
else x(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t1=bp/100:bp/100:100*length(x)*(bp/100);
subplot(3,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('transmitting information as digital signal');
%XX Binary-ASK modulation XXXX%
A1=10; % Amplitude of carrier signal for information 1
A2=0; % Amplitude of carrier signal for information 0
br=1/bp; % bit rate
f=br*10; % carrier frequency
t2=bp/99:bp/99:bp;
ss=length(t2);
m=[];
for (i=1:1:length(x))
if (x(i)==1)
y=A1*cos(2*pi*f*t2);
else
y=A2*cos(2*pi*f*t2);
end
m=[m y];
end
t3=bp/99:bp/99:bp*length(x);
subplot(3,1,2);
plot(t3,m);
xlabel('time(sec)');
ylabel('amplitude(volt)');
17
EXPT.NO.5 GENERATION AND DETECTION OF ASK
1. Simulation ofASK
AIM:
SOFTWARE REQUIRED:
MATLAB
THEORY:
transmitting 1, the coordinates S11takes the value as √Eb and for transmitting 0, the
coordinates S21takes the value as0. At the receiver side same basis function is multiplied
with the received signal and then integrated from 0 to Tb to get the value of Xi. if the
Xivalue is greater than 0 then the receiver assumes that the transmitted message is 1 or if
the value is equal to zero then the receiver assumes that the transmitted message is zero.
Due to noise the value of the coordinates may get changed. So the threshold value is set as
0.5√Eb.if the Xi value is greater than 0.5√𝑬𝒃 then the receiver assumes that the transmitted
message is 1 or if the value is less than 0.5√𝑬𝒃then the receiver assumes that the
transmitted message is zero
18
title('waveform for binary ASK modulation corresponding binary information');
%XX Binary ASK demodulation XX%
mn=[];
for n=ss:ss:length(m)
t=bp/99:bp/99:bp;
y=cos(2*pi*f*t); % carrier signal
mm=y.*m((n-(ss-1)):n);
t4=bp/99:bp/99:bp;
z=trapz(t4,mm) % integration
zz=round((2*z/bp))
if(zz>5) % logic level = (A1+A2)/2=5
a=1;
else
a=0;
end
mn=[mn a];
end
disp(' Binary information at Receiver :');
disp(mn);
%XX Representation of binary information as digital signal which achieved after demodulation XX%
bit=[];
for n=1:length(mn);
if mn(n)==1;
se=ones(1,100);
else mn(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t4=bp/100:bp/100:100*length(mn)*(bp/100);
subplot(3,1,3)
plot(t4,bit,'LineWidth',2.5);grid on;
axis([ 0 bp*length(mn) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel (' time(sec)');
title ('received information as digital signal after binary ASK demodulation');
19
ALGORITHM:
Start the program
Get the binary information for transmission
Plot the binary wave form
Assign amplitude values as A1for 1 and A2 for 0
Multiply the amplitude values with basis function
Plot the ASK wave form
Multiply the ASK waveform with basis function
Set the threshold value as the average of A1 & A2
Compare the received value with threshold value
Decide the transmitted value based on the result
Plot the binary waveform
PROCEDURE:
Open the MATLAB software
Open new M file
Type the program
Save and run the program
See the command window if there is any error and rectify the same if any
Get the output
RESULT:
Thus the generation and detection of amplitude shift keying is implemented using
MATLAB and the output is obtained
20
PROGRAM
clc;
clear all;
close all;
x=[ 1 0 0 1 1 0 1]; % Binary Information
bp=.000001; % bit period
disp(' Binary information at Transmitter :');
disp(x);
%XX representation of transmitting binary information as digital signal XXX
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=ones(1,100);
else x(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t1=bp/100:bp/100:100*length(x)*(bp/100);
subplot(3,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('transmitting information as digital signal');
%XXXXXXX Binary-PSK modulation XXXXX%
A=5; % Amplitude of carrier signal
br=1/bp; % bit rate
f=br*2; % carrier frequency
t2=bp/99:bp/99:bp;
ss=length(t2);
m=[];
for (i=1:1:length(x))
if (x(i)==1)
y=A*cos(2*pi*f*t2);
else
y=A*cos(2*pi*f*t2+pi); %A*cos(2*pi*f*t+pi) means -A*cos(2*pi*f*t)
end
m=[m y];
end
t3=bp/99:bp/99:bp*length(x);
subplot(3,1,2);
plot(t3,m);
xlabel('time(sec)');
ylabel('amplitude(volt)');
title('waveform for binary PSK modulation corresponding binary information');
21
EXPT.NO.6 GENERATION AND DETECTION OF PSK
AIM:
SOFTWARE REQUIRED:
MATLAB
THEORY:
Phase shift keying is one of a digital modulation technique. In psk, the phase of
the carrier is varied based on the message signal. So the transmitted wave contains the
message in its phase. The general form of representing the transmitted signal is Si(t)
𝟐
√𝑻 cos (2𝝅fct+ɵi) For transmitting 1the phase of the carrier is 0 and for transmitting 0the
𝒃
𝟐𝑬 𝟐𝑬 𝟐𝑬
phase of the carrier is 𝝅.S1(t) = √ 𝑻 𝒃cos 2𝝅fct& S2(t) =√ 𝑻 𝒃cos (2𝝅fct+𝝅)= -√ 𝑻 𝒃cos
𝒃 𝒃 𝒃
2𝝅fct. The no of orthonormal basis function required to represent the transmitted signal is
𝟐
1(φ1(t)=√𝑻 cos (2𝝅fct)).the coordinates are S11 =√𝑬𝒃 and S21 = -√𝑬𝒃 so the binary wave is
𝒃
represented in polar form. To generate PSK signal the polar form of binary wave is
𝟐
multiplied with √𝑻 cos 2𝝅fc. at the receiver side same basis function is multiplied with
𝒃
the received signal and then integrated from o to Tb. if the value is greater than 0, the
receiver assumes the transmitted message is 1 and if the value is less than 0, the receiver
𝑬
assumes the transmitted message is 0.the probability of error is ½ erfc√𝑵𝒃
𝟎
22
disp(mn);
%XXRepresentation of information as digital signal which achieved after PSK demodulation XXX
bit=[];
for n=1:length(mn);
if mn(n)==1;
se=ones(1,100);
else mn(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t4=bp/100:bp/100:100*length(mn)*(bp/100);
subplot(3,1,3)
plot(t4,bit,'LineWidth',2.5);grid on;
axis([ 0 bp*length(mn) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('received information as digital signal after binary PSK demodulation');
OUTPUT
Binary information at Transmitter :
1 0 0 1 1 0 1
Binary information at Receiver :
1 0 0 1 1 0 1
23
ALGORITHM:
Start the program
Get the binary information for transmission
Plot the binary wave form
Assign amplitude values as A1 as √𝑬𝒃for 1 and A2as -√𝑬𝒃for 0
Multiply the amplitude values with basis function
Plot the PSK wave form
Multiply the PSK waveform with basis function
Set the threshold value as 0 as the average of A1 & A2 = 0
Compare the received value with threshold value
Decide the transmitted value based on the result
Plot the binary waveform
PROCEDURE:
Open the MATLAB software
Open new M file
Type the program
Save and run the program
See the command window if there is any error and rectify the same if any
Get the output
RESULT:
Thus the generation and detection of phase shift keying is implemented using MATLAB
and the output is obtained
24
PROGRAM
clear;
clc;
b = input('Enter the Bit stream \n ');
n = length(b);
t = 0:.01:n;
x = 1:1:(n+1)*100;
for i = 1:n
if (b(i) == 0)
b_p(i) = -1;
else
b_p(i) = 1;
end
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b_p(i);
end
end
bw = bw(100:end);
wo = 2*(2*pi*t);
W = 1*(2*pi*t);
sinHt = sin(wo+W);
sinLt = sin(wo-W);
st = sin(wo+(bw).*W);
subplot(4,1,1)
plot(t,bw)
grid on ; axis([0 n -2 +2])
subplot(4,1,2)
plot(t,sinHt)
grid on ; axis([0 n -2 +2])
subplot(4,1,3)
plot(t,sinLt)
grid on ; axis([0 n -2 +2])
subplot(4,1,4)
plot(t,st)
25
EXPT.NO.7 GENERATION OF FSK
AIM:
SOFTWARE REQUIRED:
MATLAB
THEORY:
In FSK, the transmitted wave contains the message in its frequency. The
frequency of the carrier signal varies based on the message. The general form of
𝟐𝑬
representing the transmitted signal is Si(t) √ 𝑻 𝒃cos (2𝝅fit) For transmitting 1the
𝒃
frequency of the carrier is f1 and for transmitting 0the frequency of the carrier is f2. S1(t)
𝟐𝑬 𝟐𝑬
= √ 𝑻 𝒃cos 2𝝅f1t & S2(t) =√ 𝑻 𝒃cos (2𝝅f2t.. The no of orthonormal basis function required
𝒃 𝒃
𝟐 𝟐
to represent the transmitted signal is 2(φ1(t)=√𝑻 cos 2𝝅f1t&φ2(t)=√𝑻 cos 2𝝅f2t). The
𝒃 𝒃
coordinates are S11 =√𝑬𝒃 ,S12=0,S21=0 and S22 = √𝑬𝒃 so the binary wave is represented in
unipolar form. To generate FSK signal the unipolar form of binary wave is multiplied
𝟐 𝟐
with φ1(t)=√ cos 2𝝅f1t and inverted form of binary wave is multiplied with φ2(t)=√ cos
𝑻𝒃 𝑻𝒃
2πf2t.Both the outputs are then added to get the FSK signal.At the receiver side both basis
function is multiplied with the received signal and then integrated from o to Tb. the
second integrated output is subtracted from first integrated output. If the value is greater
than 0, the receiver assumes the transmitted message is 1 and if the value is less than 0,
𝑬
the receiver assumes the transmitted message is 0.the probability of error is ½ erfc√𝟐𝑵𝒃
𝟎
26
27
ALGORITHM:
Start the program
Get the binary information for transmission
Plot the binary wave form
Assign frequency values for 1 and 0
Find the coordinates
Multiply the coordinates values with basis functions
Plot the FSK wave form
Multiply the FSK waveform with basis functions to find x1& x2
Subtract x2 from x1
Set the threshold value as 0 as the average of x1 &x2 = 0
Compare the received value with threshold value
Decide the transmitted value based on the result
Plot the binary waveform
PROCEDURE:
Open the MATLAB software
Open new M file
Type the program
Save and run the program
See the command window if there is any error and rectify the same if any
Get the output
RESULT:
Thus the frequency shift keying waveform is generated using MATLAB and the output
is obtained
28
clc;
clear all;
close all;
data=[0 0 1 1 0 1 1 0 1 1 1 0]; % information
figure(1)
stem(data, 'linewidth',3), grid on;
title(' Information before Transmiting ');
axis([ 0 11 0 1.5]);
data_NZR=2*data-1; % Data Represented at NZR form for QPSK modulation
s_p_data=reshape(data_NZR,2,length(data)/2); % S/P convertion of data
br=10.^6; %Let us transmission bit rate 1000000
f=br; % minimum carrier frequency
T=1/br; % bit duration
t=T/99:T/99:T; % Time vector for one bit information
y=[];
y_in=[];
y_qd=[];
d=zeros(1,length(data)/2);
for i=1:length(data)/2
p=data(2*i);
imp=data(2*i - 1);
y1=s_p_data(1,i)*cos(2*pi*f*t); % inphase component
y2=s_p_data(2,i)*sin(2*pi*f*t) ;% Quadrature component
y_in=[y_in y1]; % inphase signal vector
y_qd=[y_qd y2]; %quadrature signal vector
y=[y y1+y2]; % modulated signal vector
if (imp == 0) && (p == 0)
d(i)=exp(j*pi/4);%45 degrees
end
if (imp == 1)&&(p == 0)
d(i)=exp(j*3*pi/4);%135 degrees
end
29
EXPT.NO.8 SIMULATION OF QPSK
AIM:
To generate and QPSK waveform and obtain signal space diagram using
MATLAB.
SOFTWARE REQUIRED:
MATLAB
THEORY:
In QPSK, the phase of the carrier takes on one of four equally spaced values, such
2𝐸 2𝐸
as 𝝅/4,3𝝅4, 5𝝅/4 & 7𝝅/4, the signal is defined by Si(t) = √ 𝑇 cos (2𝝅fct +(2i-1) 𝝅/4) = √ 𝑇 [cos
(2𝝅fct) cos(2i-1)𝝅/4 – sin(2𝝅fct) sin(2i-1)𝝅/4)]. Two ortho normal basis functions are used to
2 2
represent the QPSK signal(φ1(t)=√𝑇cos 2𝝅fct&φ2(t)=√𝑇sin 2𝝅fct). So the coordinates are Si1 = √𝐸
cos (2i-1)𝝅/4 & Si2 = √𝐸 sin(2i-1)𝝅/4. We transmit two bits per symbol. The message 10 is
transmitted with phase 𝝅/4, message 00 with phase 3 𝝅/4, message 01 with phase 5𝝅/4 and
𝐸 𝐸
message ii is transmitted with phase 7𝝅/4. So the coordinates are √ 2 &−√ 2 for message 10, -
𝐸 𝐸 𝐸 𝐸 𝐸 𝐸
√ ,-√ 2 for message 00, -√ , √ for message 01 and √ ,√ for message 11. The binary
2 2 2 2 2 2
𝐸
message are represented in polar form with amplitude √ and then given to the demultiplexer.
2
2
The odd numbered sequence are multiplied with φ1(t)=√𝑇cos 2𝝅fct and even numbered sequence
2
are multiplied with φ2(t√ sin 2𝝅fct. the outputs of the product modulator is added to get the
𝑇
QPSK signal. At the receiver side the received signal is multiplied with both basis function and
then integrated to get the estimate of odd numbered and even numbered sequence. If the value is
greater than zero the receiver decides the message is 1 and 0 otherwise using a decision devices,
the output of the decision devices are amultiplexed to get the approximates of
30
if (imp == 1)&&(p == 1)
d(i)=exp(j*5*pi/4);%225 degrees
end
if (imp == 0)&&(p == 1)
d(i)=exp(j*7*pi/4);%315 degrees
end
end
Tx_sig=y; % transmitting signal after modulation
qpsk=d;
tt=T/99:T/99:(T*length(data))/2;
figure(2)
subplot(3,1,1);
plot(tt,y_in,'linewidth',3), grid on;
title(' wave form for inphase component in QPSK modulation ');
xlabel('time(sec)');
ylabel(' amplitude(volt0');
subplot(3,1,2);
plot(tt,y_qd,'linewidth',3), grid on;
title(' wave form for Quadrature component in QPSK modulation ');
xlabel('time(sec)');
ylabel(' amplitude(volt0');
subplot(3,1,3);
plot(tt,Tx_sig,'r','linewidth',3), grid on;
title('QPSK modulated signal (sum of inphase and Quadrature phase signal)');
xlabel('time(sec)');
ylabel(' amplitude(volt0');
figure(3);
plot(d,'o');%plot constellation without noise
axis([-2 2 -2 2]);
grid on;
xlabel('real'); ylabel('imag');
title('QPSK constellation');
31
𝐸
the transmitted signal. The probability of error of the QPSK signal is 𝑒𝑟𝑓𝑐√2𝑁 as the
𝑜
𝐸
qpsksignal has two bits per symbol E= 2Eb so the probability of error becomes 𝑒𝑟𝑓𝑐 √𝑁𝑏
𝑜
signal space diagram has two ortho normal basis function and four message points.
Message 11 has the boundary region from 0 to infinity for both orthonormal basis function
ALGORITHM:
Start the program
Get the binary information for transmission
Plot the binary wave form
Assign phase value for messages 1,2,3,4
Represent the binary waveform in polar format
Find the coordinates
Multiply the coordinates values with basis functions
Plot the QSK wave form
Multiply the QSK waveform with basis functions
Integrate the values
Set the threshold value as 0
Compare the output value with the threshold value
Decide the transmitted value based on the result
Plot the binary waveform
32
OUTPUT
33
PROCEDURE:
Open the MATLAB software
Open new M file
Type the program
Save and run the program
See the command window if there is any error and rectify the same if any
Get the output
RESULT:
Thus the digital modulation technique QPSK was implemented using MATLAB and its
constellation diagram was obtained.
34
PROGRAM
clc;
clear all;
close all;
M=16;
%M=input(' enter the value of M ary for QAM modulation : ');
fprintf('\n\n\n');
%XXXXXX input checking loop XXXXXXXXX
Ld=log2(M);
ds=ceil(Ld);
dif=ds-Ld;
if(dif~=0)
error('the value of M is only acceptable if log2(M)is an integer');
end
%XXXX binary Information Generation XXXXXX
nbit=64; %number of information bits
msg=round(rand(nbit,1)); % information generation as binary form
disp(' binary information at transmitter ');
disp(msg);
fprintf('\n\n');
%XX transmitting binary information as digital signal XXX
x=msg;
bp=.000001; % bit period
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=ones(1,100);
else x(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t1=bp/100:bp/100:100*length(x)*(bp/100);
figure(1)
subplot(3,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('transmitting information as digital signal');
% binary information converts into M-ary QAM modulation
M=M; % order of QAM modulation
msg_reshape=reshape(msg,log2(M),nbit/log2(M))';
disp(' information are reshaped for convert symbolic form');
disp(msg_reshape);
fprintf('\n\n');
35
EXPT.NO.8 SIMULATION OF QAM
AIM:
To generate and QAM waveform and obtain signal space diagram using
MATLAB.
SOFTWARE REQUIRED:
MATLAB
THEORY:
In QAM modulation both amplitude and phase of the carrier signal is varied based
on the message signal. The general form of M ary QAM is defined by a transmitted
𝟐𝑬𝟎 𝟐𝑬𝟎
signal Si(t) = √ aicos (2πfct)+√ bisin (2πfct) where E0 is the energy of the
𝑻 𝑻
signal with lowest amplitude. ai and bi are a pair of independent integers based on
the location of the message points. QAM uses two phase and quadrature carriers
𝟐
each of which is modulated by a set of discrete amplitudes. Ф1(t)=√𝑻cos (2πfct)&
𝟐
Ф2(t)=√𝑻sin (2πfct), the coordinates of the ith message point are ai√𝑬&bi√𝑬whereai
and biis an element of the L by L matrix where L is √𝑴. The probability of symbol
𝟏 𝒂𝒗𝟑𝑬
error for M ary QAM is 2(1- ) erfc(√𝟐(𝑴−𝟏)𝑵 ) the signal constellation for M ary
√𝑴 𝟎
QAM consists of a square lattice of message points. the transmitter of m ary QAM
converts the serial binary data into parallel data then convert the amplitude level
using 2 to L converter and then parallel data is multiplied with in phase and
quadrature phase component and then added to get the m ary QAM wave. At the
receiver side the incoming binary wave is multiplied with the inphase and
quadrature phase component and then integrated. The output of integrator is
compared with L-1 threshold to decide on the binary value then the parallel data is
combined to get the binary data.
36
size(msg_reshape);
for(j=1:1:nbit/log2(M))
for(i=1:1:log2(M))
a(j,i)=num2str(msg_reshape(j,i));
end
end
as=bin2dec(a);
ass=as';
figure(1)
subplot(3,1,2);
stem(ass,'Linewidth',2.0);
title('serial symbol for M-ary QAM modulation at transmitter');
xlabel('n(discrete time)');
ylabel(' magnitude');
disp('symbolic form information for M-ary QAM ');
disp(ass);
fprintf('\n\n');
%XXXX Mapping for M-ary QAM modulation XXXX
M=M; %order of QAM modulation
x1=[0:M-1];
p=qammod(ass,M) %constellation for M-ary QAM according to symbol
sym=0:1:M-1; % considerable symbol of M-ary QAM, for scatterplot
pp=qammod(sym,M); %constalation diagram for M-array QAM
scatterplot(pp),grid on;
title('constellation diagram for M-ary QAM');
%XXXX M-ary QAM modulation XXXXX
RR=real(p)
II=imag(p)
sp=bp*2; %symbol period for M-ary QAM
sr=1/sp; % symbol rate
f=sr*2;
t=sp/100:sp/100:sp;
ss=length(t);
m=[];
for(k=1:1:length(RR))
yr=RR(k)*cos(2*pi*f*t); % inphase or real component
yim=II(k)*sin(2*pi*f*t); % Quadrature or imagenary component
y=yr+yim;
m=[m y];
end
tt=sp/100:sp/100:sp*length(RR);
figure(1);
subplot(3,1,3);
plot(tt,m);
title('waveform for M-ary QAM modulation according to symbolic information');
xlabel('time(sec)');
37
ALGORITHM:
Start the program
Get thevalue of M
The value of M is only acceptable if log2(M)is an integer
Generate a binary message
Plot the binary wave form
Get the number of information bits
Plot the QAM waveform
Plot the signal constellation diagram for M ary QAM using scatterplot
38
Plot the binary waveform
ylabel('amplitude(volt)');
%XXX M-ary QAM demodulation XXXX
m1=[];
m2=[];
for n=ss:ss:length(m)
t=sp/100:sp/100:sp;
y1=cos(2*pi*f*t); % inphase component
y2=sin(2*pi*f*t); % quadrature component
mm1=y1.*m((n-(ss-1)):n);
mm2=y2.*m((n-(ss-1)):n);
z1=trapz(t,mm1) % integration
z2=trapz(t,mm2) % integration
zz1=round(2*z1/sp)
zz2=round(2*z2/sp)
m1=[m1 zz1]
m2=[m2 zz2]
end
%XXX de-mapping for M-ary QAM modulation XXXXX
clear i;
clear j;
for (k=1:1:length(m1))
gt(k)=m1(k)+j*m2(k);
end
gt
ax=qamdemod(gt,M);
figure(3);
subplot(2,1,1);
stem(ax,'linewidth',2);
title(' re-obtain symbol after M-ary QAM demodulation ');
xlabel('n(discrete time)');
ylabel(' magnitude');
disp('re-obtain symbol after M-ary QAM demodulation ');
disp(ax);
fprintf('\n\n');
bi_in=dec2bin(ax);
[row col]=size(bi_in);
p=1;
for(i=1:1:row)
for(j=1:1:col)
re_bi_in(p)=str2num(bi_in(i,j));
p=p+1;
end
end
disp('re-obtain binary information after M-ary QAM demodulation');
39
disp(re_bi_in')
PROCEDURE:
Open the MATLAB software
Open new M file
Type the program
Save and run the program
See the command window if there is any error and rectify the same if any
Get the output
40
fprintf('\n\n');
%XX representation of receiving binary information as digital signal XXXXXX
x=re_bi_in;
bp=.000001; % bit period
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=ones(1,100);
else x(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t1=bp/100:bp/100:100*length(x)*(bp/100);
figure(3)
subplot(2,1,2);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('receiving information as digital signal after M-ary QAM demoduation');
41
RESULT:
Thus the M ary QAM modulation and demodulation is implemented and the constellation
diagram is obtained for M=16
42
PROGRAM:
clc;
clear all;
g=input('Enter The Generator Matrix: ')
disp ('G = ')
disp ('The Order of Linear block Code for given Generator Matrix is:')
[n,k] = size(transpose(g))
for i = 1:2^k
for j = k:-1:1
if rem(i-1,2^(-j+k+1))>=2^(-j+k)
u(i,j)=1;
else u(i,j)=0;
end
end
end
u;
disp('The Possible Codewords are :')
c = rem(u*g,2)
disp('The Minimum Hamming Distance dmin for given Block Code is= ')
d_min = min(sum((c(2:2^k,:))'))
r = input('Enter the Received Code Word:')
p = [g(:,n-k+2:n)];
h = [transpose(p),eye(n-k)];
disp('Hammimg Code')
ht = transpose(h)
disp('Syndrome of a Given Codeword is :')
s = rem(r*ht,2)
for i = 1:1:size(ht)
if(ht(i,1:3)==s)
r(i) = 1-r(i);
break;
end
end
disp('The Error is in bit:')
i
disp('The Corrected Codeword is :')
r
43
EXPT.NO.9 SIMULATION OF LINEAR BLOCK CODE
AIM:
SOFTWARE REQUIRED:
MATLAB
THEORY:
ll A linear block code is a channel coding technique. In channel coding redundant
bits are added with the message in order to correct the error due to noise. It is a forward error
correcting code. In forward error correcting code the transmitter adds the parity bits. With a help
of parity bits the receiver detects and correct the error. An (n,k) block code divides the incoming
binary message into a k bit blocks and add (n-k) parity bits to convert a k bit message into a n bit
codeword. If we add any two code words from the block code, the resultant word also one of the
code word of a block code then the block code can be called as linear block code. If the message
is converted into a codeword in an unaltered form, then the cord can be called as systematic
code. In a (n,k) block code there are 2k possible messages. Then they are converted into n bit
codeword. To convert a k bit message into n bit codeword the transmitter uses generator matrix
G. the messages are multiplied with a generator matrix G to get an n bit code word ie c=mG. At
the receiver side the parity check matrix is used to decode the message. The generator matrix g is
defined by [p l Ik] or [Ik l p] where p is the parity matrix .and the parity check matrix is defined
by[In-k l pT] or [pT l In-k].the number of 1’s present in the codeword is knows as weight of the
codeword. The distance between two code words is defined as the no of places in which their
element differs. The minimum weight is always equal to minimum distance. The minimum
distance of the codeword is used to find out the no of detectable and correctable error. The
detectable error t= (Dmin – 1)/2.To find out the error the received word is multiplied with H
matrix. The result will be zero if there is no error. If there is an error the product of rHTis not
equal to zero. Then the corresponding error pattern is found out from the syndrome table and the
error pattern is added with the received message to get an original transmitted message.
44
OUTPUT:
45
If a linear block code satisfy the parameters block length n = 2m – 1 and number of message bits
k=2m – m-1 and the number of parity bits m = n – k where m ≥ 3 then the block code can be
called as Hamming code.
ALGORITHM:
Start the program
Get theparity bits to generate G matrix
Generate code words by multiplying the message with G
Find the minimum weight and minimum distance
Find the number of minimum correctable error using minimumdistance
Compute the parity check matrix H
Find the syndrome value by multiplying the received word with H
Find the corresponding error pattern for the syndrome
Add the error pattern with the received message to find the transmitted message
PROCEDURE
Open the MATLAB software
Open new M file
Type the program
Save and run the program
See the command window if there is any error and rectify the same if any
Get the output
RESULT:
Thus the error control technique using linear block code was implemented using
MATLAB.
46