Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

StateDescription

Off

The vehicle is not receiving power

IdleBrake

The car is on, but no pedals are pressed

DrivingCruise

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

...

Cruise Control


Image Added

Directional State Machine

Governs 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.

StateDescription
NeutralThe vehicle is in neutral gear
ForwardThe vehicle is in forward gear
ReverseThe vehicle is in reverse

...


Image Added

Turn Signal State Machine

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

StateDescription
No signalThe car is currently not signalling
Left signalThe car has the left signal active
Right signalThe car has the left signal active

Image Added

ADC Driver

Description

On the The STM32 is has 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:

Image Removed

The ADC on the STM32 has 19 multiplexed channels, allowing it to read signals from 16 external sources and 3 internal sources. The pin mappings for the 16 external sources are included below:

...

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


Usage

Analog-to-digital conversion of the different channels can be performed both single mode, in which the ADC converts all the channels at once in a one single sequence of conversions, and continuous mode, where the device automatically restarts the scan after converting all of the different channels. The 12-bit value obtained from the conversion will be stored in the ADC read-only data register (ADC_DR).

The following formula can be used to determine the ADC reading:

Image Added


The sequence of channels to convert is defined in the ADC's 32-bit Channel Selection register (ADC_CHSELR), which contains a series of selection bits corresponding to each analog input channel. By using this register, it is possible to select the set of channels to be converted by the ADC, making it useful for when you want to convert either a single channel or a specific set of them. 


Driver Inputs

SMT32F0 Interrupts

...

The STM32 has the first 16 external interrupt lines set aside for the GPIOs, meaning that there are only 16 digital interrupts available for use on the STM32. The GPIOs are mapped to the external interrupt lines as follows:

Image Added

This means that only one port can have have an interrupt enabled for a given pin number at a time. For instance, enabling interrupt on PA0 will preclude the enabling of interrupts for pin 0 of any other port.

Pin Assignments

Input DevicePin
PowerPC0
Gas PedalPC1
Direction SelectorPC2 - PC3
Cruise ControlPC4
Cruise Control IncreasePC5
Cruise Control DecreasePC6
Turn SignalPB7 - PB8
Hazard Light SwitchPB9
Hazard LightPC10


Handling input requests

The driver control inputs will be connected to onboard GPIOs. As we are only concerned with handling each input as they are triggered, most of the inputs will be set to be handled through the use of interrupts a common ISR (for the prototype, we will collect information on the gas pedal through polling). all set to be handled by interrupt service routine. .

Once the ISR initiates, the pin that triggered it is debounced so that a steady reading can be obtained. The ISR will then observe both the address and the current state of the pin and determine the proper event to process based on that information. For the prototype, this has been implemented through the use of switch statements. However, as more work is done on the system and the amount of input devices increases, there may be a need to add additional functions to delegate the different input requests to, since it would keep the code cleaner and modular as well as easier to debug.

After determining the proper event to process, the IRQ will go through another switch statement to ensure the event is handled by the proper state machine, after which the status of the system will be displayed as a text output. We intend to later output this information to CAN.