Stateflow    

Control Logic

The single Stateflow chart that implements the entire control logic is shown below.

The chart consists of six parallel states (denoted by dash-dotted boundaries) that represent concurrent modes of operation.

The four parallel states at the top of the diagram correspond to the four individual sensors. Each state has sub-modes or sub-states that represent the status of that particular sensor, i.e., whether it has failed or not. These sub-states are mutually exclusive: if the throttle sensor has failed then it is in the throt_fail state. Transitions determine how states can change and can be guarded by conditions. For example, the throt_norm state can change to the throt_fail state when the measurement from the throttle sensor exceeds max_throt or is below min_throt.

The remaining two parallel states at the bottom consider the status of the four sensors simultaneously and determine the overall system operating mode. The Sens_Failure_Counter superstate acts as a store for the resultant number of sensor failures. This state is polled by the Fueling_Mode state that determines the fueling mode of the engine. If a single sensor fails, operation continues but the air/fuel mixture is richer to allow smoother running at the cost of higher emissions. If more than one sensor has failed, the engine shuts down as a safety measure, since the air/fuel ratio cannot be controlled reliably.

Although it is possible to run Stateflow charts asynchronously by injecting events from Simulink when required, the fueling control logic is polled synchronously at a rate of 100 Hz. Consequently, the sensors are checked every 1/100 second to see if they have changed status and the fueling mode adjusted accordingly.


 Analysis and Physics Running the Model