diff --git a/libraries/codegen/boards/bms_carrier.yaml b/libraries/codegen/boards/bms_carrier.yaml index a56f81c3d..d563b26ea 100644 --- a/libraries/codegen/boards/bms_carrier.yaml +++ b/libraries/codegen/boards/bms_carrier.yaml @@ -25,11 +25,18 @@ length: 8 fan2: length: 8 + + battery_info: + id: 33 + target: + centre_console: + watchdog: 0 + signals: aux_batt_v: - length: 16 + length: 32 max_cell_v: - length: 16 - + length: 32 + battery_vt: id: 30 target: diff --git a/projects/bms_carrier/src/aux_sense.c b/projects/bms_carrier/src/aux_sense.c index 60c8a2143..75335524a 100644 --- a/projects/bms_carrier/src/aux_sense.c +++ b/projects/bms_carrier/src/aux_sense.c @@ -15,9 +15,10 @@ StatusCode aux_sense_init(AuxStorage *aux_storage) { StatusCode aux_sense_run() { adc_run(); adc_read_converted(aux_sense_pin, &s_aux_storage->aux_battery_voltage); + LOG_DEBUG("AUX READING ORIGINAL: %d\n", s_aux_storage->aux_battery_voltage); s_aux_storage->aux_battery_voltage = (s_aux_storage->aux_battery_voltage) * (R2_OHMS + R1_OHMS) / R2_OHMS; LOG_DEBUG("AUX READING: %d\n", s_aux_storage->aux_battery_voltage); - set_battery_status_aux_batt_v(s_aux_storage->aux_battery_voltage); + set_battery_info_aux_batt_v(s_aux_storage->aux_battery_voltage); return STATUS_CODE_OK; } diff --git a/projects/bms_carrier/src/cell_sense.c b/projects/bms_carrier/src/cell_sense.c index 811926d11..81d7fcb30 100644 --- a/projects/bms_carrier/src/cell_sense.c +++ b/projects/bms_carrier/src/cell_sense.c @@ -101,7 +101,7 @@ StatusCode cell_sense_run() { } LOG_DEBUG("MAX VOLTAGE: %d\n", max_voltage); LOG_DEBUG("MIN VOLTAGE: %d\n", min_voltage); - set_battery_status_max_cell_v(max_voltage); + set_battery_info_max_cell_v(max_voltage); if (max_voltage >= CELL_OVERVOLTAGE) { LOG_DEBUG("OVERVOLTAGE\n"); diff --git a/projects/bms_carrier/src/main.c b/projects/bms_carrier/src/main.c index 9d111bf62..6b7f8f71b 100644 --- a/projects/bms_carrier/src/main.c +++ b/projects/bms_carrier/src/main.c @@ -38,8 +38,8 @@ BmsStorage bms_storage; void pre_loop_init() { LOG_DEBUG("Welcome to BMS \n"); fault_bps_init(&bms_storage.bps_storage); - current_sense_init(&bms_storage, &i2c_settings, FUEL_GAUGE_CYCLE_TIME_MS); - cell_sense_init(&bms_storage.ltc_afe_storage); + // current_sense_init(&bms_storage, &i2c_settings, FUEL_GAUGE_CYCLE_TIME_MS); + // cell_sense_init(&bms_storage.ltc_afe_storage); aux_sense_init(&bms_storage.aux_storage); init_bms_relays(&bms_storage); bms_fan_init(&bms_storage); @@ -51,12 +51,12 @@ void run_medium_cycle() { run_can_rx_cycle(); wait_tasks(1); - cell_conversions(); - wait_tasks(1); - current_sense_run(); - wait_tasks(1); + // cell_conversions(); + // wait_tasks(1); + // current_sense_run(); + // wait_tasks(1); - cell_sense_run(); + // cell_sense_run(); aux_sense_run(); fsm_run_cycle(bms_relays); diff --git a/projects/bms_carrier/src/relays_fsm.c b/projects/bms_carrier/src/relays_fsm.c index f89c3f85c..06fcfd9cd 100644 --- a/projects/bms_carrier/src/relays_fsm.c +++ b/projects/bms_carrier/src/relays_fsm.c @@ -10,13 +10,13 @@ static const GpioAddress neg_relay_en = { .port = GPIO_PORT_B, .pin = 4 }; static const GpioAddress solar_relay_en = { .port = GPIO_PORT_C, .pin = 13 }; static void close_relays() { - // 150 MS GAP BETWEEN EACH RELAY BC OF CURRENT DRAW + // 300 MS GAP BETWEEN EACH RELAY BC OF CURRENT DRAW gpio_set_state(&pos_relay_en, GPIO_STATE_HIGH); - delay_ms(150); + delay_ms(200); gpio_set_state(&neg_relay_en, GPIO_STATE_HIGH); - delay_ms(150); + delay_ms(200); gpio_set_state(&solar_relay_en, GPIO_STATE_HIGH); - delay_ms(150); + delay_ms(200); } static void open_relays() { diff --git a/projects/centre_console/src/update_dashboard.c b/projects/centre_console/src/update_dashboard.c index e7ce7e283..e5004ac84 100644 --- a/projects/centre_console/src/update_dashboard.c +++ b/projects/centre_console/src/update_dashboard.c @@ -60,8 +60,8 @@ void update_indicators(uint32_t notif) { } // Update regen light if (notify_check_event(¬if, REGEN_BUTTON_EVENT)) { - uint16_t batt_voltage = get_battery_status_max_cell_v(); // Gets max voltage out of all cells - uint16_t batt_current = get_battery_status_max_cell_v(); + uint16_t batt_voltage = get_battery_info_max_cell_v(); // Gets max voltage out of all cells + uint16_t batt_current = get_battery_vt_current(); // solar current + regen current <= 27 AMPS // regen current shouldnt push cell above 4.2 V if (!s_regen_braking && batt_current < MAX_CURRENT && batt_voltage < MAX_VOLTAGE) { @@ -155,7 +155,7 @@ void update_displays(void) { float avg_speed = (get_motor_velocity_velocity_l() + get_motor_velocity_velocity_r()) / 2; float speed_kph = avg_speed * CONVERT_VELOCITY_TO_KPH; uint16_t batt_perc_val = get_battery_vt_batt_perc(); - uint16_t aux_battery_voltage = get_battery_status_aux_batt_v(); + uint32_t aux_battery_voltage = get_battery_info_aux_batt_v()/100; if (speed_kph >= 100) { seg_displays_set_int(&all_displays, (int)speed_kph, batt_perc_val, aux_battery_voltage); } else {