Skip to content

Commit

Permalink
Created template branch for Module 4
Browse files Browse the repository at this point in the history
  • Loading branch information
jhwang04 committed Aug 3, 2024
1 parent 481a78c commit 68e8d7f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
5 changes: 5 additions & 0 deletions lib/interfaces/include/AMSInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ class AMSInterface

private:

/**
* The approximate voltage of one cell for each particular state of charge.
* VOLTAGE_LOOKUP_TABLE[0] is the voltage at 100% charge.
* VOLTAGE_LOOKUP_TABLE[100] is the voltage at 0% charge.
*/
const float VOLTAGE_LOOKUP_TABLE[101] = {3.972, 3.945, 3.918, 3.891, 3.885, 3.874, 3.864, 3.858, 3.847, 3.836, 3.82, 3.815, 3.815, 3.798, 3.788,
3.782, 3.771, 3.755, 3.744, 3.744, 3.733, 3.728, 3.723, 3.712, 3.701, 3.695, 3.69, 3.679, 3.679, 3.668, 3.663, 3.657, 3.647,
3.647, 3.636, 3.625, 3.625, 3.625, 3.614, 3.609, 3.603, 3.603, 3.592, 3.592, 3.592, 3.581, 3.581, 3.571, 3.571, 3.571, 3.56,
Expand Down
25 changes: 17 additions & 8 deletions lib/interfaces/src/AMSInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,25 @@ float AMSInterface::get_filtered_min_cell_voltage() {
}

float AMSInterface::initialize_charge() {
int i = 0;
float lowest_voltage = HYTECH_low_voltage_ro_fromS(bms_voltages_.low_voltage_ro);
// Step 1: Read the function description in AMSInterface.h (be sure to
// read the real AMSInterface.h, not the mock interface!)

while (lowest_voltage - VOLTAGE_LOOKUP_TABLE[i] < 0) {
i++;
}
charge_ = ( (100 - i) / 100.0) * MAX_PACK_CHARGE;
SoC_ = (charge_ / MAX_PACK_CHARGE) * 100;
// Step 2: You will need to retrieve the lowest voltage from our Battery
// Management System (BMS). This is stored in the bms_voltages_
// member variable.

// Step 3: Use the lowest voltage with the defined VOLTAGE_LOOKUP_TABLE
// to determine the approximate percentage charge of the
// accumulator.

// Step 4: Initialize the charge_ member variable to the current charge

return charge_;
// Step 5: Initialize the SoC_ member variable.

// Step 6: Return the current charge, according to the specifications.

return 0; // TODO: Return the real value

}

void AMSInterface::calculate_SoC_em(const SysTick_s &tick) {
Expand Down

0 comments on commit 68e8d7f

Please sign in to comment.