Embedded Systems December 2000 Vol13_13

Issue link:

Contents of this Issue


Page 41 of 197

MARTIN GOMEZ ~~bedded State Machine plementation Turning a state machine into a program can be pretty straightforwal'd if you follow the advice of a skilled practitioner. any embedded software applications are natural candi- dates for mechanization as a state machine. A program that must sequence a series of actions, or handle inputs differently depending on what mode it's in, is often best implemented as a state machine. This article describes a simple approach to implement- ing a state machine for an embedded system. Over the last 15 years, I have used this approach to de ign dozens of system , including a softkey-based user in terface, several communications protocol , a silicon-wafer transport mechanism, an unmanned air vehicle's lost-uplink handler, and an orbi tal mechanics simulator. State machines For purposes of tllis article, a state machine is defined as an algorithm that can be in one of a small number of states. A state is a condition that causes a prescribed relationship of inputs to outputs, and of inputs to next states. A savvy reader will quickly note that tile state machines described in this article are Mealy machines. A Mealy machine is a state machine where the outputs are a function of both present state and input, as opposed to a Moore machine, in which the outputs are a function only of state.l In both cases, th e next tate is a function of both presenl state and input. Pressman 40 DECEMBER 2000 Embedded Systems Programming

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems December 2000 Vol13_13