Hi, Please how can I build a PPM modulator in simulink. The block is not available in my matlab. i am using 2008b

댓글 수: 5

Fangjun Jiang
Fangjun Jiang 2011년 12월 19일
What is PPM?
Walter Roberson
Walter Roberson 2011년 12월 19일
Pulse Position Modulation
ska109
ska109 2016년 2월 13일
I've made it working somehow...
Yashwanth
Yashwanth 대략 10시간 전
ppm full code
clc;
clear all;
close all;
% Binary PPM
fs = 100;
dt = 1/fs;
t1 = 0:dt:1-dt;
t2 = 1:dt:2-dt;
t = [t1 t2];
% PPM signals
s1 = [ones(1,length(t1)), zeros(1,length(t2))];
s2 = [zeros(1,length(t1)), ones(1,length(t2))];
% Plot transmitted signals
figure;
subplot(2,1,1);
plot(t,s1);
title('PPM Signal 1');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(2,1,2);
plot(t,s2);
title('PPM Signal 0');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
% Energy and first basis function
e1 = sum(s1.^2)*dt;
psi1 = s1/sqrt(e1);
% Second basis function using orthogonalization
s21 = sum(s2.*psi1)*dt;
d2 = s2-s21*psi1;
ed2 = sum(d2.^2)*dt;
psi2 = d2/sqrt(ed2);
% Plot basis functions
figure;
subplot(2,1,1);
plot(t,psi1);
title('Basis Function 1');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(2,1,2);
plot(t,psi2);
title('Basis Function 2');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
% Signal-space coordinates
s_11 = sum(s1.*psi1)*dt;
s_21 = sum(s2.*psi1)*dt;
s_12 = sum(s1.*psi2)*dt;
s_22 = sum(s2.*psi2)*dt;
figure;
stem([s_11 s_21],[s_12 s_22],'filled');
title('PPM Signal Space Representation');
xlabel('Coordinate 1');
ylabel('Coordinate 2');
grid on;
% AWGN with variances 0, 0.1, 1 and 2
n1 = sqrt(0)*randn(size(s1));
n2 = sqrt(0.1)*randn(size(s1));
n3 = sqrt(1)*randn(size(s1));
n4 = sqrt(2)*randn(size(s1));
% Received signals
r1 = s1+n1;
r2 = s1+n2;
r3 = s1+n3;
r4 = s1+n4;
r5 = s2+n1;
r6 = s2+n2;
r7 = s2+n3;
r8 = s2+n4;
% Plot received signals
figure;
subplot(4,2,1);
plot(t,r1);
title('Signal 1: Variance 0');
grid on;
subplot(4,2,2);
plot(t,r5);
title('Signal 0: Variance 0');
grid on;
subplot(4,2,3);
plot(t,r2);
title('Signal 1: Variance 0.1');
grid on;
subplot(4,2,4);
plot(t,r6);
title('Signal 0: Variance 0.1');
grid on;
subplot(4,2,5);
plot(t,r3);
title('Signal 1: Variance 1');
grid on;
subplot(4,2,6);
plot(t,r7);
title('Signal 0: Variance 1');
grid on;
subplot(4,2,7);
plot(t,r4);
title('Signal 1: Variance 2');
grid on;
subplot(4,2,8);
plot(t,r8);
title('Signal 0: Variance 2');
grid on;
% Correlation receiver
R = [r1; r2; r3; r4; r5; r6; r7; r8];
X = zeros(8,2);
for i = 1:8
X(i,1) = sum(R(i,:).*psi1)*dt;
X(i,2) = sum(R(i,:).*psi2)*dt;
end
% Plot signal-space coordinates for each variance
figure;
subplot(2,2,1);
stem(X([1 5],1),X([1 5],2),'filled');
title('Signal Space: Variance 0');
grid on;
subplot(2,2,2);
stem(X([2 6],1),X([2 6],2),'filled');
title('Signal Space: Variance 0.1');
grid on;
subplot(2,2,3);
stem(X([3 7],1),X([3 7],2),'filled');
title('Signal Space: Variance 1');
grid on;
subplot(2,2,4);
stem(X([4 8],1),X([4 8],2),'filled');
title('Signal Space: Variance 2');
grid on;
% Matched-filter impulse responses
h1 = fliplr(psi1);
h2 = fliplr(psi2);
% Matched-filter outputs for both basis functions
Y1 = zeros(8, length(t)+length(h1)-1);
Y2 = zeros(8, length(t)+length(h2)-1);
for i = 1:8
Y1(i,:) = conv(R(i,:),h1)*dt;
Y2(i,:) = conv(R(i,:),h2)*dt;
end
ty = 0:dt:2*(length(t)-1)*dt;
% Plot the matched-filter outputs
figure;
subplot(2,2,1);
plot(ty,Y1(1,:));
hold on;
plot(ty,Y1(5,:));
title('Matched Filter: Variance 0');
xlabel('Time (s)');
ylabel('Output');
legend('Signal 1','Signal 0');
grid on;
subplot(2,2,2);
plot(ty,Y1(2,:));
hold on;
plot(ty,Y1(6,:));
title('Matched Filter: Variance 0.1');
xlabel('Time (s)');
ylabel('Output');
legend('Signal 1','Signal 0');
grid on;
subplot(2,2,3);
plot(ty,Y1(3,:));
hold on;
plot(ty,Y1(7,:));
title('Matched Filter: Variance 1');
xlabel('Time (s)');
ylabel('Output');
legend('Signal 1','Signal 0');
grid on;
subplot(2,2,4);
plot(ty,Y1(4,:));
hold on;
plot(ty,Y1(8,:));
title('Matched Filter: Variance 2');
xlabel('Time (s)');
ylabel('Output');
legend('Signal 1','Signal 0');
grid on;
% Display correlation coordinates
disp('Rows: r1 through r8');
disp('Columns: basis function 1 and basis function 2');
disp(X);
Yashwanth
Yashwanth 대략 10시간 전
PAM
clc;
clear all;
close all;
% BINARY PAM MODULATION AND DEMODULATION
fs = 100;
dt = 1/fs;
t = 0:dt:1;
% Binary PAM signals
s1 = ones(1,length(t));
s2 = -1*ones(1,length(t));
% Plotting signals
figure;
subplot(2,1,1);
plot(t,s1);
title('Signal 1');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(2,1,2);
plot(t,s2);
title('Signal 0');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
% Energy and basis function
e1 = sum(s1.*s1)*dt;
psi1 = s1/sqrt(e1);
figure;
subplot(2,1,1);
plot(t,psi1);
title('Basis Function 1');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
% Signal space representation
s_11 = sum(s1.*psi1)*dt;
s_21 = sum(s2.*psi1)*dt;
subplot(2,1,2);
stem([s_11 s_21],[0 0],'filled');
title('Signal Space Representation');
xlabel('Signal Coordinate');
ylabel('Amplitude');
grid on;
% AWGN with different variances
n1 = sqrt(0)*randn(size(s1));
n2 = sqrt(0.1)*randn(size(s1));
n3 = sqrt(1)*randn(size(s1));
n4 = sqrt(2)*randn(size(s1));
% Received signals
r1 = s1+n1;
r2 = s1+n2;
r3 = s1+n3;
r4 = s1+n4;
r5 = s2+n1;
r6 = s2+n2;
r7 = s2+n3;
r8 = s2+n4;
% Plot received signals
figure;
subplot(4,2,1);
plot(t,r1);
title('Signal 1: Noise Variance 0');
grid on;
subplot(4,2,2);
plot(t,r5);
title('Signal 0: Noise Variance 0');
grid on;
subplot(4,2,3);
plot(t,r2);
title('Signal 1: Noise Variance 0.1');
grid on;
subplot(4,2,4);
plot(t,r6);
title('Signal 0: Noise Variance 0.1');
grid on;
subplot(4,2,5);
plot(t,r3);
title('Signal 1: Noise Variance 1');
grid on;
subplot(4,2,6);
plot(t,r7);
title('Signal 0: Noise Variance 1');
grid on;
subplot(4,2,7);
plot(t,r4);
title('Signal 1: Noise Variance 2');
grid on;
subplot(4,2,8);
plot(t,r8);
title('Signal 0: Noise Variance 2');
grid on;
% CORRELATION RECEIVER
x1 = sum(r1.*psi1)*dt;
x2 = sum(r2.*psi1)*dt;
x3 = sum(r3.*psi1)*dt;
x4 = sum(r4.*psi1)*dt;
x5 = sum(r5.*psi1)*dt;
x6 = sum(r6.*psi1)*dt;
x7 = sum(r7.*psi1)*dt;
x8 = sum(r8.*psi1)*dt;
% Correlator output plots
figure;
subplot(2,2,1);
stem([x1 x5],[0 0],'filled');
title('Correlation: Variance 0');
grid on;
subplot(2,2,2);
stem([x2 x6],[0 0],'filled');
title('Correlation: Variance 0.1');
grid on;
subplot(2,2,3);
stem([x3 x7],[0 0],'filled');
title('Correlation: Variance 1');
grid on;
subplot(2,2,4);
stem([x4 x8],[0 0],'filled');
title('Correlation: Variance 2');
grid on;
% MATCHED FILTER
h = fliplr(psi1);
figure;
plot(t,h);
title('Matched Filter Impulse Response');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
% Convolution outputs
y1 = conv(r1,h)*dt;
y2 = conv(r2,h)*dt;
y3 = conv(r3,h)*dt;
y4 = conv(r4,h)*dt;
y5 = conv(r5,h)*dt;
y6 = conv(r6,h)*dt;
y7 = conv(r7,h)*dt;
y8 = conv(r8,h)*dt;
% Convolution time axis
ty = 0:dt:2;
% Plot matched filter outputs
figure;
subplot(2,2,1);
plot(ty,y1);
hold on;
plot(ty,y5);
title('Matched Filter: Variance 0');
legend('Signal 1','Signal 0');
xlabel('Time (s)');
ylabel('Output');
grid on;
subplot(2,2,2);
plot(ty,y2);
hold on;
plot(ty,y6);
title('Matched Filter: Variance 0.1');
legend('Signal 1','Signal 0');
xlabel('Time (s)');
ylabel('Output');
grid on;
subplot(2,2,3);
plot(ty,y3);
hold on;
plot(ty,y7);
title('Matched Filter: Variance 1');
legend('Signal 1','Signal 0');
xlabel('Time (s)');
ylabel('Output');
grid on;
subplot(2,2,4);
plot(ty,y4);
hold on;
plot(ty,y8);
title('Matched Filter: Variance 2');
legend('Signal 1','Signal 0');
xlabel('Time (s)');
ylabel('Output');
grid on;
% Demodulation decision using correlator outputs
corr_out = [x1 x2 x3 x4; x5 x6 x7 x8];
disp('Correlation outputs:');
disp(corr_out);
disp('Decision: positive = Signal 1, negative = Signal 0');
disp(sign(corr_out));

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2011년 12월 19일

0 개 추천

Note that is part of the Signal Processing Toolbox.
The Technical Support note that is relevant, here says that
PPM and PWM are described in “Digital and Analog Communication Systems, 5th Ed.” by Leon Couch. Pages 209-213 describe these modulations, and show circuits that are used for the modulation.

추가 답변 (3개)

dave
dave 2011년 12월 19일

0 개 추천

Thank you. I will look through it.
sivasena reddy
sivasena reddy 2019년 5월 8일

0 개 추천

clc;
close all;
clear all;
t=0:0.001:1;
s=sawtooth(2*pi*10*t+pi);
m=0.75*sin(2*pi*1*t);
n=length(s);
for i=1:n
if (m(i)>=s(i))
pwm(i)=1;
elseif (m(i)<=s(i))
pwm(i)=0;
end
end
plot(t,pwm,'g',t,m,'r',t,s,'--b');
ylabel('Amplitude');
axis([0 1 -1.5 1.5]);
xlabel('Time index');
title('PWM Wave');
grid on;

댓글 수: 1

Walter Roberson
Walter Roberson 2019년 5월 8일
The user had requested Simulink implementation, though.
Also, you appear to be doing PWM (Pulse Width Modification) rather than PPM (Pulse Position Modification)

댓글을 달려면 로그인하십시오.

Atul Kumar
Atul Kumar 2021년 3월 21일

0 개 추천

clc;
close all;
clear all;
t=0:0.001:1;
s=sawtooth(2*pi*10*t+pi);
m=0.75*sin(2*pi*1*t);
n=length(s);
for i=1:n
if (m(i)>=s(i))
pwm(i)=1;
elseif (m(i)<=s(i))
pwm(i)=0;
end
end
plot(t,pwm,'g',t,m,'r',t,s,'--b');
ylabel('Amplitude');
axis([0 1 -1.5 1.5]);
xlabel('Time index');
title('PWM Wave');
grid on;

카테고리

도움말 센터 및 File Exchange에서 Applications에 대해 자세히 알아보기

질문:

2011년 12월 18일

댓글:

대략 10시간 전

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by