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

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open

ADBMS Integration #138

wants to merge 13 commits into from

Conversation

Sabramz
Copy link
Contributor

@Sabramz Sabramz commented Nov 18, 2024

Changes

Low level drivers and some integration.

Test Cases

test bench

To Do

  • Voltage reading function is scalable
  • Therm reading function is scalable
  • Functions for reading every register
  • Voltage reading can be configured to be s, c, filtered, and avg
  • Function for setting GPIOs as outputs
  • New configuration function for new ICs

Checklist

It can be helpful to check the Checks and Files changed tabs.
Please reach out to your Project Lead if anything is unclear.
Please request reviewers and ping on slack only after you've gone through this whole checklist.

  • All commits are tagged with the ticket number
  • No merge conflicts
  • All checks passing
  • Remove any non-applicable sections of this template
  • Assign the PR to yourself
  • Request reviewers & ping on Slack
  • PR is linked to the ticket (fill in the closes line below)

Closes #133 (issue #)

@Sabramz Sabramz marked this pull request as draft November 18, 2024 03:07
@Sabramz Sabramz requested review from dyldonahue and jr1221 November 21, 2024 23:07
@Sabramz Sabramz self-assigned this Nov 21, 2024
int DataIdx;

for (DataIdx = 0; DataIdx < len; DataIdx++) {
__io_putchar( *ptr++ );
Copy link
Contributor

Choose a reason for hiding this comment

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

messed up diff this stuff was changed on main??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this cuz printing was broken and i think it was cuz of the usart dma changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm did u use \r? Also make sure to use ner serial or else it wont work.

{
LTC6804_wrcfg(ltc68041, NUM_CHIPS, local_config);
adBmsCsLow();
adBmsCsHigh();
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add comment where the original source waits for a time?


// Init config B
chip->tx_cfgb.vov = SetOverVoltageThreshold(4.2);
chip->tx_cfgb.vuv = SetUnderVoltageThreshold(3.0);
Copy link
Contributor

Choose a reason for hiding this comment

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

can u add a comment that this prob doesnt matter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The threshold matters. If its set wrong the ic will tell us we are faulting.

Copy link
Contributor

Choose a reason for hiding this comment

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

But we don't use the over/under fault stuff right?

Copy link
Contributor

@jr1221 jr1221 left a comment

Choose a reason for hiding this comment

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

A bunch of random stuff idk you prob know all of this anyway as this is WIP.

Only thing actually wierd is the whole wakeup IC stuff and how we now have a bunch of different types of wakeup functions all seeming to do similar stuff.

#define NUM_CELLS_PER_CHIP 10
#define NUM_SEGMENTS 1
#define NUM_CHIPS 1 //NUM_SEGMENTS * 2
#define NUM_CELLS_PER_CHIP 16
#define NUM_THERMS_PER_CHIP 32
#define NUM_RELEVANT_THERMS 3
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its the number of therms that we actually wanted to read on a segment. I think we'll be getting rid of this but i think its outside the scope of this.

Drivers/adbms/lib/src/adBms6830GenericType.c \
Drivers/adbms/lib/src/adBms6830ParseCreate.c \
Drivers/adbms/program/src/serialPrintResult.c \
Drivers/adbms/program/src/mcuWrapper.c \
Copy link
Contributor

Choose a reason for hiding this comment

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

should we be using this file? Versus just defining our own.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has our edits in it (just the ones we used to get shep working at first)

#define TOTAL_IC 1
cell_asic IC[TOTAL_IC];

RD REDUNDANT_MEASUREMENT = RD_OFF;
Copy link
Contributor

Choose a reason for hiding this comment

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

we do want redundant in final rev

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure we can do that later. I want a full spec from BMS team on exactly what the configs should be and how they want the BMS to work

cell_asic IC[TOTAL_IC];

RD REDUNDANT_MEASUREMENT = RD_OFF;
CH AUX_CH_TO_CONVERT = AUX_ALL;
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to setup which AUX channel is read by which multiplexer. The mtg notes I think say the main multiplexer reads internal register and the AUX is dedicated to the GPIOs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These variables won't make it into the final draft. this was copied over from adbms source.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They'll be gone once this code is tested.


RD REDUNDANT_MEASUREMENT = RD_OFF;
CH AUX_CH_TO_CONVERT = AUX_ALL;
CONT CONTINUOUS_MEASUREMENT = SINGLE;
Copy link
Contributor

Choose a reason for hiding this comment

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

we def want continuous measurement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this variable is not used

Core/Src/segment.c Show resolved Hide resolved
void get_c_adc_voltages(cell_asic *chip)
{
wake_and_write_configs(chip);
adbms_wake();
Copy link
Contributor

Choose a reason for hiding this comment

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

why wake so many times?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thats just what worked in testing

@@ -125,9 +309,65 @@ void select_therm(uint8_t therm)
1); // 0-15, will change multiplexer to select thermistor
}
serialize_i2c_msg(i2c_write_data, comm_reg_data);
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldnt we yeet all therm selection multiplexing?

printVoltages(TOTAL_IC, &IC[0], F_volt);
} */

if (MEASURE_S_VOLTAGE == ENABLED) {
Copy link
Contributor

Choose a reason for hiding this comment

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

eventually we should just do redundant reads and not read S seperately

int DataIdx;

for (DataIdx = 0; DataIdx < len; DataIdx++) {
__io_putchar( *ptr++ );
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm did u use \r? Also make sure to use ner serial or else it wont work.

@Sabramz Sabramz marked this pull request as ready for review December 25, 2024 23:44
@Sabramz Sabramz requested review from jr1221 and removed request for dyldonahue December 25, 2024 23:46
Copy link
Contributor

@jr1221 jr1221 left a comment

Choose a reason for hiding this comment

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

more code hip hip hooray. really its impossible to figure out what is good and bad practice until the high level code gels better (we remove the years of therm and algo disable crap).

}
// 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.

*/
void read_aux2_registers(cell_asic chips[NUM_CHIPS])
{
write_config_regs(chips);
Copy link
Contributor

Choose a reason for hiding this comment

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

for all read_* commands. Why do we write to registers each time? Feels like we dont need to?

for (int chip = 0; chip < NUM_CHIPS; chip++) {
for (int i = 0; i < NUM_CELLS_PER_CHIP; i++) {
real_total_volt +=
getVoltage(bmsdata->chip_data[chip].voltage[i]);
Copy link
Contributor

Choose a reason for hiding this comment

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

see my questions in slack about chip_data. We shouldnt call getVoltage on a struct field outside of adbms, that feels wierd and takes their specific register format to the rest of the code. Imo we should either remove chipdata_t and call stuff on cell_asic or store the cell_asic stuff as floats post-conversion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate ADBMS Drivers
2 participants