You are on page 1of 17

Lab report on:

Analog to Analog and Digital to Analog conversion

Problem 1: Write a program to generate Amplitude Modulation.


Theory:
Amplitude modulation (AM) is a modulation technique used in electronic communication, most
commonly for transmitting information via a radio carrier wave. In amplitude modulation, the
amplitude (signal strength) of the carrier wave is varied in proportion to that of the message signal
being transmitted. The message signal is, for example, a function of the sound to be reproduced by a
loudspeaker, or the light intensity of pixels of a television screen.
In amplitude modulation, the amplitude or strength of the carrier oscillations is varied. For example, in
AM radio communication, a continuous wave radio-frequency signal (a sinusoidal carrier wave) has its
amplitude modulated by an audio waveform before transmission. The audio waveform modifies the
amplitude of the carrier wave and determines the envelope of the waveform. In the frequency domain,
amplitude modulation produces a signal with power concentrated at the carrier frequency and two
adjacent sidebands. Each sideband is equal in bandwidth to that of the modulating signal, and is a
mirror image of the other. Standard AM is thus sometimes called "double-sideband amplitude
modulation" (DSB-AM) to distinguish it from more sophisticated modulation methods also based on
AM.

Matlab code:
%>>> AM Modulation <<<
clc;
close all;
clear all;

%XXX Define AM modulation Index XXX

disp(' example: m=1 means 100% modulation');


%m=input(' Enter the value of modulation index (m) = ');
m=1; % for 100% modulation
if (0>m||m>1)
error('m may be less than or equal to one and geter than to zero');
end

%XXX modulating signal generation XXX


Am=5;
fa=2000;
Ta=1/fa; t=0:Ta/999:6*Ta;
ym=Am*sin(2*pi*fa*t);
figure (1)
subplot (3,1,1);
plot (t,ym), grid on;% Graphical representation of Modulating signal
title ( ' Modulating Signal ');
xlabel ( ' time(sec) ');
ylabel (' Amplitude(volt) ');

%XXXX carrier signal generation XXXX


Ac=Am/m;% Amplitude of carrier signal [ where, modulation Index
(m)=Am/Ac ]
Fc = fa*10;
Tc =1/fc;
Yc =Ac*sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,yc), grid on;
title ( ' Carrier Signal');
xlabel ( ' time(sec) ');
ylabel (' Amplitude(volt)');

%XXXX AM Modulation XXX


y=Ac*(1+m*sin(2*pi*fa*t)).*sin(2*pi*fc*t); % Equation of Amplitude
%modulated signal
subplot(3,1,3);
plot(t,y);% Graphical representation of AM signal
title ( ' Amplitude Modulated signal ');
xlabel ( ' time(sec) ');
ylabel (' Amplitude(volt) ');
grid on;

Signal Graph:
Problem 2: Write a program to generate Frequency Modulation.

Theory:
Frequency modulation (FM) is the standard technique for high-fidelity communications as is
evident in the received signals of the FM band (88-108 MHz) vs. the AM band (450-1650 KHz).
The main reason for the improved fidelity is that FM detectors, when properly designed, are not
sensitive to random amplitude variations which are the dominant part of electrical noise (heard
as static on the AM radio). Frequency modulation is not only used in commercial radio
broadcasts, but also in police and hospital communications, emergency channels, TV sound,
wireless (cellular) telephone systems, and radio amateur bands above 30 MHz. The basic idea
of an FM signal vs. an AM signal is shown in Fig. 1. In an FM signal, the frequency of the signal
is changed by the modulation (baseband) signal while its amplitude remains the same. In an
AM signal, we now know that it is the amplitude (or the envelope) of the signal that is changed
by the modulation signal.
Matlab code:
fm=input(‘Message Frequency=’);
fc=input(‘Carrier Frequency=’);
mi=input(‘Modulation Index=’);
t=0:0.0001:0.1;
m=sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,m);
xlabel(‘Time’);
ylabel(‘Amplitude’);
title(‘Message Signal’);
gridon;c=sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,c);
xlabel(‘Time’);
ylabel(‘Amplitude’);
title(‘Carrier Signal’);
grid on;y=sin(2*pi*fc*t+(mi.*sin(2*pi*fm*t)));%Frequency changing w.r.t
Message
subplot(3,1,3);
plot(t,y);
xlabel(‘Time’);
ylabel(‘Amplitude’); title(‘FM Signal’)
grid on;
Signal graph:

Problem 3: Write a program to generate Phase Modulation.


Theory:
Phase modulation (PM) is a modulation pattern for conditioning communication signals for
transmission. It encodes a message signal as variations in the instantaneous phase of a carrier wave.
Phase modulation is one of the two principal forms of angle modulation, together with frequency
modulation.
The phase of a carrier signal is modulated to follow the changing signal level (amplitude) of the message
signal. The peak amplitude and the frequency of the carrier signal are maintained constant, but as the
amplitude of the message signal changes, the phase of the carrier changes correspondingly.
Phase modulation is widely used for transmitting radio waves and is an integral part of many digital
transmission coding schemes that underlie a wide range of technologies like Wi-Fi, GSM and satellite
television.
Matlab code:
clear all
close all
t = 0:0.01:1;
fc = 7;
% create message signal m(t)
m = sin(2*pi*t);

kp = pi/2;
% modulating the carrier with the message signal
carrier = cos(2*pi*fc*t);
modulated = cos(2*pi*fc*t + kp*m)

% Plotting the signals


Plot (t, m, 'b', t, carrier, 'r', t, modulated, 'k--')
axis ([0 1 -1.5 1.5]);
x label ('Time(seconds)');
y label ('Amplitude(volt)');
title ('Phase modulation');
legend ('Message', 'Carrier', 'Modulated');

Signal graph:

Problem4: Write a program to generate Amplitude Shift Keying

Theory: Amplitude-shift keying (ASK) is a form of amplitude modulation that represents digital data as
variations in the amplitude of a carrier wave. In an ASK system, the binary symbol 1 is represented by
transmitting a fixed-amplitude carrier wave and fixed frequency for a bit duration of T seconds. If the
signal value is 1 then the carrier signal will be transmitted; otherwise, a signal value of 0 will be
transmitted.

Code: F1=input(‘Enter the frequency of carrier=’);

F2=input(‘Enter the frequency of pulse=’);

A=3;%Amplitude

t=0:0.001:1;

x=A.*sin(2*pi*F1*t);%Carrier Sine wave

u=A/2.*square(2*pi*F2*t)+(A/2);%Square wave message

v=x.*u;

subplot(3,1,1);
plot(t,x);

xlabel(‘Time’);

ylabel(‘Amplitude’);

title(‘Carrier’);

grid on;

subplot(3,1,2);

plot(t,u);

xlabel(‘Time’);

ylabel(‘Amplitude’);

title(‘Square Pulses’);

grid on;subplot(3,1,3);

plot(t,v);

xlabel(‘Time’);

ylabel(‘Amplitude’);

title(‘ASK Signal’);

grid on;

Signal Graph:
Problem 5: Write a program to generate Frequency Shift Keying (FSK)

Theory:
Frequency Shift Keying (FSK) is the digital modulation technique in which the
frequency of the carrier signal varies according to the digital signal changes. FSK is a scheme
of frequency modulation.
The output of a FSK modulated wave is high in frequency for a binary High input and is low in
frequency for a binary Low input. The binary 1s and 0s are called Mark and Space
frequencies.
Matlab Code:%>>>>>>>>> MATLAB code for binary FSK modulation >>>>>>>%
clc;
clear all;
close all;
x=[ 1 0 0 0 1 0 1];
bp=.000001;
disp(' Binary information at Trans mitter :');
disp(x);
%XX representation of transmitting binary information as digital signal XXX
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=ones(1,100);
else x(n)==0;
se=zeros(1,100);
end
bit=[bit se];

end
t1=bp/100:bp/100:100*length(x)*(bp/100);
subplot(3,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('transmitting information as digital signal');

%XXX Binary-FSK modulation XXX%

A=5;
br=1/bp;
f1=br*3;
f2=br*1;
t2=bp/99:bp/99:bp;
ss=length(t2);
m=[];
for (i=1:1:length(x))
if (x(i)==1)
y=A*cos(2*pi*f1*t2);
else
y=A*cos(2*pi*f2*t2);
end
m=[m y];
end
t3=bp/99:bp/99:bp*length(x);
subplot(3,1,2);
plot(t3,m);
xlabel('time(sec)');
ylabel('amplitude(volt)');
title('waveform for binary FSK modulation coresponding binary information');
Signal Figure:
Problem6: Write a program to generate Phase Shift Keying

Theory: Phase-shift keying (PSK) is a digital modulation process which conveys data by changing
(modulating) the phase of a constant frequency reference signal (the carrier wave). In PSK, the
constellation points chosen are usually positioned with uniform angular spacing around a circle In this
way, the moduli of the complex numbers they represent will be the same and thus so will the
amplitudes needed for the cosine and sine waves. Two common examples are "binary phase-shift
keying" (BPSK) which uses two phases, and "quadrature phase-shift keying" (QPSK) which uses four
phases, although any number of phases may be used. Since the data to be conveyed are usually binary,
the PSK scheme is usually designed with the number of constellation points being a power of two.

Matlab Code: b = input('Enter the Bit stream \n '); %b = [0 1 0 1 1 1 0];

n = length(b);

t = 0:.01:n;

x = 1:1:(n+1)*100;

for i = 1:n

if (b(i) == 0)

b_p(i) = -1;

else

b_p(i) = 1;

end

for j = i:.1:i+1

bw(x(i*100:(i+1)*100)) = b_p(i);

end
end

bw = bw(100:end);

sint = sin(2*pi*t);

st = bw.*sint;

subplot(3,1,1)

plot(t,bw)

grid on ; axis([0 n -2 +2])

subplot(3,1,2)

plot(t,sint)

grid on ; axis([0 n -2 +2])

subplot(3,1,3)

plot(t,st)

grid on ; axis([0 n -2 +2])

Signal Graph:

Problem7: Write a program to generate Unipolar:Non –Return-To-Zero(NRZ)

Theory:  In 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.
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.
Matlab Code:

close all;

n=[1 0 1 1 0 1];

for i=1:length(n)

if(n(i)==1)

nn(i)=2;

else

nn(i)=0;

end

end

i=1;

t=0:0.01:length(n);

for j=1:length(t)

if(t(j)<=i)

y(j)=nn(i);

else

y(j)=nn(i);

i=i+1;

%j=j-2;

%y(j)=nn(i);

end

end

plot(t,y,'r-');

axis([0 length(n) -4 4]);

%grid;

title('The plot of unipolar__nrz');

xlabel('Time');
ylabel('Amplitude');

Signal Graph:

Problem8: Write a program to generate polar:Non –Return-To-Zero(NRZ)

Theory: In polar NRZ encoding, we use two levels of voltage amplitude. We can have two versions of
polar NRZ: (1). NRZ-L (2). NRZ-I.

NRZ-L (NRZ-Level): The level of the voltage determines the value of the bit.

NRZ-I (NRZ-Invert): The change or lack of change in the level of the voltage determines the value of the
bit. If there is no change, the bit is 0; if there is a change, the bit is 1

Matlab Code:

close all;

%warning off;

%input

n=[1 0 1 1 0 1];

n=input();

for i=1:length(n)

if n(i)==1;

nn(i)=2;

else

nn(i)=-2;
end

end

i2=1;

t=0:0.01:length(n);

for j=1:length(t)

if t(j)<=i2;

y(j)=nn(i2);

else

y(j)=nn(i2);

i2=i2+1;

end

end

plot(t,y,'r-');

axis([0 length(n) -5 5]);

%grid;

title('The plot of polar__nrz');

xlabel('Time');

ylabel('Amplitude');

Signal Graph:
Problem9: Write a program to generate Polar Return-To-Zero(RZ)

Theory: Return-to-zero (RZ or RTZ) describes a line code used in telecommunications signals in which the
signal drops (returns) to zero between each pulse. This takes place even if a number of consecutive 0s or
1s occur in the signal. The signal is self-clocking. This means that a separate clock does not need to be
sent alongside the signal, but suffers from using twice the bandwidth to achieve the same data-rate as
compared to non-return-to-zero format.

Matlab Code: clc;

%n=input('Enter bit sequence: %d',n[i]);

%n=[0 0 0 1 0 1 0 1];

N=4;

disp('enter the binary: ');

for a=1:N

n(a)=input(['' ]);

a=a+1;

end

for i=1:length(n)

if n(i)==1

n(i)=8;
else n(i)=-8;

end

end

y=0;

i=1;

a=0;

b=0.5;

t=0:0.001:length(n);

for j=1:length(t)

if t(j)>=a && t(j)<=b

y(j) = n(i);

else if t(j)>=b && t(j)<=i

y(j)=0;

else i=i+1;

a=a+1;

b=b+1;

end

end

end

plot(t,y);

axis([0 length(n) -10 10]);

title('polar RZ wave');

xlabel('...time...');

ylabel('..amplitude..');

grid on;

Signal Graph:
Problem10: Write a program to generate Polar: Manchester

Theory: Manchester coding is a special case of binary phase-shift keying (BPSK), where the data controls
the phase of a square wave carrier whose frequency is the data rate. Manchester code ensures frequent
line voltage transitions, directly proportional to the clock rate; this helps clock recovery. The DC
component of the encoded signal is not dependent on the data and therefore carries no information.
Therefore connections may be inductively or capacitively coupled, allowing the signal to be conveyed
conveniently by galvanically isolated media (e.g., Ethernet) using a network isolator—a simple one-to-
one isolation transformer which cannot convey a DC component.

Matlab Code: clear;

N=4;

disp('Enter the binary bit');

for a=1:N

n(a)=input(['' ]);

a=a+1;

end

nnn=[];

for m=1:N

if n(m)==0

nn=[-1 1];

else

nn=[1 -1];

end
nnn=[nnn nn];

end

i=1;

l=0.5;

t=0:.01:length(n);

for j=1:length(t)

if t(j)<=l

y(j)=nnn(i);

else

y(j)=nnn(i);

i=i+1;

l=l+0.5;

end

end

plot(t,y);

axis([0 N -2 2]);

grid;

Signal Graph:

You might also like