Diagrammes d’état

Diagrammes d'état pour la modélisation de la logique de contrôle

Un diagramme d'état est un modèle de système réactif. Ce modèle définit un ensemble fini d'états et de comportements, ainsi que la façon dont le système passe d'un état à l'autre lorsque certaines conditions sont vraies.

Les diagrammes d'état permettent de modéliser une logique complexe dans les systèmes dynamiques, des boîtes de vitesses automatiques jusqu'aux systèmes robotiques, en passant par les téléphones mobiles. Vous trouverez ci-dessous des exemples de logiques complexes :

  • Séquencement de tâches ou d'étapes pour un système
  • Définition d'une logique de détection de panne, d’isolement et de remise en route
  • Implémentation d’une logique de supervision pour basculer entre les différents modes de fonctionnement
Figure 1: State diagram of a microwave oven with 3 modes of operation (off, heating and idling), modeled using Stateflow®.

Figure 1. State diagram of a microwave oven with 3 modes of operation (off, heating, and idling), modeled using Stateflow.

En s'appuyant sur les machines à états finis traditionnelles, les diagrammes d'état fournissent des fonctionnalités supplémentaires, notamment :

Moore Implementation of a State Diagram

  • Une modélisation d'états hiérarchiques pour des systèmes à grande échelle
  • L'ajout de diagrammes de flux de données pour définir une logique de décision complexe
  • La définition d'états parallèles pour représenter des systèmes concurrents
Figure 2: State diagram modeled using Moore Implementation with Stateflow.

Figure 2. State diagram modeled using Moore implementation with Stateflow.

Pour plus d'informations sur la modélisation des diagrammes d'état, y compris sur ces techniques avancées, consultez les sections consacrées à Stateflow® et Simulink®.

In this type of state machine, the outputs depend not only on the state of the system, but also on inputs to the system. As shown in the state diagram in Figure 3, outputs in a Mealy implementation are defined at the transitions.

Figure 3: State diagram modeled using Mealy implementation with Stateflow.

Figure 3. State diagram modeled using Mealy implementation with Stateflow.

With the Mealy implementation, state diagrams can be reorganized and simplified with the addition of loops to update machine outputs. This is increasingly beneficial with more complex designs.

Figure 4: Reorganized state diagram modeled using Mealy implementation with Stateflow.

Figure 4. Reorganized state diagram modeled using Mealy implementation with Stateflow.

Both Mealy and Moore machines are popular for their simplicity and clarity, and the two styles are often mixed within the same state diagram.

State Charts: Enhanced State Diagrams

The basic building blocks of state diagrams are not enough for a single diagram to represent complex logical systems. You will need additional capabilities to capture intricate design details efficiently. State charts, also known as Harel charts, add capabilities including hierarchy, parallelism or orthogonality, and event broadcasting.

The hierarchy capability allows further design compartmentalization and can reduce the number of transition lines required between states. Parent states can be introduced to create hierarchy within state machines. For example, in the state chart in Figure 5, the parent state of Baking includes the substates of Heating and Idle and the associated state diagram.

Figure 5: State chart showing  hierarchy, modeled using Stateflow.

Figure 5. State chart showing hierarchy, modeled using Stateflow.

Parallelism or orthogonality capabilities allow for a single state chart to include multiple states operating simultaneously. For example, in the state chart in Figure 6, Oven and Oven_Light can be thought of as two independent state machines operating simultaneously. The chart represents the overall system in a single graphic containing two parallel state machines.

Figure 6: State chart showing hierarchy and parallelism, modeled using Stateflow.

Figure 6. State chart showing hierarchy and parallelism, modeled using Stateflow.

Event broadcasting capabilities expand the functionality of the system by allowing information exchange between two independent states or state machines. In the previous case, the two state machines were independent, as the oven light’s operation did not depend on the oven’s heating system. With event broadcasting, a feature that turns off the oven light when baking is complete can be added using a simple command within the Oven state’s logic, as highlighted in the state chart in Figure 7.

Figure 7: State chart showing hierarchy, parallelism, and broadcasting, modeled using Stateflow.

Figure 7. State chart showing hierarchy, parallelism, and broadcasting, modeled using Stateflow.

State charts with hierarchy, parallelism, and broadcasting capabilities help to represent complex system functionalities without cluttered state diagrams.

State Diagrams and State Charts with Stateflow

Stateflow® is a graphical programming environment based on finite state machines. Using Stateflow, you can start from simple state diagrams and build out state charts to model complex logic in dynamic systems, including automatic transmissions, robotic systems, mobile phones, and more. Applications of this complex logic include:

If you need the logic created to control a software component, you can use the automatic code generation capabilities from Simulink to convert the state chart into C, HDL, or PLC code for deployment.

For more information on modeling state diagrams, including these advanced techniques, see Stateflow and Simulink. The example, Modeling a Security System, demonstrates hierarchy, parallelism, and event broadcasting in Stateflow.



Voir aussi: logique de contrôle, machine machine à états finis, systèmes de contrôle, systèmes intégrés