Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Akashem06 committed Apr 24, 2024
1 parent 0fd7652 commit 8b5a6da
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
12 changes: 5 additions & 7 deletions projects/bms_carrier/inc/current_sense.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@
#define PACK_CAPACITY_MAH 3000

// Capacity in units of 5.0uVh/Rsense
#define MAIN_PACK_DESIGN_CAPACITY \
(PACK_CAPACITY_MAH * CURRENT_SENSE_R_SENSE_MOHMS / 5)
#define MAIN_PACK_DESIGN_CAPACITY (PACK_CAPACITY_MAH * CURRENT_SENSE_R_SENSE_MOHMS / 5)

// LSB = 78.125 (micro Volts)
#define MAIN_PACK_EMPTY_VOLTAGE_MV 2500
#define MAIN_PACK_EMPTY_VOLTAGE (MAIN_PACK_EMPTY_VOLTAGE_MV / 78.125)

#define MAIN_PACK_EMPTY_VOLTAGE (MAIN_PACK_EMPTY_VOLTAGE_MV / 78.125)

#define CHARGE_TERMINATION_CURRENT 0

// // TODO (Adel C): Change these values to their actual values
// #define CURRENT_SENSE_R_SENSE_MILLI_OHMS (0.5)
// #define MAIN_PACK_DESIGN_CAPACITY
// #define MAIN_PACK_DESIGN_CAPACITY
// (1.0f / CURRENT_SENSE_R_SENSE_MILLI_OHMS) // LSB = 5.0 (micro Volt Hours / R Sense)
// #define MAIN_PACK_EMPTY_VOLTAGE (1.0f / 78.125) // Only a 9-bit field, LSB = 78.125 (micro Volts)
// #define CHARGE_TERMINATION_CURRENT (1.0f / (1.5625f / CURRENT_SENSE_R_SENSE_MILLI_OHMS))
// #define MAIN_PACK_EMPTY_VOLTAGE (1.0f / 78.125) // Only a 9-bit field, LSB = 78.125 (micro
// Volts) #define CHARGE_TERMINATION_CURRENT (1.0f / (1.5625f / CURRENT_SENSE_R_SENSE_MILLI_OHMS))

// Thresholds for ALRT Pin
#define CURRENT_SENSE_MAX_CURRENT_A (58.2f) // 58.2 Amps
Expand Down
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 @@ -145,7 +145,7 @@ StatusCode cell_sense_run() {

for (size_t cell = 0; cell < (s_afe_settings.num_devices * s_afe_settings.num_cells); cell++) {
LOG_DEBUG("CELL %d: %d\n\r", cell,
ltc_afe_storage->cell_voltages[ltc_afe_storage->cell_result_lookup[cell]]);
ltc_afe_storage->cell_voltages[ltc_afe_storage->cell_result_lookup[cell]]);
delay_ms(3);
max_voltage =
ltc_afe_storage->cell_voltages[ltc_afe_storage->cell_result_lookup[cell]] > max_voltage
Expand Down
8 changes: 4 additions & 4 deletions projects/bms_carrier/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ 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);
// cell_sense_init(&bms_storage.ltc_afe_storage);
aux_sense_init(&bms_storage.aux_storage);
init_bms_relays();
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);
// cell_conversions();
// wait_tasks(1);
current_sense_run();
wait_tasks(1);

cell_sense_run();
// cell_sense_run();
aux_sense_run();
bms_run_fan();

Expand Down
3 changes: 2 additions & 1 deletion projects/centre_console/src/update_dashboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ void update_indicators(uint32_t notif) {
pca9555_gpio_set_state(&s_output_leds[AUX_WARNING_LED], PCA9555_GPIO_STATE_LOW);
}

if (get_battery_status_fault() || get_pd_status_power_state() == EE_POWER_FAULT_STATE || get_pd_status_bps_persist()) {
if (get_battery_status_fault() || get_pd_status_power_state() == EE_POWER_FAULT_STATE ||
get_pd_status_bps_persist()) {
gpio_set_state(&bps_led, GPIO_STATE_LOW);
} else {
gpio_set_state(&bps_led, GPIO_STATE_HIGH);
Expand Down
9 changes: 6 additions & 3 deletions projects/power_distribution/src/power_seq_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ static void prv_precharge_output(void *context) {
}

static void prv_precharge_input(Fsm *fsm, void *context) {
LOG_DEBUG("GET_MOTOR_VELOCITY %d\n", (get_motor_velocity_velocity_l() + get_motor_velocity_velocity_r()));
LOG_DEBUG("GET_MOTOR_VELOCITY %d\n",
(get_motor_velocity_velocity_l() + get_motor_velocity_velocity_r()));
if (get_motor_velocity_velocity_l() && get_motor_velocity_velocity_r()) {
fsm_transition(fsm, POWER_STATE_OFF);
}
Expand All @@ -68,7 +69,8 @@ static void prv_drive_state_output(void *context) {
pd_set_active_output_group(OUTPUT_GROUP_POWER_DRIVE);
power_context.latest_state = POWER_STATE_DRIVE;
s_bps_storage.fault_bitset = 0;
s_bps_storage.vehicle_speed = (get_motor_velocity_velocity_l() + get_motor_velocity_velocity_r()) / 2;
s_bps_storage.vehicle_speed =
(get_motor_velocity_velocity_l() + get_motor_velocity_velocity_r()) / 2;
persist_commit(&s_persist);
set_pd_status_bps_persist(false);
set_pd_status_power_state(EE_POWER_DRIVE_STATE);
Expand All @@ -89,7 +91,8 @@ static void prv_drive_state_input(Fsm *fsm, void *context) {
static void prv_fault_state_output(void *context) {
LOG_DEBUG("Transitioned to FAULT STATE\n");
s_bps_storage.fault_bitset = get_battery_status_fault();
s_bps_storage.vehicle_speed = (get_motor_velocity_velocity_l() + get_motor_velocity_velocity_r()) / 2;
s_bps_storage.vehicle_speed =
(get_motor_velocity_velocity_l() + get_motor_velocity_velocity_r()) / 2;
persist_commit(&s_persist);
pd_set_active_output_group(OUTPUT_GROUP_POWER_FAULT);
set_pd_status_bps_persist(true);
Expand Down

0 comments on commit 8b5a6da

Please sign in to comment.