Define Trigger Properties
This example shows how to specify triggers. After you create faults and assign behaviors to them, you can specify how and when each fault is injected. Although you can select more than one fault for simulation, you can select only one active fault on each model element. See Define and Model Faults.
Video Walkthrough
For a walkthrough of the example, play the video.
After you create faults and assign behaviors to them, you can specify how and when each fault is injected. Although you can simulate a model that contains more than one fault, you can select only one active fault on each model element. To start, open the example model and set up the faults by entering these commands.
The model contains faults on each input signal of the two controller subsystem. The throttle signal contains two faults, and the other signals contain one fault. In this example, define the trigger properties so the fault on the throttle signal, named throttle fault, and the fault on the speed signal inject after 25 seconds of simulation time.
To start, click the Fault Badge on the throttle signal. In the preview window, click the Fault Operations button and click Properties. The property inspector opens and displays the fault properties. When you create faults, you can specify how and when they inject by specifying the trigger. When the trigger is true, the fault is injected.
In the trigger section, set the trigger type property to Timed and set the trigger fault at time property to 25. Go ahead and repeat these steps for the fault on the speed signal.
You can also create conditional triggers based on expressions or the values of model elements. For more information, see the Create and Manage Conditionals topic in the Simulink Fault Analyzer documentation.
After specifying the properties of the faults, you must select which faults to inject during simulation by enabling a model element that has faults and selecting the active fault. You can select only one active fault on each model element for fault simulation. In this example, enable the faults on the throttle signal. Disable the faults on the other model elements. And select Throttle Fault as the active fault.
First, open the fault table pane. In the Fault Analyzer tab, in the View section, click Fault Table. Then enable the first input port for the two-controller subsystem for fault injection. Next, expand the list for the first input port to the two-controller subsystem, and select Throttle Fault as the active fault. Next, disable the faults on the other model elements. Finally, ensure that fault simulation is on. This button is green when the fault simulation is enabled.
After making these changes, save the fault information file. In the Fault Analyzer tab, in the File section, expand Save All, and click Save Fault Information File. In the next step, you simulate faults by using the interface and creating scripts to run multiple simulations and then view the fault simulation results.
To learn more about this process, see the Run Fault Simulations and View Results topic in the Simulink Fault Analyzer documentation.
Specify Fault Triggers
When you create faults, you can specify how and when they inject by specifying the trigger. When the trigger is true, the fault is injected. For more information on the triggers you can select, see Trigger type.
Open the sldemo_fuelsys_fault_analyzer
model and set up the faults with the helper function, myFuelSysCase
. The helper function deletes the existing Simulink® Fault Analyzer™ model artifacts and replaces them with the faults used in the example.
myFuelSysCase(3)
After executing the function, the model contains faults on each input signal of the To Controller
subsystem. The throttle
signal contains two faults and the other signals contain one fault. In this example, you define the trigger properties so the fault on the throttle
signal named throttle_fault
and the fault on the speed
signal are injected after 25
seconds of simulation time.
Click the fault badge on the throttle
signal. In the throttle_fault
preview window, click the Fault Operations button and click Properties.
The Property Inspector displays the properties. In the Trigger section, set the Trigger type property to Timed
. Set the Trigger fault at time property to 25
.
Repeat these steps for the fault on the speed
signal. You can also create conditional triggers based on expressions or the values of model elements. For more information, see Create and Manage Conditionals.
Select Faults and Prepare for Simulation
After specifying the properties of the faults, you must select which faults are injected during simulation by enabling a model element that has faults and selecting the active fault. You can select only one active fault on each model element for fault simulation. In this example, use the Fault Table pane to enable faults on the throttle
signal, disable faults on the other model elements, and select throttle_fault
as the active fault.
Open the Fault Table pane. In the Fault Analyzer tab, in the View section, click Fault Table.
Enable the first input port for the
To Controller
subsystem for fault injection. In the Enable column, select the check box for the model elementTo Controller/Inport/1
.Expand the list for the To
Controller/Inport/1
model element.Select
throttle_fault
as the active fault on the first input port of theTo Controller
subsystem. In the Active Fault column, select the check box forthrottle_fault
. Activatingthrottle_fault
disables the other fault,throttle_fault_custom
.Enable fault simulation. In the Fault Table pane, click the turn on/off simulation of faults button. The icon is green when fault simulation is enabled.
Save the fault information file and the model. In the Fault Analyzer tab, in the File section, click Save All.