Download presentation
Presentation is loading. Please wait.
1
Finite State Machines ENGR 110 #7 2016
2
Menu Designing a controller for traffic lights.
What is a Finite State Machine? Finite State Machines for controllers. Announcements:
3
Traffic Lights Traffic lights at Salamanca Rd/The Terrace
They are annoying! How should they work? Simple – only a three way intersection Write down a design.
4
Finite State Machine What are FSM's?
A way of thinking about certain kinds of problems A way of describing/modeling/analysing systems A way of designing solutions to a wide range of engineering problems. Example applications Models of physical devices Controllers for physical devices Controllers for NPCs in computer games Protocols for communications/networking Regular expression searching in text Analysing and Designing user interfaces. Speech recognition ….
5
States and Transitions
Key idea: If a system has finite set of possible states, then you can list them, and identify each of the possible things that could happen in each state. Typically: draw labelled circles for the states draw labelled arrows for the transitions between them transition1 transition3 State1 State2 transition2
6
States and Transitions
Eg: modelling a Door: Possible states: open, closed Possible transitions: push, pull (Take system from one state to another ). , closed&Locked , turn key or back to same state) push turn key push pull push open closed closed & locked turn key pull pull turn key
7
States and Transitions
Eg: an ecommerce website: states: the series of pages in the purchase sequence transitions: the buttons: buy now, next, back, confirm, back to cart Useful model when first designing the web pages. Cart back to cart back to cart back to cart buy now next next confirm Address Details Payment Details Confirm- ation Receipt back back
8
Abstraction Typically, a Finite State Machine is an abstraction:
Simplification Capturing the significant aspects of the behaviour Leaving out unimportant details Describes the system at a particular level. eg: the door: how far open the door is, how big the door is, what kind of key it uses how hard you have to push to close it. …. eg the website no details of the actions on each page
9
Kinds of Finite State Machines.
Lots of different varieties of Finite State Machines. Describing how a passive system works. states the system can be in, actions on the system that change its state. eg: the door, the website, a DVD player, Can use the FSM description to Design the system Explain the system to users Construct a simulation of the system …. open closed & locked pull push turn key turn key
10
Kinds of Finite State Machines.
Describing/specifying an active system states the system can be in input/signals/sensors that the system may respond to actions that the system will perform eg: an autonomous vehicle with sensors a controller for a robotic toy an NPC in a video game a controller for a lift (the assignment) … begging patted start begging stop stop timer timer walking waiting turning round patted IR sensor start walk, start timer(30) start turning, start timer(10)
11
Kinds of Finite State Machines.
Specifying a pattern or a language states representing different points in the pattern characters/words/signals that are the next component of the pattern eg: Regular expression matching in an editor (SW|NW|EC)EN3[0-9][0-9] Sequence of the sounds for different phonemes in a word Simple command language for an adventure game. (Fundamental to some algorithms for text and language.) Specifying a communication protocol states representing different stages in the communication message types that are expected or required at each stage
12
? Controllers Devices to control systems. Controller
Could be hardware, but usually software, might be a microprocessor or a large computer. Controller gets input from the system Controller performs actions on the system to change its behaviour Note: two different systems here: controller and the controlled system. Might need to design both, but they are separate issues. System: robotic toy autonomous vehicle lift traffic lights vending machine animation of NPC etc. Controller ? Signals/sensors actions
13
Simple Reactive Controllers.
Controller drives the system: Input: Signal/sensor value from the system triggers an action Output: Action, reacts to the signal Same response to a sensor, every time Very limited System: robotic toy autonomous vehicle lift traffic lights vending machine animation of NPC etc. Signals/sensor values Controller Signal1 ⇒ action1 Signal2 ⇒ action2 Signal3 ⇒ action3 Signal4 ⇒ action4 actions
14
FSM Controllers. Controller drives the system: System: Controller
Input Signal/sensor from the system triggers an action and changes state (of the controller) States represent the history of what has gone before to enable different responses to same sensor at different times Much richer behaviour. System: robotic toy autonomous vehicle lift traffic lights vending machine animation of NPC etc. Signals/sensors Controller sensor action actions
15
Example: Traffic light controller
Signals/sensor values? Actions? States? what are the different conditions where the controller should act differently? eg: should it always change the lights when a car drives up?
16
States for traffic light controller
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.