...
The program will be controlled through the use of multiple Finite State Machines to ensure that inputs are only serviced at the appropriate periods. The system will use three state machines to :
Within the state machines used in this system, there exist transitions that depend on the current states of other state machines. However, since the current FSM API does not provide a way to view the current state outside of string comparisons, a wrapper struct will be used to hold both the FSMs as well as their current states. In addition, the code defining each FSM has been split up, which will make it easier to add new FSMs in the future if needed. As of now, the driver input system is controlled by four FSMs.
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.
State | Description | Transition |
---|---|---|
Off | The vehicle is not receiving power |
|
Brake | The car is on, but braking is active |
| ||
Coast | The gas pedal is pressed just enough to allow the car to coast. |
|
Drive | The brakes are engaged and the car is not moving |
|
Cruise Control | The car is currently in cruise control mode |
|
Directional 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.
State | Description | Transition |
---|---|---|
Neutral | The vehicle is in neutral gear |
|
Forward | The vehicle is in forward gear |
|
Reverse | The vehicle is in reverse |
|
Turn Signal State Machine
This state machine governs the states of the turn signals made by the driver. Independent from the other FSMs.
State | Description | Transition |
---|---|---|
No signal | The car is currently not signalling |
|
Left signal | The car has the left signal active |
|
Right signal | The car has the left signal active |
|
Hazard Light State Machine
State | Description | Transition |
---|---|---|
Hazard Light On | Hazard lights are currently active |
|
Hazard Light Off | Hazard lights are currently inactive |
|
ADC Driver
Description
The STM32 has a 12-bit onboard 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 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:
...
Once the ISR initiates, the pin that triggered it the request 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 and the ISR determines the proper event to process based on that informationthe debounced state of the pin. 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 ISR 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 later intend to later output this information to CAN.
...