Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Digital Communication Lab Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 76

Department of Electronics and Communication Engineering

DIGITAL COMMUNICATION LAB MANUAL


BECL504
CIE Marks: 50
SIE Marks: 50
Credits: 1

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

Vision of the Institution:


To emerge as a “Centre for excellence” offering Technical Education and Research
Opportunities of very high standards to students, develop the total personality of the individual,
and instill high levels of discipline and strive to set global standards, making our students
technologically superior and ethically strong, who in turn shall contribute to the advancement
of society and humankind.

Mission of the Institution:


We dedicate and commit ourselves to achieve, sustain and foster unmatched excellence in
Technical Education. To this end, we will pursue continuous development of infrastructure and
enhance state-of-the art equipment to provide our students a technologically up-to-date and
intellectually inspiring environment of learning, research, creativity, innovation and professional
activity and inculcate in them ethical and moral values.

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.

Program Outcomes (POs)


1. Engineering knowledge: Apply the knowledge of mathematics, science,
engineering fundamentals, and an engineering specialization to the solution of
complex engineering problems.
2. Problem analysis: Identify, formulate, research literature, and Analyze complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering
problems and design system components or processes that meet the specified
needs with appropriate consideration for the public health and safety, and the
cultural, societal, and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge
and research methods including design of experiments, analysis and
interpretation of data, and synthesis of the information to provide valid
conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources,
and modern engineering and IT tools including prediction and modelling to
complex engineering activitieswith 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 responsibilities relevant to the professional engineering practice.
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 and norms of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a
member or leader in diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities
with the engineering community and with society at large, such as, being able to
comprehend and write effective reports and design documentation, make
effective presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding
of the engineering and management principles and apply these to one’s own
work, as a member and leader in a team, to manage projects and in
multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability
to engage in independent and life-long learning in the broadest context of
technological change.
PROGRAM OUTCOMES (POs)
Engineering Graduates will be able to:

1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex
engineering problems.

2. Problem analysis: Identify, formulate, review research literature, and analyze


complex engineering problems reaching substantiated conclusions using first
principles of mathematics, natural sciences and engineering sciences.

3. Design/development of solutions: Design solutions for complex engineering


problems and design system components or processes that meet the specified needs
with appropriate consideration for the public health and safety, and the cultural,
societal, and environmentalconsiderations.

4. Conduct investigations of complex problems: Use research-based knowledge and


research methods including design of experiments, analysis and interpretation of
data, andsynthesis of the information to provide valid conclusions.

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.

9. Individual and team work: Function effectively as an individual and as a member or


leader in diverse teams, and in multidisciplinary settings.

10. Communication: Communicate effectively on complex engineering activities with


the engineering community and with society at large such as, being able to
comprehend and write effective reports and design documentation, make effective
presentations, and give and receive clear instructions.

11. Project management and finance: Demonstrate knowledge and understanding of


the engineering and management principles and apply these to one’s own work, as a
member and leader in a team, to manage projects and in multidisciplinary
environments.

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

This laboratory course enables students to

1. Design and demonstrate communication circuits for different digital


modulationtechniques.
2. To simulate Source coding Algorithms using C/C++/ MATLAB code.
3. To simulate Error correcting and detecting codes using C/C++/ MATLAB code.
4. Simulate the networking concepts and protocols using C/C++/ Network simulation tool.
5. Understand entropies and mutual information of different communication channels.

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

Digital Communication Lab Semester 5


BECL504 CIE Marks 50
Course Code
SEE Marks 50
Teaching Hours/Week (L: T: P: S) 0:0:2:0
Total SEE + 100
CIE
01 Exam Hours 2 Hours
Credits
Practical
Examination Type (SEE)

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.

On the Left side page of the record following has to be recorded:


1. Circuit/Program: Neatly drawn circuit diagrams/experimental set up.
2. Design: The design of the circuit/experimental set up for selecting the components
shouldbe clearly shown if necessary.
3. Observations:
a. Data should be clearly recorded using Tabular Columns.
b. Unit of the observed data should be clearly mentioned
c. Relevant calculations should be shown.
d. If repetitive calculations are needed, only show a sample calculation
andsummarize the others in a table.

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.

GENERAL RULES FOR PERSONAL SAFETY


1. REMOVE ALL METAL JEWELLERY since rings, wrist watches or bands, necklaces,
etc. make excellent electrodes in the event of accidental contact with electric
power sources.
2. DO NOT MAKE CIRCUIT CHANGES without turning off the power.
3. Make sure that equipment working on electrical power are grounded properly.
4. Avoid standing on metal surfaces or wet concrete. Keep your shoes dry.
5. Never handle electrical equipment with wet skin.

TO PROTECT EQUIPMENT AND MINIMIZE MAINTENANCE:


DOs:
1. SET MULTIRANGE METERS to highest range before connecting to an
unknownsource.
2. INFORM YOUR INSTRUCTOR about faulty equipment so that it can be sent
forrepair.

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

AIM: Generation and demodulation of the 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.

COMPONENTS AND EQUIPMENTS REQUIRED:

S.No. Items & Specifications Quantity


1 Transistor- BC 107 1 No.
2 Resistor- 4.7K, 10K, 2.2K, 1K, 1 No. each,
10K pot 1 no.
3 Capacitor- 0.01 µF 1No.
4 Diode - 1N 4001 1No.
5 Zener Diode 5Z1 2No.s
6 IC 741 1No.
7 Signal Generator 1No.
8 CRO 1No.
9 Power Supply- +/- 15V, 5V 1No.
10 Spring board 1No.
11 Wires and probes

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

carrier signal is directly connected to the output.

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

voltage for the comparator.

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

AIM: Generation and demodulation of the Phase Shift Keying signal

OBJECTIVES:

After completing this experiment, the students will be able to a) Set up PSK

modulator anddemodulator circuits and b) Identify PSK waveform.

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

coherent PSK (CPSK).

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:

S.No. Items & Specifications Quantity


1 Transistor SL100, SK100 1 No.
2 Resistor – 1KΩ, 100KΩ, 5.6 KΩ 1 No. each
3 Capacitor – 0.1Μf 1No.
4 OP Amp - μA741 1No.
5 Diode - 0A79 1No.
6 Signal generators, Power supplies, Oscilloscope. 1No.

CIRCUIT DIAGRAM:

PSK MODULATOR:

17
BECL504 SSCE
PROCEDURE:

Generation:

1 Rig up the circuit as given in the circuit diagram for generation of FSK.

2 Apply m(t ) > 7Vp-p ,300Hz square wave.

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:

a. Rig up the circuit as per the given circuit diagram.

b. It may be observed that after the first RC network, which is a low pass

filter, thewaveform becomes that of an ASK.

c. Observe the amplitude and waveform at pin no.3 of the op-Amp, which is the

output ofthe envelop detector-RC combination, a ramp.

d. Since the Op-amp is working as a comparator, vary the reference dc voltage

applied at pin no. 2 from 0V to a desired value such that a square waveform

appears at the output.

e. It may be observed that the reproduced signal, m’(t) matches with actual

message signalin terms of frequency but not in amplitude.

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

AIM: Generation and demodulation of the Frequency Shift Keying signal

OBJECTIVES:
After completing this experiment, the students will be able to a) Set up FSK modulator and

demodulator circuits and b) Identify FSK waveform.

COMPONENTS AND EQUIPMENTS REQUIRED:

S.No. Items & Specifications Quantity


1 Transistor- BC 177 1 No.
2 Resistor- 47K, 47K pot, 1 No.s each,
10K pot 7 no.s
3 Capacitor- 3Nos.
0.01µF0.02µF 4Nos.
0.047µF, 0.001µF 1No.each
4 IC LM311 1No.
5 IC 555, IC 565 1No. each
6 Signal Generator 1No.
7 CRO 1No.
8 Power Supply- +/- 5V, +-15V 1No. each
9 Spring board 1No.
10 Wires and probes

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

switchesbetween two preset frequencies, hence the name FSK.

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:

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.

23
BECL504 SSCE
5. Apply the FSK output of the modulator to the input of the demodulator, and

observe theoutput. Plot the waveforms.

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.

EXPERIMENT 4 VIVA QUESTIONS

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.

Theory: The Gram–Schmidt orthonormalization process is a technique for orthonormalizing


a collection of vectors in an inner product space, usually the Euclidean space Rn with the
standardinner product.

The Gram-Schmidt process is a collection of procedures that converts a collection of linearly


independent vectors into a collection of orthonormal vectors that cover the same space as
the original set.

The QR decomposition is obtained by applying the Gram–Schmidt process to the column


vectorsof a full column rank matrix.

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

%store the vectors as you like

Conclusion: Thus, Gram-Schmidt Orthogonalization has been studied and orthogonal


basisvectors for the given set of vectors and the orthonormal vectors has been plotted.

32
BECL504 SSCE
EXPERIMENT NO.5 VIVA QUESTIONS

1. What is the Gram-Schmidt Orthogonalization process, and what is its primary


purpose in linear algebra? Can you briefly describe the steps involved in this
process?
2. Given a set of linearly independent vectors, how does the Gram-Schmidt
process generate an orthogonal basis? Can you illustrate this with a simple
example using two or three vectors?
3. After obtaining orthogonal vectors through the Gram-Schmidt process, how do
you convert them into orthonormal vectors? What is the significance of
normalizing these vectors?
4. What are the advantages of using orthogonal or orthonormal bases in
applications such as numerical analysis, computer graphics, or signal
processing? Can you provide specific examples?
5. How would you plot the orthonormal vectors obtained from the Gram-
Schmidt process in a two-dimensional or three-dimensional space? What tools
or software would you use for this visualization?

33
BECL504 SSCE
Experiment No. 6

Simulation of binary baseband signals using a rectangular pulse and estimatethe


BER for AWGN channel using matched filter receiver.

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.

Encoding (4-bit data to 7-bit codeword):


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
3. Insert Parity Bits: Place the calculated parity bits at their respective positions in
the 7-bitcodeword.
4. Form the Codeword: The codeword is now composed of the original 4 bits of data
andthe 3 parity bits.

The resulting 7-bit codeword structure is as follows: Codeword=(P2,P1,D2,P0,D1,D0,P0)

Decoding (7-bit codeword to 4-bit data):

1. Calculate Syndrome Bits (S2, S1, S0):


 S0 is the parity of bits: P0, D1, D0, P2, D2, P1.
 S1 is the parity of bits: P1, D2, D1, P0, D0, P2.
 S2 is the parity of bits: P2, D2, D1, P1, D0, P0.

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:

Let's consider a 4-bit data: 1011 (D3, D2, D1, D0).

1. Calculate Parity Bits:


 P0 (parity for bits: D0, D1, D3) = D0 xor D1 xor D3 = 1 xor 0 xor 1 = 0 (P0 is
theleftmost bit)
 P1 (parity for bits: D0, D2, D3) = D0 xor D2 xor D3 = 1 xor 1 xor 1 = 1
 P2 (parity for bits: D1, D2, D3) = D1 xor D2 xor D3 = 0 xor 1 xor 1 = 0
2. Insert Parity Bits:
 Codeword: (0, 1, 1, 1, 0, 1, 0)

Now you have the encoded (7,4) Hamming codeword.

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
)

%Error position Syndrome Decimal 4 bit word codeworddmin

% 1 111 7 000 000000


0 0
% 2 110 6 000 000101 3
1 1
% 3 101 5 001 001010 4
0 1
% 4 011 3 001 001111 3
1 0
% 5 100 4 010 010011 3
0 0
% 6 010 2 010 010110 3
1 1
% 7 001 1 011 011001 4
0 1
36
BECL504 SSCE
%No error will give syndrome of 000 0111 0111000 3
% 1000 1000111 4
% 1001 1001100 3
% 1010 1010010 4
% 1011 1011001 3
% 1100 1100001 3
% 1101 1101010 3
% 1110 1110100 4
% 1111 1111111 3
%Any exclusive or additions of any two codewords should give another
%codeword.

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

Position of error in codeword=2

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

1. What is baseband signaling, and why is it used in digital communication?

2. Can you explain the concept of a rectangular pulse, and why is it used for
baseband signaling?

3. What is the role of the matched filter in a communication system?

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?

2. Can you explain the process of QPSK modulation?

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.

AIM : To generate 16-QAM Modulation and obtain the QAM constellation.using


MATLAB.

SOFTWARE REQUIRED: MATLAB, Computer installed with Windows XP or higher Version.

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

dataIn = randi([0 1],n*k,1); % Generate vector of binary data


Get
stem(dataIn(1:40),'filled');
title('Random Bits');
xlabel('Bit Index');
ylabel('Binary

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');

Modulate Using 16-QAM


Use the qammod function to apply 16-QAM modulation with phase offset of zero
tothe dataSymbolsIn column vector for binary-encoded and Gray-encoded bit-to-symbol
mappings.
Get
dataMod = qammod(dataSymbolsIn,M,'bin'); % Binary-encoded
dataModG = qammod(dataSymbolsIn,M); % Gray-encoded

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

1.What is 16-QAM, and how does it work in digital communication?2.How

are symbols represented in a 16-QAM constellation diagram?

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 algorithm is a popular encoding method used in electronics communication


systems. It is widely used in all the mainstream compression formats that you might
encounter—from GZIP,PKZIP (winzip, etc) and BZIP2, to image formats such as JPEG and
PNG. Some programs use just the Huffman coding method, while others use it as one step in a
multistep compression process.

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 1. Compute the probability of each character in a set of

data.Step 2. Sort the set of data in ascending order.

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.

Build the Huffman tree:

52
BECL504 SSCE
PROGRAM

%Write a MATLAB based program for encoding and decoding of Huffman


code%(variablelength source coding )
clc;
clearall;
close
all;
symbol =[1:5 % Distinct data symbols appearing in
p = [0.4 0.2 0.2 0.1 0.1]; % Probability of each data
[dict,avglen]=huffmandict(symbol,p)
Samplecode = dict{5,2} % Codeword for fifth signal
valuedict{1,:}dict{2,:}dict{3,:}dict{4,:}dict{5,:}
hcode = huffmanenco(symbol,dict);
dhsig = huffmandeco(hcode,dict); % Decode the code.
disp('encoded
msg:');disp(hcode);
disp('decoded
msg:');disp(dhsig);
code_length=length(hcode)
sum=0;
for m=1:5
H=sum+(p(m)*log2(1/p(m)));
end
disp('H=')
;disp(H);
Efficiency=(H/avglen)*100

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

1. What is Huffman coding, and why is it used in data compression?

2. Can you explain how the Huffman tree is constructed?

3. What is the difference between fixed-length coding and Huffman coding?

4. How does the decoding process work in Huffman coding?

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:

Encoding (4-bit data to 7-bit codeword):

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.

The resulting 7-bit codeword structure is as follows: Codeword=(P2,P1,D2,P0,D1,D0,P0)

Decoding (7-bit codeword to 4-bit data):

1. Calculate Syndrome Bits (S2, S1, S0):


 S0 is the parity of bits: P0, D1, D0, P2, D2, P1.
 S1 is the parity of bits: P1, D2, D1, P0, D0, P2.
 S2 is the parity of bits: P2, D2, D1, P1, D0, P0.
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.

56
BECL504 SSCE
Procedure:

Let's consider a 4-bit data: 1011 (D3, D2, D1, D0).

1. Calculate Parity Bits:


 P0 (parity for bits: D0, D1, D3) = D0 xor D1 xor D3 = 1 xor 0 xor 1 = 0 (P0 is
theleftmost bit)
 P1 (parity for bits: D0, D2, D3) = D0 xor D2 xor D3 = 1 xor 1 xor 1 = 1
 P2 (parity for bits: D1, D2, D3) = D1 xor D2 xor D3 = 0 xor 1 xor 1 = 0
2. Insert Parity Bits:
 Codeword: (0, 1, 1, 1, 0, 1, 0)

Now you have the encoded (7,4) Hamming codeword.

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
)

%Error position Syndrome Decimal 4 bit word codeworddmin

% 1 111 7 000 000000


0 0
% 2 110 6 000 000101 3
1 1
% 3 101 5 001 001010 4
0 1
% 4 011 3 001 001111 3
1 0
% 5 100 4 010 010011 3
0 0
% 6 010 2 010 010110 3
59
BECL504 SSCE
1 1
% 7 001 1011 011001 4
0 1
%No error will give syndrome of 000 0111 0111000 3
% 1000 1000111 4
% 1001 1001100 3
% 1010 1010010 4
% 1011 1011001 3
% 1100 1100001 3
% 1101 1101010 3
% 1110 1110100 4
% 1111 1111111 3
%Any exclusive or additions of any two codewords should give another
%codeword.

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

Position of error in codeword=2

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

1. What is Hamming code, and what is its purpose in communication systems?

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]);

//Append r(16) degree Zeros to

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];

//No of times to be divided ie. Msg


Lengthk=len-16;
div();
for(i=0;i<len;i++)
b[i]=b[i]^a[i]; //MOD 2
Substractionprintf("\nData to be
transmitted : ");
for(i=0;i<len;i++)
printf("%2d",b[i]);

printf("\n\nEnter the Reveived


Data : ");for(i=0;i<len;i++)
scanf("%d",&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;
}
}

Output: a) Without error

Enter the length of data


frame:4Enter the message: 1
0
1
0
Data to be transmitted : 1 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 1 0 1 0
Enter the received data: 1 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 1 0
1 0Data Recived is ERROR FREE.

Output: b) With error Enter


the length of data frame:4
Enter the message: 1
0
1
0
Data to be transmitted : 1 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 1 0 1 0
Enter the received data: 1 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 1 0
1 1ERROR in Recived Data.

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

1. What is a CRC, and why is it used in error detection?

2. Can you explain the CRC-CCITT polynomial, and how it is used to generate theCRC code?

3. Describe the process of CRC calculation for a given data string.

How does CRC detect errors in transmitted data, and how is the verificationprocess

performed?

66
BECL504 SSCE
Experiment No. 12

Encoding and Decoding of Convolution code

AIM: To write a program to encode binary data using a ((3,1,2)/suitably designed)


Convolutioncode and decode it.

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:

1. Define the input binary data.


2. Set up the convolutional code parameters (generator polynomials, rate, constraint
length,etc.).
3. Use the convenc function to perform convolutional encoding on the input data.

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);

% Define input binary data


input_data = [1 0 1 0 1]; % Example binary data

% Encoding using convolutional


code encoded_data =
convenc(input_data, t);

% Add some noise or errors (optional, for simulation purposes)


received_data = encoded_data; % Simulated received data

% Decoding using Viterbi


decodertb_depth = 12;
%Traceback depth
decoded_data = vitdec(received_data, generator_polynomials, tb_depth, 'trunc', 'hard');

% 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);

% Perform convolutional encoding for each output

bitoutput_bit1 = mod(sum(input_segment .* G1),

2); output_bit2 = mod(sum(input_segment .* G2),

2);

% Append the output bits to the output stream


output_stream = [output_stream, output_bit1,
output_bit2];end

% Return the encoded bits


encoded_bits =
output_stream;end

functiondecoded_bits = convolutional_decoder(encoded_bits)

% Define the trellis structure for Viterbi decoding


trellis = poly2trellis(3, [7 5]); % Generator polynomials: (7,5)

% Perform Viterbi decoding


decoded_bits = vitdec(encoded_bits, trellis, 5, 'trunc',
'hard');end

% Generate random binary input


datainput_bits = randi([0 1], 1,
100);

% Encode the input bits using the convolutional


encoderencoded_bits =
convolutional_encoder(input_bits);
69
BECL504 SSCE
% Simulate channel noise (you can modify this based on your
requirements) noisy_encoded_bits = mod(encoded_bits + randi([0 1],
size(encoded_bits)), 2);

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);

Manual verification:Conclusion: Thus a MATLAB program is written to encode binary


datausing a ((3,1,2)/suitably designed) Convolution code and decode it and results have
been verified.

% Parameters for the (3,1,2) convolutional


codeclc; clear all; close all;
K = 3;
G1 = 7;
G2 = 5;
msg = [1 1 0 0 1 0]
trel = poly2trellis(K,[G1
G2]);coded =
convenc(msg,trel); tblen =
length(msg);
decoded = vitdec(coded,trel,tblen,'trunc','hard')

OUTPUT:

71
BECL504 SSCE
EXPERIMENT NO. 12 VIVA VOICE QUESTIONS

1. What is a convolutional code, and how does it differ from block codes?

2. Can you explain the process of convolutional encoding?

3. What is the significance of the constraint length and code rate in convolutionalcodes?

4. What are the advantages and limitations of using convolutional codes in

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

Specifications: M(t) = 10V, 500Hz , C(t) = 5V, 10KHz.


.Equipment used:

Kit , Patch cards, Power supply and two-channel oscilloscope.

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

You might also like