DC Lab File
DC Lab File
DC Lab File
RESULT:
EXPERIMENT -2
The given example of MATLAB Simulation of Frequency Shift Keying (FSK), the user is asked about the
frequency of the two carrier wavea, Message periodic pulse & the Amplitude of the waves (considering for
square message wave & both carrier wave have equal amplitude). The frequency of the carrier wave will
change from f1 to f2 or vice versa whenever a zero is changed to 1 or vice-verso. The frequency will not
change if in 2 successive time period there is no change in message bit value.
The MATLAB below code lets the user to plot 4 graphs, namely 2 graph plot of The Carrier Waves
(Sinusoid), The Binary Message Pulse & The Modulated Wave.
ATLAB Code FOR FSK (Frequency Shift Keying) BFSK in this case:
Result:
EXPERIMENT -3
Binary Phase Shift Keying (BPSK) Modulation MATLAB
Simulation, With MATLAB Code
So what is PSK (Phase Shift Keying)?
Phase-shift keying (PSK) is a digital modulation technique that projects data by 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 digits. 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-set used by the modulator, determines the
phase of the received signal and maps it back to the symbol it represents, thus recovering the original
data.
In the example MATLAB Simulation of Phase Shift Keying (PSK), the user is asked about the frequency
of the carrier wave, Message periodic pulse & the Amplitude of the waves (considering both square
message wave & carrier wave have equal amplitude). The phase of the carrier wave will change by 180
degree whenever a zero is changed to 1 or vice-verso. The phase will not change if in 2 successive time
period there is no change in message bit value.
The MATLAB code lets the user to plot 3 graphs, namely of The Carrier Wave (Sinusoid), The Binary
Message Pulse & The Phase Shift Keyed Wave.
ylabel('Amplitude')
title('Carrier')
m=square(2*pi*fm*t);% For Plotting Message signal
subplot(3,1,2)
plot(t,m)
xlabel('time')
ylabel('ampmplitude')
title('Message Signal')% Sine wave multiplied with square wave in order to
generate PSK
x=c.*m;
subplot(3,1,3) % For Plotting PSK (Phase Shift Keyed) signal
plot(t,x)
xlabel('t')
ylabel('y')
title('PSK')
Sample is a piece of data taken from the whole data which is continuous in
the time domain.
SamplingFrequency=1Ts=fsSamplingFrequency=1Ts=fs
Where,
Nyquist Rate
Suppose that a signal is band-limited with no frequency components higher
than W Hertz. That means, W is the highest frequency. For such a signal,
for effective reproduction of the original signal, the sampling rate should be
twice the highest frequency.
Which means,
fS=2WfS=2W
Where,
Sampling Theorem
The sampling theorem, which is also called as Nyquist theorem, delivers
the theory of sufficient sample rate in terms of bandwidth for the class of
functions that are bandlimited.
If the signal x(t) is sampled above the Nyquist rate, the original signal can
be recovered, and if it is sampled below the Nyquist rate, the signal cannot
be recovered.
That means,
fs=2Wfs=2W
Where,
fs<2Wfs<2W
Aliasing
Aliasing can be referred to as “the phenomenon of a high-frequency
component in the spectrum of a signal, taking on the identity of a low-
frequency component in the spectrum of its sampled version.”
This choice of having the sampling rate higher than Nyquist rate, also helps
in the easier design of the reconstruction filter at the receiver.
Any signal can be decomposed in terms of sum of sines and cosines using
this Fourier transform.
EXPERIMENT -5
MATLAB CODE FOR QPSK MODULATION AND DEMODULATION
clc;
clear all;
close all;
data=[0 1 0 1 1 1 0 0 1 1]; % information
%Number_of_bit=1024;
%data=randint(Number_of_bit,1);
figure(1)
stem(data, 'linewidth',3), grid on;
title(' Information before Transmiting ');
axis([ 0 11 0 1.5]);
data_NZR=2*data-1; % Data Represented at NZR form for QPSK modulation
s_p_data=reshape(data_NZR,2,length(data)/2); % S/P convertion of data
br=10.^6; %Let us transmission bit rate 1000000
f=br; % minimum carrier frequency
T=1/br; % bit duration
t=T/99:T/99:T; % Time vector for one bit information
% XXXXXXXXXXXXXXXXXXXXXXX QPSK modulatio
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
y=[];
y_in=[];
y_qd=[];
for(i=1:length(data)/2)
y1=s_p_data(1,i)*cos(2*pi*f*t); % inphase component
y2=s_p_data(2,i)*sin(2*pi*f*t) ;% Quadrature component
y_in=[y_in y1]; % inphase signal vector
y_qd=[y_qd y2]; %quadrature signal vector
y=[y y1+y2]; % modulated signal vector
end
Tx_sig=y; % transmitting signal after modulation
tt=T/99:T/99:(T*length(data))/2;
figure(2)
subplot(3,1,1);
plot(tt,y_in,'linewidth',3), grid on;
title(' wave form for inphase component in QPSK modulation ');
xlabel('time(sec)');
ylabel(' amplitude(volt0');
subplot(3,1,2);
plot(tt,y_qd,'linewidth',3), grid on;
title(' wave form for Quadrature component in QPSK modulation ');
xlabel('time(sec)');
ylabel(' amplitude(volt0');
subplot(3,1,3);
plot(tt,Tx_sig,'r','linewidth',3), grid on;
title('QPSK modulated signal (sum of inphase and Quadrature phase
signal)');
xlabel('time(sec)');
ylabel(' amplitude(volt0');
% XXXXXXXXXXXXXXXXXXXXXXXXXXXX QPSK demodulation
XXXXXXXXXXXXXXXXXXXXXXXXXX
Rx_data=[];
Rx_sig=Tx_sig; % Received signal
for(i=1:1:length(data)/2)
%%XXXXXX inphase coherent dector XXXXXXX
Z_in=Rx_sig((i-1)*length(t)+1:i*length(t)).*cos(2*pi*f*t);
% above line indicat multiplication of received & inphase carred
signal
Z_in_intg=(trapz(t,Z_in))*(2/T);% integration using trapizodial
rull
if(Z_in_intg>0) % Decession Maker
Rx_in_data=1;
else
Rx_in_data=0;
end
%%XXXXXX Quadrature coherent dector XXXXXX
Z_qd=Rx_sig((i-1)*length(t)+1:i*length(t)).*sin(2*pi*f*t);
%above line indicat multiplication ofreceived & Quadphase carred
signal
Z_qd_intg=(trapz(t,Z_qd))*(2/T);%integration using trapizodial rull
if (Z_qd_intg>0)% Decession Maker
Rx_qd_data=1;
else
Rx_qd_data=0;
end
Rx_data=[Rx_data Rx_in_data Rx_qd_data]; % Received Data
vector
end
figure(3)
stem(Rx_data,'linewidth',3)
title('Information after Receiveing ');
axis([ 0 11 0 1.5]), grid on;
EXPERIMENT -6
Quadrature Amplitude Modulation – QAM with Matlab Code
First, we will explain what QAM modulation is. Quadrature amplitude modulation is a
method that combines two amplitude modulated signals into a single channel. QAM is wide
used with pulse amplitude modulation (PAM) in wireless applications.
In this Matlab tutorial, we will simulate 16-QAM modulation using Matlab, and then we will
compare theoretical and simulated BER.
hDemod = modem.qamdemod(hMod); %
tx = modulate(hMod,x);
EbNo = 0:10; % In dB
rx = zeros(nSyms,length(SNR));
bit_error_rate = zeros(length(SNR),1);
for i=1:length(SNR)
rx(:,i) = awgn(tx,SNR(i),'measured');
end
rx_demod = demodulate(hDemod,rx);
for i=1:length(SNR)
[~,bit_error_rate(i)] = biterr(x,rx_demod(:,i));
end
theoryBer = 3/(2*k)*erfc(sqrt(0.1*k*(10.^(EbNo/10))));
figure;
grid on;
xlabel('Eb/No, dB');
At the receiver end, a pulse code demodulator decodes the binary signal back
into pulses with same quantum levels as those in the modulator. By further
processes we can restore the original analog waveform.
Basically two types of techniques are used for the sampling process. Those
are 1. Natural Sampling and 2. Flat- top Sampling.
Quantization
In quantization, an analog sample with an amplitude that converted into a
digital sample with an amplitude that takes one of a specific defined set of
quantization values. Quantization is done by dividing the range of possible
values of the analog samples into some different levels, and assigning the
center value of each level to any sample in quantization interval. Quantization
approximates the analog sample values with the nearest quantization values.
So almost all the quantized samples will differ from the original samples by a
small amount. That amount is called as quantization error. The result of this
quantization error is we will hear hissing noise when play a random signal.
Converting analog samples into binary numbers that is 0 and 1.
As we know,
L=2n, then Step size Q = (Fmax – Fmin) / L
Interval i is mapped to the middle value. We will store or send only index value
of quantized value.
But there are some problems raised in uniform quantization those are
In DPCM only the difference between a sample and the previous value is
encoded. The difference will be much smaller than the total sample value so
we need some bits for getting same accuracy as in ordinary PCM. So that the
required bit rate will also reduce. For example, in 5 bit code 1 bit is for polarity
and the remaining 4 bits for 16 quantum levels.
It is seen from the above figure that, if the data bit is Low i.e., 0, then the
phase of the signal is not reversed, but continued as it was. If the data is a
High i.e., 1, then the phase of the signal is reversed, as with NRZI, invert
on 1 (a form of differential encoding).
If we observe the above waveform, we can say that the High state
represents an M in the modulating signal and the Low state represents
a W in the modulating signal.
DPSK Modulator
DPSK is a technique of BPSK, in which there is no reference phase signal.
Here, the transmitted signal itself can be used as a reference signal.
Following is the diagram of DPSK Modulator.
DPSK encodes two distinct signals, i.e., the carrier and the modulating
signal with 180° phase shift each. The serial data input is given to the
XNOR gate and the output is again fed back to the other input through 1-
bit delay. The output of the XNOR gate along with the carrier signal is
given to the balance modulator, to produce the DPSK modulated signa
DPSK Demodulator
In DPSK demodulator, the phase of the reversed bit is compared with the
phase of the previous bit. Following is the block diagram of DPSK
demodulator.
From the above figure, it is evident that the balance modulator is given
the DPSK signal along with 1-bit delay input. That signal is made to
confine to lower frequencies with the help of LPF. Then it is passed to a
shaper circuit, which is a comparator or a Schmitt trigger circuit, to
recover the original binary data as the output.