DC Lab Manual
DC Lab Manual
PREPARED BY,
Shalini M G, Assistant Professor
Mahadev S, Assistant Professor
Dr. Sumaiya M N, Associate Professor
Dr. Banani Talukdar, Assistant Professor
Dept. of ECE,DASTM
Course Outcomes: At the end of the Course, the Student will be able to:
Design the basic digital modulation and demodulation circuits for different
CO1
engineering applications.
CO2 Design of optimum communication receivers for AWGN channels.
Illustration of different digital modulations using the signals and its equivalent
CO3 vector representations.
Implement the source coding and channel coding procedures using suitable
CO4
software
Sl
. LIST OF EXPERIMENTS
N
o
1
Generation and demodulation of the Amplitude Shift Keying signal.
2
Generation and demodulation of the Phase Shift Keying signal.
3
Generation and demodulation of the Frequency Shift Keying signal.
Dept. of ECE,DASTM
4
Generation of DPSK signal and detection of data using DPSK transmitter and
receiver.
5
Gram-Schmidt Orthogonalization: To find orthogonal basis vectors for the
estimate the BER for AWGN channel using matched filter receiver.
7
Perform the QPSK Modulation and demodulation. Display the signal and its
constellation.
8
Generate 16-QAM Modulation and obtain the QAM constellation.
9
Encoding and Decoding of Huffman code.
10
Encoding and Decoding of binary data using a Hamming code.
11
For a given data, use the CRC-CCITT polynomial to obtain the CRC code.
EXPERIMENT NO 1
Aim: To design and study the working of ASK modulation and demodulation system
with the help of suitable circuit
Specifications: M(t) = 10V, 500Hz, C(t) = 5V, 10KHz.
Equipment used:
BCLT-001 Trainer kit ---1
Dept. of ECE,DASTM
ASK MODULATION CIRCUIT DIAGRAM:
ASK DEMODULATION CIRCUIT DIAGRAM:
Theory:
Dept. of ECE,DASTM
has the largest probability of bit error when compared to FSK and PSK systems.
There are sharp discontinuities shown at the transition points. These result in the
signal having an unnecessarily wide bandwidth. Band limiting is generally introduced
before transmission, in which case these discontinuities would be ‗rounded off‘. The
band limiting may be applied to the digital message, or the modulated signal itself.
One of the disadvantages of ASK, compared with FSK and PSK, for example, is that it
has not got a constant envelope. This makes its processing (e.g., power amplification)
more difficult, since linearity becomes an important factor. However, it does make for
ease of demodulation with an envelope detector.
Procedure:
1.Connect the AC Adaptor to the mains and the other side to the experimental trainer.
2. Observe the Bit Clock frequency on the Oscilloscope. Adjust the frequency to 10
KHz and connect it to--.
3.Set the SPDP switches pattern to the desired code (say 0000 1111).
4. Parallel load by changing the switch to opposite side to shift side for a short
duration and get back to shift position.
5. Observe the 8 Bit word pattern at the output of the 8 Bit word generator. This is the
actual modulating signal.
6. Adjust the carrier frequency of---- KHz and --- Volt p-p, give this input to the ASK
modulator inputs using a patch chord.
7.Connect the 8 Bit word generators output to the data input terminal of the ASK Modulator.
8.Observe the data input on one channel on a CRO and ASK output on the second channel.
9.To get demodulated signal, connect the ASK modulator output to demodulator input.
10. Adjust the two knobs simultaneously to get the original digital message at the
demodulator output on a CRO.
Pre-viva Questions:
1. State different types of Digital modulation techniques?
2. What is shift keying? What are applications of shift keying?
3. What is a binary modulation technique?
4. Define ASK?
Table : ASK Modulation & Demodulation (Amplitude & Frequency)
Expected Waveforms
Dept. of ECE,DASTM
Msg
signal
150Hz,
5V
Carrier
Signal 1
KHz, 5V
Dept. of ECE,DASTM
Modulated O/P
Demodula
ted O/P
Results: ASK waveforms for different amplitude (1 - 10V) values of message signal
verified and found correct.
Conclusions: ASK setup is Implemented using ASK BCLT-001 Trainer kit and the
waveforms are validated and verified.
Experiment No 2
PSK generation and detection
Aim: To design and study the working of PSK modulation and demodulation using suitable circuit.
Theory:
Phase shift keying is one of the most efficient digital modulation techniques. It is used for very high
bit rates. In PSK, the phase of the carrier is modulated to represent Binary values. In BPSK, the carrier
phase is used to switch The phase between 00 and1800 by digital polar Format. Hence it is also
known as phase reversal keying. The modulated carrier is given by:
Binary 1: S (t) = Ac max. Cos. (2πfct)
Binary 0: S (t) = Ac max. Cos. (2πfct + 180)
Dept. of ECE,DASTM
= - Ac max. Cos. (2πfct)
Design:
For modulator :
VC= 5VP-P, Vm= 8Vp-p , fm= 100Hz, fc = 1khz,
Assume hfe=β= 50, Vbe(sat)=0.8V, Vce(sat)= 0.2V, Ic= 10 ma= Ie,
Vm(peak)= IcRc+Vce(sat)…i.e5= IbRb+0.8
Ib=4.2/RB (β=50, Rb=22kΩ(63kΩmax value));
Vc(peak)= IcRc+Vce(sat)+IeRe; Ie=Vc(p)- VCE(sat)/Re…i.e 1.8/Rc
Ib>Ic/β…i.e 4.2/RB>1.8/Rcβ
Assume Re=4.7kΩ therefore Rb=2.2kΩ
For demodulator:
1/fm >RC> 1/Fc1
3.3ms>RC>1ms
Let Rc= 2.2ms, C=0.2µf, R=10kΩ
Circuit Diagram:
Modulation:
Demodulation:
Dept. of ECE,DASTM
Inverting summing amplifier Envelop detector Comparator
Procedure:
1) The connections are made as per the circuit diagram.
2) A sine wave of amplitude 5v and 2kHz is fed to the Collector of the transistor as carrier.
3) the message signal, a square wave of amplitude 5V and 150Hz is fed to the base of the transistor.
4) The BPSK wave is observed at pin 6 of the op-amp IC 741.
5) The demodulation circuit is also connected.
6) BPSK wave obtained is fed as input to the demodulation circuit.
7) The demodulated waveform is observed
8) All the required waveform to be plotted.
Waveforms:
Dept. of ECE,DASTM
Result:
Experiment No 3
FSK generation and detection
Aim:
To design and study the working of FSK modulation and demodulation with the help of a suitable
circuit.
Theory:
As its name suggests, a frequency shift keyed transmitter has its frequency shifted by the message.
Although there could be more than two frequencies involved in an FSK signal, in this experiment the
message will be a binary bit stream, and so only two frequencies will be involved. The word „keyed‟
suggests that the message is of the „on-off‟ (mark-space) variety, such as one (historically) generated
by a morse key, or more likely in the present context, a binary sequence. Conceptually, and in fact, the
transmitter could consist of two oscillators (on frequencies f1 and f2), with only one being connected
to the output at any one time. Unless there are special relationships between the two oscillator
frequencies and the bit clock there will be abrupt phase discontinuities of the output waveform during
transitions of the message.
Bandwidth:
Practice is for the tones f1 and f2 to bear special inter-relationships, and to be integer multiples of the
bit rate. This leads to the possibility of continuous phase, which offers advantages, especially with
respect to bandwidth control. FSK signals can be generated at baseband, and transmitted over
telephone lines (for example). In this case, both f1 and f2 (of Figure 2) would be audio frequencies.
Alternatively, this signal could be translated to a higher frequency. Yet again, it may be generated
directly at carrier frequencies.
Design:
Modulator.
RC=VCC-VCE/(IC)=1kΩ
RB==10KΩ
Demodulator.
Low pass filter
fc=2KHz, C=0.1µf
fc=
Dept. of ECE,DASTM
R=7.9KΩ (Choose 10KΩ)
Envelope Detector.
fm=200Hz, fC=10KHz.
Hence C=0.1µf, and R=10KΩ
Circuit Diagram:
Procedure:
1. Rig up the modulator circuit as shown in the figure.
2. Apply carrier of amplitude 2 V(P- P) and frequency 1 kHz.
3. Apply carrier of amplitude 2 V(P- P) and frequency 2 kHz.
4. Apply message signal of amplitude 10 V(P - P) and frequency of 250 Hz. .
5. Observe ASK outputs at each collector of transistor, and also observe FSK output at pin 6 of op-
amp.
6. Connect demodulator circuit.
7. Observe the demodulated output on CRO.
Dept. of ECE,DASTM
Waveforms:
Result:
4.Write a MATLAB program to encode binary data using Huffman code and decode it.
Dept. of ECE,DASTM
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 compress
data, 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. The
shortest codes are assigned to the most frequent characters and the longest codes are assigned to
infrequent characters.
Procedure:
Dept. of ECE,DASTM
PROGRAM
%Write a MATLAB based program for encoding and decoding of Huffman code% (variable length
source coding )
clc;clear all; 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 value dict{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
The function returns a cell array dict, which is a Huffman dictionary containing symbols and their
corresponding Huffman codewords.
Dept. of ECE,DASTM
This program defines two functions: huffmanenco is used to encode data using the Huffman coding
technique based on a given Huffman dictionary. Huffman encoding replaces each symbol with its
corresponding Huffman codeword from the dictionary, resulting in a compressed representation of the
data. and huffmandeco is used to decode data 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:
Manual verification:
Conclusion: Thus, Huffman coding efficiently represents the input data using variable-length codes,
achieving compression by using shorter codes for more frequent symbols.
5.Write a MATLAB program to encode binary data using a (7,4) Hamming code and decode
it.
Dept. of ECE,DASTM
Aim: To write a MATLAB program to encode binary data using a (7,4) Hamming code and decode 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.
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
3. Insert Parity Bits: Place the calculated parity bits at their respective positions in the 7-bit
codeword.
4. Form the Codeword: The codeword is now composed of the original 4 bits of data and the 3
parity bits.
Procedure:
Let's consider a 4-bit data: 1011 (D3, D2, D1, D0).
PROGRAM
Dept. of ECE,DASTM
%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;clear all; close all;
n = 7%# of codeword bits per block
k = 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 sequence
code = 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);
%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)
Dept. of ECE,DASTM
% 3 101 5 0010 0010101 4
% 4 011 3 0011 0011110 3
% 5 100 4 0100 0100110 3
% 6 010 2 0101 0101101 3
% 7 001 1 0110 0110011 4
%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) in the 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 =
Dept. of ECE,DASTM
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: Thus a MATLAB program is written to encode and decode binary data using a (7,4)
Hamming code and results have been verified.
6.Write a MATLAB program to encode binary data using a ((3,1,2)/suitably designed) Convolution
code and decode it.
Aim: To write a program to encode binary data using a ((3,1,2)/suitably designed) Convolution code
Dept. of ECE,DASTM
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.
% Display results
disp('Original Data:');
disp(input_data);
disp('Encoded Data:');
Dept. of ECE,DASTM
disp(encoded_data);
disp('Received Data:');
disp
In this example, convenc is used for encoding, and vitdec is used for decoding with a Viterbi decoder.
Make sure to adjust the input data, generator polynomials, and other parameters based on your
specific requirements for the convolutional code.
or
Dept. of ECE,DASTM
% Simulate channel noise (you can modify this based on your requirements)
noisy_encoded_bits = mod(encoded_bits + randi([0 1], size(encoded_bits)), 2);
% 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 data using a ((3,1,2)/suitably
designed) Convolution code and decode it and results have been verified.
OUTPUT:
Dept. of ECE,DASTM
7.For a given data, use CRC-CCITT polynomial to obtain the CRC code. Verify the program
for 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 and is 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
16 12 5
polynomial x +x +x +1, which corresponds to the hex value 0x1021. We'll create a MATLAB program
to generate the CRC code for a given input data and then simulate both cases: without error and with
Dept. of ECE,DASTM
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.
Dept. of ECE,DASTM
1111
0000001101011010 000
1111
0000000010011010 000
1111
0000000001101010 000
1111
0000000000010010 000
1111
0000000000001100 000
1111
0000000000000011 000
11 11
0000000000000000 110
The remainder bits, 110, are the check value for this message.
PROGRAM
crc=r(length(msg)+1:end)
frame = bitor(mseg,r)
Dept. of ECE,DASTM
% Calculate check value
message = 0b1101100111011010u32;
messageLength = 16;
divisor = 0b1111u32;
divisorDegree = 3;
divisor = bitshift(divisor,messageLength-divisorDegree-1);
dd=dec2bin(divisor) %initialize the polynomial divisor. Use dec2bin to display
% the bits of the result shift the divisor and message so that they have the correct
% number of bits (16 bits for the message and 3 bits for the remainder)
divisor = bitshift(divisor,divisorDegree);
remainder = bitshift(message,divisorDegree);
sdd=dec2bin(divisor)
sdr=dec2bin(remainder)
%Perform the division steps of the CRC using a for loop.
%The for loop always advances a single bit each step, so include
% a check to see if the current digit is a 1. If the current digit is a 1,
% then the division step is performed; otherwise, the loop advances a bit and continues.
for k = 1:messageLength
if bitget(remainder,messageLength+divisorDegree)
remainder = bitxor(remainder,divisor);
end
remainder = bitshift(remainder,1);
end
%Shift the bits of the remainder to the right to get the check value for the operation.
CRC_check_value = bitshift(remainder,-messageLength);
scrc=dec2bin(CRC_check_value)
%You can use the check value to verify the integrity of a message by repeating
% the same division operation. However, instead of using a remainder of 000 to start,
% use the check value 110. If the message is error free, then the result of the division
% will be zero.Reset the remainder variable, and add the CRC check value to
% the remainder bits using a bit-wise OR. Introduce an error into the message
% by flipping one of the bit values with bitset.
remainder = bitshift(message,divisorDegree);
remainder = bitor(remainder,CRC_check_value);
remainder = bitset(remainder,6);
br=dec2bin(remainder)
for k = 1:messageLength
if bitget(remainder,messageLength+divisorDegree)
remainder = bitxor(remainder,divisor);
end
remainder = bitshift(remainder,1);
end
if remainder == 0
disp('Message is error free.')
else
disp('Message contains errors.')
end
OUTPUT:
Dept. of ECE,DASTM
CRC generation
Input Message sequence :[1 1 1 0 0 0 1 1]
Input Generator Polynomial :[1 1 0 0 1 1]
crc =
1 1 0 1 0
frame =
1 1 1 0 0 0 1 1 1 1 0 1 0
'1111000000000000'
sdd =
'1111000000000000000'
sdr =
'1101100111011010000'
scrc =
'110'
br =
'1101100111011110110'
In this program, bitshift is a MATLAB function that performs bitwise shifting on integer values. It
shifts the bits of an integer to the left or right by a specified number of positions. dec2bin is a
MATLAB function used to convert decimal (base-10) numbers to binary (base-2) representation.
Manual verification:
Conclusion: The CRC code is obtained for a given data using CRC-CCITT polynomial and the program
is verified for the cases a) Without error b) With error.
Dept. of ECE,DASTM
8.Gram-Schmidt Orthogonalization: To find orthogonal basis vectors for the given set of
vectors and plot the orthonormal vectors.
Aim: To write a MATLAB program to find orthogonal basis vectors for the given set of vectors and plot
the orthonormal vectors using Gram-Schmidt Orthogonalization.
% Program
clc;
clear all;
close all;
% Input matrix
A = [1 3; 4 -7; -1 -12];
% Initialize matrices
[rows, n] = size(A); % Dimensions of A
Q = zeros(rows, n); % Orthogonal matrix
QN = zeros(rows, n); % Orthonormal matrix
% Gram-Schmidt Process
for j = 1:n
v = A(:, j); % Start with the j-th column of A
for i = 1:j-1
% Projection of A(:,j) on Q(:,i)
rij = (Q(:, i)' * A(:, j)) / (Q(:, i)' * Q(:, i));
v = v - rij * Q(:, i); % Subtract projection
Dept. of ECE,DASTM
end
Q(:, j) = v; % Store orthogonal vector
QN(:, j) = v / norm(v); % Normalize to unit norm
end
disp('ortho =');
disp(orthogonality_check);
disp('orthonormal =');
disp(QN.' * QN); % Identity matrix for orthonormal vectors
Result
A =
1 3
4 -7
-1 -12
ortho =
4.2426 0
0 13.8784
orthonormal =
1.0000 0.0000
0.0000 1.0000
Dept. of ECE,DASTM
9. Perform the QPSK Modulation and demodulation. Display the signal and its constellation
Program
% Modulation
M = 4; % Number of symbols
k = log2(M); % Number of bits per symbol
bits_per_symbol = length(data) / k;
data_reshaped = reshape(data, k, bits_per_symbol)';
symbol = bi2de(data_reshaped, 'left-msb')';
% Demodulation
demodulated_signal = pskdemod(rx_signal, M, pi/4); % Phase offset pi/4 for QPSK
Dept. of ECE,DASTM
% Convert symbols to bits
demodulated_bits = de2bi(demodulated_signal, k, 'left-msb')';
received_data = reshape(demodulated_bits', 1, []);
numErrs = symerr(data,received_data)
subplot(2,1,2);
stem(received_data, 'linewidth', 2);
title('Received Data');
xlabel('Bit');
ylabel('Amplitude');
axis([0 length(received_data) 0 1.5]);
% Scatter plot
% Define demodulated symbols
demodulated_symbols = demodulated_signal; % Replace with your demodulated symbols
Output:
Dept. of ECE,DASTM
Dept. of ECE,DASTM
11. Simulation of binary baseband signals using a rectangular pulse and estimate
the BER for AWGN channel using matched filter receiver
Aim of the Experiment: To simulate binary baseband signals using a rectangular pulse and estimate
the BER for AWGN channel using matched filter receiver.
Theory: Binary baseband signaling is the transmission of binary data (0s and 1s) over a
communication channel using a baseband signal, such as a rectangular pulse. Binary data is
represented using a rectangular pulse waveform. Each bit (0 or 1) is mapped to a signal with specific
amplitude and duration. The rectangular pulse serves as the carrier for transmitting binary
information, providing a straightforward method for modulation in baseband communication systems.
An Additive White Gaussian Noise (AWGN) channel models the real-world communication medium,
where the transmitted signal encounters random noise. AWGN is characterized by its constant power
spectral density and Gaussian amplitude distribution. The matched filter is a signal processing
technique used at the receiver to maximize the signal-to-noise ratio (SNR). It is designed to be the
conjugate of the transmitted pulse, enabling optimal detection of binary symbols in the presence of
noise. The output of the matched filter is then sampled at the optimal time instants to decide the
transmitted bit. The BER quantifies the system's performance by measuring the ratio of incorrectly
detected bits to the total transmitted bits. For an AWGN channel, the theoretical BER can be derived
and compared with simulated values to validate system design and functionality.
Program code:
% Simplified Parameters
Dept. of ECE,DASTM
N = 1e4; % Number of bits
SNR_dB = 0:5:20; % SNR values in dB
pulse_width = 1; % Pulse width for rectangular pulse
% Generate random binary data
data = randi([0 1], N, 1);
% Add AWGN
SNR = 10^(SNR_dB(snr_idx) / 10);
noise_power = 1 / (2 * SNR);
noise = sqrt(noise_power) * randn(length(tx_signal), 1);
rx_signal = tx_signal + noise;
% Matched Filter
matched_filter = rect_pulse;
filtered_signal = conv(rx_signal, matched_filter, 'same');
% Sample the output of the matched filter
Dept. of ECE,DASTM
sample_interval = round(length(filtered_signal) / N);
sampled_signal = filtered_signal(1:sample_interval:end);
Output:
Dept. of ECE,DASTM
12. Generate 16-QAM Modulation and obtain the QAM constellation.
Aim of the Experiment: To Generate 16-QAM Modulation and obtain the QAM constellation using
MATLAB.
Theory: Quadrature Amplitude Modulation (QAM) is a widely used digital modulation scheme in
modern communication systems. In QAM, two carrier waves, typically sinusoidal and orthogonal to
each other, are modulated in amplitude by the input signals. These two carriers correspond to the in-
phase (I) and quadrature-phase (Q) components, which combine to form a constellation of points in
the complex plane. In 16-QAM, the modulation order M=16, meaning it can represent 16 distinct
Program code:
clc;
clear all;
close all;
% Parameters
m = 16; % Modulation order (16-QAM)
Dept. of ECE,DASTM
k = log2(m); % Bits per symbol
n = 9000; % Total number of bits
n = k * floor(n / k); % Ensure n is a multiple of k
nsamp = 1; % Oversampling factor
% Generate random bit sequence
x = randi([0 1], n, 1); % Random binary sequence
figure;
stem(x(1:20), 'filled'); % Plot first 20 bits
title('Bit Sequence');
xlabel('Bit Index');
ylabel('Bit Amplitude');
% Convert bits to symbols
xsym = bi2de(reshape(x, k, length(x) / k).', 'left-msb'); % Group bits into symbols
figure;
stem(xsym(1:10), 'filled'); % Plot first 10 symbols
title('Symbol Plot');
xlabel('Symbol Index');
ylabel('Symbol Amplitude');
% Modulate using 16-QAM
y = qammod(xsym, m, 'UnitAveragePower', true); % Normalize power
ytx = y; % Transmitted signal
% Add AWGN to the signal
ebno = 10; % Eb/No in dB
snr = ebno + 10*log10(k) - 10*log10(nsamp); % Calculate equivalent SNR
yn = awgn(ytx, snr, 'measured'); % Add noise to the signal
% Received signal
yrx = yn;
% Scatter plot of transmitted and received signals
figure;
scatterplot(y); % Transmitted signal
title('Constellation diagram of Y');
figure;
scatterplot(yrx, 30); % Received signal with noise
title('Constellation diagram of Yrx');
Dept. of ECE,DASTM
Output:
Dept. of ECE,DASTM