Skip to Main Content Skip to Search
Product Documentation

Testing a Chart with Fault Detection and Redundant Logic

Goal of the Tutorial

Suppose that you want to test the response of the sf_aircraft model to one or more actuator failures in an elevator system. (For details of how this model works, see the demo description for Modeling Fault Management Control Logic in an Aircraft Elevator Control System.)

The Mode Logic chart monitors the status of actuators for two elevators. Each elevator has an outer (primary) actuator and an inner (secondary) actuator. In normal operation, the outer actuators are active and the inner actuators are on standby.

When the four actuators are working correctly, the left and right elevators reach steady-state positions in 3 seconds.

Suppose that you want to see what happens at t = 3 when at least one actuator fails. You can simulate the model, save the SimState at t = 3, load and modify the SimState, and then simulate again between t = 3 and 10.

StepTaskReference
1Define the SimState for your chart.Defining the SimState
2Load the SimState and modify values for one actuator failure.Modifying SimState Values for One Actuator Failure
3Test the modified SimState by running the model.Testing the SimState for One Failure
4Modify SimState values for two actuator failures.Modifying SimState Values for Two Actuator Failures
5Test the modified SimState by running the model again.Testing the SimState for Two Failures

Defining the SimState

  1. Open the model.

    Type sf_aircraft at the command prompt.

  2. Enable saving of a SimState.

    1. Open the Configuration Parameters dialog box and go to the Data Import/Export pane.

    2. Select the Final states check box.

    3. Enter a name, such as xFinal.

      You can choose any alphanumeric string for the name.

    4. Select the Save complete SimState in final state check box.

    5. Click Apply.

     Programmatic equivalent

  3. Define the stop time for this simulation segment.

    1. In the Configuration Parameters dialog box, go to the Solver pane.

    2. For Stop time, enter 3.

    3. Click OK.

     Programmatic equivalent

  4. Start simulation.

    When you simulate the model, you save the complete simulation state at t = 3 in the variable xFinal in the MATLAB base workspace.

  5. Disable saving of a SimState.

    This step prevents you from overwriting the SimState you saved in the previous step.

    1. Open the Configuration Parameters dialog box and go to the Data Import/Export pane.

    2. Clear the Save complete SimState in final state check box.

    3. Clear the Final states check box.

    4. Click OK.

     Programmatic equivalent

Modifying SimState Values for One Actuator Failure

  1. Enable loading of a SimState.

    1. Open the Configuration Parameters dialog box and go to the Data Import/Export pane.

    2. Select the Initial state check box.

    3. Enter the variable that contains the SimState of your chart: xFinal.

    4. Click OK.

     Programmatic equivalent

  2. Define an object handle for the SimState values of the Mode Logic chart.

    At the command prompt, type:

    blockpath = 'sf_aircraft/Mode Logic';
    c = xFinal.getBlockSimState(blockpath);

      Tip   If the chart appears highlighted in the model window, you can specify the block path using gcb:

      c = xFinal.getBlockSimState(gcb);

     What does the getBlockSimState method do?

  3. Look at the contents of the SimState.

    c = 
    
      Block:    "Mode Logic"    (handle)    (active)
      Path:     sf_aircraft/Mode Logic
    
      Contains:
    
        + Actuators          "State (OR)"          (active)
        + LI_act             "Function"
        + LO_act             "Function"
        + L_switch           "Function"
        + RI_act             "Function"
        + RO_act             "Function"
        + R_switch           "Function"
          y                  "Block output data"    ModeBus [1, 1]
    

    The SimState of your chart contains a list of states, functions, and data in hierarchical order.

  4. Highlight the states that are active in your chart at t = 3.

    At the command prompt, type:

    c.highlightActiveStates;

    Active states appear highlighted. By default, the two outer actuators are active and the two inner actuators are on standby.

    To highlight active states automatically at the end of a simulation, enable chart animation and select Maintain Highlighting in the debugger. For details, see Animating Stateflow Charts.

      Tip   To check if a single state is active, you can use the isActive method. For example, type:

      c.Actuators.LI.L1.standby.isActive

      This command returns true (1) when a state is active and false (0) otherwise. For information on other methods, see Methods for Interacting with the SimState of a Chart.

  5. Change the state activity in the chart to reflect one actuator failure.

    Assume that the left outer (LO) actuator fails. To change the state, use this command:

    c.Actuators.LO.isolated.setActive;

    The newly active substate appears highlighted in the chart.

    The setActive method ensures that the chart exits and enters the appropriate states to maintain state consistency. However, the method does not perform entry actions for the newly active substate. Similarly, the method does not perform exit actions for the previously active substate.

  6. Change the value of output bus element y.LO_mode.

    You can change the value of y.LO_mode to Isolated by typing:

    c.y.Value.LO_mode = sf_aircraft_ModeType.Isolated;

    This value belongs to the list of enumerated values for the sf_aircraft_ModeType definition. For more information, see Rules for Modifying Data Values.

  7. Save the modified SimState by using this command:

    xFinal = xFinal.setBlockSimState(blockpath, c);

Testing the SimState for One Failure

  1. Define the new stop time for the simulation segment to test.

    1. Go to the Solver pane of the Configuration Parameters dialog box.

    2. For Stop time, enter 10.

    3. Click OK.

    You do not need to enter a new start time because the simulation continues from where it left off.

     Programmatic equivalent

  2. Start simulation.

    Chart animation shows that the other three actuators react appropriately to the failure of the left outer (LO) actuator.

    This actuator...Switches from...Because...
    Left inner (LI)Standby to activeThe left elevator must compensate for the left outer (LO) actuator failure.
    Right inner (RI)Standby to activeThe same hydraulic line connects to both inner actuators.
    Right outer (RO)Active to standbyOnly one actuator per elevator can be active.

    Both elevators continue to maintain steady-state positions.

Modifying SimState Values for Two Actuator Failures

  1. Change the state activity in the chart to reflect two actuator failures.

    Assume that the left inner (LI) actuator also fails. To change the state, use this command:

    c.Actuators.LI.isolated.setActive;
  2. Change the value of output bus element y.LI_mode.

    You can change the value of y.LI_mode to Isolated by typing:

    c.y.Value.LI_mode = sf_aircraft_ModeType.Isolated;
  3. Save the modified SimState by using this command:

    xFinal = xFinal.setBlockSimState(blockpath, c);

Testing the SimState for Two Failures

  1. In the Configuration Parameters dialog box, verify that the stop time is 10.

  2. Restart simulation.

    Because of failures in both actuators, the left elevator stops working. The right elevator maintains a steady-state position.

If you modify the SimState of your chart to test the response of the right elevator to actuator failures, you get similar results.

  


Free Stateflow Interactive Kit

Learn how engineers use Stateflow to model state machines in their Simulink models.


Get free kit

Trials Available

Try the latest version of Stateflow.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS