You are on page 1of 27

G.

H Raisoni College of Engineering, Nagpur


(An Autonomous Institute Under Act 1956)
Department of Computer Science & Engineering

Lab Manual

Subject
DATA COMMUNICATION

Session:-2018-2019 (Even)
Semester:-IVth
LIST OF PRACTICAL
Sr. CO
Name of Experiment
No Mapping

To implement basic MATLAB commands required for Data


1. CO1
Communication System.

Write a MATLAB Program to generate & Analyze various waveforms


2. CO1,CO2
(Sine, Cosine, Square, Sawtooth.)

Write a MATLAB Program to convert Analog Signal to Digital Signal


3. CO1,CO2
for the given values.

Write a MATLAB Program to calculate Nyquist sample rate for a given


4. CO2
sinusoidal signal.

Design & Implement Amplitude Modulation and perform simulation in


5. CO2
MATLAB.

Design & Implementation of pulse Amplitude Modulation and perform


6. CO1,CO2
simulation in MATLAB.

7. Implementation of ASK and perform simulation in MATLAB CO2

Implementation of Phase Shift keying (PSK) and perform simulation in


8. CO2
MATLAB.

Implementation of Frequency Division Multiplexing and perform


9. CO2
simulation in MATLAB

10. Design and Implementation of frequency modulation and perform


CO3
simulation in MATLAB.

11. Design and Implementation of phase modulation and perform


CO2
simulation in MATLAB

12. Open ended design of Practical.


CO3

Faculty: Dr. Meenakshi Arya

Prof. P. P. Borekar HoD, CSE

Prof. S. Sapra
Experiment No. 1
Aim To implement basic MATLAB commands required for Data Communication System.
Theory: MATLAB is an interactive program for numerical computation and data visualization. You
can enter a command by typing it at the MATLAB prompt '>>' on the Command Window.

Commands for Managing a Session


MATLAB provides various commands for managing a session. The following table provides all such
commands –

Input and Output Commands


MATLAB provides the following input and output related commands –
Plotting Commands
MATLAB provides numerous commands for plotting graphs. The following table shows some of the
commonly used commands for plotting −

To plot the graph of a function, you need to take the following steps −
 Define x, by specifying the range of values for the variable x, for which the function is to be
plotted
 Define the function, y = f(x)

 Call the plot command, as plot(x, y)

Following example would demonstrate the concept. Let us plot the simple function y = x for the
range of values for x from 0 to 100, with an increment of 5.

Create a script file and type the following code −

x = [0:5:100];
y = x;
plot(x, y)

When you run the file, MATLAB displays the following plot –
Conclusion: Hence we studied the basics data communication system for computing.
Experiment No. 2
Aim: Write a MATLAB Program to generate & analyze various waveforms

Theory: A waveform is the shape and form of a such as a wave moving in a physical medium in
electronic circuits. We need to produce many different types, frequencies and shapes of Signal
Waveforms such as Square Waves, Rectangular Waves, Triangular Waves; Saw-toothed
Waveforms.Whether the waveform is uni-directional, bi-directional, periodic, non-periodic,
symmetrical, non-symmetrical, simple or complex, all electrical waveforms include the following
three common characteristics:

Period: – This is the length of time in seconds that the waveform takes to repeat itself from start to
finish. This value can also be called the Periodic Time, ( T ) of the waveform for sine waves, or the
Pulse Width for square waves.
 Frequency: – This is the number of times the waveform repeats itself within a one second
time period. Frequency is the reciprocal of the time period, ( ƒ = 1/T ) with the standard unit
of frequency being the Hertz, (Hz).
 Amplitude: – This is the magnitude or intensity of the signal waveform measured in volts or
amps.

A Sine Wave Waveform:

Y= sin (2 * pi*f*t)

A Square Wave Waveform:

Y= square(2*pi*f*t,duty_cycle)
The argument duty Cycle is optional and it defines the desired duty cycle of the square wave. By
default (when the duty cycle argument is not supplied) the square wave is generated with 50 duty
cycle.

Sawtooth Waveforms:

Observation Table:

Sine Waveform

Sr. No. Frequency

Cosine Waveform

Sr. No. Frequency

Saw tooth waveform


Sr. No. Amplitude (volts) Frequency Duty Cycle
1
2
3
Square waveform
Sr. No. Amplitude (volts) Frequency Duty Cycle
1
2
3
Conclusion: Hence we have generated & analyzed various waveforms (Sine, Cosine, Square ,
Sawtooth).

Experiment No. 3

Aim: Write a MATLAB Program to convert analog signal to digital signal for
the given values.

Theory:

In pulse modulation some characteristics of pulse (carrier) is changed in accordance with the sample
of the modulation signal. Such type of modulation is called as Pulse Modulation. It is applied in
many types. But some of common types are Pulse Amplitude Modulation (PAM), Pulse Width
Modulation (PWM), and Pulse Position Modulation (PPM). If the characteristics of pulse such as
amplitude, duration (width), position are changed in accordance with the modulation signal then it is
called as PAM, PDM or PWM and PPM respectively. If the amplitude of the pulse is varied in
accordance with the modulation signal, then it is called as Pulse Amplitude Modulation. PAM gives
dual polarity (AC type) PAM output called as Natural PAM Sampling. But, if DC level is introduced
to the modulating signal then it results in single polarity PAM

Matlab code

b=2; % Number of bits.

N=40; % Number of samples in final signal.

n=0:(N-1); %Index

t=0:0.025:1 %sampling interval

x=0.8*cos(2*pi*t)+0.15; %signal% Quantize a signal to "b" bits.

xq=floor((x+1)*2^(b-1)); % Signal is one of 2^n int values (0 to 2^n-1)

xq=xq/(2^(b-1)); % Signal is from 0 to 2 (quantized)

xq=xq-(2^(b)-1)/2^(b); % Shift signal down (rounding)

xe=x-xq; % Quantization error


stem(x,'b');

hold on;

stem(xq,'r');

hold on;

stem(xe,'g');

legend('exact','quantized','error','Location','Southeast')

title(sprintf('Signal, Quantized signal and Error for %g bits, %g quantization levels',b,2^b));

hold off

Conclusion: Hence we have generated analog signal & converted analog signal into digital signal
& performed simulation in MATLAB.
Experiment No. 04
Aim: Write a MATLAB Program to calculate nyquist sample rate for a given
sinusoidal signal.

Theory:
Generating a continuous signal and sampling it at a given rate is demonstrated here. In simulations,
we may require to generate a continuous time signal and convert it to discrete domain by appropriate
sampling.For baseband signal, the sampling is straight forward. By Nyquist Shannon sampling
theorem, for faithful reproduction of a continuous signal in discrete domain, one has to sample the
signal at a rate \(f_s\) higher than at-least twice the maximum frequency \(f_m\) contained in the
signal (actually, it is twice the one-sided bandwidth occupied by a real signal. For a baseband signal
bandwidth (\(0\) to \(f_m\)) and maximum frequency \(f_m\) in a given band are equivalent).

Matlab or any other simulation softwares process everything in digital i.e, discrete in time.
Therefore, we cannot generate a real continuous-time signal on it, rather we can generate a
“continuous-like” signal by using a very very high sampling rate. When plotted, such signals look
like a continuous signal.

Matlab Code

f_m=input('enter the maximum frequency component ');


fs1=3*f_m; %30kHz sampling rate
f=1;
nCyl=5; %generate five cycles of sinusoid
t1=0:1/fs1:nCyl*1/f; %time index
x1=cos(2*pi*f*t1);
subplot(2,1,1);
plot(t1,x1);
hold on;
stem(t1,x1);

Sampling at Nyquist Rate(fs=2*f_m)


Under Sampling- Sampling below Nyquist Rate
Under sampling-Sampling below Nyquist Rate

Overersampling- Sampling above the nyquist rate

Conclusion: The nyuist sample rate for sinusoidal wave is calculated successfully.
Experiment No. 05
Aim: Design & Implementation of Amplitude Modulation and perform
simulation in MATLAB.
Theory:
Let us return to equation

e(t) = EP sin(t + )

As previously mentioned, it is possible to vary both (FM) and (PM) in the above equation.
Each term is part of the argument of the sine wave. So, what is the difference between varying one
versus the other? A simple answer is that there is no difference, as either one will change the sine
wave’s frequency. However, closer inspection and the employment of more mathematical rigor
reveal that there are some subtle differences between the two forms of angle modulation. However,
due to the complex mathematics involved these differences will not be discussed here. Practically
speaking, it is possible to obtain FM from PM, as depicted in Figure; but most present-day FM
systems do not generate FM by this method. This process of generating FM is known as indirect
FM.
the amplitude of the input signal, it is FM. On the other hand, if the instantaneous phase of the signal
is proportional to the amplitude of the input signal, it is PM. This last statement, although correct, is
unclear because the term instantaneous phase is undefined at present. Another way of expressing this
last statement is to say that for PM, the transmitter output frequency is at the rest frequency when the
input signal is at either its most positive or most negative voltage. The subtle difference between FM
and PM is not really very important, for the vast majority of wireless angle modulation transmitters
use FM. That being the case, our comments will focus almost entirely on FM from this point on.

Matlab source code

clc;
clear all;
t = 0:0.001:1;
vm = input('Enter the amplitude of message signal = ');
vc = input('Enter the amplitude of carrier signal = ');
fm = input('Enter the message frequency = ');
fc = input('Enter the carrier frequency = ');
m = input('Enter modulation index = ');
sm = vm*sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,sm);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Message Signal');
grid on;
sc = vc*sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,sc);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Carrier Signal');
grid on;
y = vc*sin(2*pi*fc*t+m.*sin(2*pi*fm*t));
subplot(3,1,3);
plot(t,y);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('PM Wave');
grid on;
Output:
Enter the amplitude of message signal = 5
Enter the amplitude of carrier signal = 5
Enter the message frequency = 10
Enter the carrier frequency = 100
Enter modulation index = 4

Conclusion: In this practical we conclude & understand the amplitude modulation &
its bandwidth in MATLAB.
Experiment No.6
AIM: Design & Implementation of Pulse Amplitude Modulation and perform
simulation in MATLAB.

Theory:
Pulse-amplitude modulation (PAM), is a modulation scheme where the message is encoded in the
amplitude of a series of amplitude pulses. Its an analog modulation scheme in which the amplitudes
of a train of carrier pulses are varied according to the amplitude of message signal. (This code
assumes that the M is very large for a M-PAM Modulation).

MATLAB CODE

clc;
close all;
clear all;
a = input('Enter the amplitude = ');
f = input('Enter the frequency = ');
t = 0:0.02:2; % for a total of 16 samples
x1 = 1; %generation of an impulse signal
x2 = a*sin(2*pi*f*t); %generation of sine wave
y = x1.*x2; %modulation step
subplot(3,1,1); %for impulse signal plot
stem(x1);
title('Impulse Signal');
xlabel('Time');
ylabel('Amplitude ');
subplot(3,1,2) %for sine wave plot
plot(t,x2);
title('Sine Wave');
xlabel('Time ');
ylabel('Amplitude ');
subplot(3,1,3) %for PAM wave plot
stem(t,y);
title('PAM Wave');
xlabel('Time');

Conclusion: In this practical we conclude & understand the pulse Amplitude


Modulation and performed simulation in MATLAB.
Experiment No. 07
Aim: Implementation of ASK and perform simulation in MATLAB.
Theory:

Generation of ASK

Amplitude shift keying -ASK -is a modulation process, which imparts to a sinusoid two or more
discrete amplitude levels. These are related to the number of levels adopted by the digital message.
For a binary message sequence there are two levels, one of which is typically zero. The data rate is a
sub-multiple of the carrier frequency. Thus the modulated waveform consists of bursts of a sinusoid.
One of the disadvantages of ASK, compared with FSK and PSK, for example, is that it has not got a
constant envelope. This makes its processing (eg, power amplification) more difficult, since linearity
becomes an important factor. However, it does make for ease of demodulation with an envelope
detector.

Demodulation

ASK signal has a well defined envelope. Thus it is amenable to demodulation by an envelope
detector. Some sort of decision-making circuitry is necessary for detecting the message. The signal is
recovered by using a correlator and decision making circuitry is used to recover the binary sequence.

Algorithm

Initialization commands

ASK modulation

Generate carrier signal. Start FOR loop Generate binary data, message signal(on-off form)
Generate ASK modulated signal. Plot message signal and ASK modulated signal. End FOR loop.
Plot the binary data and carrier.

ASK demodulation

1. Start FOR loop


2. Perform correlation of ASK signal with carrier to get decision variable
3. Make decision to get demodulated binary data. If x>0, choose '1' else choose '0'
4. Plot the demodulated binary data.

Program :

%ASK Modulation
clc;
clear all;
close all;
%GENERATE CARRIER SIGNAL
Tb=1; fc=10;
t=0:Tb/100:1;
c=sqrt(2/Tb)*sin(2*pi*fc*t);
%generate message signal
N=8;
m=rand(1,N);
t1=0;t2=Tb
for i=1:N
t=[t1:.01:t2]
if m(i)>0.5
m(i)=1;
m_s=ones(1,length(t));
else
m(i)=0;
m_s=zeros(1,length(t));
end
message(i,:)=m_s;
%product of carrier and message
ask_sig(i,:)=c.*m_s;
t1=t1+(Tb+.01);
t2=t2+(Tb+.01);
%plot the message and ASK signal
subplot(5,1,2);axis([0 N -2 2]);plot(t,message(i,:),'r');
title('message signal');xlabel('t--->');ylabel('m(t)');grid on
hold on
subplot(5,1,4);plot(t,ask_sig(i,:));
title('ASK signal');xlabel('t--->');ylabel('s(t)');grid on
hold on
end
hold off
%Plot the carrier signal and input binary data
subplot(5,1,3);plot(t,c);
title('carrier signal');xlabel('t--->');ylabel('c(t)');grid on
subplot(5,1,1);stem(m);
title('binary data bits');xlabel('n--->');ylabel('b(n)');grid on

% ASK Demodulation
t1=0;t2=Tb
for i=1:N
t=[t1:Tb/100:t2]
%correlator
x=sum(c.*ask_sig(i,:));
%decision device
if x>0
demod(i)=1;
else
demod(i)=0;
end
t1=t1+(Tb+.01);
t2=t2+(Tb+.01);
end
%plot demodulated binary data bits
subplot(5,1,5);stem(demod);
title('ASK demodulated signal'); xlabel('n--->');ylabel('b(n)');grid on
Model Graphs

Conclusion: The program for ASK modulation and demodulation has been simulated in
MATLAB and necessary graphs are plotted.
Experiment No. 08
Aim: Implementation of PSK and perform simulation in MATLAB.
Theory: Phase Shift Keying (PSK) is the digital modulation technique in which the phase of the
carrier signal is changed by varying the sine and cosine inputs at a particular time. PSK technique is
widely used for wireless LANs, bio-metric, contactless operations, along with RFID and Bluetooth
communications.

PSK is of two types, depending upon the phases the signal gets shifted. They are −

Binary Phase Shift Keying (BPSK)

This is also called as 2-phase PSK or Phase Reversal Keying. In this technique, the sine wave carrier
takes two phase reversals such as 0° and 180°.

BPSK is basically a Double Side Band Suppressed Carrier (DSBSC) modulation scheme, for
message being the digital information.

Quadrature Phase Shift Keying (QPSK)

This is the phase shift keying technique, in which the sine wave carrier takes four phase reversals
such as 0°, 90°, 180°, and 270°.

If this kind of techniques are further extended, PSK can be done by eight or sixteen values also,
depending upon the requirement.

BPSK Modulator

The modulation of BPSK is done using a balance modulator, which multiplies the two signals
applied at the input. For a zero binary input, the phase will be 0° and for a high input, the phase
reversal is of 180°.

Following is the diagrammatic representation of BPSK Modulated output wave along with its given
input.
Program:

fm=input('enter the frequency of message signal')


fc=input('enter the frequency of carrier signal')
t=0:0.001:1
a=3
x1=a.*square(2*3.14*fm*t)
x2=a.*sin(2*3.14*fc*t)
y=x1.*x2
subplot(3,1,1)
plot(t,x1)
title('Digital signal')
xlabel('Time')
ylabel('Amplitude')
subplot(3,1,2)
plot(t,x2)
title('Carrier wave')
xlabel('Time')
ylabel('Amplitude')
subplot(3,1,3)
plot(t,y)
title('PSK')
xlabel('Time')
ylabel('Amplitude')
Output:

Conclusion: The program for PSK modulation and demodulation has been simulated in MATLAB
and necessary graphs are plotted
Experiment No. 9
Aim: Implementation of Frequency Division Multiplexing and perform
simulation in MATLAB
Theory
FDM frequency-division multiplexing (FDM) is a technique by which the total bandwidth available
in a communication medium is divided into a series of non-overlapping frequency sub-bands, each of
which is used to carry a separate signal. These sub-bands can be used independently with completely
different information streams, or used dependently in the case of information sent in a parallel
stream. This allows a single transmission medium such as the radio spectrum, a cable or optical fiber
to be shared by multiple separate signals
The most natural example of frequency-division multiplexing is radio and television broadcasting, in
which multiple radio signals at different frequencies pass through the air at the same time. Another
example is cable television, in which many television channels are carried simultaneously on a single
cable. FDM is also used by telephone systems to transmit multiple telephone calls through high
capacity trunklines, communications satellites to transmit multiple channels of data on uplink and
downlink radio beams, and broadband DSL modems to transmit large amounts of computer data
through twisted pair telephone lines, among many other uses

Matlab Code:
clc;
clearall;
closeall;
x=1:20;
sig1=sin(x);
l=length(sig1);
sig2=triang(l);
subplot(2,3,1);
plot(sig1,'r');
subplot(2,3,2);
plot(sig2,'g');
subplot(2,3,3);
stem(sig1,'r');
subplot(2,3,4);
stem(sig2,'g');
fori=1:l
sig(1,i)=sig1(i);
sig(2,i)=sig2(i);
end
tdmrg=reshape(sig,1,2*l);
subplot(2,3,[5,6]);
stem(tdmrg);

Conclusion: The program of Frequency Division Multiplexing has been simulated in MATLAB
and necessary graphs are plotted.
Experiment No.10
Aim: Implementation of Frequency Modulation and perform simulation in
MATLAB.
Matlab Code:
Frequency Modulation

clc;
clear all;
t = 0:0.001:1;
vm = input('Enter the amplitude of message signal = ');
vc = input('Enter the amplitude of carrier signal = ');
fm = input('Enter the message frequency = ');
fc = input('Enter the carrier frequency = ');
m = input('Enter modulation index = ');
sm = vm*sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,sm);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Message Signal');
grid on;
sc = vc*sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,sc);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Carrier Signal');
grid on;
y = vc*sin(2*pi*fc*t+m.*cos(2*pi*fm*t));
subplot(3,1,3);
plot(t,y);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('FM Signal');
grid on;

Output:
Enter the amplitude of message signal = 5
Enter the amplitude of carrier signal = 5
Enter the message frequency = 10
Enter the carrier frequency = 100
Enter modulation index = 4

Conclusion: The program frequency modulation and demodulation has been simulated in
MATLAB and necessary graphs are plotted.
Experiment No.11
Aim: Design and Implementation of phase modulation and perform simulation in
MATLAB.

Theory:
As previously mentioned, it is possible to vary both (FM) and (PM) in the above equation.
Each term is part of the argument of the sine wave. So, what is the difference between varying one
versus the other? A simple answer is that there is no difference, as either one will change the sine
wave’s frequency. However, closer inspection and the employment of more mathematical rigor
reveal that there are some subtle differences between the two forms of angle modulation. However,
due to the complex mathematics involved these differences will not be discussed here. Practically
speaking, it is possible to obtain FM from PM, as depicted in Figure; but most present-day FM
systems do not generate FM by this method. This process of generating FM is known as indirect
FM.
Matlab source code
clc;
clear all;
t = 0:0.001:1;
vm = input('Enter the amplitude of message signal = ');
vc = input('Enter the amplitude of carrier signal = ');
fm = input('Enter the message frequency = ');
fc = input('Enter the carrier frequency = ');
m = input('Enter modulation index = ');
sm = vm*sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,sm);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Message Signal');
grid on;
sc = vc*sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,sc);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Carrier Signal');
grid on;
y = vc*sin(2*pi*fc*t+m.*sin(2*pi*fm*t));
subplot(3,1,3);
plot(t,y);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('PM Wave');
grid on;

Conclusion: The program of phase modulation and demodulation has been simulated in
MATLAB and necessary graphs are plotted.

You might also like