Test a Chart with Fault Detection and Redundant Logic
An operating point is a snapshot of the state of a Simulink® model at a specific time during simulation. For a Stateflow® chart, an operating point includes:
Activity of chart states
Values of chart local data
Values of chart output data
Values of persistent data in MATLAB® functions and Truth Table blocks
For more information, see Using Operating Points in Stateflow.
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 Detect Faults in 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 operating point at t = 3, load and modify the operating point, and then simulate again between t = 3 and 10.
Step | Task | Reference |
---|---|---|
1 | Define the operating point for your chart. | Define the Operating Point |
2 | Load the operating point and modify values for one actuator failure. | Modify Operating Point Values for One Actuator Failure |
3 | Test the modified operating point by running the model. | Test the Operating Point for One Failure |
4 | Modify operating point values for two actuator failures. | Modify Operating Point Values for Two Actuator Failures |
5 | Test the modified operating point by running the model again. | Test the Operating Point for Two Failures |
Define the Operating Point
Open the
sf_aircraft
model.openExample("stateflow/FaultDetectionControlLogicInAnAircraftControlSystemExample")
Open the Configuration Parameters dialog box.
Enable saving of an operating point. In the Data Import/Export pane:
Select Final states.
Enter a name, such as
xFinal
.Select Save final operating point.
Define the stop time for this simulation segment. In the Solver pane, set Stop time to
3
.Click OK.
Start the simulation.
When you simulate the model, you save the complete operating point at t = 3 in the variable
xFinal
in the MATLAB base workspace.Disable saving of an operating point. In the Configuration Parameters dialog box, in the Data Import/Export pane, clear the Save final operating point and Final states parameters and click OK.
This step prevents you from overwriting the operating point you saved in the previous step.
Modify Operating Point Values for One Actuator Failure
Enable loading of an operating point. In the Configuration Parameters dialog box, in the Data Import/Export pane, select Initial state and enter the variable that contains the operating point of your chart:
xFinal
.Define an object handle for the operating point values of the Mode Logic chart.
At the command prompt, type:
blockpath = "sf_aircraft/Mode Logic"; c = xFinal.get(blockpath);
Tip
If the chart appears highlighted in the model window, you can specify the block path using
gcb
(Simulink):c = xFinal.get(gcb);
Look at the contents of the operating point.
c
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" + LI_mode "State output data" sf_aircraft_ModeType [1,1] + LO_mode "State output data" sf_aircraft_ModeType [1,1] + RI_mode "State output data" sf_aircraft_ModeType [1,1] + RO_mode "State output data" sf_aircraft_ModeType [1,1]
The operating point of your chart contains a list of states, functions, and data in hierarchical order.
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.
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 Operating Point of a Chart.
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 performentry
actions for the newly active substate. Similarly, the method does not performexit
actions for the previously active substate.Save the modified operating point by using this command:
xFinal = xFinal.set(blockpath,c);
Test the Operating Point for One Failure
Define the new stop time for the simulation segment to test. In the Configuration Parameters dialog box, in the Solver pane, set Stop time to
10
.You do not need to enter a new start time because the simulation continues from where it left off.
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 active The left elevator must compensate for the left outer (LO) actuator failure. Right inner (RI) Standby to active The same hydraulic line connects to both inner actuators. Right outer (RO) Active to standby Only one actuator per elevator can be active. Both elevators continue to maintain steady-state positions.
Modify Operating Point Values for Two Actuator Failures
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;
Save the modified operating point by using this command:
xFinal = xFinal.set(blockpath,c);
Test the Operating Point for Two Failures
Open the Configuration Parameters dialog box and, in the Solver pane, verify that Stop time is
10
.Restart the simulation.
Because of failures in both actuators, the left elevator stops working. The right elevator maintains a steady-state position.
If you modify the operating point of your chart to test the response of the right elevator to actuator failures, you get similar results.