Observers allow you to you monitor the dynamic response of your system model while preserving the system model design and system result integrity. Observers are the Observer Reference block and the Observer Port block. The Observer Reference block wirelessly links a system model to an Observer model, which houses a verification subsystem. Inside an Observer model, you use Observer Port blocks to send signals from the system model to the verification subsystem.
The Observer Reference block does not have inports or outports. You map your Simulink®signals to Observer Port blocks, which are contained within the Observer model. The Observer Port blocks are mapped to output data from your system model. Once the Observer Port blocks are mapped to a signal, you connect that signal line to the verification subsystem within the Observer model. Running your system model also causes the linked Observer model to run.
This wireless access allows you to use Observers to monitor your system model without causing changes to the system. Observers allow you to create a clear differentiation between your system design and verification subsystems.
For your Observer model to simulate, do not:
Use a library model as an Observer model
Include an Observer Reference block within an Observer model
Reference the system model that contains the Observer Reference block from the Observer Reference block
Use root inports within an Observer model
Generate code from a system model that includes an Observer Reference model
The Observer Reference block references a separate verification model that you use to verify your system model. To add an Observer Reference block to your system model, right-click the top level of your Simulink canvas. In the contextual menu, select Observers > Add Observer here.
An Observer Reference block is added to your system model, and an Observer model is created. You must save the Observer model in a writable folder on the MATLAB® path.
To connect an Observer Reference block to an Observer model that you have already created, first save your Observer model in a writable folder on the MATLAB path. Next, open the Observer Reference block parameters by right-clicking the Observer Reference block. Select Block Parameters (ObserverReference).
Enter the name of the Observer model that you want to connect to your system and select Apply. When you double click your Observer Reference block, your Observer model opens in a new window.
To create an Observer model that is mapped to a signal line in your model, select and right-click on one or more signals that you want to verify. Select Observers > Observe Selected Signals > New Observer. Simulink creates a new Observer model and adds an Observer Reference block to your system model.
Each Observer Reference block contains one or more Observer Port blocks. After mapping an Observer Port block to an object or signal within a system model, the Observer Port block outputs the same output as its mapped object.
A new Observer Port block shows a line through the signal symbol, signifying that the block is not mapped to a signal.
To map an Observer Port block to a signal on your system model, right-click on an Observer block and select Observers > Manage Observer.... This opens the Observer Dialog box. Within the Observer Dialog box you can:
Filter and select signals for observation
Add, remove, or configure Observer Port blocks
On the left-hand side of the Observer Dialog box is the Observable Area pane. The Observable Area pane displays the block hierarchy and observable outputs of your model. Observed signals appear bold in the hierarchy.
The right hand side of the Observer Dialog box shows the Observer pane. The Observer pane displays the block hierarchy within the Observer Reference block. An Observer Port block that is mapped to a signal appears bold and displays the signal to which it is attached. Once the Observer Port is mapped to a signal, the symbol updates to show that the Observer Port is attached to a signal.
To view the full path of an observed object, hover your cursor over the Observer Port block.
If you change the name of an observed signal in your system model, the Observer Reference block updates the name of the output signal from the Observer Port block. If a signal is not named and does not have a label, the output of the Observer Port block is set to an empty string.
To map a signal to an Observer Port block, open the Observer Dialog box. In the Observable Area pane, select the signal that you want to observe. You can map the signal to an existing Observer Port block by redirect Observer Port icon. You can also map the signal to a new Observer Port block by selecting the add new Observer Port icon. You can then connect the signal to a verification subsystem to test your results.
The Observer model is used to monitor signals in your system model and checks that your system model is running within specified parameters. With or without an Observer Reference block, your system model simulation results are the same. The Observer Reference block does not affect the compilation of your system model and supports only normal simulation mode. The Observer Reference block supports multiple execution rates, continuous dynamics, and zero crossings.
Before running a system model that includes an Observer Reference block, configure your system model and your Observer model to use a fixed-step solver. See Fixed Step Solvers in Simulink (Simulink). Set the simulation mode for both to normal. These signal types are supported:
This example shows how to use an Observer
Reference block to wirelessly observe
signals and verify results. In this system, the plant is
modeled using Simulink, and the controller is modeled using
Stateflow®. The goal of the example is to monitor the
temperature of the heat pump as well as when the pump is
cooling or heating the room. Cooling and heating are denoted
by which direction the fan is blowing. The data name is
pump_dir, and it is connected
to port 3 in the Stateflow chart.
To open this example, enter:
To create a new Observer model to measure the temperature of the
pump, open the plant model and highlight the signal
T. Right-click the highlighted
signal and select Observers > Observe selected
signals > New Observer. Simulink adds an Observer
Reference block to your system model and
creates a new Observer model called
The Observer model contains an Observer Port
block that is mapped to the signal
Save the new Observer model in a writable folder.
Add a second Observer Port block to your Observer
model. Double-click the Observer Port to open
the Observer Dialog. In the Observer pane, the second
ObserverPort1, is listed below
the first port.
To map the second
ObserverPort1 to the
pump_dir, click on
Outport3. Once both are
highlighted, click the Reconfigure button .
The two Observer Port blocks are now both mapped to the signals and are ready to be connected to scopes or a verification subsystem.
To convert a verification subsystem to an Observer Reference block, right-click the verification subsystem. Select Observers > Move selected block to Observer > New Observer. This operation can not be undone.
In this example, a cruise control system generates the trottle and the target speed. The Safety Properties block is a verification subsystem that verifies the safety of the cruise control system.
By converting the verification subsystem to an Observer Reference block, you remove the signals that link the verification subsystem to the system model while preserving the ability to test the integrity of the system.
The two signals,
output1, are automatically
mapped to two Observer Port blocks within the