1 / 42

ECEN/MAE 3723 – Systems I

ECEN/MAE 3723 – Systems I. MATLAB Lecture 2. Lecture Overview. What is Simulink? How to use Simulink Getting Start with Simulink Building a model Example 1 (Differential Equations ) Example 2 (Transfer Function) Creating Subsystems Useful Information. What is Simulink? (1).

egan
Download Presentation

ECEN/MAE 3723 – Systems I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECEN/MAE 3723 – Systems I MATLAB Lecture 2

  2. Lecture Overview • What is Simulink? • How to use Simulink • Getting Start with Simulink • Building a model • Example 1 (Differential Equations ) • Example 2 (Transfer Function) • Creating Subsystems • Useful Information

  3. What is Simulink? (1) • A software package for modeling, simulating, and analyzing dynamic systems. • Supports linear and nonlinear systems, modeled in continuous time, sample time, or a hybrid of the two. • Systems can also be multirate (i.e. different parts that are sampled or updated at different rates)

  4. What is Simulink? (2) • For modeling, it provides a graphical user interface (GUI) for building models as block diagrams (using click-and-drag mouse operations) • Can build models in hierarchical fashion (using both top-down and bottom-up approaches) • You can simulate, analyze the output results, explore, revise your models and have FUN!

  5. Lecture Overview • What is Simulink? • How to use Simulink • Getting Start with Simulink • Building a model • Example 1 (Differential Equations ) • Example 2 (Transfer Function) • Creating Subsystems • Useful Information

  6. Click on the SIMULINK icon on toolbar Type simulink on Matlab command window Start a Simulink Session

  7. SEARCH window CREAT NEW MODEL icon BLOCK set for model construction LIBRARY Simulink Library Browser

  8. Create a New Model CREAT NEW MODEL icon Workspace where you construct your model

  9. Lecture Overview • What is Simulink? • How to use Simulink • Getting Start with Simulink • Building a model • Example 1 (Differential Equations ) • Example 2 (Transfer Function) • Creating Subsystems • Useful Information

  10. x (states) u (Input) y (Output) Building a Model • Simulink Block Diagram – pictorial model of a dynamic system • Each block represents an elementary dynamic system that produces an output (either continuous or discrete output) • Lines represent connections of block inputs to block outputs

  11. Building a Model (2) The following steps will guide you to construct a system/model: STEP 1: Creating Blocks STEP 2: Making connections STEP 3: Set Parameters STEP 4: Running Simulation

  12. Save this model This is the Sine Wave block is from the Sources library Click-Drag-Drop the Sine Wave block to Workspace Window Sources library Building a Model (3) • Step 1: Creating Blocks

  13. The Gain block is from the Math library These are from the Sinks library The Mux block is from the Signals &Systems library Building a Model (4) • Step 1: Creating Blocks

  14. To make connection: left-click while holding down control key (on keyboard) and drag from source port to a destination port A connected Model Building a Model (5) • Step 2: Making connections

  15. Double click the Gain block to set the parameter for the Gain block Name the output parameter as “out1” Gain value = 5 Building a Model (6) • Step 3: Set Parameters

  16. Click here to run the simulation click “simulation parameters” to set up the desired parameters You can change the “stop time” and then click the “OK button” Building a Model (7) • Step 4: Running Simulation

  17. Output of the scope To fit graph to frame Yellow: Input sine wave Purple: Output (sine wave with gain of 5 Double click on Scope block to display output of the scope Note: Scope block is similar to oscilloscope! Building a Model (8) • View output via Scope block

  18. You can plot the output using the plot function Three outputs show here Building a Model (9) • View output (workspace)

  19. Lecture Overview • What is Simulink? • How to use Simulink • Getting Start with Simulink • Building a model • Example 1 (Differential Equations ) • Example 2 (Transfer Function) • Creating Subsystems • Useful Information

  20. x M K B Example 1:Differential Equations (1) • Example of a dynamic system: A mass-spring-damper system The Mathematical model of the system is describe by: Lets M=2kg; B = 2 Ns/m; K=2 N/m

  21. f(t), N 1 0 Time, s Example 1:Differential Equations (2) • Use Simulink to simulate the step response of the system, i.e. STEP 1: Creating Blocks Unit Step Input

  22. Example 1:Differential Equations (2) STEP 2: Making connections

  23. Set Step time =0 Note: Assume all initial conditions = 0 Example 1:Differential Equations (3) STEP 3: Set Parameters

  24. 1 Open “simulation parameters” window 2 RUN Simulation Set “Stop time” = 30 Example 1:Differential Equations (4) STEP 4: Running Simulation

  25. Example 1:Differential Equations (5) Step Response for the mass-spring-damper system example Output from Scope block Plot system response

  26. Lecture Overview • What is Simulink? • How to use Simulink • Getting Start with Simulink • Building a model • Example 1 (Differential Equations ) • Example 2 (Transfer Function) • Creating Subsystems • Useful Information

  27. Example 2: Transfer Function (1) • Use the same mass-spring-damper system example and simulate the response using transfer function approach The transfer function of the equation (assume all initial conditions =0)

  28. Example 2: Transfer Function (2) STEP 1: Creating Blocks

  29. Example 2: Transfer Function (3) STEP 2: Making connections

  30. Set Step time =0 Example 2: Transfer Function (4) STEP 3: Set Parameters

  31. 1 Open “simulation parameters” window 2 RUN Simulation Set “Stop time” = 30 Example 2: Transfer Function (5) STEP 4: Running Simulation

  32. Example 2: Transfer Function (6) Same output as before (Slide 21) Output from Scope block Plot system response

  33. Lecture Overview • What is Simulink? • How to use Simulink • Getting Start with Simulink • Building a model • Example 1 (Differential Equations ) • Example 2 (Transfer Function) • Creating Subsystems • Useful Information

  34. Creating Subsystems (1) • Subsystem – similar to “Subroutine” • Advantage of Subsystems: • Reduce the number of blocks display on the main window (i.e. simplify the model) • Group related blocks together (i.e. More organized) • Can create a hierarchical block diagram (i.e. you can create subsystems within a subsystem ) • Easy to check for mistakes and to explore different parameters

  35. This is the Subsystem block is from the Subsystems library Creating Subsystems (2) Create Subsystem using model in Example 1 STEP 1: Creating Blocks (Main window)

  36. Creating Subsystems (3) STEP 2: Double click Subsystem block and create a model in the Subsystem block Inport (named from “sum” Outport (three outports)

  37. Creating Subsystems (4) STEP 3: Making connections (Main window)

  38. Creating Subsystems (5) STEP 4: Set Parameter (Main window) STEP 5: Running Simulation Then view output response Output from Scope block

  39. Lecture Overview • What is Simulink? • How to use Simulink • Getting Start with Simulink • Building a model • Example 1 (Differential Equations ) • Example 2 (Transfer Function) • Creating Subsystems • Useful Information

  40. Set Slope Set Start time for Ramp function Set initial value Useful Information (1) Ramp Function

  41. Input(t) 5 5 t(s) 0 Useful Information (2) Unit Step Function or Impulse Start at 0 s Start at 5.01 s

  42. Useful Information (3) • To run programs, have to be in the current active directory or in a directory in the path (goto File Set path... ) • To copy the SIMULINK Model from Simulink Workspace and add to report (EditCopy model to clipboard) • Need help on SIMULINK (At Simulink Library Browser  Click Help)

More Related