Case Study: Cruise Control Murray Cole Cruise Control 1 - - PowerPoint PPT Presentation

case study cruise control
SMART_READER_LITE
LIVE PREVIEW

Case Study: Cruise Control Murray Cole Cruise Control 1 - - PowerPoint PPT Presentation

I V N E U R S E I H T Y T O H F G R E U D I B N Case Study: Cruise Control Murray Cole Cruise Control 1 Cruise Control Basic idea allow driver to set a speed to be maintained without his/her intervention (


slide-1
SLIDE 1

T H E U N I V E R S I T Y O F E D I N B U R G H

Case Study: Cruise Control

Murray Cole

Cruise Control

slide-2
SLIDE 2

1

Cruise Control

Basic idea

  • allow driver to set a speed to be maintained without his/her

intervention (e.g. 70mph down a long straight motorway)

  • no need to keep accelerator pressed (less driver fatigue)

Cruise Control

slide-3
SLIDE 3

2

Specification

Pin down some requirements

  • Driver can request the system to maintain the current speed
  • Driver can always turn it off
  • System should not operate after braking
  • System should allow the driver to travel faster than the set speed

Cruise Control

slide-4
SLIDE 4

3

Design an FSM

We need to

  • specify the inputs
  • specify the outputs
  • decide on the required states (and a start state)
  • specify the transitions

Cruise Control

slide-5
SLIDE 5

4

Driver Inputs

  • n: on/off button
  • set: set the cruise speed to the current speed
  • brake: the brake has been pressed
  • accP: the accelerator has been pressed
  • accR: the accelerator has been released
  • resume: resume travelling at the set speed

Cruise Control

slide-6
SLIDE 6

5

Sensor Inputs

  • correct: indicates the car is travelling at the correct speed.
  • slow: indicates the car is going slower than the set speed
  • fast: indicates the car is going faster than the set speed

Cruise Control

slide-7
SLIDE 7

6

Control Outputs

  • store: store the current speed as the cruise speed
  • inc: increase the throttle
  • dec: decrease the throttle

Cruise Control

slide-8
SLIDE 8

7

States

Off: System is not operational. Ready: Switched on but no cruise speed set. Set: Actively controlling speed. Wait: Speed set but subsequently overridden by brake. Wait to be told to resume control. Acc: Accelerator is currently pressed down (so override)

Cruise Control

slide-9
SLIDE 9

8

The Controller

accP accR

  • n
  • n

set/store

  • n

brake resume correct fast/dec Acc Set

  • n
  • n

Wait Ready Off slow/inc

All other inputs are loops with no output (ie ignored). Omitted here for clarity!

Cruise Control

slide-10
SLIDE 10

9

Java Implementation

Model (real system would interact with car hardware)

  • inputs with strings from the keyboard
  • utputs with strings to the monitor
  • state by a variable holding an integer
  • transitions by code which changes state and makes outputs in

response to inputs

Cruise Control

slide-11
SLIDE 11

10

Overview

// Initialise Values // Repeat Forever while(true) { // Display Current State // Read input from keyboard // Make a transition // Display any output }

Cruise Control

slide-12
SLIDE 12

11

public class CruiseControl { // Inputs public static final int on = 1; public static final int set = 2; public static final int brake = 3; public static final int accP = 4; ......... // Outputs public static final int store = 10; public static final int inc = 11; public static final int dec = 12; // States public static final int OFF = 13; public static final int READY = 14; ......

Cruise Control

slide-13
SLIDE 13

12

int input = 0; int output = 0; int state = OFF; while(true) { String in = keyboard.readLine(); if (in.equals("on")) input = on; else if (in.equals("set")) input = set; .......... else input = 0; // Make the appropriate transition (NEXT OVERHEAD) switch(output) { // Display any output case store: System.out.println(" store "); break; ......... } }

Cruise Control

slide-14
SLIDE 14

13

switch(state) { ............. case SET: switch(input) { case on: state = OFF; break; case brake: state = WAIT; break; case accP: state = ACC; break; case fast:

  • utput = dec; break;

case slow:

  • utput = inc; break;

case correct: break; default: break; } break; .......... }

Cruise Control

slide-15
SLIDE 15

14

Maintenance

The incident occurred when the driver was on a highway on a rainy night. The traffic was slow, travelling at about 40 mph. The driver engaged cruise control and set it to 40 mph. Later the rain cleared and the traffic got faster so the driver used the accelerator to increase the speed to 60 mph and travelled in this mode for some miles (the controller still in set mode but

  • verridden by the accelerator).

Coming to the exit ramp the driver turned off and released the accelerator to coast up the ramp. At that point the cruise control aimed to stabilise the speed at the set level (40 mph). The driver was taken by surprise and lost control of the car which travelled through a stop sign without braking. Fortunately no accident

  • ccurred.

Cruise Control