New Videos Explain Finite State Machines

share on: 
Share on reddit
Share on linkedin
Share on twitter
Share on email
Originally published on:  
Last updated on: 
Hierarchical State Machine
Table of Contents

The popular “Modern Embedded Programming” video course now contains a segment devoted to state machines. If you really want to understand state machines, this is your ultimate resource!

Playlist: State Machines
Video playlist "State Machines"

What are State Machines?

These lessons start a new segment about STATE MACHINES. The lesson starts with the biggest challenge of event-driven programming, which is preserving the context from one event to the next. You’ll see how the usual improvised context management leads to “spaghetti code”.

Next, you’ll see a different approach, in which you capture only the “relevant history” of the system and how this leads to the concepts of “State” and “State Machine”. You’ll also learn the basic elements of state diagrams, and you’ll see how to design a state machine diagram for the “Blinky-Button” example.

Finally, you’ll see how state machines complement the Active-Object design pattern and you go through the experience of coding a state machine in C.

State Machines Basics

2 Videos

What are Different Kinds of State Machines?

This lesson continues the subject of STATE MACHINES, whereas today’s subject is “input-driven state machines”. This type of software state machines is the closest to their hardware precursors.

The lesson starts with an introduction to Mealy and Moore circuits and how they can be described by truth tables and state diagrams.

Later the lesson introduces input-driven state machines in software and shows several examples and terminology. You will learn about the inputs driving the state machines, the execution environment of such state machines, and the main problems.

The project for this lesson is based on in input-driven Blinky state machine used briefly in lesson 21. You will see examples of problems with unreliable polling of the inputs. You will also see how adding more and more buffering of inputs gradually leads to event-driven state machines.

Kinds of State Machines

2 Videos

How to Implement a State Machine in C?

This lesson continues the subject of STATE MACHINES. Today you will learn the “optimal” state machine implementation in C. You will start with designing a simple “domain specific language” (DSL) for specifying state machines and then you will turn it into a C program. You will then generalize the implementation into a reusable “event processor” to include this optimal state machine implementation strategy directly in the Micro-C-AO active object framework that you’ve been building in this segment of lessons.

This lesson includes quite a bit of coding with the intent to give you some “pair programming” experience as you witness gradual transformation of the design into C.

Also, you will see and compare other state machine DSL based on the SMC (State Machine Compiler).

Finally, you will see a technique of measuring code execution speed on ARM Cortex-M CPUs by means of the Cycle Counter register in the DWT (Data Watchpoint and Trace) hardware block.

What are Hierarchical State Machines?

This lesson continues the subject of STATE MACHINES. Today you will get the first glimpse of the modern hierarchical state machines. You will learn what hierarchical state machines are and how they differ from the traditional finite state machines. You will also get an idea how to implement state hierarchy in C and you’ll see which aspects are easy and which are harder to implement. Finally, you ‘ll port your TimeBomb application from the toy Micro-C-AO framework to the professional QP/C framework, where hierarchical state machines are fully supported.

How to Implement Hierarchical State Machine in C?

This lesson continues the subject of STATE MACHINES. Today you will see how automatic code generation works in practice. Graphical modeling and automatic code generation do not seem to be mainstream yet, but they are very much parts of the modern approach and I believe they are the future of embedded software development.

How Exactly a HSM Reacts to Events?

This lesson continues the subject of STATE MACHINES. Today you will dive deeper into the semantics of hierarchical state machines. Specifically, in this lesson you will examine a hierarchical state machine with multiple levels of state nesting. You will then see how this more advanced state machine handles various transitions and exactly which actions are executed in which order.


Leave a Reply