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 8 Next »

Finite State Machine

The program will be controlled through the use of a Finite State Machine to ensure that inputs can only be serviced at the appropriate periods. The states defined are defined as follows:

StateDescription

Off

The vehicle is not receiving power

Idle

The car is on, but no pedals are pressed

Driving

The gas pedal is pressed car is in motion.
BrakeThe brakes are engaged and the car is not moving


Each input can only be serviced during certain states. Certain inputs can also cause transitions when serviced during certain states.

Input DeviceOffIdleDrivingBrakingNotes
Horn

Check mark symbol

Check mark symbol

Check mark symbol


Power Switch

Check mark symbol

Check mark symbol



Transitions between the "off" state to the "idle" state
Emergency Switch

Check mark symbol

Check mark symbol

Check mark symbol

Driver needs to be able to always access this

Push-to-talk


Check mark symbol

Check mark symbol

Check mark symbol


Direction Selector



Check mark symbol

Need to be holding the brakes to change gears
Headlights

Check mark symbol

Check mark symbol

Check mark symbol


Turn Signals

Check mark symbol

Check mark symbol

Check mark symbol

Direction indicator lights must flash at a rate of 90±30 flashes per minute (between 1 and 2 Hz)
Hazard Lights

Check mark symbol

Check mark symbol

Check mark symbol


Cruise Control ON/OFF

Check mark symbol

Check mark symbol


Needs to turn off automatically once the program transitions to "idle"
Cruise Control Inc/Dec


Check mark symbol



Regen Strength

Check mark symbol

Check mark symbol

Check mark symbol


Gas Pedal

Check mark symbol

Check mark symbol


Triggers a transition from the "idle" state to the "driving" state when pressed, and a transition from "driving" to "idle" when released
Brake Pedal

Check mark symbol

Check mark symbol

Check mark symbol

If anti-lock brakes are used, the front wheels must be stopped before the back wheels

ADC Driver

On the STM32 is a 12-bit analog-to-digital converter (ADC). The role of an ADC is to take an analog signal as an input and give as output a digital number proportional to the magnitude of the input signal. The following formula can be used to determine the ADC reading:

The ADC has 19 multiplexed channels, with 16 of them being mapped to analog input pins. The 16 external pin mappings for the STM32 are as follows:


ADC ChannelPin Name
ADC_IN0PA0
ADC_IN1PA1
ADC_IN2PA2
ADC_IN3PA3
ADC_IN4PA4
ADC_IN5PA5
ADC_IN6PA6
ADC_IN7PA7
ADC_IN8PB0
ADC_IN9PB1
ADC_IN10PC0
ADC_IN11PC1
ADC_IN12PC2
ADC_IN13PC3
ADC_IN14PC4
ADC_IN15PC5

In addition, the ADC has two different modes for converting analog signals:

Single Conversion Mode: The ADC performs the conversion for a channel and stops after the conversion for that channel has been completed

Continuous Conversion Mode: The ADC will convert a channel indefinitely at regular intervals 


  • No labels