Vous êtes sur la page 1sur 20

Chapter 3

The Continuous Blocks Library

his chapter is an introduction to the Continuous Blocks library. This is the second library
in the Simulink group of libraries and contains the ContinuousTime Linear Systems
SubLibrary, and the ContinuousTime Delays SubLibrary blocks shown below. We
will describe the function of each block included in this library and we will perform simulation
examples to illustrate their application.

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

31

Chapter 3 The Continuous Blocks Library


3.1 The ContinuousTime Linear Systems SubLibrary
The ContinuousTime Linear Systems SubLibrary contains the blocks described in Subsections 3.1.1 through 3.1.5 below.

3.1.1 The Integrator Block

The Integrator block is described in Section 2.14, Chapter 2, Page 220.

3.1.2 The Derivative Block

The Derivative block approximates the derivative of its input. The initial output for the block is
zero. The accuracy of the results depends on the size of the time steps taken in the simulation.
Smaller steps allow a smoother and more accurate output curve from this block. Unlike blocks
that have continuous states, the solver does not take smaller steps when the input changes rapidly. Let us consider the following simple example.
Example 3.1
We will create a model that will compute and display the waveform of the derivative of the function y = cos x .
The model is shown in Figure 3.1, and the input and output waveforms are shown in Figure 3.2.

Figure 3.1. Model for Example 3.1

To convert the sine function in the Sine Wave block to a cosine function, in the Source Block
Parameters dialog box we specify Phase = 2 . As we know, the derivative of the cosine function is the negative of the sine function and this is shown in Figure 3.2.

32

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

The ContinuousTime Linear Systems SubLibrary


To scale the vertical axis in Figure 3.2, we move the cursor near that axis, we rightclick, and we
set the values as indicated. We will follow this practice in subsequent illustrations.

Figure 3.2. Input and output waveforms for the model of Figure 3.1

The Simulink Help for the derivative block states that using the MATLAB function linmod to
linearize a model that contains a Derivative block can be troublesome. Let us elaborate on linearization.
We prefer to work with linear functions since the slope is constant and thus we can find the output for any input. Unfortunately, the equations that describe the behavior of most physical phenomena are nonlinear. If we are interested in values of the function close to some point (a,b), we
can replace the given function by its first Taylor polynomial, which is a linear function.* We recall
that the Taylor series are defined as in relation (3.1) below.
(n)

f ( x 0 )
f ( x0 )
2
n
f ( x ) = f ( x 0 ) + f ( x 0 ) ( x x 0 ) + ---------------- ( x x 0 ) + + ------------------- ( x x 0 )
2!
n!

(3.1)

In (3.1), the first two terms on the right side define an equation of a straight line, i.e., y = mx + b ,
2

a linear function. For example, if y = f ( x ) = x , the first two terms on the right side of (3.1) at
point x=3 are represented by 9 + 6 ( x 3 ) = 6x 9 . The same is true for a function f of two variables, say x and y , i.e., f ( x, y ) , where if we let L denote the local linearization at the point ( a, b ) ,
we get
f
f
L ( x, y ) = f ( a, b ) + ----- ( a, b ) ( x a ) + ----- ( a, b ) ( y b )
y
x

(3.2)

* The first Taylor polynomial is often called the local linearization.

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

33

Chapter 3 The Continuous Blocks Library


Relation (3.2) yields the three numbers required to define the local linearization. The first number
is the value of f at point ( a, b ) , the second is the value of the partial derivative with respect to x
at point ( a, b ) , and the third is the value of the partial derivative with respect to y at point ( a, b ) .
2

Taking the partial derivative of z = f ( x, y ) = x + y and evaluating it at the point ( 1, 2 ) we find


that the local linearization is w = L ( 1, 2 ) = 5 + 2 ( x 1 ) + 4 ( y 2 ) . We observe that this local
linearization contains x and y terms of first degree. We can plot these functions with the following MATLAB script. The plot is shown in Figure 3.3.
x=-3:0.01:3; y=x; z=x.^2+y.^2;...
w=5+2.*(x1)+4.*(y2);...
plot(x,z,x,w); grid

Figure 3.3. An example of linearization at a specified point

MATLAB provides three functions to extract linear functions in the form of statespace matrices
A , B , C , and D . We recall that the inputoutput relationship in terms of these matrices is
x = Ax + Bu
y = Cx + Du

(3.3)

where x represents the state(s), u the input, and y the output, and the inputs and outputs must
be Inport and Outport blocks. Other blocks cannot be used as inputs and outputs.
Example 3.2
We will use the MATLAB linmod(x) function to extract the linear model for the model shown
in Figure 3.4.
We save the given model as Figure_3_4, and in MATLABs Command Window we execute the
command [A,B,C,D]=linmod('Figure_3_4'). MATLAB displays the four matrices as

34

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

The ContinuousTime Linear Systems SubLibrary

Figure 3.4. Model for Example 3.2

A =
-5

1
0

-6

0
1

-1

0
-2

B =
1
0
0
C =
0

D =
0
and thus the model of Figure 3.4 can be represented as
x =

5 6 1
1
x
+
1 0 0
0 u
0 1 2
0

y = 0 1 0 x+ 0 u

The Simulink Extras library contains the Switched derivative for linearization block and the
Switched transport delay for linearization block. The former should be used in place of the
derivative when we are linearizing the model. It approximates the derivative with a proper transfer function. The latter delays the input by a specified amount of time. It can be used to simulate a
time delay.
To avoid possible problems with derivatives we can incorporate the derivative block in other
blocks.
Example 3.3
Let us consider the model of Figure 3.5.
Introduction to Simulink with Engineering Applications
Copyright Orchard Publications

35

Chapter 3 The Continuous Blocks Library

Figure 3.5. Model with derivative block

Recalling that differentiation in the time domain corresponds to multiplication by s in the complex frequency domain minus the initial value of f ( t ) at t = 0 , that is,
d

f ' ( t ) = ----- f ( t ) sF ( s ) f ( 0 )
dt

and assuming that the initial value is zero, we can replace the model of Figure 3.5 with that of Figure 3.6.

Figure 3.6. Model equivalent to the model of Figure 3.5

3.1.3 The StateSpace Block

The State-Space block implements a system defined by the statespace equations


x = Ax + Bu
y = Cx + Du

(3.4)

where x and u are column vectors, matrix A must be an n n square matrix where n represents
the number of the states, matrix B must have dimension n m where m represents the number
of inputs, matrix C must have dimension r n where r represents the number of outputs, and
matrix D must have dimension r m .
For examples with the statespace block please refer to Chapter 1, Examples 1.1 and 1.2.

3.1.4 The Transfer Fcn Block

36

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

The ContinuousTime Linear Systems SubLibrary


The Transfer Fcn block implements a transfer function where the input V in ( s ) and output
V out ( s ) can be expressed in transfer function form as the following equation
V out ( s )
G ( s ) = ----------------V in ( s )

(3.5)

Example 3.4
Let us consider the op amp circuit of Figure 3.7.
R1
Vin (s)

R2

R3

1/sC2

1/sC1

Vout (s)

Figure 3.7. Circuit for Example 3.3 to be simulated.

It can be shown* that the transfer function of the op amp circuit of Figure 3.7 is given by
V out ( s )
1
- = ---------------------------------------------------------------------------------------------------------------------------------G ( s ) = ----------------R 1 [ ( 1 R 1 + 1 R 2 + 1 R 3 + sC 1 ) ( sR 3 C 2 ) + 1 R 2 ]
V in ( s )

(3.6)

and this transfer function describes a second order lowpass filter. For simplicity, we let
R1 = R2 = R3 = 1
C1 = C2 = 1 F

and by substitution of these values into (3.6) we obtain


V out ( s )
1
- = -------------------------------G ( s ) = ----------------2
V in ( s )
[s + 3s + 1]

(3.7)

Assuming that the input V in ( s ) is the unit step function, we will create a model using the Transfer Fcn block to simulate the output V out ( s ) .
The model is shown in Figure 3.8 where in the Function Block Parameters dialog box for the
Transfer Fcn block we have entered 1 for the numerator and [ 1 3 1 ] for the denominator.

* The derivation of this transfer function is shown in Chapter 4, Signals and Systems with MATLAB Applications, ISBN 0-9709511-6-7.

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

37

Chapter 3 The Continuous Blocks Library

Figure 3.8. Model for Example 3.4

Upon execution of the Simulation start command, the Scope displays the waveform shown in Figure 3.9.

Figure 3.9. Output waveform for the model of Figure 3.8

3.1.5 The ZeroPole Block

The Zero-Pole block implements a system with the specified zeros, poles, and gain in the s
domain. This block displays the transfer function depending on how the parameters are specified:
1. If each is specified as an expression or a vector, the icon shows the transfer function with the
specified zeros, poles, and gain. If we specify a variable in parentheses, the variable is evaluated.
For example, if in the Function Block Parameters dialog box we specify Zeros as [2 4 6 8], Poles
as [1 3 5 7 9], and Gain as 25, the block looks like as shown in Figure 3.10.*

Figure 3.10. The Zero-Pole block specified in vector form

* We may need to stretch the block to see the entire block shown above.

38

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

The ContinuousTime Linear Systems SubLibrary


2. If each is specified as a variable, e.g., zeros, poles, Gain, in MATLABs Command Window we
enter
zeros=[2 4 6 8]; poles=[1 3 5 7 9]; Gain=25;

the block shows the variable name followed by (s) if appropriate. For this example the block
appearance will be as shown in Figure 3.11.

Figure 3.11. The Zero-Pole block specified as variables

Example 3.5
The system transfer function of a system has a gain factor of 1.5 , zeros at 2 j , and poles at 3
and at 1 j . We will create a model to display the step response of this system.
The model and the input and output waveforms are shown in Figures 3.12 and 3.13 respectively.

Figure 3.12. Model for Example 3.5

Figure 3.13. Input and output waveforms for the model of Figure 3.12

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

39

Chapter 3 The Continuous Blocks Library


3.2 The ContinuousTime Delays SubLibrary
The ContinuousTime Delays SubLibrary contains the blocks described in Subsections 3.2.1
through 3.2.3 below.

3.2.1 The Transport Delay Block

The Transport Delay block delays the input by a specified amount of time. It can be used to simulate a time delay. At the start of the simulation, the block outputs the Initial input parameter
until the simulation time exceeds the Time delay parameter. The Time delay parameter must be
nonnegative. Best accuracy is achieved when the delay is larger than the simulation step size.
Example 3.6
For the model shown in Figure 3.14, the Time delay in the Function Block Parameters dialog box
is specified as 2, and this delay is shown in Figure 3.15.

Figure 3.14. Model to illustrate the use of the Transport Delay block

Figure 3.15. Input and output waveforms for the model of Figure 3.14

310

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

The ContinuousTime Delays SubLibrary


When an output is required at a time that does not correspond to the times of the stored input
values, the Transport Delay block interpolates linearly between points. For a more detailed discussion please refer to the Help menu for this block.
The Transport Delay block does not interpolate discrete signals. Instead, it returns the discrete
value at the required time.

3.2.2 The Variable Time Delay Block

The Variable Time Delay block and the Variable Transport Delay block appear as two blocks in
the Simulink block library. However, they are actually the same builtin Simulink block with different settings of a Select delay type parameter. In the Variable Time Delay mode, the block has a
data input, a time delay input, and a data output. The block's output at the current time step
equals the value of its data input at a previous time which is equal to the current simulation time
minus a delay time specified by the block's time delay input.
Example 3.7
The model in Figure 3.16 shows a Variable Time Delay block where the Signal Generator block
output is a square wave and the Constant block is set to the value 0.5 to introduce a delay of 0.5
second. The input and output of the Variable Time Delay block are shown in Figure 3.17.

Figure 3.16. Model with Variable Time Delay

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

311

Chapter 3 The Continuous Blocks Library

Figure 3.17. Signal Generator block and Variable Time Delay block for the model of Figure 3.16

3.2.3 The Variable Transport Delay Block

In the Variable Transport Delay block the output is equal to the value of its data input at an earlier time which is equal to the current time minus a transportation delay. If we let u ( t ) be the
input, t d ( t ) the transportation delay, and y ( t ) the output, then
y = u ( t td ( t ) )

(3.8)

Example 3.8
From electric circuit theory, we know that an alternating current i C through a capacitor C leads
the voltage v C by 90 . Using a Variable Transport Delay block, we will create a model that will
display the current and voltage waveforms.
The model and the input and output waveforms are shown in Figures 3.18 and 3.19 respectively.

Figure 3.18. Model for Example 3.8

312

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

The ContinuousTime Delays SubLibrary

Figure 3.19. Input and output waveforms for the model of Figure 3.18

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

313

Chapter 3 The Continuous Blocks Library


3.3 Summary
The Integrator block outputs the integral of its input at the current time step.
The Derivative block approximates the derivative of its input. The block accepts one input
and generates one output. The initial output for the block is zero. For nonlinear models, we
can use the MATLAB function linmod to linearize a model that contains a Derivative block.
To avoid problems, it is recommended that before linearizing we replace troublesome blocks
with blocks found in the Simulink Extras library in the Linearization sublibrary. To avoid possible problems with derivatives we can incorporate the derivative block in other blocks.
MATLAB provides three functions to extract linear functions in the form of state-space matrices A , B , C , and D . The input-output relationship in terms of these matrices is
x = Ax + Bu
y = Cx + Du

where x represents the state(s), u the input, and y the output, and the inputs and outputs
must be Inport and Outport blocks. Source and Sink blocks cannot be used as inputs and outputs.
The Simulink Extras library contains the Derivative for linearization block and the Transport
Delay block. The former should be used in place of the derivative when we are linearizing the
model. It approximates the derivative with a proper transfer function. The latter delays the
input by a specified amount of time. It can be used to simulate a time delay.
The State-Space block implements a system defined by the state-space equations
x = Ax + Bu
y = Cx + Du

where x and u are column vectors, A and C must be matrices conformable for multiplication
with x , and B and D must be matrices conformable for multiplication with u .
The Transfer Fcn block implements a transfer function where the input V in ( s ) and output (y)
can be expressed in transfer function form as the following equation
V out ( s )
G ( s ) = ----------------V in ( s )

The Zero-Pole block implements a system with the specified zeros, poles, and gain in the sdomain. The Zero-Pole block displays the transfer function depending on how the parameters
are specified. If each is specified as an expression or a vector, the icon shows the transfer function with the specified zeros, poles, and gain. If we specify a variable in parentheses, the variable is evaluated.

314

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

Summary
The Transport Delay block delays the input by a specified amount of time. It can be used to
simulate a time delay. At the start of the simulation, the block outputs the Initial input parameter until the simulation time exceeds the Time delay parameter, when the block begins generating the delayed input. The Time delay parameter must be nonnegative. Best accuracy is
achieved when the delay is larger than the simulation step size.
The Variable Time Delay block and the Variable Transport Delay block appear as two blocks
in the Simulink block library. However, they are actually the same built-in Simulink block with
different settings of a Select delay type parameter. In the Variable Time Delay mode, the block
has a data input, a time delay input, and a data output. The block's output at the current time
step equals the value of its data input at a previous time equal to the current simulation time
minus a delay time specified by the block's time delay input.
In the Variable Transport Delay block the output at the current time step is equal to the
value of its data input at an earlier time equal to the current time minus a transportation delay.
If we let u ( t ) be the input, t d ( t ) the transportation delay, and y ( t ) the output, then
y = u ( t td ( t ) )

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

315

Chapter 3 The Continuous Blocks Library


3.4 Exercises
1. Using MATLABs linmod(x) function, express the model below in statespace form.

2. Create a model that includes a Transfer Fcn block to simulate the output v out of the circuit
below where R g represents the internal resistance of the applied (source) voltage v g , and R L
represents the resistance of the load that consists of R L , L , and C . The values of the circuit
constants are R g = 100 , R L = 1 K , L = 10 mH , and C = 500 F .
+
RL
Rg

vg

v out

3. From electric circuit theory, it is known that charging a capacitor with a constant current produces a linear voltage across it, that is,
I
V C = ---- t
C

where C is the capacitance in farads, I is the constant current through the capacitor in
amperes, and V C is the linear voltage across the capacitor in volts. Using a Variable Transport
Delay block create a model to display the output if I = 2 mA , C = 1000 F , and the voltage
across the capacitor at some time t 0 is V 0 = 2 v .

316

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

Solutions to EndofChapter Exercises


3.5 Solutions to EndofChapter Exercises
1. The first step is to replace the source and sink blocks with Inport and Outport blocks as shown
below. This model is saved as Exercise_3_1A.

From MATLABs Command Window we execute the statement


[A,B,C,D]=linmod('Exercise_3_1A')

and MATLAB displays


A =
3
10

0
-1

B =
1
0
C =
1
0

0
1

D =
0
0
Therefore, the linear model of the given model in state-space form is expressed as
x =

3 0 x+ 1 u
10 1
0

y = 1 0 x+ 0 u
0 1
0

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

317

Chapter 3 The Continuous Blocks Library


2.
The s domain equivalent circuit is shown below.
+
RL
Rg

V in ( s )

V out ( s )

sL
1----sC

The transfer function G ( s ) is readily found by application of the voltage division expression
R L + sL + 1 sC
V out ( s ) = ---------------------------------------------------- V in ( s )
R g + R L + sL + 1 sC

Then,
R L + Ls + 1 sC
V out ( s )
- = --------------------------------------------------G ( s ) = ----------------V in ( s )
R g + R L + Ls + 1 sC
2

LCs + R L Cs + 1
V out ( s )
- = ----------------------------------------------------------G ( s ) = ----------------2
V in ( s )
LCs + ( R g + R L )Cs + 1

With R g = 100 , R L = 1 K , L = 10 mH , and C = 500 F , the transfer function


becomes
6 2
4
V out ( s )
5 10 s + 5 10 s + 1
- = -------------------------------------------------------------------G ( s ) = ----------------6 2
4
V in ( s )
5 10 s + 5.5 10 s + 1
2
5
V out ( s )
s + 500s + 2 10
G ( s ) = ----------------- = ---------------------------------------------2
5
V in ( s )
s + 550s + 2 10

This transfer function is very nearly unity for all values of the variable s and thus we expect
the output to be the same as the input. In the model shown below, the Signal Generators
waveform was chosen as sawtooth with amplitude 2 and frequency 0.25 Hz.

318

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

Solutions to EndofChapter Exercises

3.
I
3
V C = ---- t = 2 10 t
C
Slope = m = I C . Then
3

I
2 10
m = ---- = -------------------- = 2
3
C
10
I
V C = ---- t = 2t
C

For V C = V 0 = 2 v
2
t = t 0 = --- = 1 s
2

The model and the input and output are shown below where the slope for the Ramp block is
set to 2 and the time delay of 1 second is specified by the Constant block.

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

319

Chapter 3 The Continuous Blocks Library

320

Introduction to Simulink with Engineering Applications


Copyright Orchard Publications

Vous aimerez peut-être aussi