[WIP] Controls Leader

[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 ✅

image-20251202-222807.png

5v → 3.3v LDO ✅

image-20251202-222821.png

LSOM Testing

Need LSOM from Tony

RevB Modifications:

CHANGE HORN PWR FLYBACK DIOD FOOTPRINT!!!!
add a fuse for 24v powering lights
yay

RevB Testing Plan (gpio is too ez)

Priority:

solder fuse holders, inductor, conns
build nanofit test female conns to plug into the board and test each input (2x6, 2x3, 1x4 are all the ones i need)
there are some resistors on the back that are not soldered… solder them

Hardware testing:

check for shorts on the 24v->5v buck with multimeter (i trust that this works, only problem last time was my soldering. I’ll still check this just in case)
check for shorts on 24v->16v (i already have existing test points for testing around the IC)
CHECK VOLTAGE DIVIDER RATIO
continuity test across the input signal FETscircuits to check for shorts
connect 5v and check if FETs short the drain and source (3.3v_lsom with the gpio pin inputs)

Software testing

connect the brand new lsoms and test my GET_FLASHED code to test all the status LEDs
check if the Controls_HB_LED is tweaking again (hopefully the soldering was the issue and is fixed now)
use my IO test code to test all input FET circuits, and check if LSOM can read the gpio input via software
I haven't started on CAN…. something for me Todo for RevB in general

Software Testing

Software Design

RTOS Tasks:

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

    1. if bps fault enable, stop polling, send static messages: no driver input message, static lights commands of just hazards

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

  2. Task#2:

    1. Write CarCAN (steering angle, driver msg, controls status)

    2. Write ControlsCAN (PeripheralCAN) - lighting board msgs here

    3. polling switches: Hazard, Regen Active, Cruise Enable, Cruise Set, Horn, Left Blinker, Right Blinker, regen enable, Push to talk

  3. Task #3: read SteeringAngleCAN (task waits for CAN ISR)

  4. Task #4: Read ControlsCAN - status messages from each lighting board? (make this dynamic) - no msg for a while a/multiple boards faulted.

ISRs:

  1. switches:

    1. Ignition Switch (3 states)

    2. gear switch (3 states)

Driver message: CarCAN

  • image-20260206-063628.png

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)