Centre console is the board which contains the main drive state logic for the entire car. When the car is off (Relays to main battery are open, and car is powered off the aux battery), this board, along with BMS carrier and power distribution are the only ones which are powered, so that they can be used to start the car.
Centre console also provides feedback on the state of the car through:
Buttons to change state
Drive, Reverse, and Neutral
Power button
Regen Braking button
Hazard Button
three 7-segment displays with the below quantities
Speedometer (speed in km/h)
Battery Percentage Indicator (Percent remaining charge)
Cruise Control indicator (desired speed in km/h)
Indicator LEDS
One for each of the above buttons (P/D/N/R/Haz/Reg)
Left turn signal
Right Turn Signal
Cruise control enabled indicator
We will also be displaying error codes on centre console 7-segs when faults occur.
Centre Console Functionality
Module: cc_buttons
This module provides a functions to get all button values. Buttons should be read in the fast cycle. They are connected to the pca9555 gpio expander, and must be read over i2c. This read function should just send notifications to the requisite tasks.
Power Button, hazard, regen: send notifications to main task
R, N, D → Send notifications to Drive FSM
Module: update_dashboard:
Static variables:
cruise_control_state
target_velocity
regen_braking_state
power_state_to_transmit
Functions (all called in medium cycle):
dashboard_init()
update_indicators()
Gets notification value from button presses, updates indicator lights and output can_messages
Power button:
Set cc_power_ctrl.power_event
POWER_EV_NONE if no power button pressed event
POWER_EV_BTN if button is pressed and brake reading == 0
POWER_EV_BTN_AND_BRAKE if button is pressed and brake reading != 0
Hazard enabled:
when pressed, toggle static hazard state
update indicator and cc_power_control.hazard_enabled message based on stored value
Regen Brake:
when pressed, toggle static regen brake state
update indicator and drive_output.regen_brake_enabled message based on stored value
Lights left/right
update left/right indicator based on steering_info.input_lights
Cruise Control Enabled:
update static cc state based on steering_info.cc_input
update indicator based on cc_state
update drive_output based on cc_state + target_velocity
update_displays()
Reads values from CAN messages, uses values for 7-seg:
motor_info.current_speed → speed display
battery_info.batt_percentage → battery display
if (cruise control enabled) target_velocity → cruise control display
cruise_control_monitor()
Checks for cruise control inputs from steering
Updates Cruise control target speed
Drive FSM
The Drive FSM handles the control of drive state of the car. It receives the drive buttons (Neutral (N), Drive (D), Reverse(R)) and runs the preparations and checks needed to change the drive state of the car, and communicate this value with the motor controllers.
The initial/default state is Neutral. This is the mandated state of the FSM when we are in POWER_OFF state or POWER_ON state as dictated by power distribution. In addition, any major faults should force the car into neutral.
The drive state is dependent on power_state == power_drive. We expect to receive this message every cycle, and if we do not receive this message, we will record a fault after 3 cycles
State Input Functions:
All the following must be met for a transition to happen from the following states
Neutral → Drive
Button pressed (D)
Power state == POWER_DRIVE (received from Power distribution)
Speed == 0: All drive state transitions should happen when we are stopped
Actions:
Transmit DRIVE state to MCI
Neutral → Reverse
Button pressed (D)
Power state == POWER_DRIVE (received from Power distribution)
Speed == 0: All drive state transitions should happen when we are stopped
Actions:
Transmit REVERSE state to MCI
Drive → Neutral
Neutral button or force (sent by power fsm)
Transmit NEUTRAL state to MCI
Reverse → Neutral
Neutral button or force (sent by power fsm) or drive_state != main (drive state)
Transmit NEUTRAL state to MCI, receive ACK (state 1)