[WIP] Controls Leader
Github link:
Clickup link: https://app.clickup.com/t/868e8qn90
Description
This board handles dashboard inputs, robustly detects connection failures, and relays data to other boards.
Design Spec
Hardware
2x CAN chips and in/out connector pairs
Controls CAN
Car CAN
Receive main power/ground (24V)
Buck for MCU/PSOMs
Receive isolated power/ground
for CAN
Dashboard IO:
Ignition switch
Gear switch
Cruise set
Cruise enable
Regen enable
Hazard lights
Sup switch (isolated)
Steering wheel IO:
Left turn indicator
Right turn indicator
Horn
Regen active
Software
Send on CarCAN:
ignition state [2 bits]
gear state [2 bits]
regen en [1 bit]
regen active [1 bit]
left indicator on [1 bit]
right indicator on [1 bit]
headlights on [1 bit]
brakelights on [1 bit]
cruise en [1 bit]
cruide set [32 bits]
error status bitmap [XX bits]
Read from CarCAN:
Pedals info from pedals board (for brakelights)
BPS fault (start hazards automatically)
Look for faults in button/switch states
Send commands on ControlsCAN whether we need to turn on lights or not
headlights on [1 bit]
brake light on [1 bit]
left turn indicator en [1 bit]
right turn indicator en [1 bit]
(for hazards just set left and right to both 1)
blink synchronization bit [1 bit]
(1 for light on, 0 for light off)
custom config 1 [1 bit]
custom config 2 [1 bit]
custom config 3 [1 bit]
Receive status messages from lighting boards on ControlsCAN and forward to CarCAN
Hardware Testing
MOSFET Button inputs ✅ - mosfet turns on and off when signal input (gate) is set to high
24v → 5v buck ✅
5v → 3.3v LDO ✅
LSOM Testing
RevB Modifications:
RevB Testing Plan (gpio is too ez)
Priority:
Hardware testing:
Software testing
Software Testing
Software Design
RTOS Tasks:
Task #1: read CarCAN → when BPS Fault call a function and set global variable → turns on hazards, status led, and indication pwm bps fault led
if bps fault enable, stop polling, send static messages: no driver input message, static lights commands of just hazards
watch dog for BPS - if input from BPS status takes more than 2x its message send rate, then consider it as a fault - use xTaskCreateTimer for a software timer
Task#2:
Write CarCAN (steering angle, driver msg, controls status)
Write ControlsCAN (PeripheralCAN) - lighting board msgs here
polling switches: Hazard, Regen Active, Cruise Enable, Cruise Set, Horn, Left Blinker, Right Blinker, regen enable, Push to talk
Task #3: read SteeringAngleCAN (task waits for CAN ISR)
Task #4: Read ControlsCAN - status messages from each lighting board? (make this dynamic) - no msg for a while a/multiple boards faulted.
ISRs:
switches:
Ignition Switch (3 states)
gear switch (3 states)
Driver message: CarCAN
Controls Status Message:
Includes the error bit map
Switches
Switches.h:
FWD_SW (adc1_in1) - A0
Neautral_Gear (adc1_in6) - C0
Rev_SW (i2c4_sda) - C7
Cruise_Enable (i2c4_scl) - C6
Cruise_Set (i2c3_sda) - C9
Regen_Enable (adc1_in8) - C2
Hazard (i2c3_scl) - A8
Horn (uart5_rx) - D2
Regen_Active (uart5_tx) - C12
Right_Blinker (usart1_tx) - C4
Left_Blinker (usart1_rx) - C5
PTT (adc2_in12) - B2
Ign_OFF (adc1_in3) - A2
Ign_ARR (ADC1_IN15) - B0
Ign_MTR (ADC1_in2) - A1
Switch.c:
get_switch_state(gpiopin, gpioport)
Status LEDs
Status_LEDs.h:
CarCan_RX_Pin 3, Port B
CarCan_TX_Pin 5, Port B
PH_CAN_RX_Pin 15, Port A
PH_CAN_TX_Pin 4, Port B
Controls_HB_LED_Pin 11, Port C
BPS_Fault_LED_Pin 6, Port A
Indicator_PWM_Pin 15, Port B @Srikiran Sathvik Yechuri todo
Akshay_LED (Uart4_tx) - c10
X_LED2 (spi2_miso) - b14
Status_LEDs_test.c:
void toggle_LED(GPIO_TypeDef port, uint16_t pin, GPIO_Pin_State state)