modeling algebraic systems - technionesml.iem.technion.ac.il › wp-content › uploads › 2015 ›...

19
© 2015 The MathWorks, Inc. Modeling Algebraic Systems Simulink ® for System and Algorithm Modeling

Upload: others

Post on 06-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

© 2015 The MathWorks, Inc.

Modeling Algebraic Systems

Simulink® for System and Algorithm Modeling

Page 2: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 2Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Outline

• Defining the system and identifying its components

• Modeling the system with equations

• Starting Simulink

• Building a block diagram for the model

• Defining the model parameters

• Defining the model I/O

• Simulating the system

• Creating signal viewers

• Modifying solver settings

• Validating the simulation results

Page 3: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 3Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Defining the System and Identifying Its Components One of the outputs of the throttle subsystem is its angle.

This is computed in radians and needs to be translated to

degrees for analysis, and then translated to voltage for use in

the controller by a potentiometer.

Before modeling the system with equations, answer the

following questions:

• How many inputs?

• How many outputs?

• How many states?

• What are the parameters?

• Are there any intermediate signals?

radians voltsdegrees

Page 4: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 4Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Modeling the System with Equations

• The following equation describes the relationship between

the angle in radians, u, and the position in volts, y.

• Compute y using a lookup table that linearly interpolates

between points to determine voltages for angles that fall

between 0 and 90 degrees.

)(905.4

)(05.0

*/180

throttleopenifV

throttleclosedifVy

u

Page 5: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 5Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Starting Simulink

• Open the Simulink Library Browser by typing simulink at

the MATLAB command line or by selecting the icon.

Page 6: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 6Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Using the Simulink Library Browser

Blockset

Library

Block

Block Description

Block Search

Page 7: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 7Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Building a Block Diagram for the Model

Page 8: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 8Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Adding Blocks

To add blocks, drag and

drop them from the

Simulink Library Browser

into the model.

Page 9: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 9Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Connecting Blocks

• To connect blocks, select the output port of the source

block, and then left-click and drag a line to the destination

block.

Page 10: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 10Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Defining the Block Parameters

• To view and modify block parameters, double-click the

block icon.

Set the Gain value to 180/pi.

(degrees = 180/pi * radians)

Page 11: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 11Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Defining the Lookup Table Parameters• To compute y from the throttle angle in degrees using

the Lookup Table block, define the following parameters:

• The Vector of input values are [0 90]

• The Vector of output values are [.5 4.5]

• Select Interpolation-Use End Values as the

Look-up method.

Page 12: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 12Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Labeling Blocks and Signals

• To rename a block, click the block label and edit.

• Block labels must be unique.

• To label a signal, double-click the signal line and enter

text.

>> etc_r2v1

Page 13: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 13Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Defining the System Input

• Signals fed in from root-level Inports can be loaded from the MATLAB workspace.

• Select the Data Import/Export option from the Configuration Parameters dialog box.

>> t = linspace(0,10,100)';

>> u = linspace(0,pi/2,100)';

Page 14: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 14Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Defining the System Output

• Signals fed to root-level Outport blocks can be saved to the MATLAB workspace.

• Signals are written to the workspace when the simulation is stopped or paused.

• Select the Data Import/Export option from the Configuration Parameters dialog box.

• Select Output and Time from Save to workspace. The voltage signal is written to the variable yout.

Page 15: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 15Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Simulating the Model and Visualizing the Response

>> plot(t,u,tout,yout,'k:')

>> xlabel('simulation time')

>> legend('input angle (rad)','output (volts)')

Start Simulation

Page 16: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 16Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Adding Signal Viewers

Page 17: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 17Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Modifying Solver Settings

To select a solver,

• Select Simulation Configuration Parameters.

• Select the Solver option at the left of the dialog.• Set the Type to Fixed-Step and the Solver to

discrete(no continuous states)

• Select OK to confirm settings.

>> etc_r2v3

Page 18: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 18Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Simulating and Analyzingthe Response

Auto-scale scope axis

>> etc_r2v3

Page 19: Modeling Algebraic Systems - Technionesml.iem.technion.ac.il › wp-content › uploads › 2015 › 12 › 3.pdfDefining the System and Identifying Its Components One of the outputs

3 - 19Modeling Algebraic Systems

© 2006 The MathWorks, Inc.

Summary

• Defining the system and identifying its components

• Modeling the system with equations

• Starting Simulink

• Building a block diagram for the model

• Defining the model parameters

• Defining the model I/O

• Simulating the system

• Creating signal viewers

• Modifying solver settings

• Validating the simulation results