90 likes | 264 Views
Fourier Analysis. % Figure 8-5 p. 204 Power Electronics Text-book % created 11 Sept 2007 % h.pota@adfa.edu.au % f1=1000; %control voltage frequency fs=15000; %trigger voltage frequency Vd=300; %Input DC Voltage Vcp=0.8; % control voltage peak Vtp=1; % trigger voltage peak ma=Vcp/Vtp;
E N D
% Figure 8-5 p. 204 Power Electronics Text-book % created 11 Sept 2007 % h.pota@adfa.edu.au % f1=1000; %control voltage frequency fs=15000; %trigger voltage frequency Vd=300; %Input DC Voltage Vcp=0.8; % control voltage peak Vtp=1; % trigger voltage peak ma=Vcp/Vtp; imf=f1/fs; %inverse of mf mf=1/imf; % Obtaining the switching instants theta1=[]; theta2=[]; theta=[]; for n = 0:((fs/f1)+1)/2-1, x1=fzero(@(x1)Vcp*sin(imf*(2*pi*n+x1))-Vtp*(2/pi)*x1,0); theta1=[theta1, imf*(2*pi*n+x1)]; theta=[theta, imf*(2*pi*n+x1)]; x2=fzero(@(x2)Vcp*sin(imf*(2*pi*n+pi/2+x2))-(Vtp - Vtp*(2/pi)*x2),0); theta2=[theta2, imf*(2*pi*n+pi/2+x2)]; theta = [theta, imf*(2*pi*n+pi/2+x2)]; end; % Obtaining Fourier co-efficients numofhar=3*mf+5; B=zeros(1,numofhar); for n=1:numofhar, for m=1:length(theta)-1 B(n) = B(n) + quadl(@(x)(-1)^m*(Vd/2)*sin(n*x),theta(m),theta(m+1)); end; B(n) = 2*B(n)/pi; end;
% Obtaining Fourier co-efficients numofhar=3*mf+5; B=zeros(1,numofhar); for n=1:numofhar, for m=1:length(theta)-1 B(n) = B(n) + quadl(@(x)(-1)^m*(Vd/2)*sin(n*x),theta(m),theta(m+1)); end; B(n) = 2*B(n)/pi; end;
% Plotting part figure(1); subplot(211); hold off %xtrig=[0, imf*pi/2:imf*pi:2*pi-imf*pi/2,2*pi]; %0 to 2*pi xtrig=[0, imf*pi/2:imf*pi:pi-imf*pi/2,pi]; %0 to pi ytrig=[0]; for n = 1:length(xtrig)-2, ytrig=[ytrig,Vtp*(-1)^(n+1)]; %trigger waveform end; ytrig=[0]; for n = 1:length(xtrig)-2, ytrig=[ytrig,Vtp*(-1)^(n+1)]; %saw-tooth trigger waveform end; ytrig=[ytrig,0]; plot(xtrig,ytrig,'g'); title('PWM (Half-Cycle)'); grid on; ylabel('V_{control}, V_{trigger}'); xlabel('angle (rad/s)'); axis([0 pi -1.5 1.5]) hold on; plot(xtrig,Vcp*sin(xtrig),'r'); %control waveform
%figure(2); subplot(212); %hold off; xt=[];yt=[]; eps=pi/(mf*3000); for n = 1:length(theta), xt = [xt, theta(n), theta(n)+eps]; %eps is to shift the point just a tiny bit yt = [yt, (-1)^(n+1), (-1)^(n+2)]; %alternate minus and plus for the square wave end; yt=(Vd/2)*yt; plot(xt,yt,'r'); grid on; xlabel('angle (rad/s)'); ylabel('V_{out}, V_{01}'); axis([0 pi -0.75*Vd 0.75*Vd]) hold on; xs=[0:0.001*pi:pi]; ys1=B(1)*sin(xs); ys=B(1)*sin(2*xs); %plot(xs,ys,'g',xs,ys1,'b'); plot(xs,ys1,'b'); hold off; figure(2); stem(abs(B)/(Vd/2)); grid on; title(['m_a = ',num2str(ma),', m_f = ',num2str(mf)]); ylabel('B_n'); xlabel('n');