+ All Categories
Home > Documents > Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

Date post: 03-Jun-2018
Category:
Upload: aryo-daniel
View: 217 times
Download: 0 times
Share this document with a friend

of 32

Transcript
  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    1/32

    MATLAB SIMULINK - Simulation andModel Based Design

    http://www.mathworks.com

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    2/32

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    3/32

    Simulink runs under Matlab. Firststart Matlab, then type simulink at

    the Matlab prompt.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    4/32

    The first window that

    pops up is the Library

    Browser.

    This is a library ofblocks that are

    available for putting

    into the Simulink blockdiagram.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    5/32

    Simulink Help

    Select Simulink

    Help from thehelp menu in thelibrary browser.

    Here you canfind tutorials,demos,information onavailable blocks,and so on.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    6/32

    A Simulink model is a block diagram. ClickFile|New|Model in the Library Browser. An empty

    block diagram will pop up. You can drag blocks intothe diagram from the library.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    7/32

    Sources: Produce Signals

    Select sources from the library.

    Drag any block you want to useinto the model.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    8/32

    Sinks: Terminate Signals

    Select sinks from the library.

    Drag any block you want to useinto the model.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    9/32

    Connecting Blocks

    Drag a signal line from the output

    of a block to the input of anotherblock.

    Ctrl-Click will automaticallyconnect.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    10/32

    Running the Simulation

    Change parameters under

    Simulation | Configuration

    Parameters.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    11/32

    Running the Simulation

    Set start and

    stop time for thesimulation here.

    I often change

    from variable-stepto fixed-step to get

    a smoother-lookingsolution.

    Note: numericalsolution usingode45!

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    12/32

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    13/32

    Viewing Results: Scope

    Double click on the scope icon to

    open up the viewer. You oftenhave to zoom out using thebinocular icon if the curve doesntfit in the default axes.

    You can save data from the scope to

    the workspace using the Parameters,Data History tab.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    14/32

    Modifying Block Properties

    Double click on any block tobring up a properties box.

    Here are the sine waveproperties. If you dont knowwhat something is leave italone!!!

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    15/32

    Adding Comments

    You can add text commentsanywhere in the block diagramby double clicking and typing insome text.

    You can change the defaultcomments under the blocks bydouble clicking and editing thetext.

    Do In-Class Problem #1. Should be 2:00 at the end of

    the problem.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    16/32

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    17/32

    Signal Routing

    Under the signal routing library,the MUX block can be used tobundle a group of signalstogether into a single line.

    The DEMUX block does thereverse.

    This can be useful to:

    1. Clear up clutter in acomplicated block diagram.

    2. Send multiple signals to thesame scope; then bothsignals will be displayed on

    the same plot.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    18/32

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    19/32

    Transfer Functions

    U(s) = 1/s

    X(s)=1/(s(s+1))=1/s-1/(s+1)

    So x(t)=1-exp(-t)

    Do In-Class Problem #2. It should be 2:20 by the end of the problem.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    20/32

    Closed Loop Control System:

    Here is an example of a closed-loop system

    with an on-off controller. Notice theoscillations in the response.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    21/32

    Integrators and Derivatives

    Integrators and derivatives are available in

    the continuous library.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    22/32

    Integrators

    For integrators, you can set theinitial condition and limit theoutput to not be allowed to goabove or below some value onthe properties for that block.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    23/32

    Setting Up Systems with Integrators

    If you have a nonlinear equation system, you cant describe it with a transferfunction. One option is to put all of the operations in as individual blocks:

    i(t)

    J(t)=ki(t)-f()

    where f(w) is coulomb and viscous friction.

    Use integrators rather

    than derivatives, andput in as many

    integrators as there arestates. Thenbootstrap!

    Do in-class problem #3. It should be 2:40 at the end of the problem.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    24/32

    Subsystems

    You can group a set of blocks together into a subsystem, by selecting them

    and right clicking and saying Create Subsystem. They will all go under asingle block. If you double click the subsystem, you can see what is underthe mask.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    25/32

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    26/32

    Running Simulink Models from M-files

    [T,X,Y] = SIM('model',TIMESPAN,OPTIONS,UT)

    Here is the heartof the m-file.

    Constants in the

    simulink modelcan be defined inthe workspace.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    27/32

    Running Simulink Models from M-files

    The input and output of

    the simulink model aredefined in the block

    diagram using input andoutput sources andsinks.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    28/32

    Control and Estimation Tool

    Set input and output

    points by right clickingon a signal, and

    selecting LinearizationPoints.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    29/32

    Control and Estimation Tool SelectTools:Control

    Design: LinearAnalysis fromthe simulinkmenu.

    The control and

    estimation toolwill pop up.Select the type ofplot you want to

    generate, andclick linearizemodel. Thesystem will belinearized about

    the operatingpoint (see Ogata3-10 andSimulink Help)

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    30/32

    Control and Estimation ToolThe selected type of

    plot will pop up foryour linearizedsystem. If you wanta different type of

    plot, look underEdit:PlotConfigurations.

    To export thelinearized system tothe Workspace soyou can use it withother design tools inMatlab, select File:

    Export.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    31/32

    Communicating with the WorkspaceAny constant or variable defined

    in the Matlab workspace isavailable in the block diagram.

    The simin and simout blocksallow you to pass signals in fromthe workspace, and out to theworkspace. Change the saveformat to Array for easiest use

    (double click on the ToWorkspace block for options).

    The clock source allows you togenerate a time signal if youwant to send that back to theworkspace.

  • 8/12/2019 Www.tufts.edu ~Rwhite07 PRESENTATIONS REPORTS Simulink

    32/32

    Other Useful Blocks

    Under Discontinuous youwill find coulomb friction,dead zone, saturation, andrelay.

    Under Continuous thereis a delay block.

    Under Simulink Extrasthere is a PID controller,transfer function with non-

    zero initial conditions,some useful sinks (suchas power spectraldensity), and radians-to-

    degrees and Fahrenheit-to-Celsius converters.


Recommended