81 #define MAXIMUM_SOE_PERC (100.0f)
82 #define MINIMUM_SOE_PERC (0.0f)
153 float soeMinimumValue_perc,
154 float soeMaximumValue_perc,
155 float soeAverageValue_perc,
156 uint8_t stringNumber);
169 float stringSoe_perc = 0.0f;
170 const float stringEnergy_Wh = (float)energy_Wh;
176 return stringSoe_perc;
180 float energy_Wh = 0.0f;
188 return (uint32_t)energy_Wh;
197 for (uint8_t stringNumber = 0u; stringNumber <
BS_NR_OF_STRINGS; stringNumber++) {
209 float soe_perc = 50.0f;
211 uint16_t between_high = 0;
212 uint16_t between_low = 0;
217 between_low = i + 1u;
223 if (!(((0u == between_high) && (0u == between_low)) ||
243 float soeMinimumValue_perc,
244 float soeMaximumValue_perc,
245 float soeAverageValue_perc,
246 uint8_t stringNumber) {
274 #if POSITIVE_DISCHARGE_CURRENT == false
331 if (
true == ec_present) {
343 #if POSITIVE_DISCHARGE_CURRENT == false
357 bool continueFunction =
true;
360 continueFunction =
false;
363 if (
true == continueFunction) {
371 for (uint8_t stringNumber = 0u; stringNumber <
BS_NR_OF_STRINGS; stringNumber++) {
379 float timestep_s = (((float)timestamp - (
float)previous_timestamp)) / 1000.0f;
380 if (timestep_s > 0.0f) {
389 #if POSITIVE_DISCHARGE_CURRENT == false
391 deltaSOE_Wh *= (-1.0f);
394 pSoeValues->
averageSoe_Wh[stringNumber] -= (uint32_t)deltaSOE_Wh;
395 pSoeValues->
minimumSoe_Wh[stringNumber] -= (uint32_t)deltaSOE_Wh;
396 pSoeValues->
maximumSoe_Wh[stringNumber] -= (uint32_t)deltaSOE_Wh;
414 float deltaSoe_perc =
418 #if POSITIVE_DISCHARGE_CURRENT == false
420 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,...
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(float x1, float y1, float x2, float y2, 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
STD_RETURN_TYPE_e FRAM_Read(FRAM_BLOCK_ID_e blockId)
Reads a variable from the FRAM.
STD_RETURN_TYPE_e FRAM_Write(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).
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
void SOE_Init(DATA_BLOCK_SOX_s *pSoeValues, bool ec_present, uint8_t stringNumber)
initializes startup state-of-energy (SOE) related values
struct SOE_STATE SOE_STATE_s
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.
void SOE_Calculation(DATA_BLOCK_SOX_s *pSoeValues)
periodically called algorithm to calculate state-of-energy (SOE)
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
DATA_BLOCK_HEADER_s header
uint32_t timestampCurrent[BS_NR_OF_STRINGS]
int32_t current_mA[BS_NR_OF_STRINGS]
uint32_t timestampEnergyCounting[BS_NR_OF_STRINGS]
int32_t highVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR]
int32_t energyCounter_Wh[BS_NR_OF_STRINGS]
uint32_t previousTimestampCurrent[BS_NR_OF_STRINGS]
int16_t maximumCellVoltage_mV[BS_NR_OF_STRINGS]
DATA_BLOCK_HEADER_s header
int16_t averageCellVoltage_mV[BS_NR_OF_STRINGS]
int16_t minimumCellVoltage_mV[BS_NR_OF_STRINGS]
float maximumSoe_perc[BS_NR_OF_STRINGS]
uint32_t averageSoe_Wh[BS_NR_OF_STRINGS]
uint32_t maximumSoe_Wh[BS_NR_OF_STRINGS]
float minimumSoe_perc[BS_NR_OF_STRINGS]
uint32_t minimumSoe_Wh[BS_NR_OF_STRINGS]
float averageSoe_perc[BS_NR_OF_STRINGS]
float maximumSoe_perc[BS_NR_OF_STRINGS]
float averageSoe_perc[BS_NR_OF_STRINGS]
float minimumSoe_perc[BS_NR_OF_STRINGS]
float ecScalingAverage[BS_NR_OF_STRINGS]
float ecScalingMaximum[BS_NR_OF_STRINGS]
bool sensorEcUsed[BS_NR_OF_STRINGS]
float ecScalingMinimum[BS_NR_OF_STRINGS]
uint32_t previousTimestamp[BS_NR_OF_STRINGS]