Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 51 Next »

Overview

The objective of the driver input system is to wait on the events generated by the attached input devices and use those events to broadcast the relevant message to the correct subsystem. Since the events will, for the most part, be user-initiated, using interrupts is the ideal way to handle incoming events. A series of finite state machines will be used to monitor the current state of the vehicle based on the actions generated by each event. 

Driver Inputs

IO Initialization

To simplify device setup, two separate modules have been created to take care of IO initialization for both digital and analog inputs. A configuration file has also been set up to define the addresses used for each device.

In addition, since the type of ISR needed to handle an input event will depend on whether the input is digital or analog, the responsibility for handling the events for particular device will fall onto either the digital or analog module, depending on the device.

Input Handling 

Since input commands are to be made by the user, the events will be handled through the ISRs. The idea is to use the triggering address to correctly identify an input event, and then raise it in a global event queue. 

Once an event is popped from the queue in the main loop, it must be processed with the correct FSM. Additionally, we must also ensure that a given event is not processed if any of the FSMs are in a state that disallows the event (To prevent situations such as powering off while the car is moving). However, this approach can create dependencies between FSMs, which can result in coupled implementations. To avoid this, an event arbiter is used to see if an event can be processed at the current time. The event arbiter works by looking at the current state of each active state machine and determining whether the event can be processed. This can be thought of as similar to a Caesar Cipher, where the correct alignment of states is needed for the event to be passed.

Through this approach, we can filter out events while also eliminating dependencies between different state machines.

CAN Data Scheme

Until a sufficient protocol can be defined for sending driver input data over CAN, we will be using the following dummy scheme for the event data field:

232221201918171615141312111098
Device IDDevice StateXAnalog Data MSB
76543210
Analog Data LSB
BitDescription
Device ID [7:0]The ID of the device sending the message
Device StateOutputs the new state of the device ()
Analog/DigitalIf the event is an analog signal, con
Analog Data



Pin Assignments

Input DevicePinType
PowerPC0Digital
Gas PedalPA1Analog
Mechanical BrakePA2Analog
Direction Selector ForwardPB2Digital
Direction Selector ReversePB3Digital
Cruise ControlPC4Digital
Cruise Control IncreasePC5Digital
Cruise Control DecreasePC6Digital
Turn Signal RightPC7Digital
Turn Signal LeftPC8Digital
Hazard Light SwitchPC9Digital
I2C Serial Data LinePB9I2C
I2C Serial Clock LinePB8I2C

Finite State Machine

The system will use a series of Finite State Machines to both monitor the current state of the vehicle and ensure that the proper input events are serviced at the correct times.

For a given FSM, each of its states be assigned a filter function to determine if an event can be passed. When an event is raised, all active FSMs will have the filter functions of their respective current states called, with the event passing if all functions return true. This allows us to control eeping separate the implementations of each state machine.

Power State Machine:

Keeps track of the car's functional state.

StateDescriptionTransition
Power OffThe vehicle is off
  • Receiver INPUT_EVENT_POWER signal while in brake and neutral.
Power OnThe vehicle is on
  • Receiver INPUT_EVENT_POWER signal while in the off state.


Pedal State Machine:

This state machine governs the running state of the car and defines the conditions under which the driver can turn on and move the vehicle. Transitions for this FSM depend on the state of the directional state machine.

StateDescriptionTransition

Pedal Brake

The car is on, but braking is active
  • Receive INPUT_EVENT_POWER while in the off state
  • Receive INPUT_EVENT_PEDAL_BRAKE signal while in coast, drive, or cruise control

Pedal Coast

The gas pedal is pressed just enough to allow the car to coast.
  • Receive INPUT_EVENT_PEDAL_COAST signal while in the brake or drive state
Pedal DriveThe brakes are engaged and the car is not moving
  • Receive INPUT_EVENT_PEDAL_PRESSED while in the coast state or brake state (Direction state must be in either forward or reverse)
Cruise ControlThe car is currently in cruise control mode
  • Receive INPUT_EVENT_CRUISE_CONTROL while in coast or drive

Direction State Machine

This state machine governs the possible gear shifts made by the user. Transitions in the pedal state machine depend on the current state of this FSM.

StateDescriptionTransition
NeutralThe vehicle is in neutral gear
  • Receive INPUT_EVENT_DIRECTION_SELECTOR_NEUTRAL signal while the Pedal FSM is in the brake state
ForwardThe vehicle is in forward gear
  • Receive INPUT_EVENT_DIRECTION_SELECTOR_DRIVE signal while the Pedal FSM is in the brake state
ReverseThe vehicle is in reverse
  • Receive INPUT_EVENT_DIRECTION_SELECTOR_REVERSE signal while the Pedal FSM is in the brake state


Turn Signal State Machine

This state machine governs the states of the turn signals made by the driver. Independent from the other FSMs.

StateDescriptionTransition
No signalThe car is currently not signalling
  • Receive INPUT_EVENT_TURN_SIGNAL_NONE signal while either signal is active
Left signalThe car has the left signal active
  • Receive INPUT_EVENT_TURN_SIGNAL_LEFT signal while the left signal is inactive
Right signalThe car has the left signal active
  • Receive INPUT_EVENT_TURN_SIGNAL_RIGHT signal while the right signal is inactive

Hazard Light State Machine

StateDescriptionTransition
Hazard Light On

Hazard lights are currently active

  • Receive INPUT_EVENT_HAZARD_LIGHT signal while hazard lights are off
Hazard Light OffHazard lights are currently inactive
  • Receive INPUT_EVENT_HAZARD_LIGHT signal while hazard lights are on

Horn State Machine

StateDescriptionTransition
Horn OffThe horn is off
  • Receive INPUT_EVENT_HORN signal while the horn is active
Horn OnThe horn is blaring
  • Receive INPUT_EVENT_HORN signal while horn is off

Push-to-Talk State Machine

StateDescriptionTransition
Push-to-Talk ActivePush-to-Talk is currently
  • Receive INPUT_EVENT_PUSH_TO_TALK signal while Push-to-Talk is off
Push-to-Talk InactivePush-to-Talk is off
  • Receive INPUT_EVENT_PUSH_TO_TALK signal while Push-to-Talk is active

  • No labels