Assignment 3
Assignment 3
You are to write a state-machine model for an automobile cruise control system. When
active, the cruise control system keeps a car travelling steadily at a driver-specified speed,
without the driver having to keep his foot on the accelerator pedal. The cruise control
system can be activated only if the car is travelling at least 60 km/hr and if the brake is
not being pressed. An active cruise control system is automatically deactivated if the
driver engages the brake (presumably to react to road or traffic conditions). The driver
can resume a deactivated cruise control system. The cruise control system terminates
when the car’s ignition is turned off.
The driver interacts with the cruise control system via buttons on the steering wheel.
There are four input (button) events:
• activate - used to activate cruise control. The speed-to-be-maintained is initially the
current speed of the vehicle when cruise control is activated.
• inc - used, when cruise control is active, to increment the speed-to-be-maintained
• dec - used, when cruise control is active, to decrement the speed-to-be-maintained
• resume - used to resume cruise control, if the system is deactivated. When cruise
control is resumed, the speed-to-be-maintained will be whatever value it was when the
cruise control system was last active. The command to resume cruise control will succeed
only if the vehicle’s current speed is within 10 km/hr of the speed-to-be-maintained and if
the brake pedal is not being pressed.
In addition to the cruise control buttons, other inputs to the system are
• speed(value) - an event that communicates (via parameter value) the car’s current
speed
• brake pressed - an event that indicates that the driver has pressed the brake pedal
• brake released - an event indicating that the driver has stopped pressing the brake
pedal
• ignition off - an event that indicates that the car’s ignition has been turned off
The system’s outputs are commands to the car’s throttle, to accelerate or decelerate the
vehicle:
• accelerate - an output event to the throttle, to try to accelerate the car
• decelerate - an output event to the throttle, to try to decelerate the car
Draw a State Machine model of the described cruise control system. You may use any
state machine modelling construct presented in lecture. You are restricted to using only
the above input and output events. You do not need to declare these events. Do declare
any constants, variables, and functions that you use.
You are to write a state-machine model for a new safe and efficient system for lighting a
room. The new system avoids waste by automatically turning lights off when a room is
unoccupied.
Draw a State Machine model of the described lighting system. You may use any state
machine modelling construct presented in lecture. Declare any constants, events,
variables and functions that you use.
The following are properties of the above state machine models. For each of these
properties, write an equivalent temporal logic expression. Your formulae must be
expressions over your State Machines' events, states, and variables.
• When cruise control is active, pressing the inc button will cause the speed-to-be-
maintained to increase by 1.
• The brake is never depressed while cruise control is active.
• When cruise control is active and accelerating the car, it will continue to
accelerate until the car speed equals the speed-to-be-maintained or until cruise
control becomes inactive.
• The room is initially not illuminated.
• If the room is unoccupied, then if the room is not reoccupied, the lights will
eventually be turned off.
• When the room is occupied, it is illuminated and remains illuminated until the
room is unoccupied for T1 seconds.