You are on page 1of 1

2/11/19 5:42 PM C:\Users\SUHEL\Docum...\drive_assignm1.

m 1 of 1

% Solving Dc motor Equations by Runga Kutta's 4th Order Method


% MOHAMMAD SUHEL KHAN 18104059
clc
clear all
If=2;Ra=0.4;La=0.01;Md=1;J=12;B=0;P=4;TL=0;Va=230;
Ia=0;
Wr=0;
h=0.0001 % Time step
Idot= (Va-Ia*Ra-Wr*Md*If)/La;
Wdot = P/(2*J)*((P/2)*Md*Ia*If-(2/P)*B*Wr-TL);
for k=1:1:3/h
ki1=h*(Va-(Ia)*Ra-(Wr)*Md*If)/La;
ki2=h*(Va-(Ia+ki1/2)*Ra-(Wr+h/2)*Md*If)/La;
ki3=h*(Va-(Ia+ki2/2)*Ra-(Wr+h/2)*Md*If)/La;
ki4=h*(Va-(Ia+ki3)*Ra-(Wr+h)*Md*If)/La;
Ia=Ia+(ki1+2*(ki2+ki3)+ki4)/6; % Armature after end of
iteration
kw1=h*(P/(2*J))*(P/2*Md*(Ia)*If-(2/P)*B*((Wr)-TL));
kw2=h*(P/(2*J))*(P/2*Md*(Ia+kw1/2)*If-(2/P)*B*((Wr+h/2)-TL));
kw3=h*(P/(2*J))*(P/2*Md*(Ia+kw2/2)*If-(2/P)*B*((Wr+h/2)-TL));
kw4=h*(P/(2*J))*(P/2*Md*(Ia+kw3)*If-(2/P)*B*((Wr+h)-TL));
Wr=Wr+(kw1+2*(kw2+kw3)+kw4)/6; % Speed after end of iteration
i(k)=Ia;
w(k)=Wr;
end
i=[0,i];
w=[0,w];
Te=(P/2)*Md*(i)*If; % calculating torque
t=0:0.0001:3;
subplot(311),plot(t,i,'r','linewidth',2); % Ploting armature current
ylabel('Armature current(amps)')
xlabel('time(seconds)')
title('Armature current vs time')
grid on
subplot(312),plot(t,w,'g','linewidth',2); % Ploting speed current
ylabel('speed(rd/sec)')
xlabel('time(seconds)')
title('Speed rd/s vs time')
grid on
subplot(313),plot(t,Te,'b','linewidth',2);
ylabel('Motor torque(N-M)') % Ploting motor torque current
xlabel('time(seconds)')
title('Motor torque Vs time')
grid on

You might also like