Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

#36 State Machines Part-2: Guard conditions

19.6K views on YouTube

This lesson continues with STATE MACHINES. Today’s subject is “GUARD CONDITIONS” as a mechanism for making your state machines more flexible. This concept will be needed in the upcoming lessons where I’ll discuss the promised other variants of state machines.

The project for this lesson is to build a state machine for a time-bomb controller. You’ll see why the static state transitions are insufficient to down-count for an arbitrary number of seconds. You’ll then see how a choice pseudostate and GUARD CONDITIONS checked at run-time can be applied to make the state machine flexible to do what you want.

You’ll see the state machine design performed in the freeware QM modeling tool. Later the design will be manually coded in C, whereas you will see how the choice pseudostate and guard conditions map to the C code.

——-
Resources:

Companion web page for this video course:
https://www.state-machine.com/quickstart

GitHub repository for projects for this video course:
https://github.com/QuantumLeaps/modern-embedded-programming-course

Freeware QM modeling tool download:
https://github.com/QuantumLeaps/qm/releases

Transcript of this lesson:
https://www.state-machine.com/course/lesson36.txt

Music credits:
The background music comes from:
https://www.bensound.com/royalty-free-music/track/straight