Main Content

Define and Model Faults

Faults represent anomalies in physical and software systems, subsystems, components, and parts. Engineers attempt to understand the impact of faults on their designs by modeling the faults in a process known as fault modeling. After modeling the faults, engineers perform fault injection to introduce their behavior into a system. Depending on where the fault is and the kind of behavior it injects, faults can insignificantly affect a product or cause total failure.

You can perform fault injection on your Simulink® models by using Simulink Fault Analyzer™. After you add faults to your models, you can adjust the behavior, control how they inject behavior, and simulate their impact on the model.

Open the Example Model

This example takes a sine wave and checks when it is greater than or equal to 1.25. You can view the simulation results in the Scope block. The model does not include faults. Open the model to get started.

Add Faults to the Model

Open the Fault Analyzer app. In the Simulink model, in the Apps tab, click Fault Analyzer. Next, add a fault to the model. In the model, click the Sine Wave block output signal. In the Fault Analyzer tab, in the Prepare Faults section, click Add Fault. Alternatively, you can click a signal, point to the ellipsis to open the action bar, and click the Add a fault on the signal icon . The Add Fault window displays the properties you can assign to the fault.

This image shows the window that appears when you add a fault to a signal.

When you add a fault, select the model element by specifying the Model element property. You can select block input or output ports connected to the signal. If you select an input port, the fault modifies the signal just before it enters the block. If you select an output port, the fault starts at the output signal of the Simulink block and propagates downstream until the signal encounters another block. In this example, assign the fault to the output port of the Sine Wave block by setting Model element to fault_analyzer_intro/Sine Wave/Outport/1.

Simulink Fault Analyzer comes with a list of built-in example fault behaviors. Access these example behaviors by selecting mwfaultlib from the Fault library property. You can use these fault behaviors as-is for scalar double signals. If your signal is a different type, you may need to create custom behaviors instead. For more information on predefined and custom behaviors, see Create Predefined and Custom Fault Behaviors.

After selecting the library, you can select a fault behavior by setting the Fault behavior property. In this example, add a fault with noise behavior. Set Fault behavior to Add Noise and click OK. After you add a fault, the fault badge appears next to the signal.

This image shows the Sine Wave block output port with the fault badge.

When you add the first fault to a model element, Simulink Fault Analyzer creates an XML file that contains fault information for the model. This file is called the fault information file. Each model uses one fault information file. By default, Simulink Fault Analyzer saves the fault information file in the current working directory. You can specify a different directory for the fault information file when you add the first fault to your model. In the Add Fault window, specify the directory in the Fault information directory property. Additional faults automatically use the same fault information file.

Highlight Faults and Affected Signals

You can highlight faults to visualize the affected model elements and signals. To turn highlighting on or off, in the View section, click Highlight Faults.

This image shows the fault_analyzer_intro model with highlighted faults.

Investigate the Fault Behavior

To model fault behaviors, Simulink Fault Analyzer uses blocks in subsystems that are separate from your design. In this example, open the fault behavior for SineWave_Outport1_fault. Click the fault badge. Click on the preview window. The fault behavior assigned to this fault uses a White Noise block to add noise to the signal.

This shows the fault behavior used. When enabled, it injects noise into the model signal.

Simulink Fault Analyzer stores the assigned fault behavior in a separate SLX file called the fault model. If you add fault behavior to a fault, the software adds an instance of the fault behavior to the fault model in a Fault Subsystem block. You can view the fault model by navigating to the parent model of the subsystem or by directly opening the fault model. You specify the directory that the fault models is saved in the Fault model directory property in the Add Fault window. By default, the fault model uses the name of the file and appends it with _FaultModel. In this example, that file is fault_analyzer_intro_FaultModel.

Add or Delete Faults

You can add multiple faults to a block output signal. Add another fault to the output signal of the Sine Wave block. The default name for this fault is SineWave_Outport1_fault_1. For this example, do not edit the fault name. Set the Fault behavior property to Gain. Click OK. Save the new fault by saving the model, or by clicking Save All in the Fault Analyzer tab, in the File section. If you attempt to close the model without saving, Simulink displays a dialog box that prompts you to save the fault model and fault information file before closing.

To delete a fault:

  1. Click the fault badge where the fault is added.

  2. In the fault behavior preview window, click the Fault Operations icon .

  3. Click Delete.

  4. Save the model.

Deleting faults also deletes the associated fault behavior in the fault model. If you delete a fault and the fault behavior is the only one in the fault model, you also delete the fault model.

You can also delete a fault by deleting the associated model element.

Enable, Modify, and Select Active Faults

Faults cannot affect the model until you enable their assigned model element. Once you enable faults on a model element, you then must select the fault that affects the model element, known as the active fault. At least one fault is active on each enabled fault element. Consequentially, if you only have one fault on an enabled model element, the fault is automatically active.

You can enable model elements and activate faults by accessing the fault properties. To access the properties of the faults on the Sine Wave block:

  1. Click the fault badge where the fault is added.

  2. In the fault behavior preview window, click the Fault Operations icon .

  3. Click Properties.

To adjust the properties of a fault, select the fault from the Select fault to view property. For more information, see Specify Fault Properties.

This image shows the Property Inspector as it appears for this example.

Enable faults on the block output signal by selecting Enable. If faults are enabled on the signal, you can select one active fault for a model element. In the Property Inspector, select SineWave_Outport1_fault as the active fault from the Active fault for simulation property. To disable the faults on a single model element, clear the Enable property. If you want to activate a different fault, select the fault in the Active fault for simulation property.

Adjust the Fault Trigger Properties with the Property Inspector

When you enable faults on a model element and select an active fault, Simulink Fault Analyzer does not inject the behavior to the model during simulation until specific conditions occur. You specify these conditions for each fault with a trigger. If the trigger conditions are met, the fault behavior is injected into the model. To control how a fault triggers, adjust the trigger for the fault with the Trigger type property.

For this example, set SineWave_Outport1_fault to trigger after five seconds of simulation time. To do this, change the Trigger type to Timed and enter 5 in the Trigger fault at time property.

View and Select Faults in the Fault Table

You can use the Fault Table pane to view and select faults in your model. By default, the Fault Table pane opens at the bottom of the Simulink Editor when you select Fault Analyzer in the Apps tab. If you close the Fault Table pane, you can open it again by clicking Fault Table in the Fault Analyzer tab.

This image shows the Fault Table pane resulting from the previous example after the fault has been added.

The pane shows the model elements that contain faults, the faults associated with each model element, the activation status of the faults, and whether the model element is enabled. You can use the pane to view and manage faults:

  • Click the Expand/Collapse button to expand all of the model elements.

  • Save the fault information file by clicking the Save fault information button . (since R2024a)

  • Search for faults that match your search criteria. Search is not case-sensitive.

  • View the properties of faults in the Property Inspector by selecting a fault and clicking the Property Inspector button .

  • Highlight faults in the model by clicking on a fault. You can highlight one fault at a time. To clear highlighting, right-click the name of the highlighted fault and click Remove all fault highlighting.

Simulate the Model

To allow fault simulation, you must turn it on. In the Fault Analyzer tab, in the Status section, click the Fault Simulation button. Fault simulation is on when the button is green and the status is on.

The left side of the Fault Analyzer app toolstrip. The Fault Simulation button is depressed, and the button icon is green.

You can also enable fault simulation by pressing the Turn on/off simulation of faults button in the Fault Table pane.

Turn on fault modeling and click Run. Open the Scope block to view the effects of the fault. The Sine Wave block output now has noise when the time is 5.

This image shows the effect of the fault on the model. The Sine Wave has noise despite the source block not producing noise on its own

If you disable fault simulation, the Sine Wave block output returns to normal.

You can confirm that the fault injected by opening the Fault Dashboard tab (since R2024a). In the Fault Analyzer tab, in the View section, click Fault Dashboard. The Simulation Results tab shows that the active fault, SineWave_Outport1_fault, triggered during the simulation.

The Fault Dashboard pane. It shows 1/1 faults simulated, and the specified fault, SineWave_Outport1_fault. In the Triggered Faults drop down.

If the fault is not injected during simulation, the Triggered Faults section does not display it.

Delete Faults and Behaviors and Start Over

If you want to delete the faults and behaviors that you created without manually deleting each fault or model element:

  1. Close out of the model or models that contain faults.

  2. Clear the associated fault models from memory using one of these methods:

    1. If the fault model is open, close the fault model.

    2. If the fault model has only been loaded into memory, clear the model from memory by using the close_system function.

  3. Delete the fault information file and the fault models.

Deleting these files permanently deletes the fault artifacts associated with the models that use the fault information file or fault model.

Related Topics