Main Content

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.

The input ports to the To Controller subsystem. Each input port has a fault, as shown by the fault badge next to them.

In this example, add another fault to the throttle signal with custom behavior.

  1. In the Apps tab, click Fault Analyzer.

  2. Select the throttle signal.

  3. In the Fault Analyzer tab, in the Prepare Faults section, click Add Fault.

  4. In the Add Fault window, specify the fault properties. Set Model element to sldemo_fuelsys_fault_analyzer/To Controller/Inport/1, set Fault name to throttle_fault_custom, and set Fault behavior to Custom fault behavior.

The Add Fault window after selecting the throttle signal and adding a fault. The Fault name property says throttle_fault_custom and is yellow, indicating that this field is modified. The Fault Behavior property is set to Custom 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.

The cursor points to the fault badge on the throttle signal. The preview windows below the fault badge display two previews. One preview corresponds to the throttle_fault fault, and the other corresponds to the custom fault behavior you just added.

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.

The throttle_fault_custom fault behavior. The model for the fault behavior has only two blocks, the Fault Inport and Fault Outport blocks.

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.

The updated fault behavior that satisfies the requirements described above. A MinMax block connects the signal from the Fault Inport block to its first input, and a Constant block to its second input. The MinMax block output connects to the Fault Outport block.

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.

The cursor points to the fault badge on the throttle signal. The preview windows below the fault badge display two previews. One preview corresponds to the throttle_fault fault, and the other corresponds to the custom fault behavior. The custom fault behavior looks like the behavior that you just created.

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.

Related Topics