Digital Communication Lab Manual
Digital Communication Lab Manual
Digital Communication Lab Manual
Prepared By Reviewed By
Mr.P Venugopal, ECE Ms. Savitha H S
Ms. Mohanthi Kakarla
Approved By
Dr. A Poonguzhali
HOD, ECE
Vision and Mission of the Institute
Department Mission:
M1: To achieve, sustain and excellence in the field of Electronics and Communication Engineering.
M2: To adopt proper pedagogical methods to maximize the knowledge transfer.
M3: To enhance the understanding of theoretical concepts through professional society activities.
M4: To improve the infrastructure and provide conducive environment of learning and research
following ethical and moral values.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge
to assess societal, health, safety, legal and cultural issues and the consequent
responsibilitiesrelevant to the professional engineering practice.
4
BECL504 SSCE
7. Environment and sustainability: Understand the impact of the professional
engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities
andnorms of the engineering practice.
12. Life-long learning: Recognize the need for, and have the preparation and ability to
engagein independent and life-long learning in the broadest context of technological
change.
5
BECL504 SSCE
COURSE OBJECTIVES & COURSE OUTCOMES
COURSE OBJECTIVES
COURSE OUTCOMES
On the completion of this laboratory course, the students will be able to:
1. Design and test the digital modulation circuits and display the waveforms.
2. To Implement the source coding algorithm using C/C++/ MATLAB code.
3. To Implement the Error Control coding algorithms using C/C++/
MATLABcode.
4. Illustrate the operations of networking concepts and protocols
using Cprogramming and network simulators.
6
BECL504 SSCE
Experiment Lists
Revised Bloom’s
S.No. Experiments Details Taxonomy
(RBT) Level
Hardware Experiments
Generation and demodulation of the Amplitude Shift
1 L1, L2, L3
Keying signal.
Generation and demodulation of the Phase Shift Keying
2 L1, L2, L3
signal
Generation and demodulation of the Frequency Shift
3 L1, L2, L3
Keying signal.
Generation of DPSK signal and detection of data using
4 L1, L2, L3
DPSK transmitter and receiver.
Simulation Experiments
(Use MUKU:GO / MATLAB / Scilab /LabVIEW or any other suitable software)
Gram-Schmidt Orthogonalization: To find orthogonal L1, L2, L3
5 basis vectors for the given set of vectors and plot the
orthonormal vectors.
Simulation of binary baseband signals using a rectangular L1, L2, L3
6 pulse and estimate the BER for AWGN channel using
matched filter receiver.
Perform the QPSK Modulation and demodulation. Display L1, L2, L3
7 the signal and its constellation.
Generate 16-QAM Modulation and obtain the QAM L1, L2, L3
8 constellation.
Encoding and Decoding of Huffman code L1, L2, L3
9
Encoding and Decoding of binary data using a Hamming L1, L2, L3
10 code.
For a given data, use CRC-CCITT polynomial to obtain L1, L2, L3
11 the CRC code. Verify for the cases, a) Without error b)
With error
L1, L2, L3
12 Encoding and Decoding of Convolution code
L1, L2, L3
13 QPSK Generation and Detection
7
BECL504 SSCE
Scheme Analysis
8
BECL504 SSCE
GENERAL INSTRUCTIONS
On the right-side page of the record following has to be written:
1. Title: The title of the experiment should be written in the page in capital letters.
2. In the left top margin, experiment number and date should be written.
3. Aim: The purpose of the experiment should be written clearly.
4. Apparatus/Tools/ Equipment /Components used: A list of the
Apparatus/Tools/Equipment/Components used for doing the experiment
should be entered.
5. Principle: Simple working of the circuit/experimental set up/algorithm should be written.
6. Procedure: steps for doing the experiment and recording the readings should be
brieflydescribed (flow chart/programs in the case of computer/processor related
experiments)
7. Results: The results of the experiment must be summarized in writing and
should befulfilling the aim.
8. Inference: Inference from the results is to be mentioned.
4. Graphs: Graphs can used to present data in a form that show the results obtained,
as oneor more of the parameters are varied. A graph has the advantage of
9
BECL504 SSCE
presenting large amounts of data in a concise visual form. Graph should be in a
square format.
DO NOT:
1. Do not MOVE EQUIPMENT around the room except under the supervision of
an instructor.
10
BECL504 SSCE
Experiment No.1
Amplitude Shift Keying signal
OBJECTIVES:
After completing this experiment, the students will be able to-
a) Set up ASK modulator and demodulator circuits
b) Identify ASK waveform.
THEORY:
Amplitude Shift Keying (ASK) is a digital modulation scheme where the binary data is
transmitted using a carrier signal with two different amplitude levels. For binary 0 and 1,
the carrier switches between these two levels. In its simplest form, a carrier is sent during
one inputand no carrier is sent during the other. This kind of modulation scheme is called
on-off keying.
11
BECL504 SSCE
A simple ASK modulator circuit is shown in figure. Here a sinusoidal high frequency
carrier signal is sent for logic ‘0’ (-5V) and no carrier is sent for logic ‘1’ (+5V). The
transistorworks as a switch closes when the input (base) voltage is +5V (logic ‘1’) and
shorts the output.When the input voltage is -5V (logic ‘0’), the switch opens and the
The demodulator circuit consists of an envelope detector and a comparator. The diode
D selects the positive half cycle of the ASK input. The envelop detector formed by 2.2K
resistorand 0.01uF capacitor detects the data out of the ASK input. The Op Amp
comparator and the zener diode amplitude limiter convert this detected signal to its
original logic levels. The 10Kpotentiometer may be varied to set suitable reference
PROCEDURE:
1. Test all the components and probes.
2. Set up the FSK modulator and demodulator circuits on the bread board. Switch
on thepower supplies.
3. Feed 5V, 100Hz (10Vpp, 100Hz) square wave as the data input. Vary the pot RC to
adjustthe output frequencies if needed.
4. Observe both the input and output waveforms on CRO and plot.
5. Apply the FSK output of the modulator to the input of the demodulator, and
observe theoutput. Plot the waveforms.
12
BECL504 SSCE
CIRCUIT DIAGRAM:
ASK Modulator
ASK Demodulator
13
BECL504 SSCE
WAVEFORM:
RESULT: ASK modulator and demodulator circuits were set up and the waveforms
wereplotted.
14
BECL504 SSCE
EXPERIMENT NO.1 VIVA QUESTIONS
1. What is Amplitude Shift Keying (ASK) and how does it differ from other
modulation techniques like Frequency Shift Keying (FSK) and Phase Shift
Keying (PSK)?
2. Explain the basic principle of how information is transmitted using ASK. What
role does the amplitude of the carrier signal play in this modulation
technique?
3. What are the advantages and disadvantages of using Amplitude Shift Keying
for digital communication? In what scenarios would ASK be preferred over
other modulation schemes?
4. Describe the impact of noise on ASK signals. How does noise affect the
demodulation process, and what techniques can be employed to mitigate
these effects?
5. Can you explain the concept of bandwidth efficiency in the context of ASK?
How does the bandwidth requirement of ASK compare to that of other
modulation techniques?
15
BECL504 SSCE
Experiment No.2
Phase Shift Keying signal
OBJECTIVES:
After completing this experiment, the students will be able to a) Set up PSK
THEORY:
Phase-shift keying (PSK) is a digital modulation scheme that conveys data by changing, or
modulating the phase of a reference signal (the carrier wave). Any digital modulation
scheme uses a finite number of distinct signals to represent digital data. PSK uses a finite
number of phases; each assigned a unique pattern of binary bits. Usually each phase
encodes an equal number of bits. Each pattern of bits forms the symbol that is represented
by the particular phase.The demodulator which is designed specifically for the symbol it
represents thus recovering theoriginal data. This requires the receiver to be able to
compare the phase of the received signal to a reference signal- such a system is termed
BPSK or PRK (Phase Reversal Keying) is the simplest form of PSK. It uses two phases
which are separated by 180 and so can also be termed as 2-PSK. It is however only able to
modulate 1bit/symbol and so it is unsuitable for high data-rate applications when
bandwidth is limited.
16
BECL504 SSCE
COMPONENTS AND EQUIPMENTS REQUIRED:
CIRCUIT DIAGRAM:
PSK MODULATOR:
17
BECL504 SSCE
PROCEDURE:
Generation:
1 Rig up the circuit as given in the circuit diagram for generation of FSK.
3 Apply c1(t) = 3Vp-p, 2KHz and c2(t) = 3Vp-p, 10KHz Sine wave.
4 Observe PSK output at the transmitter at the emitter of the transistor on an oscilloscope.
Detection:
b. It may be observed that after the first RC network, which is a low pass
c. Observe the amplitude and waveform at pin no.3 of the op-Amp, which is the
applied at pin no. 2 from 0V to a desired value such that a square waveform
e. It may be observed that the reproduced signal, m’(t) matches with actual
18
BECL504 SSCE
PSK DEMODULATOR:
19
BECL504 SSCE
RESULT: The PSK modulator and demodulator circuits were set up and the waveforms
wereplotted.
20
BECL504 SSCE
EXPERIMENT NO.2 VIVA QUESTIONS
1. What is Phase Shift Keying (PSK) and how does it differ from Amplitude Shift
Keying (ASK) and Frequency Shift Keying (FSK)?
2. Explain the basic principle of PSK. How is information encoded in the phase of
the carrier signal, and what are the different types of PSK?
3. What are the advantages and disadvantages of using Phase Shift Keying for
digital communication? In what applications is PSK typically preferred?
4. Discuss the effects of noise on PSK signals. How does noise influence the
demodulation process, and what techniques can be used to improve the
robustness of PSK against noise?
5. Can you explain the concept of symbol rate and bit rate in the context of PSK?
How do they relate to the bandwidth requirements of PSK compared to other
modulation schemes?
21
BECL504 SSCE
Experiment No.3
Frequency Shift Keying signal
OBJECTIVES:
After completing this experiment, the students will be able to a) Set up FSK modulator and
22
BECL504 SSCE
THEORY:
Frequency Shift Keying (FSK) is a digital modulation scheme where the digital data is
transmitted using a high frequency carrier signal. For logic ‘0’ and ‘1’ the carrier signal
A frequency shift keying modulator circuit made up of 555 timer is shown in figure.
The 555 works in monostable mode. For logic ‘1’ transistor BC 177 is OFF and the
monostable
works in normal mode and capacitor C1 charges through RA and RB and the output
frequency is at the first preset level. For logic ‘0’ the transistor is ON and the resistor RC
comes in parallel with RA and reduces its effective resistance. The charging rate of the
capacitor increases and a higher frequency signal is obtained at the output. This is the
second preset frequency level. Thusthe output signal switches between the two preset
frequencies for logic ‘0’ and ‘1’. The resultingsignal is FSK modulated.
PROCEDURE:
2. Set up the FSK modulator and demodulator circuits on the bread board. Switch
on thepower supplies.
3. Feed 5V, 100Hz (10Vpp, 100Hz) square wave as the data input. Vary the pot RC to
4. Observe both the input and output waveforms on CRO and plot.
23
BECL504 SSCE
5. Apply the FSK output of the modulator to the input of the demodulator, and
CIRCUIT DIAGRAM:
24
BECL504 SSCE
WAVEFORM:
RESULT: The FSK modulator and demodulator circuits were set up and the waveforms
wereplotted.
25
BECL504 SSCE
EXPERIMENT NO. 3 VIVA QUESTIONS
1. What is Frequency Shift Keying (FSK) and how does it differ from Amplitude
Shift Keying (ASK) and Phase Shift Keying (PSK)?
2. Explain the basic principle of FSK. How is information transmitted using
different frequencies, and what are the common types of FSK?
3. What are the advantages and disadvantages of using Frequency Shift Keying in
digital communication? In what scenarios is FSK typically preferred over
other modulation techniques?
4. Discuss the impact of noise on FSK signals. How does noise affect the
demodulation process, and what methods can be employed to enhance the
performance of FSK in noisy environments?
5. Can you explain the concept of frequency deviation in FSK? How does it relate
to the bandwidth requirements of FSK compared to other modulation
schemes?
26
BECL504 SSCE
Experiment No.4
Generation of DPSK signal and detection of data using DPSK transmitter and
receiver.
AIM: To Study various steps involved in generating DPSK signal at the modulation and
therecovery of the binary signal from the received DPSK signal.
COMPONENTS REQUIRED: DPSK Trainer kit, Power chords, 20 MHz Dual trace CRO,
Power supply.
THEORY:
Differential phase shift keying (DPSK), a common form of phase modulation conveys data by
changing the phase of carrier wave. In Phase shift keying, High state contains only one cycle
but DPSK contains one and half cycle. High state is represented by a M in modulated signal
and low state is represented by a wave which appears like W in modulated signal DPSK
encodes two distinct signals of same frequency with 180 degrees phase difference between
the two.
WAVEFORMS:
27
BECL504 SSCE
28
BECL504 SSCE
DPSK WAVEFORMS:
29
BECL504 SSCE
PROCEDURE:
1. Select either 600 bps or 1200 bps clock.
2. Connect the power supply to the kit.
3. Switch off the power. Connect the probe to the CRO.
4. Connect measuring probe of the CRO to SEL CLK.
5. Using patch cords given connect the clock and data.
6. Connect the CRO probe to SEL CLK.
7. Adjust the DIP switch to any digital pattern of 8 bits.
8. Observe the DPSK waveform on the CRO.
9. Also observe the signals at all points of the circuit.
30
BECL504 SSCE
10. Plot the graph for given Input sequence
11. At the receiver section, observe the reconstructed data.
Result: Study and observe different wave forms. Write your comments on the results obtained.
1. What is Differential Phase Shift Keying (DPSK) and how does it differ from
standard Phase Shift Keying (PSK)? What advantages does DPSK offer in terms
of signal transmission?
2. Explain the process of generating a DPSK signal. What are the key components
involved in a DPSK transmitter, and how is the phase of the carrier signal
modulated based on the input data?
3. Describe the role of the phase comparator in a DPSK receiver. How does it
facilitate the detection of the transmitted data, and what are the steps
involved in the demodulation process?
4. What are the advantages and disadvantages of using DPSK for digital
communication? In what scenarios would DPSK be preferred over other
modulation techniques like ASK or FSK?
5. Discuss the impact of noise and interference on DPSK signals. How does the
design of a DPSK receiver help mitigate these effects, and what techniques can
be employed to improve the robustness of DPSK communication?
31
BECL504 SSCE
Experiment No. 5
Gram-Schmidt Orthogonalization: To find orthogonal basis vectors for the given set of
vectorsand plot the orthonormal vectors.
AIM: To write a MATLAB program to find orthogonal basis vectors for the given set of
vectorsand plot the orthonormal vectors.
MATLAB CODE:
for i=1:size(vec,1)
v=vec(i,:);
%generate a random vector
r=rand(1,3);
%check it is not parallel to original vectorwhile
~cross(r,v)
r=rand(1,3);
end
%first perpendicular vector
q1=r-dot(r,v)/dot(v,v)*v;
%second perpendicular vector
q2=cross(q1,v);
en
d
32
BECL504 SSCE
EXPERIMENT NO.5 VIVA QUESTIONS
33
BECL504 SSCE
Experiment No. 6
AIM: To write a MATLAB program to encode binary data using a (7,4) Hamming code
anddecode it.
Theory: The (7,4) Hamming code is an error-correcting code that allows the correction of
single-bit errors and the detection of two-bit errors. It operates on 4 bits of data and adds 3
parity bits to form a 7-bit codeword.
2. Determine Error Position: Use the syndrome bits to identify the position of the
error, ifany. The binary representation of the syndrome bits indicates the error
position.
3. Correct Error: If an error is detected, correct the bit at the identified error position.
4. Extract Data Bits: Remove the parity bits to obtain the 4-bit original data.
34
BECL504 SSCE
Procedure:
PROGRAM
%Simulation for encoding and decoding of a [7,4] Hamming code. The decoder
%can correct one error as shown and as theory states. The table at the end
%of the file shows the various outputs with different error positions and
%message bits. One error can be placed at any of the 7 bit locations and
%corrections made.
clc;
clearall;
close
all;
n = 7%# of codeword bits per
blockk = 4%# of message bits per
block
A = [ 1 1 1;1 1 0;1 0 1;0 1 1 ];%Parity submatrix-Need binary(decimal combination of
7,6,5,3)
G = [ eye(k) A ]%Generator matrix
H = [ A' eye(n-k) ]%Parity-check matrix
% ENCODER%
msg = [ 1 1 1 1 ] %Message block vector-change to any 4 bit
sequencecode = mod(msg*G,2)%Encode message
% CHANNEL ERROR(add one error to code)%
%code(1)=
~code(1);code(2)=
~code(2);
%code(3)= ~code(3);
%code(4)= ~code(4);%Pick one,comment out others
%code(5)= ~code(5);
35
BECL504 SSCE
%code(6)= ~code(6);
%code(7)= ~code(7);
recd = code %Received codeword with error
% DECODER%
syndrome = mod(recd * H',2)
%Find position of the error in codeword
(index)find = 0;
for ii = 1:n
if ~find
errvect =
zeros(1,n);
errvect(ii) = 1;
search = mod(errvect *
H',2);if search ==
syndrome
find = 1;
index = ii;
end
end
end
disp(['Position of error in
codeword=',num2str(index)]);correctedcode = recd;
correctedcode(index) = mod(recd(index)+1,2)
%Corrected codeword
%Strip off parity bits
msg_decoded=correctedcode;
msg_decoded=msg_decoded(1:4
)
In MATLAB, the eye function is used to create an identity matrix, which is a square matrix
with ones on the main diagonal and zeros elsewhere. Where n is the number of rows (and
columns) inthe resulting identity matrix.
Output
n =7
k =4
G=
1 0 0 0 1 1 1
0 1 0 0 1 1 0
0 0 1 0 1 0 1
0 0 0 1 0 1 1
H=
1 1 1 0 1 0 0
1 1 0 1 0 1 0
1 0 1 1 0 0 1
msg =
1 1 1 1
code =
37
BECL504 SSCE
1 1 1 1 1 1 1
recd =
1 0 1 1 1 1 1
syndrome =
1 1 0
correctedcode =
1 1 1 1 1 1 1
msg_decoded =
1 1 1 1
Manual verification:
Conclusion: Thus a MATLAB program is written to encode and decode binary data using a
(7,4)Hamming code and results have been verified.
38
BECL504 SSCE
VIVA VOICE QUESTIONS Experiment No. 6
2. Can you explain the concept of a rectangular pulse, and why is it used for
baseband signaling?
4. What is Bit Error Rate (BER), and how is it estimated in a simulated systemusing a
matched filter?
39
BECL504 SSCE
Experiment No. 7
Perform the QPSK Modulation and demodulation. Display the signal and its
constellation.
AIM: To perform the QPSK Modulation and demodulation. Display the signal and its
constellation.
THEORY:
40
BECL504 SSCE
41
BECL504 SSCE
42
BECL504 SSCE
43
BECL504 SSCE
OUTPUT : The desired QPSK waveforms ,i.e., binary data, message signal, carrier signal 1&
2 and output waveforms have been shown below:
CONCLUSION:
The program for QPSK modulation has been simulated in MATLAB and observed the
desiredwaveforms.
44
BECL504 SSCE
EXPERIMENT NO. 7 VIVA VOICE QUESTIONS
1. What is QPSK modulation, and how does it differ from other digital modulation
schemes?
3. What is the significance of the constellation diagram in QPSK, and how do youinterpret
it?
4. How is QPSK demodulation performed, and what challenges arise during this
process?
5. What are the advantages of QPSK over BPSK in terms of bandwidth efficiencyand error
performance?
45
BECL504 SSCE
Experiment No. 8
Generate 16-QAM Modulation and obtain the QAM constellation.
THEORY: The conventional format for representing a signal in MATLAB is a vector or matrix.
The length of the data stream (that is, the number of rows in the column vector) is arbitrarily
set to 30,000. Set the rng function to its default state, or any static seed value, so that the
example produces repeatable results. Then use the randi function to generate a column
vector containing random values of a binary data stream.
Get
M = 16; % Modulation order
k = log2(M); % Number of bits per symbol
n = 30000; % Number of symbols per frame
sps = 1; % Number of samples per symbol (oversampling factor)
rng default % Use default random number generator
Value');
46
BECL504 SSCE
Get
dataSymbolsIn = bit2int(dataIn,k);
Plot the first 10 symbols in a stem plot.
Get
figure; % Create new figure window.
stem(dataSymbolsIn(1:10));
title('Random Symbols');
xlabel('Symbol Index');
ylabel('Integer Value');
47
BECL504 SSCE
Calculate the SNR when the channel has an Eb/N0 of 10 dB by using the convertSNR function.
Get
EbNo = 10;
snr = convertSNR(EbNo,'ebno',
...samplespersymbol=sps, ...
bitspersymbol=k);
Pass the signal through the AWGN channel for the binary and Gray coded symbol mappings.
Get
receivedSignal = awgn(dataMod,snr,'measured');
receivedSignalG = awgn(dataModG,snr,'measured');
Create Constellation Diagram
Use the scatterplot function to display the in-phase and quadrature components of the
modulated signal, dataMod, and the noisy signal received after the channel. The effects of
AWGN are presentin the constellation diagram.
Get
sPlotFig = scatterplot(receivedSignal,1,0,'g.');
hold on
scatterplot(dataMod,1,0,'k*',sPlotFi
g)
48
BECL504 SSCE
49
BECL504 SSCE
EXPERIMENT NO.8 VIVA VOICE QUESTIONS
3. What is the difference between QAM and PSK (Phase Shift Keying), and why isQAM
used?
4. What is the difference between QAM and PSK (Phase Shift Keying), and why isQAM
used?
5. How does noise affect the 16-QAM constellation, and how would you interpret anoisy
constellation diagram?
50
BECL504 SSCE
Experiment No. 9
Encoding and Decoding of Huffman code
AIM: To write a MATLAB program to encode and decode binary data using Huffman code.
Theory:
Huffman coding is a widely used method for lossless data compression, named after David
A. Huffman who introduced it in 1952. It's a variable-length prefix coding algorithm used to
compressdata, where the most frequent symbols are represented using shorter codes and
the least frequent symbols are represented using longer codes.
Encoding the information before transmission is necessary to ensure data security and
efficient delivery of the information. The MATLAB program presented here encodes and
decodes the information and also outputs the values of entropy, efficiency and frequency
probabilities of characters present in the data stream.
Huffman coding & deciding algorithm is used in compressing data with variable-length codes.
Theshortest codes are assigned to the most frequent characters and the longest codes are
assigned to infrequent characters.
Procedure:
Step 3. Create a new node where the left sub-node is the lowest frequency in the sorted list
and theright sub-node is the second lowest in the sorted list.
Step 4. Remove these two elements from the sorted list as they are now part of one node
and addthe probabilities. The result is the probability for the new node.
51
BECL504 SSCE
Step 5. Perform insertion sort on the list.
Step 6. Repeat steps 3, 4 and 5 until you have only one node left.
52
BECL504 SSCE
PROGRAM
Description:
symbols: A cell array of symbols to be encoded.
probabilities: A vector of probabilities corresponding to each symbol. The
probabilitiesshould sum up to 1.
The function returns a cell array dict, which is a Huffman dictionary containing
symbolsand their corresponding Huffman codewords.
This program defines two functions: huffmanenco is used to encode data using
the Huffman coding technique based on a given Huffman dictionary. Huffman
encoding
53
BECL504 SSCE
replaces each symbol with its corresponding Huffman codeword from the
dictionary, resulting in a compressed representation of the data.andhuffmandeco
is used to decodedata that has been encoded using the Huffman coding technique,
based on a given Huffman dictionary. It takes the encoded data and the Huffman
dictionary as input, returning the decoded data.
Output:
Conclusion: Thus, Huffman coding efficiently represents the input data using
variable-length codes, achieving compression by using shorter codes for more
frequent symbol
54
BECL504 SSCE
EXPERIMENT NO.9 VIVA VOICE QUESTIONS
5. What are the advantages and limitations of Huffman coding in real-world applications?
55
BECL504 SSCE
Experiment NO. 10
Encoding and Decoding of binary data using a Hamming code.
Aim: To write a MATLAB program to encode binary data using a (7,4) Hamming code and
decodeit.
Theory: The (7,4) Hamming code is an error-correcting code that allows the correction of
single-bit errors and the detection of two-bit errors. It operates on 4 bits of data and adds 3
parity bits to form a 7-bit codeword.
Let's go through the steps to encode and decode a (7,4) Hamming code:
1. Data Preparation: Let's assume we have a 4-bit data sequence (D3, D2, D1, D0).
2. Calculate Parity Bits (P0, P1, P2):
P0 is the parity bit for bits: D0, D1, D3
P1 is the parity bit for bits: D0, D2, D3
P2 is the parity bit for bits: D1, D2, D3
2. Insert Parity Bits: Place the calculated parity bits at their respective positions in
the 7-bitcodeword.
3. Form the Codeword: The codeword is now composed of the original 4 bits of data
andthe 3 parity bits.
56
BECL504 SSCE
Procedure:
PROGRAM
%Simulation for encoding and decoding of a [7,4] Hamming code. The decoder
%can correct one error as shown and as theory states. The table at the end
%of the file shows the various outputs with different error positions and
%message bits. One error can be placed at any of the 7 bit locations and
%corrections
made.clc;
clearall;
close
all;
n = 7%# of codeword bits per
blockk = 4%# of message bits per
block
A = [ 1 1 1;1 1 0;1 0 1;0 1 1 ];%Parity submatrix-Need binary(decimal combination of
7,6,5,3)
G = [ eye(k) A ]%Generator matrix
H = [ A' eye(n-k) ]%Parity-check matrix
% ENCODER%
msg = [ 1 1 1 1 ] %Message block vector-change to any 4 bit
sequencecode = mod(msg*G,2)%Encode message
% CHANNEL ERROR(add one error to code)%
%code(1)=
~code(1);code(2)=
~code(2);
%code(3)= ~code(3);
%code(4)= ~code(4);%Pick one,comment out others
%code(5)= ~code(5);
%code(6)= ~code(6);
57
BECL504 SSCE
%code(7)= ~code(7);
58
BECL504 SSCE
recd = code %Received codeword with error
% DECODER%
syndrome = mod(recd * H',2)
%Find position of the error in codeword
(index)find = 0;
for ii = 1:n
if ~find
errvect =
zeros(1,n);
errvect(ii) = 1;
search = mod(errvect *
H',2);if search ==
syndrome
find = 1;
index = ii;
end
en
d
en
d
disp(['Position of error in
codeword=',num2str(index)]);correctedcode = recd;
correctedcode(index) = mod(recd(index)+1,2)%Corrected codeword
%Strip off parity bits
msg_decoded=correctedcode;
msg_decoded=msg_decoded(1:4
)
In MATLAB, the eye function is used to create an identity matrix, which is a square matrix
with ones on the main diagonal and zeros elsewhere. Where n is the number of rows (and
columns) inthe resulting identity matrix.
Output
n =7
k =4
G=
1 0 0 0 1 1 1
0 1 0 0 1 1 0
0 0 1 0 1 0 1
0 0 0 1 0 1 1
H=
1 1 1 0 1 0 0
1 1 0 1 0 1 0
1 0 1 1 0 0 1
msg =
60
BECL504 SSCE
1 1 1 1
code =
1 1 1 1 1 1 1
recd =
1 0 1 1 1 1 1
syndrome =
1 1 0
correctedcode =
1 1 1 1 1 1 1
msg_decoded =
1 1 1 1
Manual verification:
Conclusion: MATLAB program is written to encode and decode binary data using a
(7,4)Hamming code and results have been verified.
61
BECL504 SSCE
EXPERIMENT NO.10 VIVA VOICE
2. Can you explain how Hamming code generates parity bits for error detection and correction?
3. What is the minimum Hamming distance for a Hamming code, and why is it important?
4. How does the decoding process work in Hamming code, particularly in detecting and
correctingerrors?
5. What are the advantages and limitations of using Hamming code for error correction?
62
BECL504 SSCE
Experiment No. 11
For a given data, use CRC-CCITT polynomial to obtain the CRC code. Verifyfor the
cases, a) Without error b) With error
AIM: To obtain the CRC code for a given data using CRC-CCITT polynomial and to Verify the
program for the cases a) Without error b) With error
Theory:The cyclic redundancy check, or CRC, is a technique for detecting errors in digital data,
but not for making corrections when errors are detected. It is used primarily in data
transmission. This Cyclic Redundancy Check is the most powerful and easy to implement
technique. CRC is based on binary division. In CRC, a sequence of redundant bits, called cyclic
redundancy check bits, are appended to the end of data unit so that the resulting data unit
becomes exactly divisible by a second, predetermined binary number. At the destination, the
incoming data unit is divided by the same number. If at this step there is no remainder, the
data unit is assumed to be correct andis therefore accepted. A remainder indicates that the
data unit has been damaged in transit and therefore must be rejected.The CCITT CRC-16
polynomial (used in a variety of applications) is represented by the polynomial
x16+x12+x5+1, which corresponds to the hex value 0x1021. We'll create a ‘C’ program to
generate the CRC code for a given input data and then simulate both cases:without error and
with error in the received data.
Procedure:
1. Generate CRC for the given data using the CRC-CCITT polynomial.
2. Introduce an error in the data.
3. Recalculate CRC for the erroneous data.
4. Verify if the CRC detects the error.
Program
#include<stdio.h>
int a[100],b[100],i,j,len,k,count=0;
//Generator
Polynomial:g(x)=x^16+x^12+x^5+1int
gp[]={1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,};
int main()
{
void div();
printf("\nEnter the length of Data Frame :");
63
BECL504 SSCE
scanf("%d",&len);
printf("\nEnter the
Message :");
for(i=0;i<len;i++)
scanf("%d",&a[i]);
Msg bitsfor(i=0;i<16;i++)
a[len++]=0;
//Xr.M(x) (ie. Msg+16 Zeros)
for(i=0;i<len;i++)
b[i]=a[i];
]);div();
for(i=0;i<len;i++)
if(a[i]!=0)
{
printf("\nERROR in Recived
Data");return 0;
}
printf("\nData Recived is ERROR FREE");
}
void div()
64
BECL504 SSCE
{
for(i=0;i<k;i++)
{
if(a[i]==gp[0])
{
for(j=i;j<17+i;j++)
a[j]=a[j]^gp[count++];
}
count=0;
}
}
Conclusion: The CRC code is obtained for a given data using CRC-CCITT polynomial and
theprogram is verified for the cases a) Without error b) With error.
65
BECL504 SSCE
EXPERIMENT NO. 11 VIVA VOICE QUESTIONS
2. Can you explain the CRC-CCITT polynomial, and how it is used to generate theCRC code?
How does CRC detect errors in transmitted data, and how is the verificationprocess
performed?
66
BECL504 SSCE
Experiment No. 12
Theory:
Creating a complete MATLAB program for encoding and decoding using a specific
convolutional code requires a significant amount of code and understanding of the specific
code parameters (rate,constraint length, generator polynomials, etc.). I'll provide you with a
general outline and steps to create the encoding and decoding processes for a (3,1,2)
convolutional code.
Procedure:
Let's define the generator polynomials for a (3,1,2) convolutional code:
Generator polynomials:
g1=[1,0,1]
g2=[1,1,1]
Encoding:
Decoding:
1. Define the received encoded data (potentially with added noise or errors).
2. Set up the Viterbi decoder parameters (trellis structure, traceback depth, etc.).
3. Use the vitdec function to perform Viterbi decoding on the received encoded data.
67
BECL504 SSCE
% Parameters for the (3,1,2) convolutional
codeconstraint_length = 3;
generator_polynomials = [1 0 1; 1 1
1];code_rate = 1/3;
t = poly2trellis(constraint_length, generator_polynomials);
% Display results
disp('Original
Data:');
disp(input_data);
disp('Encoded
Data:');
disp(encoded_data);
disp('Received
Data:');disp
In this example, convenc is used for encoding, andvitdec is used for decoding with a Viterbi
decoder. Make sure to adjust the input data, generator polynomials, and other parameters
based onyour specific requirements for the convolutional code.
Or
functionencoded_bits = convolutional_encoder(input_bits)
% Define the convolutional code
matricesG1 = [1 1 0];
G2 = [1 0 1];
68
BECL504 SSCE
% Initialize the output
streamoutput_stream = [];
% Perform convolutional
encodingfor i =
1:length(input_bits)
% Extract the current input bits for
encodinginput_segment =
input_bits(i:i+2);
2);
functiondecoded_bits = convolutional_decoder(encoded_bits)
70
BECL504 SSCE
% Decode the noisy encoded bits using the convolutional
decoderdecoded_bits =
convolutional_decoder(noisy_encoded_bits);
% Display results
disp('Input Bits:');
disp(input_bits);
disp('Encoded Bits:');
disp(encoded_bits);
disp('Noisy Encoded
Bits:');
disp(noisy_encoded_bits);
disp('Decoded Bits:');
disp(decoded_bits);
OUTPUT:
71
BECL504 SSCE
EXPERIMENT NO. 12 VIVA VOICE QUESTIONS
1. What is a convolutional code, and how does it differ from block codes?
3. What is the significance of the constraint length and code rate in convolutionalcodes?
communication systems?
72
BECL504 SSCE
Experiment 13: Quadrature Phase Shift Keying (QPSK)
Modulation & Demodulation ( Beyond Syllabus)
Aim:
To generate the QPSK waveform for a given binary signal and demodulate the same
QPSK to get back the original signal
Block diagram:
Theory:
The QPSK is the type of modulation in which the information is carried by the transmitted wave
is contained in the phase. In particular, the phase of the carrier takes on one of the four equally
spaced value such as .each possible value of the phase corresponds to a unique pair of bits called
debit.
For exited phase value can represent set digits 10, 00, 01 and 11.
73
BECL504 SSCE
The QPSK waveform is widely used because it offers the best tradeoff between power and
bandwidth reqirements.also, it provides very low probability of error
The modulated signals are:
Se = be (t) √ps sin 2 πfot
So = bo (t) √ps cos. 2πfot The output of the adder is:
S (t) = Se (t) + So (t).
S (t) = be (t) √ps sin (2πfo t) + bo (t) √ps Cos. (2πfo t).
Digital Phase Modulation (or Phase Shift Keying - PSK) is very similar to Frequency Modulation. It
involves changing the phase of the transmitted waveform instead of the frequency, these finite phase
changes representing digital data. In its simplest form, a phase- modulated waveform can be generated
by using the digital data to switch between two signals of equal frequency but opposing phase. Taking
the above concept of PSK one stage further, it can be supposed that the number of phase shifts is not
limited to only two states. The transmitted "carrier" can undergo any number of phase changes and by
multiplying the received signal by a sine wave of equal frequency will demodulate the phase shifts into
frequency independent voltage levels. This is, indeed the case in QPSK (Quadrature Phase Shift Keying,
Sometimes this is known as quaternary PSK, quadriphase PSK, 4-PSK). With QPSK, the carrier undergoes
four changes in 4 phases and can thus represent two bits of binary data. While this may seem insignificant
at first glance, a modulation scheme has now been supposed that enables a carrier to transmit two bits
of information instead of one, thus effectively doubling the bandwidth of carrier. QPSK has four phases
and for a given bit-rate, the QPSK requires half the bandwidth of PSK and is widely used for this reason.
(In quardrature Phase Shift keying each pair of consecutive data bit is treated as a two bit (or dibit) code
which is used to switch the phase of the carrier sine wave between one of four phases 90° apart. The four
possible combination of dibit code are 00, 01, 10 and 11. Each code represents either a phase of 45°,
135°, 225°, and 315° lagging, relative to the phase of the original un-modulated carrier. The choice of
these phases is arbitrary as it is convenient to produce them. Quadrature phase shift keying offers an
advantage over PSK, in a manner that now each phase represents a two bit code rather than a single bit.
This means now either we can change phase per second or the same amount of data can be transmitted
with half as many phase changes per second. The second choice results in a lowering of bandwidth
requirement. The four phases are produced by adding two carrier waves of same frequency but 90° out
of phases. The 0° phase carrier is called In-phase carrier and is labeled 1 The other is 90° (lagging) phase
74
BECL504 SSCE
carrier termed as the quadrature carrier and is labeled Q.)
Procedure: Modulation
1. Connect the power supply cable at the POWER IN connector and switch ON the power.
2. Connect the QPSK-TX to QPSK-RX.
3. Give the input through Dip switch S1 and observe the phase shift at QPSK-TX, compare the
waveform with fig.
4. EX: Through the Dip switch select the bits as 11100100 (The switch is upper side=O, the switch is
lower side= 1)
5. Change the bit pattern by using the Dipswitch and observe the corresponding changes at SLDATA-
TX.
6. Demodulated output can be observed at SLDATA-RX at this point you will get the same pattern as
that at SLDATA-TX and you can see the same at the 8-LEDs.
7. Ex: If your selected bit pattern is 11100100 then at the demodulation side LED D3, D4, D5 &D8
Should be ON and D6, 07, 09 & 010 should be OFF,
8. Note the delay between, SLDATA-TX and SLDATA-RX, There is 0.2 In sec delay. This is due to the
delay between LT6/5-6(ISIG-QSIG)and U6/ I(SH/LD). Here first data is shifting and after 0.2 m sec
75
BECL504 SSCE
Expected Waveform:
Results: QPSK waveforms for different binary values of message signal M(t) = 10V,
500Hz , C(t) = 5V, 10KHz are are verified and found correct.
Verification/Validation: QPSK waveforms are validated against expected output
waveforms for the given message signal M(t) = 10V, 500Hz , C(t) = 5V, 10KHz and found
correct.
Viva Questions:
1. How signals are modulated and de modulated in QPSK?
2. What is the frequency range of the input and output signal and why?
3. What are the applications of DPSK technique?
4. What is the bandwidth range required for QPSK ?
76
BECL504 SSCE