State Machines

State Machines

Copyright: © 2017 |Pages: 22
DOI: 10.4018/978-1-68318-000-5.ch011
OnDemand PDF Download:
$30.00
List Price: $37.50

Chapter Preview

Top

Introduction

State diagrams are used to implement Moore or Mealy machines having a number of inputs, outputs and states. These diagrams pictorially describe the algorithms to be realized in hardware. A state diagram consists of the following:

  • The states of the machine.

  • The inputs which take the machine from one state to another.

  • Moore and/or Mealy outputs. Moore outputs change at the clock transition whereas Mealy outputs change immediately as a function of the inputs applied and the current state of the machine.

In brief, state diagrams summarize the behavior of a state machine with all pertaining details. Commonly, they are used to implement sequential circuits via MSI/LSI components or programmable chips such as PALs, GALs or FPGAs. This chapter emphasizes the software realization of state machines through a number of microcontroller applications.

Top

Garage Door Opener

A garage door opener is a motorized device that opens and closes garage doors. Most are controlled by switches on the garage wall, as well as by remote controls carried by the owner. A simple model of the whole system, illustrated in Figure 1, consists of:

  • 1.

    A rolling door controlled by a DC motor. The motor is driven by an H-bridge with two control signals MotorUp and MotorDn that specify the direction: MotorUp = 1 rolls the door up and MotorDn = 1 rolls it down. If none of these signals is asserted then the motor stands still.

  • 2.

    A push-button B (Button) which serves to either start the motor when it is stopped or simply to reverse the door’s motion direction when the motor is running.

  • 3.

    Two limit switches that can detect whether the door is in the rolled-up position or in the rolled down position. These sensors are “ORed” together to provide one input signal C (Complete) to the controller; cause in both cases the motor must be stopped.

  • 4.

    An infrared sensor whose role is to detect any obstruction (car, human, animal, etc.) in the door path. This consists of an IR transmitter which emits a beam of invisible light between the door’s rails. If this beam is obstructed, a signal S (Stalled) applied to the controller is asserted. This reverses the door’s direction in case it is going down.

  • 5.

    Last but not least is the microcontroller that implements the state machine of the garage door opener.

The three switches emulating the actual sensors use internal pull-up resistors. Obviously, these switches provide active-low logic levels when pressed. However, since they are tied to the INTx (x = 0, 1, 2) pins, the associated flags INTxIF (x = 0, 1, 2) not only offer active-high logic levels but also they memorize the button pressing event.

The H-bridge is used to reverse the motor’s direction. For instance, if MotorDn is driven high, the MOSFETs P2G and N1G conduct and hence they provide a current path to the motor via terminals 2 and 1. As a result, the door rolls down.

Figure 1.

Hardware for the garage door opener

The state diagram of the garage door opener is shown in Figure 2. Again, the machine has three inputs: Button (B), Complete (C) and Stalled (S) along with four states:

Complete Chapter List

Search this Book:
Reset