Professional Documents
Culture Documents
PID Controller by Matlab
PID Controller by Matlab
PID Controller by Matlab
MATLAB
Automatic Control Course By :
Mahmoud Taha; Demonstrator.
Benha Faculty of Engineering
Benha University
April., 2015
1
Outlines:
Effect of Adding PID contr oller to Ar matur e Contr olled DC motor & Repr esent
it in MATLAB Simulink using 3 methods to model DC motor
Repr esent Diff Equation using Integr ator
Using Tr ansfer Function Consept
Using State Space Repr esentation Method
Refer ences
Gc(s)
G(s)
Closed
Loop
Response
Kp
Rise
time
Decrease
Increase
Small change
Steady
state
error
Decrease
Ki
Decrease
Increase
Increase
Eliminate
Kd
Small
change
Decrease
Decrease
No
change
M * x + b * x + K * x =
F
where X ..... output and F..... Input
6
X (s )
1
=
F (s ) M * s 2 + b * s + K
Let M= 1 kg & b = 10 N.s/m & K= 20 N/m and F= 1 N
1
G (s ) = 2
s + 10s + 20
7
10
When you are designing a PID controller for a given system, follow
the steps shown below to obtain a desired response.
Obtain an open-loop response and determine what needs to be
improved
Add a proportional control to improve the rise time
Add a derivative control to improve the overshoot
Add an integral control to eliminate the steady-state error
Adjust each of Kp, Ki, and Kd until you obtain a desired overall response.
You can always refer to the table shown in this "PID Tutorial" page to
find out which controller controls what characteristics.
11
Lastly, please keep in mind that you do not need to implement all
three controllers (proportional, derivative, and integral) into a single
system, if not necessary. For example, if a PI controller gives a good
enough response (like the above example), then you don't need to
implement a derivative controller on the system. Keep the controller
as simple as possible.
12
MATLAB provides tools for automatically choosing optimal PID gains which
makes the trial and error process described above unnecessary. You can
access the tuning algorithm directly using pidtool command to open PID
(GUI).
pidtool(SYS,TYPE) designs a PID controller for plant SYS. SYS is a single-inputsingle-output LTI system
TYPE defines controller type, and can be one of the following strings:
'P'
Proportional only control
'I'
Integral only control
'PI'
PI control
'PD' PD control
'PDF' PD control with first order derivative filter
'PID' PID control
'PIDF' PID control with first order derivative filter
13
14
15
dia
V a =ia * Ra + La *
+ Kb *w
dt
Mechanical Equation:
dw
Kt * ia T=
J*
+ B *w
L
dt
TL
Block Diagram :
+
Va
1
Ra + La * s
ia
Kt
Te
w
1
J *s + B
Kb
16
17
&
dw Kt * ia T L B
=
*w
dt
J
J J
18
&
dw Kt * ia T L B
=
*w
dt
J
J J
19
Where Closed Loop System shown and we make subsystem and mask to DC
motor Model
20
21
22
23
Va
1/ La
s + Ra / La
ia
Kt
Te
1/ J
s +B /J
Kb
24
K t / La J
w (s )
=
V a (s ) (s + R a / La )(s + B / J ) + K b K t / La J
2
= 2
s + 12s + 20.02
25
26
27
=
x Ax + Bu
=
y Cx + Du
From the Diff Equation :
dia V a Ra
Kb
=
* ia
*w
dt
La La
La
Ia = 2*V a 2* ia 0.02*w
28
&
dw Kt * ia T L B
=
*w
dt
J
J J
w =
ia 100T L 10*w
0 V a
Ia 2 0.02 Ia 2
+
T
10 w 0 100 L
w 1
29
V a
ia
( 01) w + ( 0 0 ) T
L
30
31
32
References
http://en.wikipedia.org/wiki/PID_controller#/media/File:PID_en_updated_feedbac
k.svg
http://www.mathworks.com/help/control/examples/dc-motor-control.html
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=Con
trolPID
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=Sim
ulinkModeling
http://ctms.engin.umich.edu/CTMS/index.php?example=AircraftPitch§ion=Sim
ulinkModeling