SPEED CONTROL OF DC MOTOR USING PID

114 views (last 30 days)
Hi,I'm trying to simulate the Speed control of a DC motor using a Pid controller.The transfer function of this motor is: K/(Ls+R)(Js+b)+K^2while the input is:v(s)+Td*(Ls+R)/K, v(s) is a unit step and i have no difficulty to simulate the step responce, but when i put Td different from 0, my simulation doesn't work properly.What is the problem of this code?
  3 Comments
Giuseppe D'Auria
Giuseppe D'Auria on 21 Jun 2021
Edited: Giuseppe D'Auria on 21 Jun 2021
J = 0.01; b = 0.1; K = 0.01; R = 1; L = 0.5; Td = -0.5; s=tf('s'); numz1=[L,R]; denz1=(K); z=tf(numz1,denz1); f=Td*z; Kp=1000; Ki=0; Kd=0; C=pid(Kp,Ki,Kd); numin1=[f,1]; denin2=[1]; in=tf(numin1,denin2); P_motor=K/((J*s+b)*(L*s+R)+K^2); sys_c1=feedback(C*P_motor,1); sys2=in_sys_c1; t=0:0.01:5; step(sys2,t) grid title('Step Response with Proportional Control')
Abid Hasan
Abid Hasan on 13 Nov 2022
Can any one share me full model of simulink please

Sign in to comment.

Accepted Answer

Mathieu NOE
Mathieu NOE on 22 Jun 2021
hello Giuseppe
I don't understand why you say : the input is:v(s)+Td*(Ls+R/K),
where does that comes from ??
I double checked quickly , according to this block diagram (just remove the pump load block that does not apply in your case)
for me the transfer function omega vs input voltage is only omega / Va = K/(Ls+R)(Js+b)+K^2 - so this portion I agree with you , but now we simply close the loop by taking omega as our measured value and the PID output becomes our controlled voltage Va
the input of the PID is a step input - also this is clear
so for me there are some parts of your code that are unnecessary (just a bit confusing) and you can see it works fine with Kp = 1000 and Kd = 100;
hope it helps
clc;
clearvars
J = 0.01;
b = 0.1;
K = 0.01;
R = 1;
L = 0.5;
% Td = -0.5;
s=tf('s');
% numz1=[L,R];
% denz1=(K);
% z=tf(numz1,denz1);
% f=Td*z;
Kp=1000;
Ki=0;
Kd=100;
C=pid(Kp,Ki,Kd);
% numin1=[f,1];
% denin2=[1];
% in=tf(numin1,denin2);
P_motor=K/((J*s+b)*(L*s+R)+K^2);
sys_c1=feedback(C*P_motor,1);
t=0:0.0025:1;
step(sys_c1,t); grid;
title('Step Response with Proportional Control')
  6 Comments
Giuseppe D'Auria
Giuseppe D'Auria on 22 Jun 2021
I see, in fact at first i simulate the program with Td=0, but this program must be entered in a school thesis and my teacher would prefer me to do a simulation with a value of Td different from 0
Mathieu NOE
Mathieu NOE on 23 Jun 2021
If I would be you, I'd rather now switch to Simulink , this would allow more flexibility to generate the different scenario. keep the xisting matlab code as a first tool to refine the PID, then you can do whatever you want on the two inputs in your simulink model. You can also call the simulation of the simulink model from a matlab script (use sim).
all the best

Sign in to comment.

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!