Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
534 views

Study of P, PD, Pi, Pid Controllers Using Mat Lab

This document summarizes a study of P, PD, PI, and PID controllers using MATLAB. It describes the basic equations and transfer functions for each type of controller. It provides an example using a mass-spring-damper system to demonstrate how each controller type affects rise time, overshoot, settling time, and steady-state error. It also describes how to design a PID controller by starting with P and then adding D and I terms, and how MATLAB tools can be used for automated PID tuning.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
534 views

Study of P, PD, Pi, Pid Controllers Using Mat Lab

This document summarizes a study of P, PD, PI, and PID controllers using MATLAB. It describes the basic equations and transfer functions for each type of controller. It provides an example using a mass-spring-damper system to demonstrate how each controller type affects rise time, overshoot, settling time, and steady-state error. It also describes how to design a PID controller by starting with P and then adding D and I terms, and how MATLAB tools can be used for automated PID tuning.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

STUDY OF P, PD, PI, PID CONTROLLERS USING MAT LAB

AIM:

To study the effect of P, PD, PI, PID controllers using Mat lab.

Consider the following unity feedback system:

The output of a PID controller, equal to the control input to the plant (u), in the time-domain is as
follows:

( ) ( ) ∫ ( ) (1)
Working of PID controller in a closed-loop system

The variable ( ) represents the tracking error, the difference between the desired input value ( )
and the actual output ( ). This error signal ( ) will be sent to the PID controller, and the controller
computes both the derivative and the integral of this error signal. The control signal ( ) to the
plant is equal to the proportional gain ( ) times the magnitude of the error plus the integral gain
( ) times the integral of the error plus the derivative gain ( ) times the derivative of the error.

This control signal ( ) is sent to the plant, and the new output ( ) is obtained. The new output ( )
is then fed back and compared to the reference to find the new error signal ( ). The controller
takes this new error signal and computes its derivative and its integral again, ad infinitum.

The transfer function of a PID controller is found by taking the Laplace transform of (1).

= Proportional gain = Integral gain = Derivative gain


For example:

Kp = 1; Ki = 1; Kd = 1;

sys = tf('sys');

C = Kp + Ki/s + Kd*s
C=

s^2 + s + 1

-----------

Continuous-time transfer function.

Alternatively, use of MATLAB's pid controller object to generate an equivalent continuous-time


controller is as follows:

C = pid (Kp,Ki,Kd)

C=

Kp + Ki * --- + Kd * s

with Kp = 1, Ki = 1, Kd = 1

Continuous-time PID controller in parallel form.

Converting the pid object to a transfer function using the command tf(C)

ans =

s^2 + s + 1

----------------

Continuous-time transfer function.


The Characteristics of P, I, and D Controllers
A proportional controller ( ) will have the effect of reducing the rise time and will reduce but
never eliminate the steady-state error. An integral control ( ) 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 ( ) will have the effect of increasing the stability of the system, reducing the
overshoot, and improving the transient response.
The effects of each of controller parameters, , , and on a closed-loop system are
summarized in the table below.

CL RESPONSE RISE TIME OVERSHOOT SETTLING TIME S-S ERROR


Kp Decrease Increase Small Change Decrease
Ki Decrease Increase Increase Eliminate
Kd Small Change Decrease Decrease No Change
Note that these correlations may not be exactly accurate, because , , and 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
, and .
Example Problem
Suppose we have a simple mass, spring, and damper problem.

The modeling equation of this system is

Taking the Laplace transform of the modeling equation, we get

The transfer function between the displacement and the input then becomes
Let

M = 1 kg

b = 10 N s/m

k = 20 N/m

F=1N

Plug these values into the above transfer function

The goal of this problem is to show how each of , and contributes to obtain

 Fast rise time


 Minimum overshoot
 No steady-state error

Open-Loop Step Response


sys = tf('sys');

P = 1/(s^2 + 10*s + 20);

Step (P)
The DC gain of the plant transfer function is 1/20, so 0.05 is the final value of the output to a unit
step input. This corresponds to the steady-state error of 0.95, quite large indeed. Furthermore, the
rise time is about one second, and the settling time is about 1.5 seconds. Let's design a controller
that will reduce the rise time, reduce the settling time, and eliminate the steady-state error.

P CONTROLLER

The closed-loop transfer function of the above system with a proportional controller is:

kp

----------------

s^2 + 10 s + 20+kp

Kp = 300;

C = pid(Kp)

T = feedback(C*P,1);

t = 0:0.01:2;

step(T,t)

C =

Kp = 300

T =

300

----------------

s^2 + 10 s + 320
Step Response
1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (sec)

Proportional controller (Kp) reduces the rise time, increases the overshoot, and reduces the
steady-state error.

PD CONTROLLER

The closed-loop transfer function of the given system with a PD controller is:

kd s + kp

----------------

s^2 + (10+kd) s + (20+kp)

kp=300;

kd=10;

num=[kd kp];

den=[1 10+kd 20+kp];

sys=tf(num,den)

t=0:.01:2;

step(num,den,t)
Step Response
1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (sec)

The derivative controller (Kd) reduces both the overshoot and the settling time.

PI CONTROLLER

The closed-loop transfer function with a PI control is:

Kp s + ki

------------------------

s^3 + 10 s^2 + (20+kp) s + ki

kp=30;

ki=70;

num=[kp ki];

den=[1 10 20+kp ki];

sys=tf(num,den)

t=0:.01:2;

step(num,den,t)
Step Response
1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (sec)

An integral controller (Ki) decreases the rise time, increases both the overshoot and the settling
time, and eliminates the steady-state error.

PID CONTROLLER

The closed-loop transfer function of the given system with a PID controller is:

kd s^2 + kp s + ki

--------------------------

s^3 + (10+kd) s^2 + (20+kp) s + ki

kp=350;

ki=300;

kd=50;

num=[kd kp ki];

den=[1 10+kd 20+kp ki];

sys=tf(num,den)

t=0:.01:2;

step(num,den,t)
Step Response
1

0.9

0.8

0.7

0.6
Amplitude

0.5

0.4

0.3

0.2

0.1

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (sec)

Steps for Designing a PID Controller

1. Obtain an open-loop response and determine what needs to be improved


2. Add a proportional control to improve the rise time
3. Add a derivative control to improve the overshoot
4. Add an integral control to eliminate the steady-state error

Adjust each of Kp, Ki, and Kd until a desired overall response is obtained.

Lastly, please keep in mind that all three controllers (proportional, derivative, and integral) may
not be implemented into a single system. For example, if a PI controller gives a good enough
response, then don't need to implement a derivative controller on the system. Keep the controller
as simple as possible.

Automatic PID Tuning


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 pidtune or through a nice graphical user interface (GUI) using pidtool.
The MATLAB automated tuning algorithm chooses PID gains to balance performance (response
time, bandwidth) and robustness (stability margins). By default the algorthm designs for a 60
degree phase margin.

Let's explore these automated tools by first generating a proportional controller for the mass-
spring-damper system by entering the following commands:

Pidtool (P, 'p')

The pidtool GUI window, like that shown below, should appear.
Notice that the step response shown is slower than the proportional controller we designed by
hand. Now click on the Show Parameters button on the top right. As expected the proportional
gain constant, Kp, is lower than the one we used, Kp = 94.85 < 300.
We can now interactively tune the controller parameters and immediately see the resulting
response in the GUI window. Try dragging the response time slider to the right to 0.14s, as shown
in the figure below. The response does indeed speed up, and we can see Kp is now closer to the
manual value. We can also see all the other performance and robustness parameters for the
system. Note that the phase margin is 60 degrees, the default for pidtool and generally a good
balance of robustness and performance.
Now let's try designing a PID controller for our system. By specifying the previously designed or
(baseline) controller, C, as the second parameter, pidtool will design another PID controller
(instead of P or PI) and will compare the response of the system with the automated controller
with that of the baseline.

Pidtool (P,C)

We see in the output window that the automated controller responds slower and exhibits more
overshoot than the baseline. Now choose the Design Mode: Extended option at the top, which
reveals more tuning parameters.
Now type in Bandwidth: 32 rad/s and Phase Margin: 90 deg to generate a controller similar in
performance to the baseline. Keep in mind that a higher bandwidth (0 dB crossover of the open-
loop) results in a faster rise time, and a higher phase margin reduces the overshoot and improves
the system stability.
Finally we note that we can generate the same controller using the command line
tool pidtune instead of the pidtool GUI

opts = pidtuneOptions('CrossoverFrequency',32,'PhaseMargin',90);
[C, info] = pidtune(P, 'pid', opts)
C=

Kp + Ki * --- + Kd * s

s
with Kp = 320, Ki = 169, Kd = 31.5 Continuous-time PID controller in parallel form.

info =

Stable: 1

CrossoverFrequency: 32

PhaseMargin: 90

You might also like