Uploaded by rahulkumarboy83

35311502719-dc

advertisement
EXPERIMENT-1
AIM-
To Study Sampling Theorem.
SOFTWARE USEDMATLAB ONLINE
THEORY-
SAMPLING THEOREMThe sampling theorem essentially says that a signal has to be sampled at
least with twice the frequency of the original signal. Since signals and their
respective speed can be easier expressed by frequencies, most
explanations of artifacts are based on their representation in the frequency
domain. The sampling frequency required by the sampling theorem is
called the Nyquist Frequency.
CODE%Sampling Theorem
clc;
clear all;
t = -100:0.01:100;
fm = 0.02
x = cos(2*pi*t*fm);
subplot(2,2,1);
plot(t,x)
PRIYA _YADAV_00411507220
xlabel('time in sec'),ylabel('x(t)')
title('Continuous time signal')
%fs1<2fm
fs1 = 0.02
n = -2:2;
x1 = cos(2*pi*fm*n/fs1)
subplot(2,2,2);
stem(n,x1)
hold on
subplot(2,2,2)
plot(n,x1,':');
xlabel('n'),ylabel('x(n)');
title('Discrete time signal x(n) for fs<2fm');
%fs2=2fm
fs2 = 0.04;
n1 = -4:4;
x2 = cos(2*pi*fm*n1/fs2);
subplot(2,2,3);
stem(n1,x2)
hold on
subplot(2,2,3)
plot(n1,x2,':');
PRIYA _YADAV_00411507220
xlabel('n1'),ylabel('x(n1)');
title('Discrete time signal x(n) for fs=2fm');
%fs3>2fm
fs3 = 0.5;
n2 = -100:50;
x3 = cos(2*pi*fm*n2/fs3);
subplot(2,2,4);
stem(n2,x3)
hold on
subplot(2,2,4);
plot(n2,x3,':');
xlabel('n2'),ylabel('x(n2)');
title('Discrete time signal x(n2) for fs>2fm');
OUTPUT-
PRIYA _YADAV_00411507220
PRIYA _YADAV_00411507220
EXPERIMENT-02
AIM:TO STUDY OF PULSE CODE MODULATION AND PROBABILITY OF ERROR.
SOFTWARE USEDMATLAB ONLINE
THEORY
PULSE CODE MODULATION
Pulse code modulation is a method that is used to convert
an analog signal into a digital signal so that a modified analog
signal can be transmitted through the digital communication
network. PCM is in binary form, so there will be only two possible
states high and low(0 and 1). We can also get back our analog
signal by demodulation. The Pulse Code Modulation process is
done in three steps Sampling, Quantization, and Coding. There
are two specific types of pulse code modulations such as
differential pulse code modulation(DPCM) and adaptive
differential pulse code modulation(ADPCM).
CODE
%Quantization Process
clc;
clear all;
fm=5;
fs = 90;
t=0:1/fs:2;
n=4; % number of bits
L=16; %no of levels
a=5;
signal=a+a*sin(2*pi*fm.*t);
subplot(6,1,1);
plot(t,signal);
subplot(6,1,2);
stem(t,signal);
%quantization process
VH=max(signal);
VL=min(signal);
delta=(VH-VL)/L;
part=VL:delta:VH;
code=VL-(delta/2):delta:VH+(delta/2);
[ind,q]=quantiz(signal,part,code);
length_ind=length(ind);
for i=1:length_ind
if(ind(i)~=0)
ind(i)=ind(i)-1;
end
end
subplot(6,1,3);
stairs(t,q)
%encoding
enc= de2bi(ind,'left-msb')%decim
k=1
for i=1:length_ind
for j=1:n
coded(k)=enc(i,j)
k=k+1;
end
end
subplot(6,1,4);
stairs(0:(length(t)*4)-1,coded);
%demodulation
k=1;
for i=1:length_ind
for j=1:n
quant(i,j)=coded(k);
% convert coded row vector to code matrix
k=k+1;
end
end
index=bi2de(quant,'left-msb');
% Getback the index in decimal form
q=delta*index+VL+(delta/2);
% getback Quantized values
[n d]=butter(5,0.5);
de=filter(n,d,q);
subplot(6,1,5); grid on;
stairs(t,q);
% Plot Demodulated signal
title('Demodulated Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
subplot(6,1,6);
plot(t,de);
title('Reconstructed Analog Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
OUTPUT
EXPERIMENT-3
AIM:To calculate S/N ratio and probability of error of Delta Modulation.
SOFTWARE USED:MATLAB ONLINE
THEORY:DELTA MODULATION
A modulation technique that converts or encodes message
signal into a binary bit stream is known as Delta Modulation.
Here only 1 bit is used to encode 1 voltage level thus, the
technique allows transmission of only 1 bit per sample.
CODE:clc;
clear all;
fm=5;
fs=90;
t=0:1/fs:2;
m=sin(2*pi*t);
subplot(2,1,1);
plot(t,m);
title('Continuous Signal');
xlabel('Time'); ylabel('Amplitude');
am=1;
d=2*pi*fm*am/fs;
for n=1:length(m);
if n==1
e(n)=m(n);
eq(n)=d*sign(e(n));
mq(n)=eq(n);
else
e(n)=m(n)-mq(n-1);
eq(n)=d*sign(e(n));
mq(n)=mq(n-1)+eq(n);
end
end
subplot(2,1,2);
stairs(t, mq);
title('Demodulated Signal');
xlabel('Time'); ylabel('Amplitude');
Output
Experiment-04
AIM:To calculate S/N ratio and probability of error of Differential Pulse
Code Modulation.
SOFTWARE USED:MATLAB ONLINE
THEORY:Differential PulseCode Modulation(DPCM)
Differential pulse code modulation is a technique of analog to
digital signal conversion. This technique samples the analog
signal and then quantizes the difference between the sampled
value and its predicted value, then encodes the signal to form a
digital value. Before going to discuss differential pulse code
modulation, we have to know the demerits of PCM (Pulse Code
Modulation).
clc;
clear all;
fm=5;
fs=15;
am=1;
t=0:1/50:1;
x=1*cos(2*pi*fm*t);
for n=1:length(x)
if n==1
e(n)=x(n);
eq(n)=round(e(n));
xq(n)=eq(n);
else
e(n)=x(n)-xq(n-1);
eq(n)=round(e(n));
xq(n)=eq(n)+xq(n-1);
end
end
subplot(2,2,1);
plot(t,x);
title('Continuous Signal');
subplot(2,2,2);
plot(t,eq);
title('DPCM Signal');
for n=1:length(x)
if n==1
xqr(n)=eq(n);
else
xqr(n)=eq(n)+xqr(n-1);
end
end
subplot(2,2,3);
plot(t,xqr);
title('Decoded Sampled Signal ');
[n,d]=butter(2,.2)
rec_op=filter(n,d,xqr)
subplot(2,2,4);
plot(t,rec_op);
title('Recovered Signal');
Output:-
EXPERIMENT-4
AIM:To calculate S/N ratio and Probability of error of Differential Pulse
Code Modulation.
SOFTWARE USED:MatlabR2021a.
THEORY:Differential pulse-code modulation (DPCM) is a signal encoder
that uses the baseline of pulse-code modulation (PCM) but
adds some functionalities based on the prediction of the
samples of the signal. The input can be an analog signal or
a digital signal.
If the input is a continuous-time analog signal, it needs to
be sampled first so that a discrete-time signal is the input to the
DPCM encoder.
•
Option 1: take the values of two consecutive samples; if
they are analog samples, quantize them; calculate the
difference between the first one and the next; the output
is the difference.
•
Option 2: instead of taking a difference relative to a
previous input sample, take the difference relative to
the output of a local model of the decoder process; in
this option, the difference can be quantized, which
allows a good way to incorporate a controlled loss in
the encoding.
AYUSH MITTAL
20211502719
Applying one of these two processes, short-term redundancy
(positive correlation of nearby values) of the signal is
eliminated; compression ratios on the order of 2 to 4 can be
achieved if differences are subsequently entropy
coded because the entropy of the difference signal is much
smaller than that of the original discrete signal treated as
independent samples.
DPCM was invented by C. Chapin Cutler at Bell Labs in 1950;
his patent includes both methods.[1]
The operations at DPCM transmitter and DPCM receiver are
given below through figure:
CODE:
clc;
AYUSH MITTAL
20211502719
clear all;
fm=5;
fs=15;
am=1;
t=0:1/100:1;
x=1*cos(2*pi*fm*t);
for n=1:length(x)
if n==1
e(n)=x(n);
eq(n)=round(e(n));
xq(n)=eq(n);
else
e(n)=x(n)-xq(n-1);
eq(n)=round(e(n));
xq(n)=eq(n)+xq(n-1);
end
end
figure(1)
plot(t,x);
title('continuous time signal');
xlabel('Time');
ylabel('Signal');
figure(2)
plot(t,eq);
title('DPCM Signal');
xlabel('Time');
ylabel('Signal');
for n=1:length(x)
if n==1
xqr(n)=eq(n);
else
xqr(n)=eq(n)+xqr(n-1);
end
AYUSH MITTAL
20211502719
end
figure(3)
plot(t,xqr);
title('reported sampled Signal');
xlabel('Time');
ylabel('Signal');
[n,d]=butter(2,.2);
rec_op=filter(n,d,xqr);
figure(4)
plot(t,rec_op);
title('recovered Signal');
xlabel('Time');
ylabel('Signal');
AYUSH MITTAL
20211502719
OUTPUT:
figure1:
Figure2:
Figure3:
AYUSH MITTAL
20211502719
Figure4:
AYUSH MITTAL
20211502719
EXPERIMENT-5
AIM:To write a code for different lines code.
SOFTWARE USED:MatlabR2021a.
THEORY:Data as well as signals that represents data can either be
digital or analog. Line coding is the process of
converting digital data to digital signals. By this technique we
converts a sequence of bits to a digital signal. At the sender
side digital data are encoded into a digital signal and at the
receiver side the digital data are recreated by decoding the
digital signal.
We can roughly divide line coding schemes into five
categories:
1. Unipolar (eg. NRZ scheme).
2. Polar (eg. NRZ-L, NRZ-I, RZ, and Biphase –
Manchester and differential Manchester).
3. Bipolar (eg. AMI and Pseudoternary).
4. Multilevel
5. Multitransition
AYUSH MITTAL
20211502719
But, before learning difference between first three schemes we
should first know the characteristic of these line coding
techniques:
• There should be self-synchronizing i.e., both receiver
and sender clock should be synchronized.
• There should have some error-detecting capability.
• There should be immunity to noise and interference.
• There should be less complexity.
• There should be no low frequency component (DCcomponent) as long distance transfer is not feasible for
low frequency component signal.
• There should be less base line wandering.
Unipolar scheme –
In this scheme, all the signal levels are either above or below
the axis.
• Non return to zero (NRZ) – It is unipolar line coding
scheme in which positive voltage defines bit 1 and the
zero voltage defines bit 0. Signal does not return to
zero at the middle of the bit thus it is called NRZ. For
example: Data = 10110.
But this scheme uses more power as compared to
polar scheme to send one bit per unit line resistance.
Moreover for continuous set of zeros or ones there will
be self-synchronization and base line wandering
problem.
Polar schemes –
In polar schemes, the voltages are on the both sides of the
axis.
AYUSH MITTAL
20211502719
•
NRZ-L and NRZ-I – These are somewhat similar to
unipolar NRZ scheme but here we use two levels of
amplitude (voltages). For NRZ-L(NRZ-Level), the level
of the voltage determines the value of the bit, typically
binary 1 maps to logic-level high, and binary 0 maps to
logic-level low, and for NRZ-I(NRZ-Invert), two-level
signal has a transition at a boundary if the next bit that
we are going to transmit is a logical 1, and does not
have a transition if the next bit that we are going to
transmit is a logical 0.
Note – For NRZ-I we are assuming in the example that
previous signal before starting of data set “01001110”
was positive. Therefore, there is no transition at the
beginning and first bit “0” in current data set
“01001110” is starting from +V. Example: Data =
01001110.
Comparison between NRZ-L and NRZ-I: Baseline
wandering is a problem for both of them, but for NRZ-L
it is twice as bad as compared to NRZ-I. This is
because of transition at the boundary for NRZ-I (if the
next bit that we are going to transmit is a logical 1).
Similarly self-synchronization problem is similar in both
for long sequence of 0’s, but for long sequence of 1’s it
is more severe in NRZ-L.
•
Return to zero (RZ) – One solution to NRZ problem is
the RZ scheme, which uses three values
positive,negative,and zero. In this scheme signal goes
AYUSH MITTAL
20211502719
to 0 in the middle of each bit.
Note – The logic we are using here to represent data is
that for bit 1 half of the signal is represented by +V and
half by zero voltage and for bit 0 half of the signal is
represented by -V and half by zero voltage. Example:
Data = 01001.
Main disadvantage of RZ encoding is that it requires
greater bandwidth. Another problem is the complexity
as it uses three levels of voltage. As a result of all
these deficiencies, this scheme is not used today.
Instead, it has been replaced by the better-performing
Manchester and differential Manchester schemes.
•
Biphase (Manchester and Differential Manchester ) –
Manchester encoding is somewhat combination of the
RZ (transition at the middle of the bit) and NRZ-L
schemes. The duration of the bit is divided into two
halves. The voltage remains at one level during the
first half and moves to the other level in the second
half. The transition at the middle of the bit provides
synchronization.
Differential Manchester is somewhat combination of
the RZ and NRZ-I schemes. There is always a
transition at the middle of the bit but the bit values are
determined at the beginning of the bit. If the next bit is
0, there is a transition, if the next bit is 1, there is no
transition.
Note –
1. The logic we are using here to represent data using
AYUSH MITTAL
20211502719
Manchester is that for bit 1 there is transition form -V to
+V volts in the middle of the bit and for bit 0 there is
transition from +V to -V volts in the middle of the bit.
2. For differential Manchester we are assuming in the
example that previous signal before starting of data set
“010011” was positive. Therefore there is transition at
the beginning and first bit “0” in current data set
“010011” is starting from -V. Example: Data = 010011.
The Manchester scheme overcomes several problems
associated with NRZ-L, and differential Manchester
overcomes several problems associated with NRZ-I as
there is no baseline wandering and no DC component
because each bit has a positive and negative voltage
contribution.
Only limitation is that the minimum bandwidth of
Manchester and differential Manchester is twice that of
NRZ.
Bipolar schemes –
In this scheme there are three voltage levels positive,
negative, and zero. The voltage level for one data element is
at zero, while the voltage level for the other element alternates
between positive and negative.
AYUSH MITTAL
20211502719
•
•
Alternate Mark Inversion (AMI) – A neutral zero voltage
represents binary 0. Binary 1’s are represented by
alternating positive and negative voltages.
Pseudoternary – Bit 1 is encoded as a zero voltage
and the bit 0 is encoded as alternating positive and
negative voltages i.e., opposite of AMI scheme.
Example: Data = 010010.
The bipolar scheme is an alternative to NRZ.This
scheme has the same signal rate as NRZ,but there is
no DC component as one bit is represented by voltage
zero and other alternates every time.
CODE:clc;
clear all;
x=round(rand(1,10))
nx=length(x)
sign=1;
AYUSH MITTAL
20211502719
for i=1:nx
t=i:0.001:i+1-0.001;
if x(i)==1
unipolar_nrz=square(t*2*pi,100);
polar_nrz=square(t*2*pi,100);
ami_nrz=sign*square(t*2*pi,100);
unipolar_rz=(1+square(t*2*pi,50))/2;
polar_rz=(1+square(t*2*pi,50))/2;
ami_rz=sign*(1+square(t*2*pi,50))/2;
nrz_m=sign*square(2*pi*t,100);
sign=-1*sign;
manchester_code=square(t*2*pi,50);
else
unipolar_nrz = 0;
polar_nrz= -square(t*2*pi,100);
ami_nrz=0;
unipolar_rz=0;
polar_rz= -(1+square(t*2*pi,50))/2;
ami_rz=0;
manchester_code=-square(t*2*pi,50);
end
subplot(4,2,1);
plot(t,unipolar_nrz);
ylabel('unipolar NRZ');
AYUSH MITTAL
20211502719
hold on;
grid on;
axis([1 10 -1.5 1.5]);
subplot(4,2,2);
plot(t,unipolar_rz);
ylabel('unipolar RZ');
hold on;
grid on;
axis([1 10 -1.5 1.5]);
subplot(4,2,3);
plot(t,polar_nrz);
ylabel('polar NRZ');
hold on;
grid on;
axis([1 10 -1.5 1.5]);
subplot(4,2,4);
plot(t,polar_rz);
ylabel('polar RZ');
hold on;
grid on;
axis([1 10 -1.5 1.5]);
AYUSH MITTAL
20211502719
subplot(4,2,5);
plot(t,ami_nrz);
ylabel('AMI NRZ');
hold on;
grid on;
axis([1 10 -1.5 1.5]);
subplot(4,2,6);
plot(t,ami_rz);
ylabel('AMI RZ');
hold on;
grid on;
axis([1 10 -1.5 1.5]);
subplot(4,2,7);
plot(t,nrz_m);
ylabel('NRZ_M code');
hold on;
grid on;
axis([1 10 -1.5 1.5]);
subplot(4,2,8);
AYUSH MITTAL
20211502719
plot(t,manchester_code);
ylabel('manchester_code');
hold on;
grid on;
axis([1 10 -1.5 1.5]);
end
OUTPUT
AYUSH MITTAL
20211502719
EXPERIMENT-6
AIM:To calculate S/N ratio and Probability of error of Amplitude Shift
Keying (ASK).
SOFTWARE USED:MatlabR2021a.
THEORY:Amplitude Shift Keying (ASK) is a type of Amplitude Modulation
which represents the binary data in the form of variations in the
amplitude of a signal.
Any modulated signal has a high frequency carrier. The binary
signal when ASK modulated, gives a zero value for Low input
while it gives the carrier output for High input.
The following figure represents ASK modulated waveform along
with its input.
AYUSH MITTAL
20211502719
To find the process of obtaining this ASK modulated wave, let
us learn about the working of the ASK modulator.
ASK Modulator:
The ASK modulator block diagram comprises of the carrier
signal generator, the binary sequence from the message signal
and the band-limited filter. Following is the block diagram of the
ASK Modulator.
AYUSH MITTAL
20211502719
The carrier generator, sends a continuous high-frequency
carrier. The binary sequence from the message signal makes
the unipolar input to be either High or Low. The high signal
closes the switch, allowing a carrier wave. Hence, the output will
be the carrier signal at high input. When there is low input, the
switch opens, allowing no voltage to appear. Hence, the output
will be low.
The band-limiting filter, shapes the pulse depending upon the
amplitude and phase characteristics of the band-limiting filter or
the pulse-shaping filter.
ASK Demodulator:
There are two types of ASK Demodulation techniques. They are
−
•
•
Asynchronous ASK Demodulation/detection
Synchronous ASK Demodulation/detection
The clock frequency at the transmitter when matches with the
clock frequency at the receiver, it is known as a Synchronous
AYUSH MITTAL
20211502719
method, as the frequency gets synchronized. Otherwise, it is
known as Asynchronous.
Asynchronous ASK Demodulator:
The Asynchronous ASK detector consists of a half-wave
rectifier, a low pass filter, and a comparator. Following is the
block diagram for the same.
The modulated ASK signal is given to the half-wave rectifier,
which delivers a positive half output. The low pass filter
suppresses the higher frequencies and gives an envelope
detected output from which the comparator delivers a digital
output.
Synchronous ASK Demodulator:
Synchronous ASK detector consists of a Square law detector,
low pass filter, a comparator, and a voltage limiter. Following is
the block diagram for the same.
AYUSH MITTAL
20211502719
The ASK modulated input signal is given to the Square law
detector. A square law detector is one whose output voltage is
proportional to the square of the amplitude modulated input
voltage. The low pass filter minimizes the higher frequencies.
The comparator and the voltage limiter help to get a clean digital
output.
CODE:
clc;
x=round(rand(1,10));
nx=length(x)
t=0:0.01:nx;
f=4;
for i=1:nx
t=i:0.001:i+1-0.001;
ct = sin(2*f*pi*t);
ans= x(i).*ct;
AYUSH MITTAL
20211502719
subplot(2,1,1);
plot(t,ans);
ylabel('ASK');
hold on;
grid on;
axis([1 10 -1 1]);
end
OUTPUT:
AYUSH MITTAL
20211502719
Download