A deep dive into finite state machines (FSMs) and Harel statecharts for embedded systems programming. Using a motorized couch as a running example, the author demonstrates how FSMs expose corner cases, clarify timing constraints, and produce unambiguous system specifications. The piece covers the limitations of sequential imperative code for concurrent hardware control, the formal definition of FSMs, the evolution to hierarchical statecharts, and a survey of implementation approaches including hand-coded switch statements, tabular implementations, the State pattern, Boost libraries, the QP framework, and model-based code generation tools like SinelaboreRT and Stateflow. Historical context from David Harel's avionics work and the Philips CDR870 project illustrates why formal behavioral specification matters in complex systems.

46m read timeFrom embeddedrelated.com
Post cover image
Table of contents
The Tale of a Young Programmer: Fantasy and EnlightenmentState Machines to the Rescue! (Why Uncle Vic Is Right After All)Hierarchy and StatechartsDetermining Desirable System Behavior: An Exercise in Managing ComplexityTools and Implementation MethodsWrap-up and Further Reading
3 Impressions