80 uint32_t previousTimestamp
85 #define MAXIMUM_SOE_PERC (100.0f)
86 #define MINIMUM_SOE_PERC (0.0f)
157 float_t soeMinimumValue_perc,
158 float_t soeMaximumValue_perc,
159 float_t soeAverageValue_perc,
160 uint8_t stringNumber);
173 float_t stringSoe_perc = 0.0f;
174 const float_t stringEnergy_Wh = (float_t)energy_Wh;
180 return stringSoe_perc;
184 float_t energy_Wh = 0.0f;
192 return (uint32_t)energy_Wh;
213 float_t soe_perc = 50.0f;
215 uint16_t between_high = 0;
216 uint16_t between_low = 0;
221 between_low = i + 1u;
227 if (!(((between_high == 0u) && (between_low == 0u)) ||
234 (float_t)voltage_mV);
247 float_t soeMinimumValue_perc,
248 float_t soeMaximumValue_perc,
249 float_t soeAverageValue_perc,
250 uint8_t stringNumber) {
278 #if BS_POSITIVE_DISCHARGE_CURRENT == false
335 if (ec_present ==
true) {
347 #if BS_POSITIVE_DISCHARGE_CURRENT == false
361 bool continueFunction =
true;
364 continueFunction =
false;
367 if (continueFunction ==
true) {
383 float_t timestep_s = (((float_t)timestamp - (float_t)previous_timestamp)) / 1000.0f;
384 if (timestep_s > 0.0f) {
386 float_t deltaSOE_Wh =
392 #if BS_POSITIVE_DISCHARGE_CURRENT == false
394 deltaSOE_Wh *= (-1.0f);
416 float_t deltaSoe_perc =
420 #if BS_POSITIVE_DISCHARGE_CURRENT == false
422 deltaSoe_perc *= (-1.0f);
457 #ifdef UNITY_UNIT_TEST
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_t MATH_LinearInterpolation(const float_t x1, const float_t y1, const float_t x2, const float_t y2, const float_t 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 GEN_REPEAT_U(x, n)
Macro that helps to generate a series of literals (for array initializers).
void SE_InitializeStateOfEnergy(DATA_BLOCK_SOE_s *pSoeValues, bool ec_present, uint8_t stringNumber)
initializes startup state-of-energy (SOE) related values
void SE_CalculateStateOfEnergy(DATA_BLOCK_SOE_s *pSoeValues)
periodically called algorithm to calculate state-of-energy (SOE)
static float_t 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 float_t SOE_GetStringSoePercentageFromEnergy(uint32_t energy_Wh)
calculates string SOE in percentage from passed string energy in Wh
static void SOE_SetValue(DATA_BLOCK_SOE_s *pSoeValues, float_t soeMinimumValue_perc, float_t soeMaximumValue_perc, float_t soeAverageValue_perc, uint8_t stringNumber)
sets SOE value with a parameter between 0.0 and 100.0.
static uint32_t SOE_GetStringEnergyFromSoePercentage(float_t stringSoe_perc)
calculates string energy in Wh from passed SOE in percentage
static void SOE_RecalibrateViaLookupTable(DATA_BLOCK_SOE_s *pSoeValues)
initializes database and FRAM SOE values via lookup table (average, min and max).
static void SOE_CheckDatabaseSoePercentageLimits(DATA_BLOCK_SOE_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 configuration.
#define SOE_STRING_ENERGY_Wh
Header for state-estimation module responsible for the estimation of state-of-charge (SOC),...
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]
uint32_t minimumSoe_Wh[BS_NR_OF_STRINGS]
float_t maximumSoe_perc[BS_NR_OF_STRINGS]
uint32_t maximumSoe_Wh[BS_NR_OF_STRINGS]
uint32_t averageSoe_Wh[BS_NR_OF_STRINGS]
float_t averageSoe_perc[BS_NR_OF_STRINGS]
float_t minimumSoe_perc[BS_NR_OF_STRINGS]
float_t maximumSoe_perc[BS_NR_OF_STRINGS]
float_t minimumSoe_perc[BS_NR_OF_STRINGS]
float_t averageSoe_perc[BS_NR_OF_STRINGS]
bool sensorEcUsed[BS_NR_OF_STRINGS]
float_t ecScalingMinimum[BS_NR_OF_STRINGS]
uint32_t previousTimestamp[BS_NR_OF_STRINGS]
float_t ecScalingAverage[BS_NR_OF_STRINGS]
float_t ecScalingMaximum[BS_NR_OF_STRINGS]