74 #define MAXIMUM_SOC_PERC (100.0f)
75 #define MINIMUM_SOC_PERC (0.0f)
124 float socMinimumValue_perc,
125 float socMaximumValue_perc,
126 float socAverageValue_perc,
127 uint8_t stringNumber);
155 for (uint8_t stringNumber = 0u; stringNumber <
BS_NR_OF_STRINGS; stringNumber++) {
168 float socMinimumValue_perc,
169 float socMaximumValue_perc,
170 float socAverageValue_perc,
171 uint8_t stringNumber) {
180 float ccOffset_perc =
183 #if POSITIVE_DISCHARGE_CURRENT == false
184 ccOffset_perc *= (-1.0f);
243 if (ccPresent ==
true) {
246 float scalingOffset_perc =
250 scalingOffset_perc *= (-1.0f);
253 #if POSITIVE_DISCHARGE_CURRENT == false
254 scalingOffset_perc *= (-1.0f);
282 bool continueFunction =
true;
285 continueFunction =
false;
288 if (
true == continueFunction) {
296 for (uint8_t stringNumber = 0u; stringNumber <
BS_NR_OF_STRINGS; stringNumber++) {
305 if (timestep_s > 0.0f) {
308 float deltaSOC_perc =
313 #if POSITIVE_DISCHARGE_CURRENT == false
314 deltaSOC_perc *= (-1.0f);
338 float deltaSoc_perc =
342 #if POSITIVE_DISCHARGE_CURRENT == false
343 deltaSoc_perc *= (-1.0f);
371 float soc_perc = 0.50f;
374 uint16_t between_high = 0;
375 uint16_t between_low = 0;
380 between_low = i + 1u;
386 if (!(((0u == between_high) && (0u == between_low)) ||
uint16_t bc_stateOfChargeLookupTableLength
const BC_LUT_s bc_stateOfChargeLookupTable[]
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
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).
float SOC_GetFromVoltage(int16_t voltage_mV)
look-up table for SOC initialization
void SOC_Init(DATA_BLOCK_SOX_s *pSocValues, bool ccPresent, uint8_t stringNumber)
initializes startup SOC-related values like lookup from nonvolatile ram at startup
void SOC_Calculation(DATA_BLOCK_SOX_s *pSocValues)
periodically called algorithm to calculate state-of-charge (SOC)
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.
struct SOC_STATE SOC_STATE_s
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.
Header for SOC module, responsible for calculation of SOC.
#define SOC_STRING_CAPACITY_As
#define SOC_STRING_CAPACITY_mAs
DATA_BLOCK_HEADER_s header
uint32_t timestampCurrent[BS_NR_OF_STRINGS]
int32_t current_mA[BS_NR_OF_STRINGS]
int32_t currentCounter_As[BS_NR_OF_STRINGS]
uint32_t timestampCurrentCounting[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 minimumSoc_perc[BS_NR_OF_STRINGS]
float averageSoc_perc[BS_NR_OF_STRINGS]
float maximumSoc_perc[BS_NR_OF_STRINGS]
float minimumSoc_perc[BS_NR_OF_STRINGS]
float maximumSoc_perc[BS_NR_OF_STRINGS]
float averageSoc_perc[BS_NR_OF_STRINGS]
float ccScalingMaximum[BS_NR_OF_STRINGS]
bool sensorCcUsed[BS_NR_OF_STRINGS]
float ccScalingMinimum[BS_NR_OF_STRINGS]
float ccScalingAverage[BS_NR_OF_STRINGS]
uint32_t previousTimestamp[BS_NR_OF_STRINGS]