How to Create a State Transition Table - MATLAB & Simulink
Video Player is loading.
Current Time 0:00
Duration 4:06
Loaded: 6.68%
Stream Type LIVE
Remaining Time 4:06
 
1x
  • Chapters
  • descriptions off, selected
  • captions off, selected
      Video length is 4:06

      How to Create a State Transition Table

      State transition tables provide an easy on-ramp for learning Stateflow® and are an ideal solution for simple, process-oriented, sequential state machines. In this “how to” demonstration, follow an example of a quadcopter takeoff that explains the basic components of a state transition table.

      Watch to learn:

      • What finite state machines are used for
      • Why to use state transition tables
      • How to build a state transition table
      • How to visualize state transition tables in other ways

      Published: 22 Apr 2024

      Finite state machines are useful to model systems that are in one of a known number of states at any given time, like the cruise control in a car or a battery management system.

      State transition tables are a visual method that can be used to model finite state machines in Stateflow. Each row in the table contains a state and the conditions required to transition from that state to another. The simple tabular format makes them easy to read and align with requirements.

      Consider a requirement for a quadcopter that needs to transition from standby to taking off when the battery voltage passes two volts and transition back to standby when the battery voltage is two volts or less. Let's model this requirement using a state transition table.

      I have a Simulink model with a ramp block representing increasing battery voltage and a scope for viewing the eventual output. I can add a state transition table from the state flow section of the library browser or double-click the canvas and search for it. State transition tables are created with some default states. I'll rename them standby and takeoff to match my requirement. You can always insert additional states or introduce child states to create hierarchy in the table.

      To determine when to transition from standby to takeoff, the battery voltage signal needs to be sent to the state transition table. I'll go back to the Simulink model, click and drag the battery voltage signal to the table. The battery voltage now appears as input data in the Symbols pane, but a warning indicates that this input data is currently unused. Let's fix that by adding the logic for the requirement.

      For each state, I'll add the condition and destination given that condition is true. When the battery voltage is above two volts, the system transitions to takeoff. For voltage less than or equal to two volts, it transitions to standby.

      Similar to state flow, you can perform actions upon entering, exiting, or during a state. Let's add a signal to start the motors upon takeoff, called Motor Command. I'll implement this in the state transition table using entry actions. When entering standby, the signal to the motor will be 0, and for takeoff, I'll set it to 0.5 to indicate 50% of the max RPM.

      After adding motor command in the table, it will appear in the Symbols pane. The data type is undefined, but Stateflow will suggest an anticipated type. Here, it's expected that the mode will be output data, which is correct, so I'll click this button to resolve my undefined symbols. If a symbol is ever misclassified, you can change the type by clicking the icon next to the symbol and choosing the correct type from the dropdown menu.

      Back in the Simulink model, I'll connect the output motor command to the scope to monitor its value. Now, I have all the logic for my requirement captured in the state transition table. I'll open up the scope to view the outputs while I execute the simulation. You can see states are highlighted in blue as the state chart is executing. Right as the battery voltage crests two volts, you can see the motor command transition from 0 for standby to 0.5 for takeoff.

      You always have the option to auto-generate a state chart from your state transition table for a different view of the system. And once your state transition table is complete, you can utilize code generation tools to deploy your model logic onto embedded hardware. But that's all it takes to model a simple requirement in a state transition table. To learn more, visit the Stateflow Product page, Stateflow Onramp, or our help documentation.

      View more related videos