0% found this document useful (0 votes)
11 views12 pages

Cematlab

Uploaded by

160622735083
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views12 pages

Cematlab

Uploaded by

160622735083
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

PULSE AMPLITUDE MODULATION AND DEMODULATION

Aim:
To study the pulse amplitude modulation and demodulation.

Hardware and software requirements:


Personal computer (PC)
MATLAB Software R2013a

Program:
clc; clear all; close all;
fc = 100; % Carrier frequency
fm = fc/10; % Modulating frequency
fs = 100*fc; % Sampling frequency
t = 0:1/fs:4/fm; % Time array

% Message signal
mt = cos(2*pi*fm*t);

% Carrier signal
ct = 0.5*square(2*pi*fc*t)+0.5;

% Modulated signal
st = mt.*ct;

% Single-sided PAM
tt = zeros(size(st));
for i = 1:length(st)
if st(i) < 0
tt(i) = 0;
else
tt(i) = st(i) + 2;
end
end

% Plotting
figure(1);
subplot(4,1,1);
plot(t, mt);
title('Message Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(4,1,2);
plot(t, ct);
title('Carrier Signal');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(4,1,3);
plot(t, tt);
title('Pulse Amplitude Modulated Signal');
xlabel('Time (s)');
ylabel('Amplitude');

% Demodulation
dt = st.*ct;
dt_frequency = fftshift(abs(fft(dt)));
filter = fir1(200, fm/fs, 'low');
original_t_signal = conv(filter, dt);
t1 = 0:1/(length(original_t_signal)-1):1;

subplot(4,1,4);
plot(t1, original_t_signal);
title('Demodulated Signal');
xlabel('Time (s)');
ylabel('Amplitude');
Result:
Pulse amplitude modulation (PAM) and demodulation is studied.
PULSE WIDTH MODULATION AND DEMODULATION

Aim:
To study the pulse width modulation and demodulation.

Hardware and software requirements:


Personal computer (PC)
MATLAB Software R2013a

Program:
clear all; clc; close all;
t = 0:0.001:1;
fc = 10;
fm = 1;
a = 5;
b = 4;

vc = a.*sawtooth(2*pi*fc*t);
vm = b.*sin(2*pi*fm*t);
n = length(vc);
pwm1 = zeros(n,1);

for i = 1:n
if (vm(i)>=vc(i))
pwm1(i) = 1;
else
pwm1(i) = 0;
end
end

figure;
subplot(3,1,1);
plot(t,vm);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Message Signal');
grid on;

subplot(3,1,2);
plot(t,vc);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Carrier Signal');
grid on;

subplot(3,1,3);
stairs(t,pwm1); % Use stairs instead of plot
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('PWM Signal');
axis([0 1 0 2]);
grid on;
Model waveforms:

Result:
Pulse width modulation (PWM) and demodulation is studied.
AMPLITUDE SHIFT KEYING (ASK) GENERATION AND DETECTION
Aim:
To study the Modulation and demodulation techniques of Amplitude Shift Keying (ASK).
Hardware and software requirements:
Personal computer (PC)
MATLAB Software R2013a

Program:
clc; clear all; close all;

% Carrier signal initialization


f = 7;
a = 1;
t = 0:0.01:6;
y1 = a*sin(2*pi*f*t);

% 6 bits are used.


% THE BIT SEQUENCE IS 1,0,1,1,0,0 ==> 6 BITS.
n = [1 0 1 1 0 0];
l = length(n);
if n(l) == 1
n(l+1) = 1;
else
n(l+1) = 0;
end
l1 = length(n);
tn = 0:l1-1;

% Plot message signal


subplot(4,1,1);
stairs(tn,n);
title('Message Signal');
xlabel('Time');
ylabel('Amplitude');

% Plot carrier signal


subplot(4,1,2);
plot(t,y1);
title('Carrier Signal');
xlabel('Time');
ylabel('Amplitude');

% Modulation process
s = zeros(size(t));
for i = 1:6
for j = (i-1)*100+1:i*100
if(n(i) == 1)
s(j) = y1(j);
else
s(j) = 0;
end
end
end

% Plot ASK signal


subplot(4,1,3);
plot(t,s);
title('ASK Modulated Signal');
xlabel('Time');
ylabel('Amplitude');

% Demodulation process
x = zeros(size(t));
for i = 1:6
for j = (i-1)*100+1:i*100
if(s(j) == y1(j))
x(j) = 1;
else
x(j) = 0;
end
end
end

% Plot demodulated signal


subplot(4,1,4);
stairs(t,x);
title('ASK Demodulated Signal');
xlabel('Time');
ylabel('Amplitude');
Model Waveforms:

Result:
Amplitude shift keying is studied.
FREQUENCY SHIFT KEYING (FSK) GENERATION AND DETECTION
Aim:
To study the Modulation and demodulation techniques of Frequency Shift Keying (FSK).
Hardware and software requirements:
Personal computer (PC)
MATLAB Software R2013a

Program:
clear all; clc; close all;

% Initialization of carrier signals


f1 = 8;
f2 = 2;
a = 1;

% Plot carrier signal


t = 0:0.01:6;
y1 = a*sin(2*pi*f1*t);
y2 = a*sin(2*pi*f2*t);

subplot(5,1,1);
plot(t,y1);
title('Carrier Signal 1');
xlabel('Time');
ylabel('Amplitude');

subplot(5,1,2);
plot(t,y2);
title('Carrier Signal 2');
xlabel('Time');
ylabel('Amplitude');

% 6 bits are used.


% THE BIT SEQUENCE IS 1,0,1,1,0,0 ==> 6 BITS.
n = [1 0 1 1 0 0];
l = length(n);

if n(l) == 1
n(l+1) = 1;
else
n(l+1) = 0;
end

l1 = length(n);
tn = 0:l1-1;

% Plot message signal


subplot(5,1,3);
stairs(tn,n);
title('Message Signal');
xlabel('Time');
ylabel('Amplitude');

% Modulation process
s = zeros(size(t));
for i = 1:6
for j = (i-1)*100+1:i*100
if(n(i) == 1)
s(j) = y1(j);
else
s(j) = y2(j);
end
end
end

% Plot FSK signal


subplot(5,1,4);
plot(t,s);
title('FSK Modulated Signal');
xlabel('Time');
ylabel('Amplitude');

% Demodulation process
x = zeros(size(t));
for i = 1:6
for j = (i-1)*100+1:i*100
if(abs(s(j) - y1(j)) < abs(s(j) - y2(j)))
x(j) = 1;
else
x(j) = 0;
end
end
end

% Plot demodulated signal


subplot(5,1,5);
stairs(t,x);
title('FSK Demodulated Signal');
xlabel('Time');
ylabel('Amplitude');

Result:
The Modulation and demodulation techniques of Frequency Shift Keying (FSK) are studied.

You might also like