77 uint32_t previousTimestamp
82 #define MAXIMUM_SOE_PERC (100.0f)
83 #define MINIMUM_SOE_PERC (0.0f)
154 float soeMinimumValue_perc,
155 float soeMaximumValue_perc,
156 float soeAverageValue_perc,
157 uint8_t stringNumber);
170 float stringSoe_perc = 0.0f;
171 const float stringEnergy_Wh = (float)energy_Wh;
177 return stringSoe_perc;
181 float energy_Wh = 0.0f;
189 return (uint32_t)energy_Wh;
210 float soe_perc = 50.0f;
212 uint16_t between_high = 0;
213 uint16_t between_low = 0;
218 between_low = i + 1u;
224 if (!(((between_high == 0u) && (between_low == 0u)) ||
244 float soeMinimumValue_perc,
245 float soeMaximumValue_perc,
246 float soeAverageValue_perc,
247 uint8_t stringNumber) {
275 #if POSITIVE_DISCHARGE_CURRENT == false
332 if (ec_present ==
true) {
344 #if POSITIVE_DISCHARGE_CURRENT == false
358 bool continueFunction =
true;
361 continueFunction =
false;
364 if (continueFunction ==
true) {
380 float timestep_s = (((float)timestamp - (
float)previous_timestamp)) / 1000.0f;
381 if (timestep_s > 0.0f) {
389 #if POSITIVE_DISCHARGE_CURRENT == false
391 deltaSOE_Wh *= (-1.0f);
413 float deltaSoe_perc =
417 #if POSITIVE_DISCHARGE_CURRENT == false
419 deltaSoe_perc *= (-1.0f);
uint16_t bc_stateOfEnergyLookupTableLength
const BC_LUT_s bc_stateOfEnergyLookupTable[]
Configuration of the battery cell (e.g., minimum and maximum cell voltage)
Configuration of the battery system (e.g., number of battery modules, battery cells,...
#define BS_NR_OF_STRINGS
Number of parallel strings in the battery pack.
BMS_CURRENT_FLOW_STATE_e BMS_GetBatterySystemState(void)
Returns current battery system state (charging/discharging, resting or in relaxation phase)
#define DATA_READ_DATA(...)
@ DATA_BLOCK_ID_CURRENT_SENSOR
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
float MATH_LinearInterpolation(const float x1, const float y1, const float x2, const float y2, const float x_interpolate)
Linear inter-/extrapolates a third point according to two given points.
math library for often used math functions
#define UNIT_CONVERSION_FACTOR_100_FLOAT
FRAM_RETURN_TYPE_e FRAM_ReadData(FRAM_BLOCK_ID_e blockId)
Reads a variable from the FRAM.
FRAM_RETURN_TYPE_e FRAM_WriteData(FRAM_BLOCK_ID_e blockId)
Writes a variable to the FRAM.
Header for the driver for the FRAM module.
#define NULL_PTR
Null pointer.
#define REPEAT_U(x, n)
Macro that helps to generate a series of literals (for array initializers).
void SOE_Init(DATA_BLOCK_SOX_s *pSoeValues, bool ec_present, uint8_t stringNumber)
initializes startup state-of-energy (SOE) related values
void SOE_Calculation(DATA_BLOCK_SOX_s *pSoeValues)
periodically called algorithm to calculate state-of-energy (SOE)
static void SOE_RecalibrateViaLookupTable(DATA_BLOCK_SOX_s *pSoeValues)
initializes database and FRAM SOE values via lookup table (average, min and max).
static float SOE_GetFromVoltage(int16_t voltage_mV)
look-up table for SOE initialization
static DATA_BLOCK_CURRENT_SENSOR_s soe_tableCurrentSensor
static SOE_STATE_s soe_state
static uint32_t SOE_GetStringEnergyFromSoePercentage(float stringSoe_perc)
calculates string energy in Wh from passed SOE in percentage
static void SOE_SetValue(DATA_BLOCK_SOX_s *pSoeValues, float soeMinimumValue_perc, float soeMaximumValue_perc, float soeAverageValue_perc, uint8_t stringNumber)
sets SOE value with a parameter between 0.0 and 100.0.
static float SOE_GetStringSoePercentageFromEnergy(uint32_t energy_Wh)
calculates string SOE in percentage from passed string energy in Wh
static void SOE_CheckDatabaseSoePercentageLimits(DATA_BLOCK_SOX_s *pTableSoe, uint8_t stringNumber)
Check if all database SOE percentage values are within [0.0, 100.0] Limits SOE values to limit values...
Header for SOE module, responsible for calculation of SOE.
Header for SOE configuration.
#define SOE_STRING_ENERGY_Wh
uint32_t previousTimestampCurrent[BS_NR_OF_STRINGS]
uint32_t timestampCurrent[BS_NR_OF_STRINGS]
int32_t current_mA[BS_NR_OF_STRINGS]
DATA_BLOCK_HEADER_s header
int32_t energyCounter_Wh[BS_NR_OF_STRINGS]
int32_t highVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR]
uint32_t timestampEnergyCounting[BS_NR_OF_STRINGS]
int16_t averageCellVoltage_mV[BS_NR_OF_STRINGS]
DATA_BLOCK_HEADER_s header
int16_t maximumCellVoltage_mV[BS_NR_OF_STRINGS]
int16_t minimumCellVoltage_mV[BS_NR_OF_STRINGS]
float minimumSoe_perc[BS_NR_OF_STRINGS]
float averageSoe_perc[BS_NR_OF_STRINGS]
uint32_t averageSoe_Wh[BS_NR_OF_STRINGS]
uint32_t maximumSoe_Wh[BS_NR_OF_STRINGS]
float maximumSoe_perc[BS_NR_OF_STRINGS]
uint32_t minimumSoe_Wh[BS_NR_OF_STRINGS]
float maximumSoe_perc[BS_NR_OF_STRINGS]
float minimumSoe_perc[BS_NR_OF_STRINGS]
float averageSoe_perc[BS_NR_OF_STRINGS]
bool sensorEcUsed[BS_NR_OF_STRINGS]
float ecScalingMinimum[BS_NR_OF_STRINGS]
uint32_t previousTimestamp[BS_NR_OF_STRINGS]
float ecScalingMaximum[BS_NR_OF_STRINGS]
float ecScalingAverage[BS_NR_OF_STRINGS]