Skip to content

Charger#1

Draft
smj-edison wants to merge 5 commits into
mainfrom
charger
Draft

Charger#1
smj-edison wants to merge 5 commits into
mainfrom
charger

Conversation

@smj-edison
Copy link
Copy Markdown

Making this so I can leave notes on the code.

Comment thread include/SOCLookUpTable.h
#include <cstddef>
#include <cstdint>

namespace soclookuptable {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Could you move the lookup function here? It would be easier to follow. Also, be sure to mention that the two tables are interlinked, where you're mapping from the first table to the second table.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Also, at the top of the namespace would be a good place to define what the SOC acronym means.

Comment thread src/BMSControl.cpp
Comment on lines +735 to +737
if (!module.connected || !module.cellDataValid) {
continue;
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Is this intentional to ignore bad cells? Might want to add a comment explaining why it's okay to ignore.

Comment thread src/BMSControl.cpp

for (size_t i=0; i < soclookuptable::kNumLookUpPoints - 1; i++) {
if (cellMv >= soclookuptable::kVoltageTable[i] && cellMv <= soclookuptable::kVoltageTable[i+1]) {
// linear interpolation
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Might be clearer to say "linear interpolation to map between the two tables."

Comment thread src/BMSControl.h
std::array<adbms6830::BMSInterface::SiliconIdReadback, constants::kModuleCount> moduleSiliconIds{};
};

struct StateOfCharge {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Could you document what this structure is used for?

Comment thread src/BMSControl.cpp Outdated
soc.minCellMv = lowestCellMv;
soc.maxCellMv = highestCellMv;
// convert Mv to V
soc.totalPackVoltageMv = static_cast<uint16_t>(totalCellMv * 0.001);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Why are you converting to volts if it's called totalPackVoltageMv?

Comment thread src/main.cpp Outdated
mutex_t gBmsDataMutex;
volatile bool gBmsDataReady = false;
bool gCan0Ready = false;
bool chargingMode = false;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This should probably be volatile (remember that there's two threads running, so you need to carefully think through synchronization).

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.

2 participants