hdlc
hdlc
Yenepoya Institute of
N.H.13, Thodar, Moodbidri- 574225, Mangaluru, DK
(Sponsored by Islamic Academy of Education)
Technology
DIGITAL COMMUNICATION LAB MANUAL
Vsemester (ECE)
Subject Code: BECL504
Contents
Vision of the Department: ........................................................................................................................ 3
Mission of the Department: ...................................................................................................................... 3
Program Educational Objectives (PEOs): ................................................................................................ 3
Program Outcomes (PO’s): ...................................................................................................................... 3
Program Specific Outcomes (PSO’s): ...................................................................................................... 4
Course Description: .................................................................................................................................. 6
Course Objectives:.................................................................................................................................... 6
Course Outcomes (COs): .......................................................................................................................... 6
Course-PO/PSO Correlation Matrix: ........................................................................................................ 7
Instructions to the Students ...................................................................................................................... 8
1. Generation and demodulation of the Amplitude Shift Keying signal. ......................................... 9
2.Generation and demodulation of the Phase Shift Keying signal. ................................................ 12
3.Generation and demodulation of the Frequency Shift Keying signal.......................................... 16
4.Generation of DPSK Signal and Detection of Data Using DPSK Transmitter and Receiver. .... 19
5 .Gram-Schmidt Orthogonalization: To find orthogonal basis vectors for the given set of vectors
and plot the orthonormal vectors. ................................................................................................... 22
6.Simulation of binary baseband signals using a rectangular pulse and estimate the BER for
AWGN channel using matched filter receiver................................................................................ 24
7.Perform the QPSK Modulation and demodulation. Display the signal and its constellation. Aim:
Write a MATLAB program to perform the QPSK Modulation and demodulation. Display the
signal and its constellation.............................................................................................................. 26
8.Generate 16-QAM Modulation and obtain the QAM constellation ............................................ 28
9.Encoding and Decoding of Huffman code .................................................................................. 30
10. Encoding and decoding of binary data using a Hamming code. .............................................. 32
11. CRC-CCITT polynomial to obtain the CRC code.................................................................... 34
12. Encoding and decoding of Convolution code........................................................................... 37
VTU SYLLABUS
Course Description:
The course introduces some of the basic mathematical concepts that will allow us to think in
the two approaches of Communications, the time domain and the frequency domain. It covers
the basic types of analog modulation (AM, FM, and phase modulation) from both a
mathematical description and from a block-diagram system approach. This course presents
the fundamentals of analog communications. Topics include the analysis of signals and
systems, noise effect random process and digital data representation.
Course Objectives:
This course will enable the students to:
1 Design of basic digital modulation techniques using electronic hardware.
2 Simulation of vector computations and derive the orthonormal basis set using Gram Schmidt
procedure.
3 Simulate the digital transmission and reception in AWGN channel
4 Simulate the digital modulations using software and display the signals and its vector
representations.
5 Implement the source coding algorithms using a suitable software platform.
5 CO5 is mapped with PO1 highly and PO2, PO5 and PO3 moderately as
student will learn to apply the knowledge of Digital modulation techniques
CO5 mapped to PSO1 moderately and PSO2 highly as students will be able
to Analyze & design the embedded & communication circuits
Experiment No. 1
1. Generation and demodulation of the Amplitude Shift Keying signal.
Aim:To generate and demodulate the Amplitude Shift Keying signal.
Components Required:
Transistor SLlOO, Resistors 22kΩ, 2.2kΩ, DRB, DCB, OpAmp 1C741, Diode-OA79.
Theory:
In ASK, the amplitude of the carrier assumes one of the two amplitudes dependent on the logic
states of the input bit stream. The binary data stream (0s and 1s) is used to modulate the carrier
signal.
• "1": The carrier signal may be transmitted at a high amplitude.
• "0": The carrier signal may be transmitted at a lower amplitude (or may be completely
absent in the case of On-Off Keying).
A high-frequency carrier wave 𝒄(𝒕) = 𝑨𝒄𝒐𝒔(𝟐𝝅𝒇𝒄𝒕)𝒄(𝒕) (where 𝑨 is the amplitude and 𝑓𝑐 is
the frequency) is modulated based on the binary data.
Design:
Specification:
Let Vc = 5 volts peak-to-peak, Vm =10 volts peak-to-peak, fm = 500 Hz, fc =50 kHz. Assume
hfe= 30, VBEsat= 0.7 volts, VCEsat= 0.3 volts, Ic=1 mA, Ic = Ie.
Biasing:
Ve peak = VCEsat + IeRe
2.5 = 0.3 + (1 m)Re, => Re = 2.2 kΩ
Vm peak = RbIb+VBEsat+IeRe
5 = RbIb + 0.7 + 2.2, where Ib=Ic/hfe
then Rbmax = 6.3 kΩ , Choose Rb = 22 k Ω
Envelope Detector:
1/fm > RdCd > 1/fc, hence 2ms > RdCd > 20µs
Let RdCd =50/fc=1 ms Assume Cd=0.01 µF,
Then Rd=100 kΩ
Circuit Diagram:
Procedure:
Amplitude Frequency
(V) (kHz)
Message signal Theoretical
,m(t) Practical
Carrier signal, Theoretical
c(t) Practical
After demodulation:
Amplitude Frequency
(V) (kHz)
Input signal
Output signal
Expected Waveform:
Result:
Experiment No. 2
2.Generation and demodulation of the Phase Shift Keying signal.
Aim: To generate and demodulate the PSK signal.
Component Required: Op-amp 741, Diodes OA79, Transistor CL100, Resistor 15KΩ,
33KΩ, 10KΩ etc.
Theory:
In PSK, the carrier signal undergoes phase changes based on the binary data (or multi-level
symbols) being transmitted. These phase shifts represent different data values. The simplest
form of PSK is Binary Phase Shift Keying (BPSK), where the carrier signal has two possible
phase states to represent binary values.
Bit "0" might correspond to a phase of 0 degrees.
Bit "1" might correspond to a phase of 180 degrees (or π radians).
Thus, the carrier signal is reversed in phase to represent the binary data.
Procedure:
Amplitude Frequency
(V) (kHz)
Message signal Theoretical
,m(t) Practical
Carrier signal, Theoretical
c(t) Practical
After demodulation:
Amplitude Frequency
(V) (kHz)
Input signal
Output signal
Expected Waveforms:
Procedure:
1. Switch on MICRO LAB INSTRUMENTS PSK/DPSK Trainer kit.
2. Connect the carrier output of carrier SIN0 (TP3) and SIN180 (TP4) degree to the PSK/DPSK
modulator Block TP9 and TP7 respectively as show in the connection diagram.
3. Connect the serial data bit (TP14) to the Data input (TP11) of the PSK/DPSK Modulator
block.
4. Observe and sketch PSK output waveform at the test point TP13 using CRO.
5. Connect the PSK modulated signal (TP13) to the PSK Demodulator/Phase comparator test
point TP24.
6. Observe the final PSK demodulated Output at the Test point TP27.
Result:
Experiment No. 3
3.Generation and demodulation of the Frequency Shift Keying signal.
Aim: To design and verify the operation of FSK generator and detector.
Theory:
In FSK modulation, the carrier signal's frequency is changed between two predefined values to
represent binary 0s and 1s. Typically, two frequencies, f1 and f2, are employed, corresponding
to the binary states. The selection of these frequencies is crucial for the performance of the
modulation system.
The FSK modulation process can be explained as follows:
• When the input digital data is '0,' the carrier signal is modulated to f1.
• When the input digital data is '1,' the carrier signal is modulated to f2.
This modulation process creates distinct frequency shifts that can be easily detected at the
receiver.
The mathematical representation of an FSK-modulated signal s(t) can be expressed as:
Here, A represents the amplitude of the carrier signal, and t denotes time.
Detection at the Receiver:
At the receiver, the demodulation process involves detecting the frequency of the received signal
to determine the transmitted binary data. This can be achieved through various methods,
including frequency discrimination or Fourier transform analysis.
Circuit Diagram:
Procedure:
Amplitude Frequency
(V) (kHz)
Message signal Theoretical
,m(t) Practical
Carrier signal, Theoretical
c(t) Practical
After demodulation:
Amplitude Frequency
(V) (kHz)
Input signal
Output signal
Expected Waveforms:
Result:
Experiment No.4
4.Generation of DPSK Signal and Detection of Data Using DPSK Transmitter and
Receiver.
Aim:To generate the operation of DPSK Transmitter and Receiver.
Component Required:
Phase Encoding:
In the DPSK transmitter, the phase of each symbol is determined relative to the phase of the
previous symbol. The phase difference, Δϕ, is used to encode the binary data.
Binary Encoding:
The binary data is differentially encoded, ensuring that each symbol represents a change in phase
from the previous symbol. This simplifies the demodulation process at the receiver.
Coherent Detection:
Coherent detection is commonly employed in DPSK demodulation. The received signal is
multiplied by a locally generated carrier signal, cos(2πfct+θ), where θ is the phase offset
between the local oscillator and the received signal.
r(t)=s(t)⋅cos(2πfct+θ)
Binary Decoding:
The differentially encoded binary data is differentially decoded, reconstructing the original
binary sequence based on the changes in phase between consecutive symbols.
.
Procedure:
3. Connect the Data Bit output (TP14) to the Differential Encoder -1(EXNOR Logic) input at
test point TP16.
4. Observe the Differential data output at the TP19 using CRO.
5. Connect the Differential Encoder -1 output (TP19) to the input of PSK/DPSK modulator
Block test point TP11.
6. Observe the DPSK signal at the test point TP13.
7. Connect the PSK/DPSK output (TP13) to the PSK/DPSK Demodulator block test point TP24.
8. Observe the DPSK Demodulated output at Test point TP 27 using CRO.
9. The frequency of modulation data signal should be equal to the demodulated O/P.
Procedure:
1. Switch on MICRO LAB INSTRUMENTS PSK/DPSK Trainer kit.
2. Connect the carrier output of carrier SIN0 (TP3) and SIN180 (TP4) degree to the PSK/DPSK
modulator Block TP9 and TP7 respectively as show in the connection diagram.
3. Connect the Data Bit output (TP14) to the Differential Encoder coder -2(EX-OR logic) input
at test point TP20.
4. Observe the differential data with EX-OR logic at the output of the Differential Encoder -2
at test point TP23.
5. Connect the Differential Encoder -2 output at Test point TP23 to Data input (TP11) of
PSK/DPSK Modulator block.
6. Observe the DPSK output at the test point TP13.
7. Connect the DPSK signal to PSK/DPSK Demodulator test point (TP23)
8. Observe DPSK demodulated data at the test point TP27.
Result:
The operation of DPSK is observed and the output waveforms are verifie
Experiment No. 5
5 .Gram-Schmidt Orthogonalization: To find orthogonal basis vectors for the given set of
vectors and plot the orthonormal vectors.
Aim: Write a MATLAB Code to find orthogonal basis vectors for the given set of vectors and
plot the orthonormal vectors.
Theory :
The Gram-Schmidt Orthogonalization process is a method used to convert a set of linearly
independent vectors into an orthogonal (or orthonormal) set of vectors. In digital
communication, particularly in multiple access systems, signal modulation schemes, or
multiple-input multiple-output (MIMO) systems, the Gram-Schmidt process is used to create
orthogonal signal vectors that minimize interference between transmitted signals, enhancing the
performance of the communication system.
Procedure:
1. Open MATLAB version R2013a
2. Open new file and enter the program and save it.
3. Add the path to the location of the file in the system.
4. Compile the program and check for any error and debug it.
5. Note down the output.
Program
A = [1 3; 4 -7; -1 -12];
[m, n] = size(A); % Initialize matrices for orthogonal and normalized vectors%
Q = zeros(m, n);
QN = zeros(m, n);
% Customize plot
xlabel('X-axis');
ylabel('Y-axis');
title('Orthonormal Vectors');
legend show;
Result: orthogonal basis vectors for the given set of vectors are found and the orthonormal
vectors are plotted .
Experiment No. 6
6.Simulation of binary baseband signals using a rectangular pulse and estimate the BER
for AWGN channel using matched filter receiver.
Aim: To write a MATLAB program for simulation of binary baseband signals using a
rectangular pulse and estimate the BER for AWGN channel using matched filter receiver.
Software: MATLAB R2013a.
Theory: Binary baseband signals are transmitted using rectangular pulses for binary 1s and
0s.The matched filter receiver is used to maximize the SNR and make the decision based on the
received signal.In the presence of AWGN, the receiver will make errors when the noise causes
the decision variable to cross the threshold incorrectly.The Bit Error Rate (BER) for binary
baseband signals with rectangular pulses in an AWGN channel can be calculated using the Q-
2A2
function: 𝐵𝐸𝑅 = 𝑄 (√ N )
0
Procedure:
1. Open MATLAB version R2013a
2. Open new file and enter the program and save it.
3. Add the path to the location of the file in the system.
4. Compile the program and check for any error and debug it.
5. Note down the output.
Program:
clc;
clear all;
close all ;
% Initialize key variables.
T_bit = 10; % 1/T_bit is the bit rate
num_bits = 300; % Desired number of bits in generated signal
%% Create the baseband signal, Create bit sequence.
bit_seq = randi([0 1], [1 num_bits]);
% Noise addition
y = s + 10^(-Eb_N0_dB(ii)/20)*num_bits; % additive white gaussian noise
Result: binary baseband signals using a rectangular pulse is simulated and BER for AWGN
channel using matched filter receiver is estimated.
Experiment No 7:
7.Perform the QPSK Modulation and demodulation. Display the signal and its
constellation.
Aim: Write a MATLAB program to perform the QPSK Modulation and demodulation. Display
the signal and its constellation.
Software: MATLAB R2013a.
Theory : QPSK works by changing the phase of the carrier signal to represent pairs of bits. In
this scheme, each symbol represents two bits, and there are four possible symbols in total, each
represented by a different phase.
Each pair of bits is mapped to one of four possible symbols, typically represented as:
• 00 → Phase 0° (or π/4\pi/4π/4 radians)
• 01 → Phase 90° (or 3π/43\pi/43π/4 radians)
• 10 → Phase 180° (or 5π/45\pi/45π/4 radians)
• 11 → Phase 270° (or 7π/47\pi/47π/4 radians)
The modulated signal can be expressed as a real and imaginary component corresponding to the
in-phase and quadrature components of the carrier signal. The signal is then transmitted over
the communication channel.
The goal of QPSK demodulation is to recover the original bit stream from the received signal.
This is done by detecting the phase of the received signal, mapping the phase back to the
corresponding bit pair, and then reconstructing the original data stream. The received signal is
affected by noise, which can be modeled as an Additive White Gaussian Noise (AWGN)
channel. The received signal r(t) can be written as:
r(t)=s(t)+n(t)
Where s(t) is the transmitted signal, and n(t) is the noise
Procedure:
1. Open MATLAB version R2013a
2. Open new file and enter the program and save it.
3. Add the path to the location of the file in the system.
4. Compile the program and check for any error and debug it.
5. Note down the output.
Program:
clc;
clear all;
close all;
N=100 ; %number of symbols to be generated
dataIn= randi([0 3],N,1); %data Generation
txSig = pskmod(dataIn,4,pi/4); %modulation
rxSig = awgn(txSig,20); %transmission through awgn channel
dataOut = pskdemod(rxSig,4,pi/4);%demodulation
%plotting
subplot(2,1,1), stem(1:N,dataIn);
xlabel('sample Number');
title('Input Data for modulation');
subplot(2,1,2),stem(1:N,dataOut);
xlabel('sample Number');
title('Output Data after demodulation');
%constlellation diagram
scatterplot(txSig)
title('Constellation Diagram of Tx Signal');
scatterplot(rxSig)
title('Contellation Diagram of Rx Signal');
Output:
Experiment No 8:
8.Generate 16-QAM Modulation and obtain the QAM constellation.
Aim:Write a MATLAB Program to generate 16-QAM Modulation and obtain the QAM
constellation.
Procedure:
1. Open MATLAB version R2013a
2. Open new file and enter the program and save it.
3. Add the path to the location of the file in the system.
4. Compile the program and check for any error and debug it.
5. Note down the output.
Program
clc;
clear all;
close all;
N=100;
d = randi([0 15], N, 1); % Generate data symbols
sym = qammod(d,16); % Generate modulated symbols
rcv = awgn(sym, 20); % Additive White Gaussian Noise
stem(1:N,d);
xlabel('Sample Number');
title('Data to be modulated');
scatterplot(rcv); % View constellation
Output:
Experiment No 9:
9.Encoding and Decoding of Huffman code.
Aim:To write a MATLAB program for encoding and decoding of Huffman code
Software: MATLAB R2013a.
Theory: Huffman coding, developed by David A. Huffman in 1952, is a widely employed
algorithm for lossless data compression. It is based on the principle of entropy encoding and is
particularly efficient in constructing variable-length codes for symbols based on their frequency
of occurrence in a given dataset. This lab experiment aims to explore the Huffman coding
algorithm, understand its construction, and observe its efficiency in compressing data.
Procedure:
1. Open MATLAB version R2013a
2. Open new file and enter the program and save it.
3. Add the path to the location of the file in the system.
4. Compile the program and check for any error and debug it.
5. Note down the output.
Program:
clc;
clear all;
close all;
symbols = 1:6;
p = [.5 .125 .125 .125 .0625 .0625]; %probability should be equal to 1
bps = ceil(log2(max(symbols))); % Bits per symbol
subplot(2,1,1),stem(1:N, inputSig);
xlabel('Sample Number');
title('Input data for encoding');
subplot(2,1,2),stem(1:N,sig);
xlabel('Sample Number');
title('Output data after decoding');
Output:
Experiment No 10:
10. Encoding and decoding of binary data using a Hamming code.
Aim:Write a MATLAB program for encoding and decoding of binary data using a Hamming
code.
Theory: Hamming Code is an error-detecting and error-correcting code widely used in digital
communication systems. It adds redundancy to the transmitted data to detect and correct
errors, ensuring data integrity during transmission.
Procedure:
Program
clc;
clear all;
close all;
subplot(2,1,1),stem(1:k, data);
xlabel('Sample Number');
title('Input data for encoding');
subplot(2,1,2),stem(1:k,decData );
xlabel('Sample Number');
title('Output data after decoding');
Output:
Result : Encoding and decoding of binary data using a Hamming code is performed..
Experiment No 11:
11. CRC-CCITT polynomial to obtain the CRC code.
Aim: Write a C Program for a given data, use CRC-CCITT polynomial to obtain the CRC
code. Verify for the cases, a)Without error b)With error
Program
#include<stdio.h>
#include<string.h>
#define N strlen(genpoly)
void xor()
{
for(c = 1;c < N; c++)
checksum[c] = (( checksum[c] == genpoly[c])?'0':'1');
}
void crc()
{
for(e=0;e<N;e++)
checksum[e]=data[e];
do
{
if(checksum[0]=='1')
xor ();
for(c=0;c<N-1;c++)
checksum[c]=checksum[c+1];
checksum[c]=data[e++];
}
while(e<=a+N-1);
}
int main()
{
printf("\nEnter data : ");
scanf("%s",data);
Dept. of ECE, YIT MOODBIDRI 34 | Page
BECL504 Digital Communication Lab
printf("\n\nChecksum is : %s",checksum);
for(e=a;e<a+N-1;e++)
data[e]=checksum[e-a];
printf("\n\nFinalcodeword is : %s",data);
Result : C Program for a given data, using CRC-CCITT polynomial,CRC code is obtained
and Verified for the cases, a)Without error b)With error.
Experiment No 12:
12. Encoding and decoding of Convolution code.
Aim:Write a MATLAB Program for encoding and decoding of Convolution code.
Procedure:
1. Open MATLAB version R2013a
2. Open new file and enter the program and save it.
3. Add the path to the location of the file in the system.
4. Compile the program and check for any error and debug it.
5. Note down the output.
Program
clc;
clear all;
close all;
K=3;
G1=7;
G2=5;
N=15;
msg= randi([0 1],1,N); %data Generation
trel=poly2trellis(K,[G1 G2]);
coded=convenc(msg,trel); %convlutional encoder
tblen = length(msg);
decoded=vitdec(coded,trel,tblen,'trunc','hard'); %viterbi algorithm
subplot(2,1,1), stem(1:N,msg)
xlabel('sample Number')
title('message signal')
subplot(2,1,2),stem(1:N,decoded)
xlabel('sample Number')
title('decoded outptut of viterbi algorithm')
Output: