Implement an Automatic Transmission Gear System that Controls Transient Signals
This example models an automotive transmission system that uses the Stateflow® temporal logic operator duration
to control transient signals. In this model, the vehicle throttle requirements and speed cause the transmission to shift gears. The Stateflow chart Gear_logic
uses the duration
operator to control transient signals when the vehicle is near the threshold to shift up or down. When Stateflow manages the transient signals, the transmission can fluidly move from one gear to the next. For more information about the duration
operator, see Control Chart Execution by Using Temporal Logic.
Examine Model
There are five major blocks in this model.
User Inputs
: Outputs two signals, brake and throttle.Engine
: Calculates engine RPM based on the impeller torque value and throttle.Gear_logic
: Calculates the next gear based on the current gear, throttle, and current vehicle speed.Transmission
: Calculates the impeller and output torque based on the RPM, gear, and transmission speed.Vehicle
: Calculates the vehicle and transmission speed based on output torque, and brake.
The Stateflow chart models the shifting of gears based on the throttle and speed of the vehicle. The down_threshold
and up_threshold
data represent the minimum and maximum speed values that throttle and current gear are able to handle. The Simulink function calculate_thresholds
calculates these two values using throttle
and gear
as inputs. If the actual speed is higher than up_threshold
for longer than TWAIT
, then the chart transitions to higher gear. Conversely, if the actual speed is lower than down_threshold
for longer than TWAIT
, then the chart transitions to a lower gear.
At each time step, the chart calls the duration
operator to find the amount of time for which speed
is higher than up_threshold
. If this time exceeds TWAIT
, the chart sets the boolean variable up
, which in turn transitions the chart from its current gear to a higher gear. Conversely, the chart transitions to a lower gear based on the value of down_threshold
.
Active state data is the enumerated data that represents the current active state during simulation. In this chart, the output data gear
maintains the current active state, which represents the current gear. This data automatically updates when a transition is taken. The downstream blocks and the Simulink® function calculate_thresholds
both use this data. For more information, see Monitor State Activity Through Active State Data.
Simulate the Model
Simulate the model and open the Scope block.