Statechart Module Tutorial Part 5: Using Orthogonal Regions and State History
- Updated2023-02-21
- 6 minute(s) read
In Part 4 of this tutorial, you learned how to create and configure regions and substates. You also learned how to use some debugging tools included in the LabVIEW Statechart Module. In Part 5 of this tutorial, you add orthogonal regions. You also use state history.
![]() |
You can complete these exercises in approximately 45 minutes. |
![]() |
Note Refer to the labview\examples\Statechart\Tutorial\Asynchronous\Getting Started 5.lvsc for a completed version of the statechart you create in this part of the tutorial. |
Defining More State Data
The first step is defining an additional state data type. This type of data is modified in the Concurrent orthogonal region. Complete the following steps to define this data type.
- Ensure you have closed all debugging windows and statechart diagrams.
- Display the Project Explorer window for the My Getting Started Statechart.lvsc statechart that you constructed in Part 4 of this tutorial. You also can navigate to the labview\examples\Statechart\Tutorial\Asynchronous directory and open Getting Started 4.lvsc for the completed statechart from Part 4 of this tutorial.
- Double-click the StateData.ctl item. LabVIEW displays the Control Editor window for this type definition.
- Right-click in the Control Editor window to access the Controls palette.
- Select Express»Text Indicators»String Indicators to add a string indicator to the type definition.
- Label this indicator Color.
- Drag this indicator inside the StateData cluster.
- Press the <Ctrl-S> keys to save this type definition.
- Close the Control Editor window to return to the Project Explorer window.
Creating the Orthogonal Region
Orthogonal regions are multiple regions in the same state. Substates in orthogonal regions execute concurrently, which means these states both execute during a single iteration of the statechart. Complete the following steps to add orthogonal regions to this statechart.
- Display the statechart diagram.
- Click and drag to increase the size of the Play superstate.
- Place a second region inside the Play superstate and to the right of the Tick Counter region.
- Label this new region Concurrent.
- Place two substates inside this region.
- Label the substates Red and Green.
- Place an Initial pseudostate in the Concurrent region.
- Create the following transitions:
- From the Initial pseudostate to the Red substate.
- From the Red substate to the Green substate.
- From the Green substate to the Red substate.
The Play superstate now resembles the following figure:

Configuring the Substates and Transitions
The next step is defining the actions of these substates and transitions. Complete the following steps to configure these items.
- Configure the initial transition to write an Empty String Constant to the Color indicator to reset this indicator every time the statechart enters the Concurrent region.
- Define the entry action of the Red substate to write Red to the Color indicator.
- Locate the transition node on the transition from the Red substate to the Green substate. Configure this transition to write Green to the Color indicator.
Configure this transition to react to the Return trigger only. Remember that the caller VI sends this trigger during the Timeout event of the Event structure. - Configure the other transition to react to the Return trigger only.

Note Even though you configured both transitions to react to the same trigger, the statechart checks only transitions that exit the current substate. Therefore, when the statechart is in the Green substate, the statechart does not consider triggers that exit the Red substate, and vice versa. - Save the statechart.
- Generate code for the statechart.
- Close the statechart diagram.
Running the Caller VI
Complete the following steps to see the effect of the orthogonal region.
- Run the caller VI from the Debugging the Statechart section of Part 4 of this tutorial, watch the state data, and click the Play front panel button. Notice the Counter indicator increments while the Color changes from Red to Green.
- Click the Highlight Execution button
to see the statechart move between orthogonal substates concurrently. You also can see the Increment trigger pass to the internal queue of the statechart. - Click this button again to turn off execution highlighting. Then, stop the caller VI.
- Close all debugging windows. You cannot edit a statechart while debugging windows are open.
Taking State History into Account
While the statechart is in the Play superstate, clicking the Pause front panel button and then the Play front panel button resets the Counter variable to 0. The next step is configuring the statechart to remember the previous value of the Counter indicator. In this configuration, when you re-enter the Play superstate from the Pause state, the variable does not reset from 0. Instead, the statechart remembers the value of the Counter indicator and begins counting from that value.
Complete the following steps to define this behavior.
- Display the statechart diagram.
- Place a Deep History pseudostate, located on the Statechart Development palette, in the Tick Counter region.

Note In this situation, you also can use the Shallow History pseudostate because the Play superstate contains only one level of hierarchy. - Locate the transition from the Pause state to the Play superstate. The triangular port of this transition is in the Play superstate.
- Move the cursor over this triangular port until the cursor changes to the Wiring tool.

Note If you do not see the Wiring tool, you might have disabled automatic tool selection. Either enable this feature or press the <Tab> key until the Wiring tool appears. - Click to initiate a transition segment.
- Move the cursor over the Deep History pseudostate.
- Click to complete the transition. The Play superstate now resembles the following figure:

- Save the statechart.
- Generate code for the statechart.
In this configuration, the first time the statechart enters the Tick Counter region, the statechart executes the Tick substate because this substate is connected to the Initial pseudostate. However, if you move to the Pause state and then return to the Play superstate, the statechart enters the substate that was active when the statechart left the Play superstate. The Deep History pseudostate defines this behavior. Because this behavior bypasses the Initial pseudostate, the Counter indicator does not reset to 0.
![]() |
Note Only the Pause state has a transition to the Deep History pseudostate. Therefore, if you leave the Play superstate and return to the Menu state, the statechart resets the Counter indicator as usual. Also, notice that the Deep History pseudostate applies only to the Tick Counter region. |
Watching the Counter
Complete the following steps to see this behavior.
- Run the caller VI and watch the state data.
- Click the Play front panel button. The statechart begins incrementing the Counter variable.
- After the Counter indicator reaches 10, click the Pause front panel button. The statechart moves to the Pause state.
- Click the Play front panel button again. The Counter variable resumes counting from the number 10.
- After the Counter indicator reaches 20, click the Menu front panel button. The statechart moves to the Menu state.
- Click the Play front panel button again. The Counter indicator resets because the Menu state does not have a transition to the Deep History pseudostate.
- Stop the caller VI.
- Close the caller VI and all debugging windows.
Summary
In this tutorial, you learned about the following tasks:
- Creating orthogonal regions.
- Defining substates that execute concurrently.
- Extending an existing transition.
- Using state history.
Where to Go from Here
In Part 6 of this tutorial, you create one transition that enters and exits multiple substates simultaneously.
