In the image above Oscium’s logic analyzer, Logiscope, and an iPad monitor numerous logic states in a micro controller implementation of a common traffic intersection. There are traffic lights in the model indicating travel for pedestrians, and cars traveling north and south, and cars traveling east and west. The finite state machine model is frequently used in programming as a basis for controlling a system with multiple inputs and outputs. Texas Instrument’s TM4C123G 64-pin Cortex M4 micro controller and LaunchPad evaluation board provide the programmable control for the system.
Simple Finite State Machines
A finite-state machine (FSM) is a model used to design computer programs and sequential logic circuits. Finite state machines are system models characterized by the following:
- A particular FSM is defined by a list of its states and the triggering condition for each transition
- The machine is in only one state at a time
- The state it is in at any given time is called the current state
- It can change from one state to another when initiated by a triggering event or condition
- The next state and output of an FSM is a function of the input and of the current state.
Well Behaved Traffic Intersection System
Programmers use tools like logic analyzers to monitor the output states of embedded systems as the inputs change and trigger events prompt state transitions. The simple traffic intersection is an ideal conceptual model of a state machine because it’s something common where most people have firsthand knowledge. The light is green for only one direction at a time. The light sequence starts with green, then changes to yellow momentarily, and then changes to red while the light for traffic in the other direction begins the sequence, starting with green.
In the image below, the states of the Red, Yellow, and Green traffic lights are shown in the display of Oscium’s Logiscope logic analyzer. See if you can pick out these observations from Logiscope’s display:
- the Green lights are never on at the same time
- the pedestrian Walk light comes on steady while traffic has Red in both directions
- the pedestrian light flashes twice before the steady “Don’t Walk” light come on and traffic flow resumes
Traffic Intersection Malfunctioning
Imagine for a moment if the traffic lights at an intersection on your way home malfunctioned by allowing traffic to move in all directions at once. The north and south bound traffic would collide with the east and west bound traffic. Pedestrians would be left to fend for themselves. In the movie The Italian Job, the hacker genius uses the LA traffic control system to create escape routes for the members of his team by creating massive traffic jams. The system broke down by going into an undefined or disallowed state.
(Originally posted on June 17, 2014 on Oscium’s Blog – Re-posted with permission from our valued partner Oscium)