diff --git a/lib/interfaces/include/AMSInterface.h b/lib/interfaces/include/AMSInterface.h index 7f412272f..aefc92272 100644 --- a/lib/interfaces/include/AMSInterface.h +++ b/lib/interfaces/include/AMSInterface.h @@ -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, diff --git a/lib/interfaces/src/AMSInterface.cpp b/lib/interfaces/src/AMSInterface.cpp index 4af9b841a..0d3e96826 100644 --- a/lib/interfaces/src/AMSInterface.cpp +++ b/lib/interfaces/src/AMSInterface.cpp @@ -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) {