control engineering lab 7

Upload: johnyrock05

Post on 07-Jul-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/18/2019 Control engineering LAb 7

    1/17

    MTS-362

    Control Engineering Lab-7

    Introduction and Some Basic Application o SIM!LI"# 

    7$% Introduction&

    Simulink is a time based software package that is included in Matlab and its main task is to solveOrdinary Differential Equations (ODE) numerically !he need for the numerical solution comes

    from the fact that there is not an analytical solution for all DE" especially for those that are

    nonlinear

    !he whole idea is to break the ODE into small time segments and to calculate the solution

    numerically for only a small segment !he length of each segment is called #step si$e% Since the

    method is numerical and not analytical there will be an error in the solution !he error depends onthe specific method and on the step si$e (usually denoted by h)

    !here are various formulas that can solve these equations numerically Simulink uses Dormand&'rince (ODE)" fourth&order unge&*utta (ODE+)" ,ogacki&Shampine (ODE-)" improved Euler 

    (ODE.) and Euler (ODE/) 0 rule of thumb states that the error in ODE is proportional to h" in

    ODE+ to h+ and so on 1ence the higher the method the smaller the error

    2nfortunately the high order methods (like ODE) are very slow !o overcome this problem

    variable step si$e solvers are used 3hen the system4s states change very slowly then the step si$e

    can increase and hence the simulation is faster On the other hand if the states change rapidly thenthe step si$e must be sufficiently small

    !he variable step si$e methods that Simulink uses are5

    6 0n e7plicit unge&*utta (+") formula" the Dormand&'rince pair (ODE+)6 0n e7plicit unge&*utta (."-) pair of ,ogacki and Shampine (ODE.-)

    6 0 variable&order 0dams&,ashforth&Moulton 'E8E solver (ODE//-)6 0 variable order solver based on the numerical differentiation formulas (9D:s) (ODE/s)

    6 0 modified osenbrock formula of order . (ODE.-s)

    6 0n implementation of the trape$oidal rule using a ;free; interpolant (ODE.-t)

    6 0n implementation of !&,D:." an implicit unge&*utta formula with a first stage that is atrape$oidal rule step and a second stage that is a backward differentiation formula of order two

    (ODE.-tb)

    !o summari$e the best method is ODE (or ODE+)" unless you have a stiff problem" and a

    smaller the step si$e is better" within reason

    7$2 Sol'ing ()E&

    Since the key idea of Simulink is to solve ODE let us see an e7ample of how to accomplish that

    !hrough that e7ample many important features of Simulink will be revealed

    !o start Simulink click on the appropriate push button from the command window:

    8ontrol Engineering

  • 8/18/2019 Control engineering LAb 7

    2/17

    ?ou will see the Simulink window

    8ontrol Engineering

  • 8/18/2019 Control engineering LAb 7

    3/17

    Open a new Simulink window by clicking on the "e* button

    7$3 Basic Elements o SIM!LI"#&

    !here are two ma@or classes of items in Simulink5 bloc+s and lines ,locks are used togenerate" modify" combine" output" and display signals

  • 8/18/2019 Control engineering LAb 7

    4/17

  • 8/18/2019 Control engineering LAb 7

    5/17

    7.3.5 Modifying Blocks

    0 block can be modified by double&clicking on it :or e7ample" if you double&click on the

    ;!ransfer :cn; block in the  simple model" you will see the following dialog bo7

    !his dialog bo7 contains fields for the numerator and the denominator of the blockCs transfer

    function ,y entering a vector containing the coefficients of the desired numerator or denominator

     polynomial" the desired transfer function can be entered :or e7ample" to change the denominatorto s..s/" enter the following into the denominator field5

    [1 2 1]

    and hit the close button" the model window will change to the following"

    which reflects the change in the denominator of the transfer function

    !he ;step; block can also be double&clicked" bringing up the following dialog bo7

    8ontrol Engineering

  • 8/18/2019 Control engineering LAb 7

    6/17

    !he default parameters in this dialog bo7 generate a step function occurring at timeF/ sec" from an

    initial level of $ero to a level of / (in other words" a unit step at tF/) Each of these parameterscan be changed 8lose this dialog before continuing

    !he most complicated of these three blocks is the ;Scope; block Double clicking on this brings

    7$ Building S/stems&

     

    Bn this section" you will learn how to build systems in Simulink using the building blocks inSimulinkCs ,lock

  • 8/18/2019 Control engineering LAb 7

    7/17

    7.4.1 Gathering Blocks:

    :ollow the steps below to collect the necessary blocks5

    • 8reate a new model ("e* from the ,ile menu or 8trl&9) ?ou will get a blank model

    window

    • Double&click on the Sources icon in the main Simulink window

    !his opens the Sources window which contains the Sources ,lock

  • 8/18/2019 Control engineering LAb 7

    8/17

    • Drag the Step block from the sources window into the left side of your model window

    8ontrol Engineering

  • 8/18/2019 Control engineering LAb 7

    9/17

    • Double&click on the

  • 8/18/2019 Control engineering LAb 7

    10/17

    • Double&click your Sum block Since you will want the second input to be subtracted" enter

    & into the list of signs field 8lose the dialog bo7

    • Double&click your Iain block 8hange the gain to . and close the dialog bo7

    • Double&click the leftmost !ransfer :unction block 8hange the numerator to L/ . and the

    denominator to L/ N 8lose the dialog bo7

    • Double&click the rightmost !ransfer :unction block

  • 8/18/2019 Control engineering LAb 7

    11/17

    7.4.2 Connecting Blocks with Lines:

     9ow that the blocks are properly laid out" you will now connect them together :ollow these steps

    • Drag the mouse from the output terminal of the Step block to the upper (positive) input of 

    the Sum block

  • 8/18/2019 Control engineering LAb 7

    12/17

    ?ou can continue the partial line you @ust drew by treating the open arrowhead as an output

    terminal and drawing @ust as before 0lternatively" if you want to redraw the line" or if the line

    connected to the wrong terminal" you should delete the line and redraw it !o delete a line (or 

    any other ob@ect)" simply click on it to select it" and hit the delete key

    • Draw a line connecting the Sum block output to the Iain input 0lso draw a line from the

    Iain to the 'B 8ontroller" a line from the 'B 8ontroller to the 'lant" and a line from the

    'lant to the Scope ?ou should now have the following

    • !he line remaining to be drawn is the feedback signal connecting the output of the 'lant to

    the negative input of the Sum block !his line is different in two ways :irst" since this lineloops around and does not simply follow the shortest (right&angled) route so it needs to be

    drawn in several stages Second" there is no output terminal to start from" so the line has to

    tap off of an e7isting line

    !o tap off the output line" 0old t0e Ctrl +e/ *0ile dragging t0e mouse rom t0e point on

    t0e e.isting line where you want to tap off Bn this case" start @ust to the right of the 'lant

    Drag until you get to the lower left corner of the desired feedback signal line as shown

     below

    8ontrol Engineering

  • 8/18/2019 Control engineering LAb 7

    13/17

     9ow" the open arrowhead of this partial line can be treated as an output terminal Draw a

    line from it to the negative terminal of the Sum block in the usual manner

    •  9ow" you will align the blocks with each other for a neater appearance Once connected"

    the actual positions of the blocks does not matter" but it is easier to read if they are aligned

    !o move each block" drag it with the mouse !he lines will stay connected and re&routethemselves !he middles and corners of lines can also be dragged to different locations

    Starting at the left" drag each block so that the lines connecting them are purely hori$ontal

    0lso" ad@ust the spacing between blocks to leave room for signal labels ?ou should havesomething like5

    8ontrol Engineering

  • 8/18/2019 Control engineering LAb 7

    14/17

    • :inally" you will place labels in your model to identify the signals !o place a label

    anywhere in your model" double click at the point you want the label to be Start by double

    clicking above the line leading from the Step block ?ou will get a blank te7t bo7 with an

    editing cursor as shown below

    !ype an r in this bo7" labeling the reference signal and click outside it to end editing

  • 8/18/2019 Control engineering LAb 7

    15/17

    • !o save your model" select Sa'e As in the ,ile menu and type in any desired model name

    7.5 i!"lation

     9ow that the model is complete" you can simulate the model Select Start from the Simulation 

    menu to run the simulation Double&click on the Scope block to view its output 1it the autoscale button (binoculars) and you should see the following

    7.# $aking %aria&les fro! M'$L'B

    Bn some cases" parameters" such as gain" may be calculated in M0!

  • 8/18/2019 Control engineering LAb 7

    16/17

    8lose this dialog bo7 9otice now that the Iain block in the Simulink model shows the variable *rather than a number

     9ow" you can re&run the simulation and view the output on the Scope !he result should be the

    same as before

    8ontrol Engineering

  • 8/18/2019 Control engineering LAb 7

    17/17

     9ow" if any calculations are done in M0!