Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADBMS Integration #138

Merged
merged 34 commits into from
Jan 25, 2025
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
60650d1
133 adbms submodule
Sabramz Nov 18, 2024
89b9d97
133 more copying
Sabramz Nov 18, 2024
004e83d
133 it works
Sabramz Nov 18, 2024
fe7b35e
133 debugging
Sabramz Nov 18, 2024
331f9dd
133 working prints
Sabramz Nov 18, 2024
a7bff61
adbms functions for config registers, get rid of some LTC code, start…
Sabramz Nov 21, 2024
ccff5e0
adbms reworking code for daisy chaining
Sabramz Nov 27, 2024
d1b4701
adbms wrapper written **untested**
Sabramz Dec 8, 2024
c671679
adbms cleaning up old functions
Sabramz Dec 8, 2024
f0a2a60
adbms balancing config changes
Sabramz Dec 14, 2024
e611107
adbms add chips to acc_data_t and make functions compatible with new …
Sabramz Dec 25, 2024
6791c57
adbms changing GPIO modes and integrating balancing functions with adbms
Sabramz Dec 26, 2024
93379f0
adbms cleaning up balancing and removing LTC driver from make file
Sabramz Dec 26, 2024
5a42a6b
adbms more cleanup of 22A code and starting on analyzer for alpha and…
Sabramz Jan 1, 2025
61e424e
adbms therms cleanup and changes for alpha and beta stacks
Sabramz Jan 6, 2025
540f19b
adbms functions for configuring chips
Sabramz Jan 6, 2025
591fe50
forgot to build
Sabramz Jan 6, 2025
a0e9240
adbms debugging volts and therms
Sabramz Jan 11, 2025
8a7b085
adbms therms mapping and temperature calculation, cleanup legacy code
Sabramz Jan 14, 2025
a3d12bc
adbms cleanup, add TODOs for future work
Sabramz Jan 14, 2025
5becce5
adbms cleanup, add TODOs for future work
Sabramz Jan 14, 2025
74ae15d
Set up task and send function for debug mode per cell data
Sabramz Jan 14, 2025
a44b476
debug mode create task and CAN message functions
Sabramz Jan 17, 2025
6e34ff5
adbms S vs C ADC comparison and PEC error count
Sabramz Jan 18, 2025
eda79ab
Merge branch 'per-cell-CAN' into 133-adbms-integration
Sabramz Jan 18, 2025
0c881b1
adbms debug mode stuff
Sabramz Jan 18, 2025
6f56377
adbms change debug mode CAN messages to use bit fields
Sabramz Jan 20, 2025
3dafe3b
General changes/improvements (#151)
jr1221 Jan 25, 2025
7e75f6a
Merge branch 'develop' into 133-adbms-integration
jr1221 Jan 25, 2025
b9218f2
fixups
jr1221 Jan 25, 2025
3426aaa
fmt
jr1221 Jan 25, 2025
89db8b6
segment reboot every 45 seconds
jr1221 Jan 25, 2025
a189aa7
fmt
jr1221 Jan 25, 2025
d02da4a
fmt
jr1221 Jan 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adbms changing GPIO modes and integrating balancing functions with adbms
Sabramz committed Dec 26, 2024
commit 6791c57046b5397caf9c57824ff1de20a22a066d
17 changes: 8 additions & 9 deletions Core/Inc/segment.h
Original file line number Diff line number Diff line change
@@ -18,12 +18,11 @@ void segment_init();
void segment_retrieve_data(acc_data_t *bmsdata);

/**
* @brief Enables/disables balancing for all cells
* @brief Disables balancing for all cells.
*
* @param chips Array of ADBMS6830 data structs.
* @param balance_enable False to disable balancing, true to enable.
*/
void segment_enable_balancing(cell_asic chips[NUM_CHIPS], bool balance_enable);
void segment_disable_balancing(cell_asic chips[NUM_CHIPS]);

/**
* @brief Enables/disables balancing for a specific cell
@@ -55,12 +54,12 @@ void segment_configure_balancing(
bool cell_is_balancing(uint8_t chip_num, uint8_t cell_num);

/**
* @brief Returns if any cells are balancing
* @todo This should just be a state variable -Scott
*
* @return true
* @return false
* @brief Returns if any cells are balancing.
*
* @param chips Array of ADBMS6830 chips.
* @return true
* @return false
*/
bool segment_is_balancing();
bool segment_is_balancing(cell_asic chips[NUM_CHIPS]);

#endif
2 changes: 1 addition & 1 deletion Core/Src/compute.c
Original file line number Diff line number Diff line change
@@ -332,7 +332,7 @@ void compute_send_bms_status_message(acc_data_t *bmsdata, int bms_state,
bms_status_msg_data.fault = bmsdata->fault_code;
bms_status_msg_data.temp_internal = (uint8_t)(0);
bms_status_msg_data.balance =
(uint8_t)(balance); // segment_is_balancing()
(uint8_t)(balance);

/* convert to big endian */
endian_swap(&bms_status_msg_data.fault,
4 changes: 2 additions & 2 deletions Core/Src/main.c
Original file line number Diff line number Diff line change
@@ -172,7 +172,7 @@ const void print_bms_stats(acc_data_t *acc_data)
printf("CCL: %d\n", acc_data->charge_limit);
printf("Cont CCL %d\n", acc_data->cont_CCL);
printf("SoC: %d\n", acc_data->soc);
printf("Is Balancing?: %d\n", segment_is_balancing());
printf("Is Balancing?: %d\n", segment_is_balancing(acc_data->chips));
printf("State: ");
if (current_state == 0) printf("BOOT\n");
else if (current_state == 1) printf("READY\n");
@@ -1256,7 +1256,7 @@ void StartDefaultTask(void *argument)
alt = !alt;

compute_send_bms_status_message(bmsdata, current_state,
segment_is_balancing());
segment_is_balancing(bmsdata->chips));

HAL_IWDG_Refresh(&hiwdg);

44 changes: 27 additions & 17 deletions Core/Src/segment.c
Original file line number Diff line number Diff line change
@@ -220,6 +220,22 @@ void set_cell_discharge(cell_asic *chip, uint8_t cell, bool discharge)
chip->tx_cfgb.dcc = set_uint16_bit(chip->tx_cfgb.dcc, cell, discharge);
}

/**
* @brief Set the mode of a GPIO pin on an ADBMS8630.
*
* @param chip ADBMS6830 chip
* @param gpio Number of the GPIO pin to change (1-10)
* @param mode Whether the pin should be an input or an output. True is input, False is output.
*/
void set_gpio_mode(cell_asic *chip, uint8_t gpio, bool mode)
{
if (gpio > 10 || gpio < 1) {
printf("ERROR: Invalid GPIO pin %d\n", gpio);
return;
}
chip->tx_cfga.gpo = set_uint16_bit(chip->tx_cfga.gpo, gpio - 1, mode);
}

/**
* @brief Write data to all chips.
*
@@ -439,10 +455,7 @@ int pull_voltages(acc_data_t *bmsdata)

get_c_adc_voltages(bmsdata->chips);

// TODO: Change number of cells per chip for alpha and beta
// or not cuz we can just copy all the values here and handle this in analyzer

// NOTE: Its kind of silly to just copy voltages like this. We should consolidate
// TODO: Its kind of silly to just copy voltages like this. We should consolidate
// chip data and chips later, or design analyzer to read voltages from chips rather
// than chipdata
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with both of the above TODOs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this didnt age well.


@@ -598,23 +611,21 @@ void segment_retrieve_data(acc_data_t *bmsdata)
sizeof(chipdata_t) * NUM_CHIPS);
}

bool segment_is_balancing()
bool segment_is_balancing(cell_asic chips[NUM_CHIPS])
{
// TODO: Change for new topology
for (int chip = 0; chip < NUM_CHIPS; chip++) {
if (chips[chip].tx_cfga.mute_st != MUTE_ACTIVATED_DISCHARGE_DISABLED) {
return true;
}
}
return false;
}

void segment_enable_balancing(cell_asic chips[NUM_CHIPS], bool balance_enable)
void segment_disable_balancing(cell_asic chips[NUM_CHIPS])
{
if (!balance_enable) {
// Initializes all array elements to zero
bool discharge_config[NUM_CHIPS][NUM_CELLS_PER_CHIP] = { 0 };
segment_configure_balancing(chips, discharge_config);
} else {
/* this func is never called with an arg of true (and shouldn't be given its function)
TODO: change this func to just be "segment disable balancing". Kept for now for compatibility with old system
*/
}
// Initializes all array elements to zero
bool discharge_config[NUM_CHIPS][NUM_CELLS_PER_CHIP] = { 0 };
segment_configure_balancing(chips, discharge_config);
}

/**
@@ -626,7 +637,6 @@ void segment_configure_balancing(
cell_asic chips[NUM_CHIPS],
bool discharge_config[NUM_CHIPS][NUM_CELLS_PER_CHIP])
{
// DEBUG: Untested
// TODO: Test
for (int chip = 0; chip < NUM_CHIPS; chip++) {
for (int cell = 0; cell < NUM_CELLS_PER_CHIP; cell++) {
8 changes: 4 additions & 4 deletions Core/Src/stateMachine.c
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ void init_boot(acc_data_t *bmsdata)
void handle_boot(acc_data_t *bmsdata)
{
prevAccData = NULL;
segment_enable_balancing(bmsdata->chips, false);
segment_disable_balancing(bmsdata->chips);
compute_enable_charging(false);
start_timer(&bootup_timer, 10000);
printf("Bootup timer started\r\n");
@@ -78,7 +78,7 @@ void handle_boot(acc_data_t *bmsdata)

void init_ready(acc_data_t *bmsdata)
{
segment_enable_balancing(bmsdata->chips, false);
segment_disable_balancing(bmsdata->chips);
compute_enable_charging(false);
return;
}
@@ -120,7 +120,7 @@ void handle_charging(acc_data_t *bmsdata)
if (sm_balancing_check(bmsdata))
sm_balance_cells(bmsdata);
else
segment_enable_balancing(bmsdata->chips, false);
segment_disable_balancing(bmsdata->chips);

/* Send CAN message, but not too often */
if (is_timer_expired(&charger_message_timer) ||
@@ -137,7 +137,7 @@ void handle_charging(acc_data_t *bmsdata)

void init_faulted(acc_data_t *bmsdata)
{
segment_enable_balancing(bmsdata->chips, false);
segment_disable_balancing(bmsdata->chips);
compute_enable_charging(false);
entered_faulted = true;
return;