pid simulink

Embed Size (px)

Citation preview

  • 8/10/2019 pid simulink

    1/14

    Page | 2

    Contents

    I. Introduction ..................................................................................................................................... 2

    II. Wind Turbine Plant .................................................................................................................... 3

    III. PID Controller Design ................................................................................................................. 4

    A. ZieglerNichols Method ............................................................................................................... 5

    B. Manual Tuning ............................................................................................................................ 7

    C. Auto-tune using Simulink ............................................................................................................ 7

    D. Comparison of the Different Plants output ................................................................................. 7

    IV. PID Controller Design ............................................................................................................... 10

    E. Digital Controller ...................................................................................................................... 10

    F. Sampling Time Effect on Digital Controller ............................................................................. 13

    V. Bibliography .............................................................................................................................. 15

    I.

    Introduction

    The following report is a resume of the work and findings done on the module Control Engineering.The objective of the laboratory work was to carry the simulations required to investigate the moreappropriate controller design. This is done using different technical approaches, this initial reportcovers two of the techniques used PID controller and Digital PID.

    The model used represent an electric generator wind turbine, in order to maintain a steady statespeed on the rotation of the blades this are normally equipped with pitch angle control, hence therotor and generator speed can be controlled using the angle pitch of the blades[1]. The model given isshown on Fig. 1 and represents the whole wind turbine system and controller with a close loop

    feedback.

    Fig. 1 Left is the block that represents the controller Right is the model plant[2].

  • 8/10/2019 pid simulink

    2/14

    Page | 3

    II.

    Wind Turbine Plant

    Systems like the wind turbine, if not use with a controller that adjust the output can becomeunstable. This could be due to multiple facts (noise, turbulences, disturbances of the system...etc.) canlead to an output outside the operational margins of the model making a system unstable and the

    model to fail in real life.

    For this reason a controllers operates with a close loop where the output is subtracted from the inputin a close loop, and feed to the input of the controller. This way the controller can make the necessaryadjustments to maintain the system stable at any time. The plant given is defined by the followingtransfer function model (1).

    2

    2 2( 1)( 2 )

    g

    g g

    n

    n n

    Kplant

    s s s (1)

    The values of the different variables are given on the following table;

    Pitch angle control for wind turbine rotor speed

    CENo CaseNo

    (time

    constant)

    gn

    (natural oscillation

    frequency)

    K(constant)

    gn

    (damping ratio x naturaloscillation frequency)

    5 19 0.8 2.1 2.3 1.0

    Table 1. Values of the plant constants

    By substituting the values of the constants with their value, the plant looks as follow(2).

    2

    2 2

    2.3 2.1

    (0.8 1)[ (2 1 ) 2.1 ]

    plant

    s s s

    3 2

    10.143

    0.8 2.6 5.528 4.41plant

    s s s

    (2)

    All the simulation and control is doneusing Simulink and Matlab. Throughthe design of the controller differentfiles with the extension .m werecreated to automatically calculate the

    parameters of the controller anddisplay the behaviour of the plant withthe controller on cascade (series). Aftermodelling the plant in Matlab a stepresponse of the plant is created toanalyse the operation of the plantFig.1. From this graph can be observehow the steady state error isapproximately of 1.3 which isunacceptable, also there is no way tohold the output on a set point withoutfeedback hence the next step is to addthe close loop.

    Fig. 2 Plant output.

  • 8/10/2019 pid simulink

    3/14

    Page | 4

    III.

    PID Controller Design

    Proportional Integral Derivative controller (PID) have been historically the choice of control

    techniques starting as early as 1890s[3], although they become more popular later with theintroduction of semiconductor on the design of electronic PIDs.

    PIDs are normally configured using the frequency domain for its simplicity, as it avoids dealing withintegration and derivatives. An equivalent to the following time domain can also be used.

    s (t) (t) i

    p d p i d

    K deK K K e K e dt K

    s dt

    Fig. 3 Frequency domain and respective time domain[4]

    Using PIDs provides the designer with a versatile control system that can be finely tune to adjust itsoperation, providing a large number of options depending of the gain applied to one of the 3

    components of the controller(Fig.4). They are the preferred close loop systems control over othertechniques because for is robustness[5]. The PID used on Simulink look like the following model, afirst order pole is added on the derivative branch to operate as a filter and reduce the effect of noise.

    Fig. 4 PID model used on Simulink with 3 constants P I and D.

    Three values are used to configure it, under a close loop system the characteristics of each module are;

    Proportional cannot eliminate state error.

    Integral slows down transient response but eliminates the steady state error.

    Derivative reduce overshoot, increase stability and improve transient response.

    Cl Response Rise Time Overshoot Settling Time S-S ErrorKp Decrease Increase Small Change DecreaseKi Decrease Increase Increase EliminateKd Small Change Decrease Decrease No Change

    Table 2. Output of increasing any of the values of the PID

    [1]

  • 8/10/2019 pid simulink

    4/14

    Page | 5

    Three different techniques were used to create and tune a PID; ZieglerNichols method, manualtuning and auto-tune of Simulink.

    A.ZieglerNichols Method

    The Ziegler-Nichols method has several variations, the one used is known as Ziegler-Nichols PIDController Gain Tuning Using Closed-loop Concepts. It provides with a good disturbance rejection,

    intending a fast close-loop response without much oscillation.

    First step to proceed on building the controller was creating a close loop (CL) model in Simulink totest the system Fig. 5.

    Figure 5 Wind turbine Simulink model with critical gain.

    Fig. 6 Kcr Gain output of Simulink model.

    2.6287, 1.3365 cr cr

    P k

    (3)

    To find requiredvalues of each of thePID components the

    ZieglerNicholsTuning Rule isapplied, this is based

    on the table 3 anduses the previous calculate Kcrand Pcr. Thistable uses the following PID form:

    1(1 T s)

    p d

    i

    KT s

    (4)

    The values are input on the table and the finalvalue of each component is calculated, table 4.

    Type of controller Kp Ti Td

    P 0.5Kcr 0

    PI 0.45kcr /1.2crP 0

    PID0.6k

    cr0.5P

    cr 0.125P

    cr

    The proportional gain is increased to the point where the system startsoscillating Fig. 6, this gain value is the critical gain (Kcr), initially this value wasfound by trial and error modifying the value and testing, ultimately the

    allmargin()Matlab function was used to obtain this value, alternatively the

    rlocus()and rlocfind()can also be used to identify the gain in which thesystem become unstable [6]. The period of the sine wave output is call thecritical period Pcr. This response is characteristic of a 0 damping ratio expressedon the s domain as a system with two imaginary poles on the 0 x axis. Running

    the .m file initializationdeclares the transfer function and calculates bothvalues (3).

  • 8/10/2019 pid simulink

    5/14

    Page | 6

    Table 3. ZieglerNichols Tuning Table

    Type of controller Kp Ti Td

    P 0.5 1.337 0.6685 0

    PI0.45 1.33 0. 77 601

    2 .5 /1 .2 2 .0 83 3

    0PID 0.6 1.337 0.8022 0 .5 2 .5 1.2 5 0 .1 25 2 .5 0 .3 12 5

    Table 4. ZieglerNichols Tuning Table Components Value.

    This ZieglerNichols Tuning Table is on the format of1

    (1 T s) p di

    KT s

    which doesnt match the

    Simulink PID form1

    P I Dss

    , the conversion is done on the .m file PID calc.m. Executing the

    script will calculate the values of each component (table 5) and displays two tables with the valuespresented and the output of the different Simulink models.

    Type of controller P I D

    P 0.6685 0 0

    PI 0.60165 0.28879 0

    PID 0.8022 0.64176 0.25069

    Table 5. PID values for a P PI and a PID controller.

    A model is created in Simulink to input the values of the different PIDs and compare their output(Fig 7);

    Fig. 7 P PI and PID controller in series with the wind turbine plant model.

    The output is transferred to the workspace by ticking the save data to workspacebox in the scope

    settings, and plotted using the Simplot()function from Matlab Fig(8).

    The P controller outputs a signal with a high steady state error, the gain is too low to reach

    the value of the input, in this case is not appropriated. A proportional controller has theadvantage of being cheap and has a fast response but could lead to overshoot and a highsteady state error.

  • 8/10/2019 pid simulink

    6/14

    Page | 7

    PI controller provides a more suitable solution but in this case the output takes too long tostabilize oscillating several times before reaching settling time

    PID is of the three systems the one that respond with a faster rise time, have a slightly largeovershoot but a significant better settling time as table 2 indicates.

    Fig. 8 Scope output of the P PI and PID controller in cascade with the wind turbine plant model.

    At a glance all of the systems are stable; in terms of the overshoot all of the system have a moderate

    overshoot of approximately 0.2; the P controller is the only one with steady-state error while the othercontrollers have almost none; settling time is reduce to half in the PID in comparison with the PI andP controller.

    B.Manual Tuning

    After tuning the PID on the previous exercise and having gained some experience on the operation ofthe controller. Two techniques were used [7]but the result were not really good, so at the end based onprevious experiment the next steps were followed.

    1. Incremented P to obtain a good raising time and not a very oscillatory system.2. Adjusted D to reduce the oscillation by a factor of 2-4.3. Adjust I to remove the steady state error without compromising the overshoot.

    The output was slightly better than the one obtained on the previous technique but the trial and errorresulted being somewhat time consuming.

    C.Auto-tune using Simulink

    Simulink has a PID tuner that can be access from the tune button on the configuration window of thePID block. This interface offers auto-tune or tuning based on two sliders. Some modifications weredone and finally the auto-tune settings were saved on the script in order to compare it against theother step functions.

    D.Comparison of the Different Plants output

    The different PID controllers were set on a Simulink file (Fig.9) in order to compare them. As noconstrains were given of the design is not very clear which would suit best the plant, but given theimprovement of the manually tuned PID on time this seems the more feasible and interesting option.

  • 8/10/2019 pid simulink

    7/14

    Page | 8

    Figure 9. Multiple plant controller system in order to compare output.

    The comparison of the 3 PIDs are plotted on Fig.10, The Auto-tune system offer small overshoot but

    the settling time differs almost 3 seconds with the manual tune while the ZieglerNichols PID is inbetween them. Rise time is slightly better in the manual tune PID, specially compared with the auto-tune.

    Fig. 10 step output of the different PIDs with the settling time markers.

  • 8/10/2019 pid simulink

    8/14

    Page | 9

    Using the function stepinfo(sys)the characteristics of each system were obtained and plotted ontable 6 for an easy comparison, with a given set of constrains a decision of the most suitable could bemade, although as state the manually tuned PID seems the more appropriated.

    ZieglerNichols Method Manual Tune Auto-tuneRise Time 0.7137 0.5359 2.0075

    Settling Time 5.5031 4.1028 6.6185Settling Min 0.8175 0.8080 0.9107Settling Max 1.1192 1.1262 1.0652Overshoot 11.9196 12.6206 6.5240Peak 1.1192 1.1262 1.0652PeakTime 1.4360 1.1122 4.5450RiseTime 0.7137 0.5359 2.0075Steady state error 0.0013 0.0016 0.0027

    Table 6. PID characteristics of the different systems.

    To obtain the steady state error the following Matlab code was used.

    Fig. 11 Matlab code used to obtain the steady state error.

    % get the response of the system to a step

    [y,t]=step(sys);

    % calculate the steady state error

    sserror=abs(1-y(end))

  • 8/10/2019 pid simulink

    9/14

    Page | 10

    IV.

    PID Controller Design

    Analog PIDs have been use for many years but are hard to reconfigure as well as having otherdownfalls, nowadays technology allow to produce digital PIDs which are not only cheaper, easy toproduce and to configure, improve sensibility results, are less sensible to noise, offers the benefit of

    digital signals as logging and transmission and also can add extra functionality and can be reprogramwithout incurring in any hardware cost[1].

    E.

    Digital Controller

    To simulate a digital controller in Simulink a few modifications are required on the model;

    Fig. 12 Simulink model of the digital controllers with a P, PI, PID Zeigler-Nichols,

    Manually Tune PID and a Auto tune PID.

    Firstly an analog to digital (A/D) and a digital to analog (D/A) converter have to be added at eachside of the controller, this converts signal to data the controller can process. The data is sampled andsent to the PID. This is replaced by a discrete transfer function block, as previously the variablenames are assigned to the blocks and the values are calculated in a .m script.

    Formulae used to input the values on Simulink have to be converted from the continuous-time systemto a discreet domain, in order to do so the PID formulae used previously (5)

    1( 100)

    1

    1

    NP I D N

    sN

    s

    (5)

  • 8/10/2019 pid simulink

    10/14

    Page | 11

    Have to be convert to a single fraction is order to convert it using Matlab c2dfunctions, to do sosubstitute the terms into the following equation:

    2

    2

    ( ) ( )

    0

    P DN s PN I s IN

    s sN

    2

    2

    (0.83778 0.25133 100)s (0.83778 100 0.69815)s 0.69815 100

    100 0s s

    2

    2

    27.15 80.8 61.01

    100

    s s

    s s

    (6)

    Using Matlab the system (6) is converted from the continuous-time (s) into a discrete function on thez domain (8). A sampling time have to be specify, to find T value the formulae (7) is used, where nris

    10

  • 8/10/2019 pid simulink

    11/14

    Page | 12

    Fig. 13 multiple graphs output form

  • 8/10/2019 pid simulink

    12/14

    Page | 13

    F. Sampling Time Effect on Digital Controller

    The conversion from analog to digital is condition for the sampling time, the smallest is the samplingtime the higher accuracy the controller has, but it also increases the computational power required.When data is sampled it can be considered as if a switch is close momentarily and a measurement of

    the signal is taken, by doing so every T sec. a discrete signal is obtained(Fig.14). Hence if thesampling time is too high the system will become unstable as the controller will not receive enoughdata to correct the output if turbulences or noise are present.

    Fig. 14 Analogy of the operation of the sampling of a signal. Left raw signal, right sampled data.

    To explore the effect the sampling time has on a system a new Simulink model was created anddifferent times (Tr=0.02 and Tr=0.05) were used to calculate the z domain model.

    Fig. 15

    The output Fig.16 shows how a higher value on the sampling time means a delay is introduce on thecontrol and hence the more it takes to stabilize the output. Also a small T rseems to produce and overdamping effect on the output of the system.

  • 8/10/2019 pid simulink

    13/14

    Page | 14

    Fig. 16

  • 8/10/2019 pid simulink

    14/14

    Page | 15

    V.

    Bibliography

    [1] R. C. Dorf and R. H. Bishop, Modern Control Systems, vol. 1. Prentice Hall, 2010.

    [2] C. Y. Tay, Lecture Slides - 4 Your design case study.Oct-2014.

    [3] PID controller,Wikipedia, the free encyclopedia. 10-Nov-2014.

    [4] Control Tutorials for MATLAB and Simulink - Introduction: PID Controller Design.[Online].

    Available:

    http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction&section=ControlPID.

    [Accessed: 1-Nov-2014].

    [5] N. S. Nise, Control Systems Engineering, vol. 1. Wiley, 2010.

    [6] D. Gu, P. H. Petkov, and M. M. Konstantinov, Robust Control Design With MATLAB, vol. 1.

    Springer, 2005.

    [7] control - What are good strategies for tuning PID loops? - Robotics Stack Exchange.[Online].

    Available: http://robotics.stackexchange.com/questions/167/what-are-good-strategies-for-tuning-

    pid-loops. [Accessed: 19-Nov-2014].

    [8] PID Controllers.[Online]. Available:

    http://www.facstaff.bucknell.edu/mastascu/econtrolhtml/pid/pid3.html. [Accessed: 19-Oct-2014].

    [9] A. Knight, Basics of MATLAB and Beyond, vol. 1. CRC Press, 1999.