75 #define MAXIMUM_SOC_PERC (100.0f)
76 #define MINIMUM_SOC_PERC (0.0f)
125 float socMinimumValue_perc,
126 float socMaximumValue_perc,
127 float socAverageValue_perc,
128 uint8_t stringNumber);
169 float socMinimumValue_perc,
170 float socMaximumValue_perc,
171 float socAverageValue_perc,
172 uint8_t stringNumber) {
181 float ccOffset_perc =
184 #if POSITIVE_DISCHARGE_CURRENT == false
185 ccOffset_perc *= (-1.0f);
244 if (ccPresent ==
true) {
247 float scalingOffset_perc =
251 scalingOffset_perc *= (-1.0f);
254 #if POSITIVE_DISCHARGE_CURRENT == false
255 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 =
336 #if POSITIVE_DISCHARGE_CURRENT == false
337 deltaSoc_perc *= (-1.0f);
361 float soc_perc = 0.50f;
364 uint16_t between_high = 0;
365 uint16_t between_low = 0;
370 between_low = i + 1u;
376 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 REPEAT_U(x, n)
Macro that helps to generate a series of literals (for array initializers).
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
float SOC_GetFromVoltage(int16_t voltage_mV)
look-up table for SOC initialization
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.
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
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]