Main Content

Add and Simulate Faults in System Composer Models

If you have System Composer™, you can add faults to the ports of components in your model. After adding faults, you can simulate the model to see their effect. You can apply and simulate faults assigned to scalar or bus connections.

Add Faults to Component Ports

You can add faults to component input or output ports. To add faults to System Composer component ports:

  1. In a saved System Composer model, select a connection.

  2. Open the Fault Analyzer app. In the Apps tab, click Fault Analyzer.

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

  4. In the Add Fault window, set the properties for the new fault.

  5. Click OK.

Faults in System Composer models have the same properties as faults in Simulink® models. For more information, see Specify Fault Properties. You can add faults to component ports associated with any component type.

Programmatically Add Faults

To add faults to a component port, use the Simulink.fault.addFault function and specify the model element as the port. For example, to add a fault to the first output port of the component myComponent, in the System Composer model, myModel, enter this command:


Simulate Faults on Components

To simulate faults in System Composer models, follow these guidelines:

  • You must add behaviors to the faults before simulating the model. Fault behaviors for System Composer models are stored in Simulink models. See Create Predefined and Custom Fault Behaviors.

  • The components must be Simulink model references. See Implement Component Behavior Using Simulink (System Composer).

  • If the connections are buses, they must be nonvirtual and must use bus compatible blocks. For more information, see Add Faults to Buses.

  • If a component takes a bus as an input, you must define the input elements manually to match the bus elements it receives.

After you simulate, if you log the signals in any of the referenced models, you can view the injection status of the fault and the logged signals from the architectural model by viewing them in the Simulation Data Inspector. In the Fault Analyzer tab, in the Review Results section, click Data Inspector.

Example System Composer Model with Fault

This example shows how to model faults in a System Composer model. The model contains three Simulink model references, and one of the connections has a fault.

Inspect the Model

In this example, the Signals referenced model produces a bus that contains three scalar elements. The Transformer referenced model takes the signals and sends each bus element to a MinMax block. Finally, the Reader referenced model reads the signal from Transformer. This architectural model uses two nonvirtual buses. The Signals model outputs a nonvirtual bus, SystemBus, which contains the Noise, Sine, and Step elements. Signals sends this bus to Transformer, which outputs the nonvirtual bus labeled TransformedBus to the Reader referenced model.

Open the Transformer referenced model to view the bus handling. The model input contains the same elements as the input bus, Signals. Because the connection is a bus, and the MinMax block does not support buses, the Transformer model separates the bus into its elements first by using a Bus Selector block, and then collects the elements into the TransformedBus bus by using a Bus Creator block.

The In Bus Element block represents the input port and manually defines the bus elements in order from Signals. If these elements do not match the incoming bus, the model is unable to simulate. Open the In Bus Element block to view the element assignments.

Inspect the Fault

This model has a fault on the output connection of the Transformer referenced model. Open the fault model, Faulted_system_model_FaultModel and click the Fault Subsystem block OutBus_fault to view the fault behavior. The fault behavior splits the bus into its elements to affect each element behavior and combines the elements into a nonvirtual bus. To maintain consistency with the input, the Bus Creator block creates a bus and assigns it to same nonvirtual bus that Transformer outputs.

Simulate the Model and View the Results

Simulate the faulted_system_model model. You can view the result in the Scope block in the Reader referenced model. Reader also logs the signal from the input port. You can view the signal results and the fault status in the Simulation Data Inspector. In the Fault Analyzer tab, in the Review Results section, click Data Inspector. You can view the logged signals in the Signals section or the fault injection status, OutBus_fault, in the Fault section.

See Also

Related Topics