Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pulse position modulation code in matlab
#1

pulse position modulation code in matlab

PWM (Pulse Width Modulation) can be easily generated in MATLAB using simple MATLAB functions. We have already discussed about PWM generator circuit using 741 Op-amp in previous posts. In PWM, width of the pulses are varied according to the amplitude of AF message signal. PWM is basically an analog pulse modulation technique. It does modulation of the duty cycle of the pulse.In addition to its use in communication systems, PWM is also used in voltage regulators such as Switched Mode Power Supplies (SMPS) to control the power delivered to the load. PWM can be generated using a comparator to which the modulating signal and a reference ramp (sawtooth) waveform are fed.The code for PWM simulation in MATLAB is shown below. The use of particular line of MATLAB code is also given as comments (%Comment field). The given MATLAB program accepts two input frequencies from the user.

PWM MATLAB Codes

[cc lang= Matlab ]clc;
clear all;
close all;
F2=input( Message frequency= );
F1=input( Carrier Sawtooth frequency= );
A=5;
t=0:0.001:1;
c=A.*sawtooth(2*pi*F1*t);%Carrier sawtooth
subplot(3,1,1);
plot(t,c);
xlabel( time );
ylabel( Amplitude );
title( Carrier sawtooth wave );
grid on;
m=0.75*A.*sin(2*pi*F2*t);%Message amplitude must be less than Sawtooth
subplot(3,1,2);
plot(t,m);
xlabel( Time );
ylabel( Amplitude );
title( Message Signal );
grid on;
n=length©;%Length of carrier sawtooth is stored to n
for i=1:n%Comparing Message and Sawtooth amplitudes
if (m(i)>=c(i))
pwm(i)=1;
else
pwm(i)=0;
end
end
subplot(3,1,3);
plot(t,pwm);
xlabel( Time );
ylabel( Amplitude );
title( plot of PWM );
axis([0 1 0 2]);%X-Axis varies from 0 to 1 & Y-Axis from 0 to 2
grid on;[/cc]
Reply

#2
????? where??????????????????????????????????????????????????????????????????????????????????????????????????
Reply

#3
please may i get the source code for Pulse position modulation in matlab
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.