1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Ch 05 state variabe modes and simulation methods

28 154 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 28
Dung lượng 2,21 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

State Variable Models and Simulation Methods HCM City Univ.. State Variable Models - Consider the second-order equation 5? + 7? + 4? = ?? - Define ?1≡ ? ?2 ≡ ? ⟹? ? 12= ? = ? then - The

Trang 1

5 State Variable Models and

Simulation Methods

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§1 State Variable Models

- Consider the second-order equation

5𝑦 + 7𝑦 + 4𝑦 = 𝑓(𝑡)

- Define

𝑥1≡ 𝑦

𝑥2 ≡ 𝑦 ⟹𝑥 𝑥 12= 𝑦 = 𝑦 then

- These two equations, called the state equations, are the

state-variable form of the model, and the state-variables 𝑥1 and 𝑥2 are

called the state variables

- The choice of state variables is not unique, but the choice

must result in a set of first order differential equations

System Dynamics 5.01 State Variable Models and Simulation Methods

Trang 2

§1 State Variable Models

- Example 5.1.1 State-Variable Model of a Two-Mass System

Consider the two-mass system with the equations of motion

5𝑥 1+ 12𝑥 1+ 5𝑥1− 8𝑥 2− 4𝑥2= 0 3𝑥 2+ 8𝑥 2+ 4𝑥2− 8𝑥 1− 4𝑥1 = 𝑓(𝑡)Put these equations into state-variable form Solution

Define 𝑧1 ≡ 𝑥1, 𝑧2 ≡ 𝑥 1, 𝑧3≡ 𝑥2, 𝑧4≡ 𝑥 2Then 𝑧 1 = 𝑧2

§1 State Variable Models

1.Vector-Matrix Model of State-Variable Models

- Vector-matrix notation enables us to represent multiple

equations as a single matrix equation

- Example

2𝑥1+ 9𝑥2 = 53𝑥1− 4𝑥2 = 7 can be represented in the form

Trang 3

§1 State Variable Models

- Example 5.1.2 Vector-Matrix Form of a Single-Mass Model

Express the mass-spring-damper model

𝑥1

𝑥2 +

01𝑚

, 𝒃 = 01𝑚HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§1 State Variable Models

- Example 5.1.3 Vector-Matrix Form of the Two-Mass Model

Express the model

8

3 −43 −83

, 𝒃 =

0001 3 System Dynamics 5.06 State Variable Models and Simulation Methods

Trang 4

§1 State Variable Models

2.Standard Form of the State Equation

3.The Output Equation

- The output vector contains the variables that are of interest

for the particular problem at hand

𝒚 = 𝑪𝒙 + 𝑫𝒖 𝒚: 𝑝 × 1 output vector

𝑪: 𝑝 × 𝑛 state output matrix

𝑫: 𝑝 × 𝑚 control output matrix

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§1 State Variable Models

- Example 5.1.4 The Output Equation for a Two-Mass Model

Consider the two-mass model

5𝑥 1+ 12𝑥 1+ 5𝑥1− 8𝑥 2− 4𝑥2= 0 3𝑥 2+ 8𝑥 2+ 4𝑥2− 8𝑥 1− 4𝑥1 = 𝑓(𝑡)

a Suppose the outputs are 𝑥1 and 𝑥2 Determine the output

matrices 𝑪 and 𝑫

b Suppose the outputs are 𝑥2− 𝑥1, 𝑥 2, and 𝑓 Determine the

output matrices 𝑪 and 𝑫

Trang 5

§1 State Variable Models

a.The outputs are 𝑥1 and 𝑥2

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§1 State Variable Models

b.The outputs are 𝑥2− 𝑥1, 𝑥 2, and 𝑓

System Dynamics 5.10 State Variable Models and Simulation Methods

Trang 6

§1 State Variable Models

3.Model Forms having Numerator Dynamics

Consider the model with numerator dynamics or input derivatives

𝑑𝑓𝑑𝑡the state variables are not so easy to identify to put the model

in the standard form

𝒙 = 𝑨𝒙 + 𝒃𝑢

𝒚 = 𝑪𝒙 + 𝑫𝑢

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§1 State Variable Models

- Example 5.1.5 Numerator Dynamics in a First-Order System

Consider the transfer function and its corresponding equation

𝑍(𝑠)𝑈(𝑠) =

5𝑠 + 3

𝑠 + 2 , 𝑧 + 2𝑧 = 5𝑢 + 3𝑢 Demonstrate two ways of converting this model to a state-

variable model in standard form

Solution

a.Divide the numerator and denominator of the 𝑇𝐹 by 𝑠

𝑍(𝑠)𝑈(𝑠) =

5𝑠 + 3

𝑠 + 2 =

5 + 3/𝑠

1+ 2/𝑠The objective is to obtain a 1 in the denominator, which is

then used to isolate 𝑍(𝑠) as follows

System Dynamics 5.12 State Variable Models and Simulation Methods

Trang 7

§1 State Variable Models

The term within square brackets multiplying 1/𝑠 is the input

to an integrator, and the integrator’s output can be selected

as a state-variable 𝑥

𝑍 𝑠 = 𝑋(𝑠) + 5𝑈(𝑠) where 𝑋 𝑠 ≡ 1𝑠 3𝑈 𝑠 − 2𝑍 𝑠

=1

𝑠 3𝑈 𝑠 − 2 𝑋 𝑠 + 5𝑈 𝑠

=1

𝑠[−2𝑋 𝑠 − 7𝑈(𝑠)]

This gives 𝑥 = −2𝑥 − 7𝑢, with output equation 𝑧 = 𝑥 + 5𝑢

This fits the standard form

𝒙 = 𝑨𝒙 + 𝒃𝑢

𝒚 = 𝑪𝒙 + 𝑫𝑢 with 𝑨 = −2, 𝑩 = −7, 𝒚 = 𝑧, 𝑪 = 1, and 𝑫 = 5

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§1 State Variable Models

b.Rewrite the transfer function in the form

𝑍 𝑠 = (5𝑠 + 3)𝑈(𝑠)

𝑠 + 2Define the state-variable 𝑥 as follows

𝑋 𝑠 ≡ 𝑈(𝑠)

𝑠 + 2⟹ 𝑠𝑋 𝑠 = −2𝑋 𝑠 + 𝑈(𝑠) The state equation

Trang 8

§1 State Variable Models

- Example 5.1.6 Numerator Dynamics in a Second-Order System

Obtain a state-variable model for

𝑋 𝑠

𝑈 𝑠 =

4𝑠 + 75𝑠2+ 4𝑠 + 7Relate the initial conditions for the state variables to the given

initial conditions 𝑥(0) and 𝑥 (0)

§1 State Variable Models

7

5𝑈 𝑠 −

7

5𝑋(𝑠) This equation shows that 𝑋(𝑠) is the output of an integration

Thus 𝑥 can be chosen as a state variable 𝑥1

𝑋1 𝑠 = 𝑋(𝑠)The term within square brackets is the input to an integration,

and thus the second state variable can be chosen as

7

5𝑈 𝑠 −

7

5𝑋1(𝑠) then

Trang 9

§1 State Variable Models

The state equations

The standard form

𝒙 = 𝑨𝒙 + 𝒃𝑢

𝒚 = 𝑪𝒙 + 𝑫𝑢 where

4575, 𝑪 = 1 0 , 𝑫 = 0

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§1 State Variable Models

System Dynamics 5.18 State Variable Models and Simulation Methods

Trang 10

§1 State Variable Models

4.Transfer Function Versus State-Variable Models

- Both models are equally effective and equally easy to use

- The decision whether to use a transfer function model or a

state-variable model depends on many factors, including

personal preference

- Application of basic physical principles sometimes directly

results in a state-variable model

- If you need to obtain the step response as a function, it might

be easier to convert the model to transfer function form and

then use the Laplace transform to obtain the desired function

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§2 State Variable Methods with Matlab

1.Creation of transfer functions or conversion to transfer function

Function: tf(num,den)

Example

Model 5𝑥 + 7𝑥 + 4𝑥 = 𝑓(𝑡), or

𝑋(𝑠)𝐹(𝑠)=

15𝑠2+ 7𝑠 + 4Matlab sys1 = tf(1, [5, 7, 4])

Model 8𝑑𝑑𝑡3𝑥3 − 3𝑑𝑑𝑡2𝑥2 + 5𝑑𝑥𝑑𝑡 + 6𝑥 = 4𝑑𝑑𝑡2𝑓2 + 3𝑑𝑓𝑑𝑡 + 5𝑓(𝑡)

Matlab sys2 = tf([4, 3, 5], [8, -3, 5, 6])

System Dynamics 5.20 State Variable Models and Simulation Methods

Trang 11

§2 State Variable Methods with Matlab

2.Creates state-space model or converts model to state space

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§2 State Variable Methods with Matlab

3.Quick access to state-space data

Function: ssdata(sys)

Example

Matlab [A, B, C, D] = ssdata(sys1)

4.Quick access to transfer function data

Function: tfdata(sys)

Example

Matlab tfsys3 = tf(sys3)

[num, den] = tfdata(sys3, 'v')

System Dynamics 5.22 State Variable Models and Simulation Methods

Trang 12

§2 State Variable Methods with Matlab

- Example 5.2.1 Transfer Functions of a Two-Mass System

Obtain the transfer functions 𝑋1(𝑠)/𝐹(𝑠) and 𝑋2(𝑠)/𝐹(𝑠) of the

state-variable model 𝒛 = 𝑨𝒛 + 𝒃𝑓, with

8

3 −43 −83

, 𝒃 =

0001 3Solution

To derive the transfer functions for 𝑥1 and 𝑥2, we must define

the 𝑪 and 𝑫 matrices to indicate that 𝑧1 and 𝑧3 are the output

variables 𝑦1 and 𝑦2

𝑪 = 1 0 0 00 0 1 0 , 𝑫 = 0

0HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§2 State Variable Methods with Matlab

Trang 13

§2 State Variable Methods with Matlab

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§2 State Variable Methods with Matlab

5.Initial condition response of state-space models

Function: initial(sys, x0)

- Example 5.2.2 Free Response of the Two-Mass Model

Consider the state-variable model 𝒛 = 𝑨𝒛 + 𝒃𝑓, with

8

3 −43 −83

, 𝒃 =

0001 3Compute the free response 𝑥1(𝑡) for 𝑥1 0 = 5, 𝑥 1 0 = −3,

𝑥2 0 = 4, 𝑥 2 0 = 2

System Dynamics 5.26 State Variable Models and Simulation Methods

Trang 14

§2 State Variable Methods with Matlab

𝒚 = 𝑪𝒛 + 𝑫𝑓 with 𝑪 = 1 0 0 0 , 𝑫 = 0 Matlab A = [0,1,0,0;-1,-12/5,4/5,8/5;0,0,0,1;4/3,8/3,-4/3,-8/3];

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§2 State Variable Methods with Matlab

6.Impulse response of LTI models

Trang 15

§2 State Variable Methods with Matlab

9.Convert roots to polynomial

Function: poly(A)

Example

Matlab A = [0, 1; -6, -5];

poly(A)

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§3 The Matlab ode Functions

Numerical methods for solving differential equations

- Example 5.3.1 MATLAB Solution of 𝑦 = 𝑠𝑖𝑛𝑡

Use the ode45 solver for the problem 𝑦 = 𝑠𝑖𝑛𝑡, 𝑦 0 = 0 for

0 ≤ 𝑡 ≤ 4𝜋 The exact solution is 𝑦(𝑡) = 1 − 𝑐𝑜𝑠𝑡

Solution

• Create and save the function file, named sinefn.m

function ydot = sinefn(t,y) ydot = sin(t);

• Matlab [t, y] = ode45(@sinefn, [0, 4*pi], 0);

Trang 16

§3 The Matlab ode Functions

A rocket-propelled sled on a track is represented in the figure as a mass

𝑚 with an applied force 𝑓 that

represents the rocket thrust The rocket thrust initially is horizontal, but the engine accidentally

pivots during firing and rotates with an angular acceleration of

𝜃 = 𝜋/50𝑟𝑎𝑑/𝑠 Compute the sled’s velocity 𝑣 for 0 ≤ 𝑡 ≤ 6 if

𝑣(0) = 0 Rocket thrust is 4000𝑁 and the sled mass is 450𝑘𝑔

§3 The Matlab ode Functions

To obtain 𝜃(𝑡), note that

𝜃 = 𝜃

𝑡 0

𝑑𝑡 = 𝜋

50𝑡 ⟹ 𝜃 = 𝜃

𝑡 0

𝑑𝑡 = 𝜋

50

𝑡 0

𝜋

100𝑡2 𝑑𝑡

• Create and save the function file, named sled.m

function vdot = sled(t,v) vdot = 80*cos(pi*t^2/100)/9;

• Matlab [t,v] = ode45(@sled,[0 6],0);

plot(t,v,t,(80*t/9)),xlabel('t (s)'), ylabel('v (m/s)'),

System Dynamics 5.32 State Variable Models and Simulation Methods

Trang 17

§3 The Matlab ode Functions

Using the ODE solvers to solve an equation of order 2 or greater

Consider the second-order equation 5𝑦 + 7𝑦 + 4𝑦 = 𝑓 𝑡

Define the state variable

• Create and save the function file, named example1.m

function xdot = example1(t,x) xdot = [x(2); (1/5)*(sin(t)-4*x(1)-7*x(2))];

• Matlab [t, x] = ode45(@example1, [0, 6], [3, 9]);

plot(t,x)

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§3 The Matlab ode Functions

- Example 5.3.3 A Nonlinear Pendulum Model

The pendulum shown in the figure consists of a concentrated mass 𝑚 attached to a rod whose mass is small compared to 𝑚 The rod’s length

is 𝐿 The equation of motion for this pendulum

𝜃 +𝑔

𝐿𝑠𝑖𝑛𝜃 = 0 Suppose that 𝐿 = 1𝑚 and 𝑔 = 9.81𝑚/𝑠2 Use Matlab to solve

this equation for 𝜃(𝑡) for two cases

• Case 1 𝜃(0) = 0.5𝑟𝑎𝑑, 𝜃 (0) = 0

• Case 2 𝜃(0) = 0.8𝜋𝑟𝑎𝑑, 𝜃 (0) = 0

System Dynamics 5.34 State Variable Models and Simulation Methods

Trang 18

§3 The Matlab ode Functions

• Create and save the function file, named pendulum.m

function xdot = pendulum(t,x) xdot = [x(2); -9.81*sin(x(1))];

• Matlab [ta, xa] = ode45(@pendulum, [0, 5], [0.5, 0]);

[tb, xb] = ode45(@pendulum, [0, 5], [0.8*pi, 0]);

plot(ta,xa(:,1),tb,xb(:,1)),xlabel('Time (s)'),

ylabel('Angle (rad)'),gtext('Case 1'),gtext('Case 2')

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§3 The Matlab ode Functions

Matrix method Matrix operations can be used to reduce the

number of lines to be typed in the derivative function file

Consider the mass-spring-damper model 𝑚𝑦 + 𝑐𝑦 + 𝑘𝑦 = 𝑓(𝑡)

Define 𝑥1≡ 𝑦, 𝑥2 ≡ 𝑦 , the equation can be rewritten

𝑥1

𝑥2 +

01

Trang 19

§3 The Matlab ode Functions

• Create and save the function file, named msd.m

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§3 The Matlab ode Functions

System Dynamics 5.38 State Variable Models and Simulation Methods

Trang 20

§4 Simulink and Linear Models

- Type simulink in the Matlab Command window to start

Simulink

- Create a new model

- Start to use …

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§4 Simulink and Linear Models

1.Simulation Diagrams

- Simulink models is constructed using a diagram that shows

the elements of the problem to be solved Such diagrams are

called simulation diagrams

- Consider the equation

𝑦 = 10𝑓(𝑡) ⟹ 𝑦 𝑡 = 10𝑓 𝑡 𝑑𝑡

which can be thought of as two steps, using an intermediate

variable 𝑥

𝑥 𝑡 = 10𝑓 𝑡 , 𝑦 𝑡 = 𝑥 𝑡 𝑑𝑡 System Dynamics 5.40 State Variable Models and Simulation Methods

Trang 21

§4 Simulink and Linear Models

The summer is used to subtract as well as to sum variables

𝑧 = 𝑥 − 𝑦

The summer symbol can be used to represent the equation

𝑦 = 𝑓 𝑡 − 10𝑦, which can be expressed as

𝑦 𝑡 = [𝑓 𝑡 − 10𝑦]𝑑𝑡

or as

𝑦 =1

𝑠(𝑓 − 10𝑦)

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§4 Simulink and Linear Models

- Example 5.4.1 Simulink Solution of 𝑦 = 10𝑠𝑖𝑛𝑡

Use Simulink to solve the following problem for 0 ≤ 𝑡 ≤ 13

𝑑𝑦

𝑑𝑡10𝑠𝑖𝑛𝑡, 𝑦 0 = 0 The exact solution is 𝑦 𝑡 = 10 1 − 𝑐𝑜𝑠𝑡

Solution

1.Start Simulink and open a new model window

2.Select and place the Sine Wave block from Sources

category (amplitude = 1, bias = 0, frequency = 1, phase =

0, sample time = 0)

3.Select and place the Gain block from the Math category

(gain value = 10)

4.Select and place the Integrator block from the Continuous

category (initial condition = 0)

System Dynamics 5.42 State Variable Models and Simulation Methods

Trang 22

§4 Simulink and Linear Models

5.Select and place the Scope block from the Sinks category

6.Connect the input port on each block to the outport port on

the preceding block

7.Click on the Simulation menu, and click the Configuration

Parameters item Click on the Solver tab, and enter 13 for

the Stop time

8.Run the simulation by clicking on the Simulation menu, and

then clicking the Start item

9.There is a bell sound when the simulation is finished

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§4 Simulink and Linear Models

- Example 5.4.2 Exporting to the MATLAB Workspace

Demonstrate how to export the results of the simulation to

the Matlab workspace, where they can be plotted or

analyzed with any of the Matlab functions

Solution

Modify the Simulink model constructed in Example 5.4.1 with

refer to the figure

System Dynamics 5.44 State Variable Models and Simulation Methods

Trang 23

§4 Simulink and Linear Models

1.Delete the Scope block and the arrow connecting the Scope

block

2.Select and place the To Workspace block from the Sinks

category and the Clock block from the Sources category

3.Select and place the Mux block from the Signal Routing

category (number of inputs = 2)

4.Connect the top input port of the Mux block to the output port

of the Integrator block, connect the bottom input port of the

Mux block to the outport port of the Clock block

5.Specify variable name 𝑦 as the output Specify the Save

Format as Array

6.After running the simulation, to plot 𝑦(𝑡), type in the MATLAB

Command window

plot(y(:,2),y(:,1)),xlabel('t'),ylabel('y')

HCM City Univ of Technology, Faculty of Mechanical Engineering Nguyen Tan Tien

§4 Simulink and Linear Models

- Example 5.4.3 Simulink Model for 𝑦 = −10𝑦 + 𝑓(𝑡)

Construct a Simulink model to solve

𝑦 = −10𝑦 + 𝑓 𝑡 , 𝑦 0 = 1 where 𝑓 𝑡 = 2𝑠𝑖𝑛4𝑡, for 0 ≤ 𝑡 ≤ 3

Solution

Simulink model for the problem

System Dynamics 5.46 State Variable Models and Simulation Methods

Ngày đăng: 07/11/2017, 14:54

TỪ KHÓA LIÊN QUAN