Академический Документы
Профессиональный Документы
Культура Документы
his chapter is an introduction to the Model Verification Library, also referred to as the
RunTime Model Verification Library. This is the eighth library in the Simulink group of
libraries and contains the blocks shown below. The blocks in this library are intended to
facilitate creation of selfvalidating models. We use model verification blocks to check whether
the signals exceed specified limits during simulation.
91
The Check Static Lower Bound block performs a check to verify that each element of the input
signal is greater than or equal to a specified lower bound. The block's parameter dialog box allows
us to specify the value of the lower bound and whether the lower bound is inclusive. If the verification condition is true, the block takes no action. If not, simulation is halted and an error message is displayed.
Example 9.1
In the model of Figure 9.1, the amplitude of a sinusoidal signal may vary 10% from its nominal
value of 1 volt . We will configure this model to display error messages when the lower inclusive
boundary is specified as 1 volt .
The Signal Generator block is specified for a sine waveform with amplitude 1.1 volt , frequency
0.3 Hz , and the Check Static Lower Bound block is specified at 1 with the Inclusive boundary
checked, Enable assertion checked, Output assertion signal checked, and icon type graphic. The
Convert block was inserted to convert the Boolean output of the Check Dynamic Gap to double
as required by the Bus Creator block.
92
Figure 9.2. Input and output waveforms for the model of Figure 9.1
The Check Static Upper Bound block performs a check to verify that each element of the input
signal is less than or equal to a specified lower bound. The block's parameter dialog box allows us
to specify the value of the upper bound and whether the bound is inclusive. If the verification
condition is true, the block takes no action. If not, simulation is halted and an error message is
displayed.
Example 9.2
In the model of Figure 9.3, the amplitude of a sinusoidal signal may vary 10% from its nominal
value of 1 volt . We will configure this model to display error messages when the lower boundary
inclusive boundary is specified as 1 volt .
The Signal Generator block is specified for a sine waveform with amplitude 1.1 volt , frequency
0.3 Hz , and the Check Static Upper Bound block is specified at +1 with the Inclusive boundary
checked, Enable assertion checked, Output assertion signal checked, and icon type graphic. The
Convert block was inserted to convert the Boolean output of the Check Dynamic Gap to double
as required by the Bus Creator block.
The input and output waveforms are shown in Figure 9.4.
93
Figure 9.4. Input and output waveforms for the model of Figure 9.3
The Check Static Range block performs checks to verify that each element of the input signal
falls inside the same range of amplitudes. The block's parameter dialog box allows us to specify the
upper and lower bounds of the valid amplitude range and whether the range includes the bounds.
If the verification condition is true, the block takes no action. If not, simulation is halted and an
error message is displayed.
Example 9.3
In the model of Figure 9.5, the amplitude of a sinusoidal signal may vary 10% from its nominal
value of 1 volt . We will configure this model to convert a sine waveform of amplitude 1 to a pulse
waveform of the same amplitude and frequency.
94
Figure 9.6. Input and output waveforms for the model of Figure 9.5
The Check Static Gap block performs a check to verify that each element of the input signal is
less than or equal to a static lower bound, or greater than or equal to a static upper bound. If the
verification condition is true, the block takes no action. If not, simulation is halted and an error
message is displayed.
Introduction to Simulink with Engineering Applications
Copyright Orchard Publications
95
Figure 9.8. Input and output waveforms for the model of Figure 9.7
96
Figure 9.10. Input and output waveforms for the model of Figure 9.9
97
The Check Dynamic Upper Bound block performs checks to verify that the amplitude of a test
signal is greater than the amplitude of a reference signal. The test signal is the signal connected to
the input labeled sig. If the verification condition is true, the block takes no action. If not, simulation is halted and an error message is displayed.
Example 9.6
For the model of Figure 9.11 the amplitude of a sinusoidal signal may vary 10% from its nominal
value of 1 volt . We will configure the model to display error messages when the amplitude
exceeds +1 volt .
The Signal Generator block has been selected as a sine waveform with the amplitude set at 1.1,
frequency at 0.1 Hz, Constant blocks at the values shown, in the Check Dynamic Upper Bound
block the Enable assertion and Output assertion signal are checked, and the icon type is selected
as graphic. The Convert block was inserted to convert the Boolean output of the Check Dynamic
Upper Bound block to double as required by the Bus Creator block. The input and output waveforms are shown in Figure 9.12.
98
Figure 9.12. Input and output waveforms for the model of Figure 9.11
The Check Dynamic Range block performs a check to verify that a test signal falls within a range
of amplitudes. The width of the range can vary from time step to time step. The input labeled sig
is the test signal, and the inputs labeled min and max are the lower and upper bounds respectively
of the valid range. If the verification condition is true, the block takes no action. If not, simulation
is halted and an error message is displayed.
Example 9.7
The amplitude of a random waveform may vary 20% from its nominal value of 1 volt . We will
create a model using a Check Dynamic Range block to display error messages when the amplitude
exceeds 1 volt .
In Figure 9.13 the Signal Generator block has been selected as a random waveform with amplitude specified at 1.2, frequency at 1 Hz, Constant blocks with the values as indicated, in the
Check Dynamic Range block the Enable assertion and Output assertion signal are checked, and
the icon type is selected as graphic. The Convert block was inserted to convert the Boolean output of the Check Dynamic Range block to double as required by the Bus Creator block. The input
and output waveforms are shown in Figure 9.14.
99
Figure 9.14. Input and output waveforms for the model of Figure 9.13
As stated above this block performs a check to verify that a signal falls inside a range of amplitudes that varies from time step to time step.
The Check Dynamic Gap block performs checks to determine whether a gap of possibly varying
width occurs in the range of a signal's amplitudes. The test signal is the signal connected to the
input labeled sig, and the inputs labeled min and max specify the lower and upper bounds respectively of the dynamic gap. If the verification condition is true, the block takes no action. If not,
simulation is halted and an error message is displayed.
910
Figure 9.16. Input and output waveforms for the model of Figure 9.15
911
The Assertion block verifies that the elements of the signal at its input have a nonzero value. If
all elements are nonzero, the block takes no action. If any element is zero, the block halts the
simulation and displays an error message. The block's parameter dialog box allows us to specify
that the block should display an error message when the assertion fails but allows the simulation
to continue.
Example 9.9
In the model of Figure 9.17, the Signal Generator block was specified for a square waveform, inadvertently the amplitude was specified as 0, and thus the Scope block displayed 0 also. To this
model we will add an Assertion block to display an error message.
The model with the addition of an Assertion block is shown in Figure 9.18 where after the simulation command is executed, the following message is displayed:
Assertion detected in Figure_9_18/Assertion at time 0.000000
912
The Check Discrete Gradient block performs a check to determine whether the absolute value
of the difference between successive samples of the element is less than an upper bound. The
block's parameter dialog box allows us to specify the value of the upper bound whose default value
is unity. If the verification condition is true, the block takes no action. Otherwise, the block halts
the simulation and displays an error message in the Simulation Diagnostics Viewer.
Example 9.10
In Figure 9.19, the Digital Clock block has been set for Sample time 1 as shown on the Scope
block and thus the difference between successive samples is 1. We will add a Check Discrete Gradient block specifying that the value of the upper bound is unity (the default) to determine
whether an error message will be displayed.
Figure 9.19. Model for Example 9.10 without a Check Discrete Gradient block
The model with the addition of a Check Discrete Gradient block where the value of the upper
bound is specified as 1 (default), is shown in Figure 9.20. After the simulation command is executed, the following message is displayed:
Assertion detected in Figure_9_20/Check Discrete Gradient at time
1.000000.
However, if the Digital Clock block is specified for Sample time less than 1, no error message will
be displayed.
913
Figure 9.20. Model for Example 9.2 with a Check Discrete Gradient block
The Check Input Resolution block performs a check to determine whether the input signal has a
specified scalar or vector resolution.* If the resolution is a scalar, the input signal must be a multi3
ple of the resolution within a 10 tolerance. If the resolution is a vector, the input signal must
equal an element of the resolution vector. If the verification condition is true, the block takes no
action. If not, simulation is halted and an error message is displayed.
In general, the resolution of an n bit analog-to-digital (A/D) converter that spans an input voltn
age of X volts is given by X ( 2 1 ) where n is the number of bit. For instance, an A/D converter with a range of 0 to 12 volts, with n = 8 the range is divided to 12 255 47.1 mV so the
resolution is 47.1 mV .
Example 9.11
In the model of Figure 9.21, the resolution for both Check Input Resolution blocks is specified as
the row vector
* Accuracy and resolution have different meaning. Accuracy is the degree with which an instrument measures a
variable in terms of an accepted standard value or true value; usually measured in terms of inaccuracy but
expressed as accuracy; often expressed as a percentage of full-scale range. Resolution is the smallest change in
the parameter being measured that causes a detectable change in the output of the instrument. For a detailed discussion on accuracy and resolution, please refer to Electronic Devices and Amplifier Circuits with MATLAB
Applications, ISBN 0-9709511-7-5.
914
and the Enable assertion and Output assertion signal is checked. The values 1 (true) and 0 (false)
in the Display blocks are justified as follows:
Since the resolution specified in the Check Input Resolution blocks is a vector, the input signal
must be equal to an element of the resolution vector. The resolution specified in the Constant 1
block is an element of the resolution vector and thus the output is 1 indicating a True condition.
However, the resolution specified in the Constant 2 block is not an element of the resolution vector and thus the output is 0 indicating a False condition.
915
916
Summary
upper bounds of the valid range at the current time step. If the verification condition is true,
the block takes no action. If not, the block halts the simulation and displays an error message.
The Check Dynamic Gap block performs checks to determine whether a gap of possibly varying width occurs in the range of a signal's amplitudes. The test signal is the signal connected to
the input labeled sig. The inputs labeled min and max specify the lower and upper bounds of
the dynamic gap, respectively. If the verification condition is true, the block takes no action. If
not, the block halts the simulation and displays an error message.
The Assertion block verifies that the elements of the signal at its input have a non-zero value.
If all elements are non-zero, the block takes no action. If any element is zero, the block halts
the simulation, by default, and displays an error message. The block's parameter dialog box
allows us to specify that the block should display an error message when the assertion fails but
allows the simulation to continue.
The Check Discrete Gradient block performs a check to determine whether the absolute
value of the difference between successive samples of the element is less than an upper bound.
The block's parameter dialog box allows us to specify the value of the upper bound (1 by
default). If the verification condition is true, the block takes no action. Otherwise, the block
halts the simulation and displays an error message in the Simulation Diagnostics Viewer.
The Check Input Resolution block performs a check to determine whether the input signal
has a specified scalar or vector resolution. If the resolution is a scalar, the input signal must be
3
a multiple of the resolution within a 10 tolerance. If the resolution is a vector, the input signal must equal an element of the resolution vector. If the verification condition is true, the
block takes no action. If not, the block halts the simulation and displays an error message.
917
2. It is known that noise voltages generated within the circuitry of an analogtodigital converter
are 0.75 mv 10% . Create a model using a Check Dynamic Gap block to display error messages when the amplitude exceeds this range.
3. For the models shown below, the resolution in both Check Input Resolution blocks 1 and 2 has
been specified as
12
------------------n
(2 1)
with n = 9 . What is the maximum value that can be specified in Constant block 1 to cause
the Display 1 block to display 0 (False), and what is the minimum value that will cause the
Display 2 block to display 1 (True)?
918
The Assertion block detects a 0 value at the start of the simulation time, in this case 10 seconds as shown by the Clock block, and thus in MATLABs Command Window it outputs the
message:
Assertion detected in 'Exercise_9_1/Assertion' at time 0.000000.
However, the simulation continues for 10 seconds since the Stop simulation when assertion
fails is unchecked.
2.
The model and input and output waveforms are shown below. Since voltage noise occurs in
random, we set the Signal Generator block for Random waveform with amplitude 0.01 and
frequency at 0.1 Hz . To allow for the 10% tolerance from the nominal 0.75 mv value, we set
the Constant blocks for +0.0085 and 0.0085 .
The output waveform is logic 0 (False) whenever assertions are detected, and jumps to 1
(True) when no assertions are detected. The precise times when assertions are detected are
displayed in MATLABs Command Window.
919
Since the resolution specified in both Check Input Resolution blocks is the scalar
12 -----------------9
(2 1)
tolerance. Since,
12
------------------- = 0.0235
9
(2 1)
any value equal of greater than 0.0235 will cause a display 1 (True), and any value less than
0.0235 will cause a display of 0 (False) as shown in the models below.
Upon execution of the Simulation command, MATLABs Command Window displays Assertions detected in the Check Input Resolution block 1 from 0 to 10 in steps of 0.2.
920