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

Ht09 fall david #5

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open

Ht09 fall david #5

wants to merge 41 commits into from

Conversation

songyueli
Copy link
Contributor

updated for loop for read_data and added a package cell voltage/auxillaries so there's no switch statement.

I also used the logic analyzer for the broadcast signal, and for some reason the 2 second delay time threw the enable / SCK off, so I increased it to 5 and that fixed it. Not once have I been able to get a MISO signal from the new board, so I'm still trying to figure that out.

…to execute write and read functions. Need to add MessageInterface
@songyueli songyueli requested a review from RCMast3r December 21, 2024 05:20
.DS_Store Outdated Show resolved Hide resolved
lib/interfaces/include/BMSDriverGroup.h Outdated Show resolved Hide resolved
lib/interfaces/include/BMSDriverGroup.tpp Outdated Show resolved Hide resolved
lib/interfaces/include/BMSDriverGroup.tpp Outdated Show resolved Hide resolved
lib/interfaces/include/LTCSPIInterface.h Outdated Show resolved Hide resolved
Comment on lines 234 to 260
uint16_t _pec15Table[256];

/**
* We will need this for both models of the IC
* This determines where we get our signals from on the Arduino
* It can only be 9 or 10
* NOTE: needs to be initialized
*/
std::array<int, num_chip_selects> _chip_select;

/**
* We will need this for both models of the IC
* This determines where we get our signals from on the Arduino
* It can only be 9 or 10
* NOTE: needs to be initialized
*/
std::array<int, num_chips> _chip_select_per_chip;

/**
* We will only end up using the address if this is a LTC6811-2
* NOTE: But if we are, we need to call a setup function to instatiate each with the correct addresses
* BMS Segments 1, 4, and 5 are on chip select 9
* BMS Segments 2, 3, and 6 are on chip select 10
* Those segments correspond to 2 ICs each, so the instance with chip_select 9
* Will have IC addresses: 0,1,6,7,8,9 | The rest are for chip_select 10
*/
std::array<int, num_chips> _address;
Copy link
Contributor

Choose a reason for hiding this comment

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

make these const if they are not going to change during runtime

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since pec15table has to be initialized through a function call during runtime, in order to make it const I have to modify the implementation by doing a static function call in the constructor (according to chatgpt). If this isn't preferable I can change it back

Copy link
Contributor

Choose a reason for hiding this comment

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

you can make the initialization of the _pec15table be calculated as a constexpr: https://en.cppreference.com/w/cpp/language/constexpr

essentially what this allows you to do is, as long as all inputs are known at compile time, your pectable generated and is calculated by the compiler when you are compiling your code so your micro does not handle the computation itself and instead just gets given a pre-computed table to pull from.

lib/interfaces/include/BMSDriverGroup.tpp Outdated Show resolved Hide resolved
Comment on lines 139 to 146
if (_chip_type == LTC6811_Type_e::LTC6811_1)
{
return _read_data_through_broadcast();
}
else
{
return _read_data_through_address();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

please use if constexpr here instead instead and make the type const.

cmd[0] = (adc_cmd >> 8) & 0xFF;
cmd[1] = adc_cmd & 0xFF;

if (_chip_type == LTC6811_Type_e::LTC6811_1)
Copy link
Contributor

Choose a reason for hiding this comment

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

if constexpr

lib/interfaces/include/BMSDriverGroup.tpp Outdated Show resolved Hide resolved
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