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.
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 |
Open the sf_aircraft
model.
Enable saving of an operating point.
Open the Model Configuration Parameters dialog box and go to the Data Import/Export pane.
Select the Final states check box.
Enter a name, such as xFinal
.
Select the Save final operating point check box.
Click Apply.
Define the stop time for this simulation segment.
In the Model Configuration Parameters dialog box, go to the Solver pane.
For Stop time, enter 3
.
Click OK.
Start 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.
This step prevents you from overwriting the operating point you saved in the previous step.
Open the Model Configuration Parameters dialog box and go to the Data Import/Export pane.
Clear the Save final operating point check box.
Clear the Final states check box.
Click OK.
Enable loading of an operating point.
Open the Model Configuration Parameters dialog box and go to the Data Import/Export pane.
Select the Initial state check box.
Enter the variable that contains the operating point of your chart:
xFinal
.
Click OK.
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
:
c = xFinal.get(gcb);
Look at the contents of the operating point.
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
perform entry
actions for the newly active substate. Similarly, the
method does not perform exit
actions for the previously active
substate.
Save the modified operating point by using this command:
xFinal = xFinal.set(blockpath, c);
Define the new stop time for the simulation segment to test.
Go to the Solver pane of the Model Configuration Parameters dialog box.
For Stop time, enter 10
.
Click OK.
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.
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);
In the Model Configuration Parameters dialog box, verify that the stop time is 10.
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 operating point of your chart to test the response of the right elevator to actuator failures, you get similar results.