|
PER Firmware
|
Provides a high-level interface for managing ADBMS6380 battery management modules in a single-direction daisy chain configuration. It handles communication, configuration, and measurement collection, and balancing for multi-module battery packs, supporting cell voltage, thermistor, GPIO readings as well as error detection via PEC checks.
adbms_bms_t struct and a TX buffer: nss_sw must be false in the SPI config).Call the periodic function regularly:
This updates cell voltage, thermistor readings, and error flags (and all the aggregate statistics) in the adbms_bms_t g_bms struct.
BMS task should have high priority to ensure timely updates of measurements and so that SPI communication is not delayed/interrupted.
After each periodic call, values can be read from the adbms_bms_t struct:
g_bms.modules[i].cell_voltages: Per-module cell voltagesADBMS6380_CELL_COUNT (16) per moduleg_bms.modules[i].therms_temps: Per-module thermistor temperatures in CelsiusADBMS6380_GPIO_COUNT (10) per moduleADBMS_GPIO_R1 = 10kOhmsADBMS_GPIO_VIN = 3.0vg_bms.min_voltage/g_bms.max_voltage/g_bms.avg_voltage/g_bms.sum_voltage: Pack-level cell voltage statisticsg_bms.min_temp/g_bms.max_temp/g_bms.avg_temp: Pack-level thermistor temperature statisticsg_bms.err_spi: SPI HAL errorg_bms.err_rega_mismatch: REGA register mismatch errorg_bms.modules[i].err_rega_mismatch and g_bms.modules[i].err_regb_mismatch)g_bms.err_*_pec: PEC error flags for various operations (register reads, cell voltage reads, GPIO voltage reads). Indicates potential communication issues or data corruption. In the case of a PEC error during reading cell or GPIO voltages (which require multiple read commands), only the specific command that failed will have its PEC error flag set and the rest of the voltages for successful commands will still be updated/valid and the pack-level statistics will be updated based on the new valid readings and the old readings for the failed commands.is_discharge_enabled field in the adbms_bms_t struct before the next periodic call: The balancing algorithm is a simple threshold-based approach:
MIN_V_FOR_BALANCE (defined in ABOX)MIN_DELTA_FOR_BALANCE (also defined in ABOX)adbms.h/c: High-level driver logic and state management.adbms6380.h/c: Low-level chip-specific functions and command encoding.commands.h/c: Command definitions for ADBMS6380.pec.h/c: PEC (CRC) calculation utilities.osDelay(ADBMS6380_WAKE_DELAY_MS) in the wake-up sequence.ADBMS_MODULE_COUNT constant matches the actual number of modules in your daisy chain configuration!!../thermistor/thermistor.c (and externed in the header): thermistor_lut