Skip to content

Conversation

@caiodasilva2005
Copy link
Contributor

Changes

Added calculation for pack SoC as a result of Coulomb counting with a look-up table at start up in new file soc.c.

To Do

Any remaining things that need to get done

-[ ] Cell profiling with the P50Bs
-[ ] Potentially incorporate pack average temp to have a more accurate estimate of the pack SoC?

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.

  • 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 #5

@caiodasilva2005 caiodasilva2005 self-assigned this Dec 30, 2025
@caiodasilva2005 caiodasilva2005 marked this pull request as ready for review January 5, 2026 22:52
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.

awesome. Technically rather than doing get_tick we should eventually read the time increment register in the 2950. But this is good enough for our purposes probably.

}

// Coulomb Counting
// SoC(t) = SoC(t-1) + I(t)/Qn * (t1 - t0)
Copy link
Contributor

Choose a reason for hiding this comment

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

the order of operations below is different, coreect? THis makes it look like the divide by capacity happens to I(t) then its multiplied by delta t

Copy link
Contributor Author

@caiodasilva2005 caiodasilva2005 Jan 8, 2026

Choose a reason for hiding this comment

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

Yes, but the order of the multiplication and division does not affect result so its the same

Core/Src/soc.c Outdated
// SoC(t) = SoC(t-1) + I(t)/Qn * (t1 - t0)

float last_soc = analyzer->soc;
float curr_time = (float)HAL_GetTick(); // in milliseconds
Copy link
Contributor

Choose a reason for hiding this comment

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

dont we need to convert hal_gettick to ms technically?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we should be using tx_time_get() (converted to milliseconds) instead of HAL_GetTick() here, since this code runs in a ThreadX task.

Core/Src/soc.c Outdated

float current = hv_plate->pack_current; // in Amperes

float soc = last_soc + (current * delta_time) / FULL_CAPACITY_AH;
Copy link
Contributor

Choose a reason for hiding this comment

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

If the ADBMS2950 reports positive current during discharge, the current sign may need to be inverted before applying this formula. Otherwise, SOC would increase during discharge.

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.

Software-Controlled Pre-Charge

4 participants