75 #define SOC_MAXIMUM_SOC_perc (100.0f)
77 #define SOC_MINIMUM_SOC_perc (0.0f)
126 float socMinimumValue_perc,
127 float socMaximumValue_perc,
128 float socAverageValue_perc,
129 uint8_t stringNumber);
170 float socMinimumValue_perc,
171 float socMaximumValue_perc,
172 float socAverageValue_perc,
173 uint8_t stringNumber) {
182 float ccOffset_perc =
185 #if POSITIVE_DISCHARGE_CURRENT == false
186 ccOffset_perc *= (-1.0f);
245 if (ccPresent ==
true) {
248 float scalingOffset_perc =
252 scalingOffset_perc *= (-1.0f);
255 #if POSITIVE_DISCHARGE_CURRENT == false
256 scalingOffset_perc *= (-1.0f);
283 bool continueFunction =
true;
286 continueFunction =
false;
289 if (continueFunction ==
true) {
305 if (timeStep_s > 0.0f) {
308 float deltaSOC_perc =
312 #if POSITIVE_DISCHARGE_CURRENT == false
313 deltaSOC_perc *= (-1.0f);
332 float deltaSoc_perc =
335 #if POSITIVE_DISCHARGE_CURRENT == false
336 deltaSoc_perc *= (-1.0f);
360 float soc_perc = 0.50f;
363 uint16_t between_high = 0;
364 uint16_t between_low = 0;
369 between_low = i + 1u;
375 if (!(((between_high == 0u) && (between_low == 0u)) ||
uint16_t bc_stateOfChargeLookupTableLength
const BC_LUT_s bc_stateOfChargeLookupTable[]
#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_1000_FLOAT
#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_CalculateStateOfCharge(DATA_BLOCK_SOX_s *pSocValues)
periodically called algorithm to calculate state-of-charge (SOC)
void SE_InitializeStateOfCharge(DATA_BLOCK_SOX_s *pSocValues, bool ccPresent, uint8_t stringNumber)
initializes startup SOC-related values like lookup from nonvolatile ram at startup
float SE_GetStateOfChargeFromVoltage(int16_t voltage_mV)
look-up table for SOC initialization
static SOC_STATE_s soc_state
static void SOC_UpdateNvmValues(DATA_BLOCK_SOX_s *pTableSoc, uint8_t stringNumber)
Set SOC-related values in non-volatile memory.
#define SOC_MINIMUM_SOC_perc
static void SOC_RecalibrateViaLookupTable(DATA_BLOCK_SOX_s *pTableSoc)
initializes database and FRAM SOC values via lookup table (average, minimum and maximum).
static DATA_BLOCK_CURRENT_SENSOR_s soc_tableCurrentSensor
static float SOC_GetStringSocPercentageFromCharge(uint32_t charge_As)
calculates string SOC in percentage from passed string charge in As
static void SOC_CheckDatabaseSocPercentageLimits(DATA_BLOCK_SOX_s *pTableSoc, uint8_t stringNumber)
Check if all database SOC percentage values are within [0.0, 100.0] Limits SOC values to limit values...
static void SOC_SetValue(DATA_BLOCK_SOX_s *pTableSoc, float socMinimumValue_perc, float socMaximumValue_perc, float socAverageValue_perc, uint8_t stringNumber)
sets SOC value with a parameter between 0.0 and 100.0.
#define SOC_MAXIMUM_SOC_perc
Header for SOC module, responsible for calculation of SOC.
#define SOC_STRING_CAPACITY_As
#define SOC_STRING_CAPACITY_mAs
uint32_t timestampCurrent[BS_NR_OF_STRINGS]
int32_t current_mA[BS_NR_OF_STRINGS]
DATA_BLOCK_HEADER_s header
int32_t currentCounter_As[BS_NR_OF_STRINGS]
uint32_t timestampCurrentCounting[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 maximumSoc_perc[BS_NR_OF_STRINGS]
float averageSoc_perc[BS_NR_OF_STRINGS]
float minimumSoc_perc[BS_NR_OF_STRINGS]
float minimumSoc_perc[BS_NR_OF_STRINGS]
float averageSoc_perc[BS_NR_OF_STRINGS]
float maximumSoc_perc[BS_NR_OF_STRINGS]
float ccScalingMinimum[BS_NR_OF_STRINGS]
uint32_t previousTimestamp[BS_NR_OF_STRINGS]
float ccScalingAverage[BS_NR_OF_STRINGS]
bool sensorCcUsed[BS_NR_OF_STRINGS]
float ccScalingMaximum[BS_NR_OF_STRINGS]