You are on page 1of 13

Amplitude Modulation

Aim:
Code:
%DSB-SC
Ac = input('carrier signal
fc = input('carrier signal
Am = input('Message signal
fm = input('message signal
t = [0:0.00001:0.05];
crr = Ac.*cos(2*pi*fc.*t);
msg = Am.*sin(2*pi*fm.*t);

amplitude : ');
freq : ');
amplitude : ');
freq : ');

subplot(3,1,1);
gridon;
plot(t,msg);
title('Message Signal');
xlabel('time ');
ylabel('Amplitude ');
subplot(3,1,2);
plot(t,crr);
title('Carrier Signal');
xlabel('time');
ylabel('Amplitude');
%DSB-AM
A = Ac.*(1+(Am/Ac).*sin(2*pi*fm.*t)).*cos(2*pi*fc.*t);
subplot(3,1,3);
plot(t,A);
title('Modulated DSB-AM Signal');
xlabel('time');
ylabel('Amplitude');
figure;
subplot(3,1,1);
gridon;
plot(t,msg);
title('Message Signal');
xlabel('time');
ylabel('Amplitude');
subplot(3,1,2);
plot(t,crr);
title('Carrier Signal');
xlabel('time ');
ylabel('Amplitude');
DSBSC = msg.*crr;
subplot(3,1,3);
plot(t,DSBSC);
title('Modulated DSB-SC Signal');
xlabel('time');
ylabel('Amplitude');
% SSB-AM
a1 = sin(2*pi.*fc.*t);
a1c = hilbert(m1);
b2 = msg;
b2c = hilbert(msg);

SSBAM = Ac.*0.5.*[b2.*a1 - b2c.*a1c];


figure;
subplot(3,1,1);
gridon;
plot(t,msg);
title('Message Signal');
xlabel('time');
ylabel('Amplitude');
subplot(3,1,2);
plot(t,crr);
title('Carrier Signal');
xlabel('time ');
ylabel('Amplitude');
subplot(3,1,3);
plot(t,abs(SSBAM));
title('Modulated SSB-SC Signal');
xlabel('time ');
ylabel('Amplitude');

Graphs:

Result:

Conclusion:

Sampling
Aim:
Code:
func1=0.1;
func2=0.2;
t=0:0.1:20;
x=sin(2*pi*func1*t);
plot(t,x);
title('orginal signal');
xlabel('time index');
ylabel('amplitude');
figure
x_samples=x(1:10:201);
stem(x_samples,'filled');
title('sampled signal');
xlabel('n');
ylabel('x[n]');
axis([0 20 -2 2]);

Result:

Conclusion:

Time Division Multiplexing


Aim:
Code:
x=0:.5:4*pi;
signala=sin(x);
l=length(signala);
signalb=triang(l);
figure(1)
stem(signalb);
ylabel('Amplitude');
xlabel('Time index');
title('triangular wave');
figure(2)
stem(signala);
ylabel('Amplitude');
xlabel('Time index');
title('sine wave');
figure(3)
fori=1:l
signal(1,i)=signala(i);
signal(2,i)=signalb(i);
end
tdmrg=reshape(signal,1,2*l);
stem(tdmrg);
ylabel('Amplitude');
xlabel('Time index');
title('time division multiplexing')

Result:
Conclusion:

Manchester Line Coding


Aim:
Code:
input=[1 1 0 1 1 0];
size2=size(input,2);
sign=1;
i=1;
whilei<size2+1
t = i:0.001:i+1-0.001;
if input(i)==1
sign=sign*-1;
mcode=-square(t*2*pi,50);
else
mcode=square(t*2*pi,50);
end
grid on
plot(t,mcode);
xlabel('time index');
ylabel('Amplitude');
title('Manchester line coding');
hold on
axis([1 10 -2 2]);
i=i+1;
end

Result:

Conclusion:

Bipolar NRZ
Aim:
Code:
input=round(randi([0 1],1,100));
k=0;
temp=0;
fori=1:length(x)
if(input(i)==0)
temp=i;
k=[k zeros(1,50)];
elseif(input(i)==1)
k=[k (-1)^temp*ones(1,50)];
end
end
figure(1)
stairs(1:length(y),y)
ylim([-1.2 1.2]);
ylabel('Amplitude');
xlabel('Time index');
title('Bipolar Non Return to Zero');

Result:

Conclusion:

Differential Encoding
Aim:
Code:
input=[1 0 1 0 1 1 0 1 1 0];
Z=size(x,2);
ref_bit = 1;
del_x = [ref_bitx(1:Z-1)];
fori= 1:Z
if (x(i) == del_x(i))
y(i) =1;
else
y(i) = 0;
end
end
diff_code = 1 - y;
figure(1)
stairs(x);
title('PN input sequence');
ylabel('Amplitude');
xlabel('Time index');
holdon;
gridon;
axis([1 10 -2 2]);
figure(2)
stairs(diff_code);
title('Differential Encoded sequence');
ylabel('Amplitude');
xlabel('Time index');
holdon;
gridon;
axis([1 10 -2 2]);

Result:

Conclusion:

PWM and PPM


Aim:
Code:
time=0:0.001:1;
signal=sawtooth(2*pi*10*t+pi);
y=length(signal);
x=0.75*sin(3*pi*1*time);
fori=1:y
if (x(i)>=signal(i))
pwm(i)=1;
elseif (x(i)<=signal(i))
pwm(i)=0;
end
end
plot(time,pwm,time,x,time,signal);
grid on;
ylabel('Amplitude');
xlabel('Time index');
title('PWM Wave');
axis([0 1 -1.5 1.5]);

%PPM
fori=2:n
if (pwm(i)==1 &&pwm(i-1)==0)
ppm(i)=1;
else
ppm(i)=0;
end
end
subplot(2,1,2)
plot(t,ppm);
ylabel('Amplitude');
xlabel('Time index');
title('PPM Wave');
axis([0 1 -1.5 1.5]);

Result:

Conclusion:

Delta Modulation
Aim:
Code:
amp=2;
t=0:2*pi/50:2*pi;
A=amp*sin(t);
l=length(x);
plot(x,'r');
delta=0.2;
hold on
An=0;
fori=1:l;
if A(i)>An(i)
d(i)=1;
An(i+1)=An(i)+delta;
else
d(i)=0; An(i+1)=An(i)-delta;
end
end
stairs(An)
title('Delta modulation')
ylabel('Amplitude');
xlabel('Time index');
legend('Analog signal','Delta modulation')

Result:

Conclusion:

Pulse Code Modulation


Aim:
Code:
n=input('Enter n value for n-bit PCM system : ');
n1=input('Enter number of samples in a period : ');
L=2^n;
x=0:2*pi/n1:4*pi;
s=8*sin(x);
subplot(3,1,1);
plot(s);
title('Analog Signal');
ylabel('Amplitude');
xlabel('Time index');
subplot(3,1,2);
stem(s);grid on; title('Sampled Signal'); ylabel('Amplitude');

%QUANTIZATION PROCESS
vmax=8;
vmin=-vmax;
del=(vmax-vmin)/L;
part=vmin:del:vmax;
code=vmin-(del/2):del:vmax+(del/2);
[ind,q]=quantiz(s,part,code);
l1=length(ind);
l2=length(q);
fori=1:l1
if(ind(i)~=0)
ind(i)=ind(i)-1;
end
i=i+1;
end
fori=1:l2
if(q(i)==vmin-(del/2))
q(i)=vmin+(del/2);
end
end
subplot(3,1,3);
stem(q);grid on;
title('Quantized Signal');
ylabel('Amplitude');
xlabel('Time index');
%

Encoding Process

figure
code=de2bi(ind,'left-msb');
k=1;
fori=1:l1
for j=1:n
coded(k)=code(i,j);
j=j+1;
k=k+1;
end
i=i+1;
end
subplot(2,1,1); grid on;
stairs(coded);
axis([0 100 -2 3]);
title('Encoded Signal');
ylabel('Amplitude--->');
xlabel('Time--->');

xlabel('Time index');

Demodulation Of PCM signal

qunt=reshape(coded,n,length(coded)/n);
index=bi2de(qunt','left-msb');
q=del*index+vmin+(del/2);
subplot(2,1,2); grid on;
plot(q);
% Plot Demodulated signal
title('Demodulated Signal');
ylabel('Amplitude');
xlabel('Time index');

Result:

Conclusion:

Frequency Modulation
Aim:
Code:
fm = input('Message signal frequency : ');
fc = input('carrier signal frequency : ');
Am = input('Message signal amplitude : ');
Ac = input(' carrier signal amplitude : ');
t = [0:0.00001:0.05];
message = Am.*sin(2*pi*fm.*t);
carrier = Ac.*cos(2*pi*fc.*t);
FM = Ac.*cos(2*pi.*fc.*t + Am.* sin(2*pi.*fm.*t));
figure;
subplot(3,1,1);
gridon;
plot(t,message);
title('Message Signal');
xlabel('time ');
ylabel('Amplitude ');
subplot(3,1,2);
plot(t,carrier);
title('Carrier Signal');
xlabel('time ');
ylabel('Amplitude');
subplot(3,1,3);
plot(t,FM);
title('Frequency Modulated Signal');
xlabel('time ');
ylabel('Amplitude ');

Result:

Conclusion: