SPEED CONTROL OF DC MOTOR USING PID

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

hello
can you share your code ? a picture is not very helpful to correct bugs
tx
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')
Can any one share me full model of simulink please

Sign in to comment.

 Accepted Answer

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

Thank you for the answer, but your program would be correct if we assumed that the outdoor couple of the motor (Td) is equal to 0. Otherwise, according to the block diagram that i attached on this message, we would have: input= v(s)+Td*(Ls+R)/K (just leading upstream the input of the outdoor couple). So i think that the pump load block have to be considered in our case. Hope this time, the problem is more comprehensible.
hello again
ok, so we have to understand how Td is applied or function of omega is we want to do a step response that includes Td effect; if Td is just left as an unknown perturbation, I don't see how Td could be taken into the step response of the system ?
also usually a system can be characterised by its response to a command signal (here the input of the PID) and / or its capability to reject perturbations (like Td); so you can tune your PID considering either the perturbation is 0 and you command the input of the system, or vice - versa you see how fast the system will recover from a pertubation (static, impulse, or steps or what you want) but usually the commanded input remains unchanged
all the best
Td=-0,5 (i found it with the other parameters of dc motor in a thesis). Now I wonder if it is possible to simulate both the step input and the perturbation Td in a single simulation and how could I do that? Because the code that I have sent you at the beggining, gave me unreliable results Thanks for the support.
as I said above , there is no benefit here to put Td = 0 or any other value as this has no effect on the open and closed loop dynamics; you don't need this to tune the PID
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
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)

Products

Tags

Community Treasure Hunt

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

Start Hunting!