Académique Documents
Professionnel Documents
Culture Documents
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.
31
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.
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
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)
33
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
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
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.
(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.
36
(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)
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
(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.
37
Upon execution of the Simulation start command, the Scope displays the waveform shown in Figure 3.9.
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.*
* We may need to stretch the block to see the entire block shown above.
38
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.
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.13. Input and output waveforms for the model of Figure 3.12
39
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
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.
311
Figure 3.17. Signal Generator block and Variable Time Delay block for the model of Figure 3.16
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.
312
Figure 3.19. Input and output waveforms for the model of Figure 3.18
313
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
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 ) )
315
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
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
317
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
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
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.
319
320