Skip to content

Commit

Permalink
validation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Akashem06 committed Mar 26, 2024
1 parent 7993fc7 commit 7a7f571
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 19 deletions.
13 changes: 10 additions & 3 deletions libraries/codegen/boards/bms_carrier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion projects/bms_carrier/src/aux_sense.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion projects/bms_carrier/src/cell_sense.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
14 changes: 7 additions & 7 deletions projects/bms_carrier/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions projects/bms_carrier/src/relays_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions projects/centre_console/src/update_dashboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ void update_indicators(uint32_t notif) {
}
// Update regen light
if (notify_check_event(&notif, 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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 7a7f571

Please sign in to comment.