PID Controller By Matlab

Post on 21-Dec-2015

85 views 14 download

Tags:

description

Discuss PID Controller by using Matlab M-files and Simulink

Transcript of PID Controller By Matlab

PID Controller By MATLAB

Automatic Control Course By :Mahmoud Taha; Demonstrator.

Benha Faculty of EngineeringBenha University

April., 20151

Outlines:• PID Controller Overview

• The Character istics of P, I, and D Controllers

• Effect of Add P,PD,PI,PID controller to Mechanical system

Represent it in MATLAB M_Files

• Effect of Adding PID controller to Armature Controlled DC motor & Represent

it in MATLAB Simulink using 3 methods to model DC motor

Represent Diff Equation using Integrator

Using Transfer Function Consept

Using State Space Representation Method

• References

We will discuss the effect of each of the PID parameters on the

closed-loop dynamics and demonstrate how to use a PID

controller to improve the system performance.

Instructor ENG / M.TAHA1

The output of a PID controller, equal to the control input to the

plant, in the time-domain is as follows:

( ) * ( ) * ( ) * deGc t Kp e t Ki e t dt Kddt

= + +∫

Gc(s) G(s)

Instructor ENG / M.TAHA2

• A proportional controller (Kp) will have the effect of reducing the rise time and will reduce but never eliminate the steady-state error.

• An integral control (Ki/s) will have the effect of eliminating the steady-state error for a constant or step input, but it may make the transient response slower.

• A derivative control (Kd*s) will have the effect of increasing the stability of the system, reducing the overshoot, and improving the transient response.

Instructor ENG / M.TAHA3

• The effects of each of controller parameters, Kp, Ki, and Kd on a closed-loop system are summarized in the table below:

Steady state error

Settling timeOver shootRisetime

ClosedLoop

ResponseDecreaseSmall changeIncreaseDecreaseKp

EliminateIncreaseIncreaseDecreaseKi

Nochange

DecreaseDecreaseSmall change

Kd

Instructor ENG / M.TAHA4

• Note that these correlations may not be exactly accurate, because Kp, Ki, and Kd are dependent on each other.

• In fact, changing one of these variables can change the effect of the other two. For this reason, the table should only be used as a reference when you are determining the values for Ki, Kp and Kd.

Instructor ENG / M.TAHA5

• Suppose Mass spring with Damper mechanical systemas shown:

It's modeling equation :

where X ..... output and F..... Input

* * *M x b x K x F+ + =

Instructor ENG / M.TAHA6

• transfer function between the displacement X(s) and the input F(s) then becomes:

Let M= 1 kg & b = 10 N.s/m & K= 20 N/m and F= 1 N

2

( ) 1( ) * *

X sF s M s b s K

=+ +

2

1( )10 20

G ss s

=+ +

Instructor ENG / M.TAHA7

Instructor ENG / M.TAHA8

Instructor ENG / M.TAHA9

Instructor ENG / M.TAHA10

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.

Instructor ENG / M.TAHA11

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.

Instructor ENG / M.TAHA12

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-input-single-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

Instructor ENG / M.TAHA13

Instructor ENG / M.TAHA14

Suppose an armature controlled DC motor as Shown :where :

Motor parameterRa= 1 ohm;La= 0.5 H;J=0.01 kg.m^2;B=0.1 N.m.s;Kb=0.01 V/rad/sec;Kt=0.01 N.m/Amp;

Instructor ENG / M.TAHA15

Model of armature controlled DC motor:

Electrical Equation:

Mechanical Equation:

Block Diagram :

* * *diaVa ia Ra La Kb wdt

= + +

* * *LdwKt ia T J B wdt

− = +

Va Kt1*Ra La s+

ia

TL

1*J s B+

Kb

wTe+ +

-

-

Instructor ENG / M.TAHA16

DC motor Model can be represented by 3 methods 1st method Represent Diff equation By integrator :

&* *dia Va Ra Kbia wdt La La La

= − −* *LTdw Kt ia B w

dt J J J= − −

Instructor ENG / M.TAHA17

DC motor Model where there are 2 Diff equation:

&* *dia Va Ra Kbia w

dt La La La= − − * *LTdw Kt ia B w

dt J J J= − −

Instructor ENG / M.TAHA18

Where DC motor Model

Instructor ENG / M.TAHA19

Where Closed Loop System shown and we make subsystem and mask to DC motor Model

Instructor ENG / M.TAHA20

Where PID controller Model

Instructor ENG / M.TAHA21

Instructor ENG / M.TAHA22

Actual speed & Ref speed

Instructor ENG / M.TAHA23

Instructor ENG / M.TAHA

• We can implement Model of DC motor By an other Method By using Transfer

Function Block Directly

• At this case there are two T.F as the system Multi input single output

• There are 2 inputs Va & TL and 1 output W

So One T.F bet W and Va and another one bet W and TL

• We assume that TL=0 ….. No Load

• So we will work By one T.F

Va Kt1//

Las Ra La+

ia1/

/J

s B J+

Kb

wTe+

-

24

Instructor ENG / M.TAHA

• T.F of Armature Controlled DC Motor

(2nd order system)

/( )( ) ( / )( / ) /

t a

a a b t a

K L Jw sVa s s R L s B J K K L J

=+ + +

2

212 20.02s s

=+ +

25

Instructor ENG / M.TAHA

• Armature Controlled DC Motor

26

Instructor ENG / M.TAHA

• Armature Controlled DC Motor

27

Instructor ENG / M.TAHA

• We can implement Model of DC motor By an other Method BY state space

Representation

• At this case the system is Multi input single output

• There are 2 inputs Va & TL and 1 output W

• From the Diff Equation :

&

x Ax Buy Cx Du= += +

* *dia Va Ra Kbia wdt La La La

= − −* *LTdw Kt ia B w

dt J J J= − −

2* 2* 0.02*Ia Va ia w= − − 100 10*Lw ia T w= − −

28

Instructor ENG / M.TAHA

• We can implement Model of DC motor By an other Method BY state space

Representation

2 0.02 2 01 10 0 100 L

VaIa IaTw w

− − = + − −

)( )(01 00L

Vaiaw

Tw

= +

29

Instructor ENG / M.TAHA

• We can implement Model of DC motor By an other Method BY state space

Representation and using PID Block

30

Instructor ENG / M.TAHA

• Using PID Block

31

Instructor ENG / M.TAHA

• Using PID Block

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&section=Con

trolPID

• http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed&section=Sim

ulinkModeling

• http://ctms.engin.umich.edu/CTMS/index.php?example=AircraftPitch&section=Sim

ulinkModeling