Define Fault Behaviors
This example shows you how to add faults with new behaviors to a model. When you model faults, you can create customized behaviors and update them without affecting your design. You can also specify how and when your faults are injected. For more information on how to define faults, see Define and Model Faults.
Video Walkthrough
For a walkthrough of the example, play the video.
Open the Model and Add a Fault
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(2)
After executing the function, the model contains a fault on each input signal of the To Controller
subsystem.
In this example, add another fault to the throttle
signal with custom behavior.
In the Apps tab, click Fault Analyzer.
Select the
throttle
signal.In the Fault Analyzer tab, in the Prepare Faults section, click Add Fault.
In the Add Fault window, specify the fault properties. Set Model element to
sldemo_fuelsys_fault_analyzer/To Controller/Inport/1
, set Fault name tothrottle_fault_custom
, and set Fault behavior toCustom fault behavior
.
Click OK. The throttle
signal now has two faults. If you click the fault badge on the throttle signal, the preview window displays two faults.
Create Custom Behavior
The custom fault behavior has no logic or semantics. You need to model the logic and semantics with blocks. In this example, add blocks that prevent the throttle signal from exceeding 10
. Click the fault badge on the throttle
signal to open the preview windows. Click the throttle_fault_custom
preview window. The model that contains the fault behaviors, known as the fault model, opens. The fault model contains the subsystems that model each of the fault behaviors. For custom fault behaviors, the model contains only a Fault Inport and Fault Outport block.
In the throttle_fault_custom
subsystem, model the behavior so that the signal to the controller stays at 10
if the input value of the throttle is greater than 10
between the Fault Inport and Fault Outport blocks.
In the MinMax block, set the Output data type property to Inherit: Inherit via internal rule
. Save the fault model. The preview window displays the updated model.
If you want to reuse this fault behavior in new faults, you can register it by saving the Fault Subsystem block in a library and using the Simulink.fault.libraries
function. See Create Predefined and Custom Fault Behaviors.