Page 873 - Mechatronics with Experiments
P. 873

®
                                                      ®
                                                MATLAB , SIMULINK , STATEFLOW, AND AUTO-CODE GENERATION  859


































                             FIGURE A.33: Stateflow Editor Menu.


                                  The SF state concept supports hierarchy: states can be grouped in a hierarchy. The
                             group of states can be exclusive (also called OR states, meaning only one of the states in
                             the group can be active at any given time, i.e., a switch state can be either ON or OFF, not
                             both at the same time) or parallel (also called AND states, meaning the states in the parallel
                             group can be active concurrently during the same sampling period). For instance, assume
                             we have ON and OFF states for a FAN motor and a HEATER. The FAN can be ON and
                             the HEATER can be ON at the same time. The states of FAN motor and HEATER motor
                             are parallel states. The states of FAN motor (ON state and OFF state) are exclusive (OR
                             states), clearly meaning that a FAN motor cannot be ON and OFF at the same time. The
                             same thing applies for the HEATER motor.
                                  Grouping states is a graphical visual aid, it does not make any difference to the logic
                             of the chart. It simply hides the sub-states in the hierarchy, making the visual display less
                             crowded. To group a state and hide its sub-states graphically, right-click on the state, and
                             then select

                                  Make Contents > Grouped

                             You must ungroup a superstate to select objects within the superstate (grouped state). To
                             ungroup a state, double-click it or its border and select

                                  Make Contents > Ungrouped

                                                                        ®
                             Once the code is auto-code generated, both Simulink and StateFlow graphical programs
                             are converted to C language and then compiled/linked into an executable code.
   868   869   870   871   872   873   874   875   876   877   878