Understanding Complex Logic with Stateflow
A fuel control system is a critical component of an engine. Ensuring the engine operates reliably requires a controller that is tolerant to sensor failures. Designing such a controller involves keeping track of multiple sensor states and determining the fuel mode based on which or how many sensors have failed.
Stateflow® has graphical programming features that will help you model interconnected and complex logic in a clear and concise manner. Its visual tools provide a powerful way to understand the behavior of complex systems. With the help of a dashboard, you can interact with the model during simulation to see how it responds to different inputs without having to first set up an input signal, letting you quickly build an intuition for the behavior of your system.
Stateflow highlights states in blue during execution to show which ones are active, making it easy to track sequences of decisions. Changing the speed lets you pay closer attention to the details as you follow along. Data syntax highlighting colors variables in the chart according to their functional role. At a glance, you can tell which variables are inputs, outputs, or local data, improving clarity and traceability.
Stateflow provides powerful tools for modelling complex logic. This video will show you how to use its visual programming features to better understand the behavior of your system.
This chart models the logic for fault detection and handling of a fuel rate control system and can be divided into three parts. The four parallel subcharts at the top keep track of the state of each individual sensor; the superstate in the middle counts how many of the sensors have failed; and the superstate at the bottom determines the fuel mode of the system based on which sensors have failed. The complexity in this chart comes from the interdependence of these parallel states and their respective child states.
This dashboard can be used to control the fail state for each of the sensors, as well as the engine speed. Interacting with the panel during simulation is a great way to explore the logic of the system.
To access this model, follow the first link below this video or execute this command in the MATLAB Command Window.
While the model is running, Stateflow displays the chart execution by highlighting in blue the active states and executed transitions. By default, this is shown very quickly. Change the execution speed in the debug tab for a more detailed look.
State highlighting provides immediate feedback to actions taken in the model and allows you to follow the logic as the simulation progresses.
The algorithm in this chart uses the number of failed sensors to determine the operating mode of the fuel system. Now that all sensors are working, the mixture runs lean and the ‘fuel_mode’ symbol is set to ‘LOW’.
When one of the sensors fails, the failure counter moves to ‘One’, making the ‘Fueling Mode’ superstate transition from ‘Normal’ to ‘Single Failure’ and the mixture now runs rich. You can verify this by hovering your mouse over any instance of the ‘fuel_mode’ symbol. Failing another sensor increases the failure counter, resulting in the ‘Fueling Mode’ superstate taking another transition. This disables fuel injection, and the engine is shut down.
There is another state that also leads to fuel injection being disabled: ‘Overspeed’. How would you get there?
The transition going into ‘Overspeed’ compares two symbols. For more clarity on their role in the chart, enable data syntax highlighting, which gives a different font color to each type of symbol. Now it is easy to tell that ‘es_i’ is an input to the chart, and ‘max_speed’ is a model parameter.
To get to ‘Overspeed’, first remove all failures to start from normal operation. The transition going into ‘Overspeed’ checks if the input speed is above the maximum. Increasing the speed in the dashboard gives the desired result.
This fuel rate control system shows how Stateflow can model complex and interconnected logic in a clear and condensed manner. Its visual tools provide a powerful way to understand complex systems.
For more information on modelling and understanding logic with Stateflow, visit the ‘Get Started’ page linked below.
Featured Product
Stateflow
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other bat365 country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)