Versions Compared

Key

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

...

  • Keeps a static BmsStorage

  • prv_setup_can(): initializes CAN

  • fault_bps(): directly calls relay_process_event() with an OPEN event, takes in a fault bitset and adds it to the current fault bitset, logs over CAN. This will be defined in a fault_bps.h header, included in any module that fault checks, but will be implemented in main.c for access to BmsStorage.fault_bitset.

  • main(): event loop, processes canCAN

  • Should initialize i2c to talk to fan controllers and gpio expander

Can_handler

  • prv_ack_handler(): acks center console during startup

  • prv_..._tx(): transmits data about …

  • prv_periodic_tx(): periodically calls all ...tx() functions

  • can_handler_init(): starts the periodic tx

  • Addendum: also sends state_of_charge

Bps_heartbeat

  • prv_handle_ack(): checks the ack from heartbeats are ok

  • prv_heartbeat_tx(): periodically transmits BPS heartbeat

  • bps_heartbeat_init(): starts the periodic heartbeat

...

  • Needs afe storage for temps

  • prv_calc_speed(): offset linear fan curve calculation based on aggregate temps

  • prv_fan_stuck_cb(): broadcasts if the fans get stuck

  • prv_periodic_set_speed(): periodically calcs speed and sets it with the fan controller driver

  • fan_control_init(): starts periodic set speed

  • when using the ADT7470 driver, in the interrupt handler for SMBAlert, grab status from both fan controllers and set state in FanStorage.

  • Need to update design to reflect that state should be stored per fan, not all together. This should help diagnosing which fan isn’t working.

Relay_control_fsm

  • State machine is:

    1. Open

    2. Close ground

    3. Close hv

    4. Closed

  • Must check relay state after each close and open, BPS fault if relays didn’t follow instructions

  • Wait 100 ms to check relay state, wait 200 ms between closing gnd and closing hv

  • prv_open(): opens gnd then hv, can do them both nearly the same time without checking state in between, but check state afterwards

  • relay_control_init(): inits pins

  • relay_process_event(): opens relays upon relay open event, advances state machine after checks

  • Note: relay sense pins are hidden behind a GPIO expander and will have to be queried through I2C

    • Should register interrupt to tell when relay states change and read latest status

Killswitch

  • Killswitch is basically just a debounced GPIO pin

  • prv_killswitch_cb(): BPS fault

  • killswitch_init(): inits pins. Hidden behind gpio expander, will have to go through that driver.

Cell_sense

  • prv_fault_check(): check fresh data for faults

  • prv_periodic…(): periodically reads AFEs for data

  • cell_sense_init(): begins periodic checks, inits SPI

  • Fault thresholds (from the LG MJ1 datasheet)

    • Undervoltage: 2.5V

    • Overvoltage: 4.2V

    • Overtemp while charging: 45C

    • Overtemp while discharging: 60C

Passive_balance

  • prv_periodic_balance(): periodically checks which cells are highest and raises event for AFEs to balance those cells

  • passive_balance_init(): inits periodic balance

...

  • prv_fault_check(): checks new data for faults

  • prv_periodic_read_current(): read current at least 100 times a second

    • Every 20 readings, update the data in CurrentStorage.

  • current_sense_init(): inits periodic read

  • Note: eventually this module will also be responsible for transmitting data to the RPI for state of charge calculations.

  • Note: to convert from the ADS1259 reading to a current reading, multiply the ADS1259 reading by 100

Data type notes

RelayStorage

...

  • Holds the last 20 current readings, all updated at the same time periodically. Stored as int16_t because current can be negative.

AfeStorage

  • Holds the voltages of 6 modules x3 AFEs

  • Holds the temps of 30 thermistors (exact number TBD) x3 AFEs

...

  • Also holds DebounceStorage, required for killswitch.

  • IMPORTANT: Also holds state_of_charge as a uint32_t or something from raspi

Raspi

  • toggle the 5V_EN pin when we want to turn the raspi on

  • send data to the raspi through UART

  • Receive data from raspi through UART

Drivers

ADT7470

  • fan controller, exposes init() and update_speed(). The ‘stuck’ interrupt is in a GPIO pin, can be registered by the module.

...

  • Current sense

  • exposes init(), and read()

AFE driver is a big WIP TBD.MCP23008

  • May need addition of interrupt configuration