foxBMS-UnitTests  1.0.0
The foxBMS Unit Tests API Documentation
soe_counting.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der
4  * angewandten Forschung e.V. All rights reserved.
5  *
6  * BSD 3-Clause License
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * We kindly request you to use one or more of the following phrases to refer
31  * to foxBMS in your hardware, software, documentation or advertising
32  * materials:
33  *
34  * ″This product uses parts of foxBMS®″
35  *
36  * ″This product includes parts of foxBMS®″
37  *
38  * ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file soe_counting.c
44  * @author foxBMS Team
45  * @date 2020-10-07 (date of creation)
46  * @updated 2020-10-07 (date of last update)
47  * @ingroup APPLICATION
48  * @prefix SOE
49  *
50  * @brief SOE module responsible for calculation of SOE
51  *
52  */
53 
54 /*========== Includes =======================================================*/
55 #include "soe_counting.h"
56 
57 #include "battery_cell_cfg.h"
58 #include "battery_system_cfg.h"
59 #include "soe_counting_cfg.h"
60 
61 #include "bms.h"
62 #include "database.h"
63 #include "foxmath.h"
64 #include "fram.h"
65 
66 /*========== Macros and Definitions =========================================*/
67 /**
68  * This structure contains all the variables relevant for the SOX.
69  */
70 typedef struct {
71  bool soeInitialized; /*!< true if the initialization has passed, false otherwise */
72  bool sensor_ec_used[BS_NR_OF_STRINGS]; /*!< true if energy counting functionality of current sensor is used */
73  float ecScalingAverage[BS_NR_OF_STRINGS]; /*!< current sensor offset scaling for average SOE */
74  float ecScalingMinimum[BS_NR_OF_STRINGS]; /*!< current sensor offset scaling for minimum SOE */
75  float ecScalingMaximum[BS_NR_OF_STRINGS]; /*!< current sensor offset scaling for maximum SOE */
76  uint32_t previousTimestamp
77  [BS_NR_OF_STRINGS]; /*!< last used timestamp of current or energy counting value for SOE estimation */
78 } SOE_STATE_s;
79 
80 /*========== Static Constant and Variable Definitions =======================*/
81 
82 /**
83  * contains the state of the SOE estimation
84  */
86  .soeInitialized = false,
87 };
88 
89 /** local copies of database tables */
90 /**@{*/
93 /**@}*/
94 
95 /*========== Extern Constant and Variable Definitions =======================*/
96 
97 /*========== Static Function Prototypes =====================================*/
98 
99 /**
100  * @brief calculates string energy in Wh from passed SOE in percentage
101  *
102  * @param[in] stringSoe_perc string SOE in percentage [0.0, 100.0]
103  *
104  * @return returns corresponding string energy in Wh
105  */
106 static uint32_t SOE_GetStringEnergyFromSoePercentage(float stringSoe_perc);
107 
108 /**
109  * @brief calculates string SOE in percentage from passed string energy in Wh
110  *
111  * @param[in] energy_Wh string energy in Wh
112  *
113  * @return returns corresponding string SOE in percentage [0.0, 100.0]
114  */
115 static float SOE_GetStringSoePercentageFromEnergy(uint32_t energy_Wh);
116 
117 /**
118  * @brief initializes database and FRAM SOE values via lookup table (average, min and max).
119  */
120 static void SOE_RecalibrateViaLookupTable(void);
121 
122 /**
123  * @brief look-up table for SOE initialization
124  *
125  * @param[in] voltage_mV cell voltage of battery cell
126  *
127  * @return SOE value in percentage [0.0 - 100.0]
128  */
129 static float SOE_GetFromVoltage(int16_t voltage_mV);
130 
131 /**
132  * @brief sets SOE value with a parameter between 0.0 and 100.0.
133  * @details limits the SOE value to 0.0 respectively 100.0 if a value outside
134  * of the allowed SOE range is passed. Updates local fram and database
135  * struct but does *NOT* write them
136  * @param[in] soeMinimumValue_perc SOE min value to set
137  * @param[in] soeMaximumValue_perc SOE max value to set
138  * @param[in] soeAverageValue_perc SOE average value to set
139  * @param[in] stringNumber string addressed
140  */
141 static void SOE_SetValue(
142  float soeMinimumValue_perc,
143  float soeMaximumValue_perc,
144  float soeAverageValue_perc,
145  uint8_t stringNumber);
146 
147 /**
148  * @brief Check if all database SOE percentage values are within [0.0, 100.0]
149  * Limits SOE values to limit values if outside of this range.
150  *
151  * @param[in,out] pTableSoe pointer to database struct with SOE values
152  * @param[in] stringNumber string that is checked
153  */
154 static void SOE_CheckDatabaseSoePercentageLimits(DATA_BLOCK_SOX_s *pTableSoe, uint8_t stringNumber);
155 
156 /*========== Static Function Implementations ================================*/
157 static float SOE_GetStringSoePercentageFromEnergy(uint32_t energy_Wh) {
158  float stringSoe_perc = 0.0f;
159  if (energy_Wh >= (uint32_t)SOE_STRING_ENERGY_Wh) {
160  stringSoe_perc = 100.0f;
161  } else {
162  stringSoe_perc = 100.0f * ((float)energy_Wh / SOE_STRING_ENERGY_Wh);
163  }
164  return stringSoe_perc;
165 }
166 
167 static uint32_t SOE_GetStringEnergyFromSoePercentage(float stringSoe_perc) {
168  float energy_Wh = 0.0f;
169  if (stringSoe_perc >= 100.0f) {
170  energy_Wh = SOE_STRING_ENERGY_Wh;
171  } else if (stringSoe_perc <= 0.0f) {
172  energy_Wh = 0.0f;
173  } else {
174  energy_Wh = SOE_STRING_ENERGY_Wh * (stringSoe_perc / 100.0f);
175  }
176  return (uint32_t)energy_Wh;
177 }
178 
179 static void SOE_RecalibrateViaLookupTable(void) {
180  DATA_BLOCK_MIN_MAX_s tableMinimumMaximumAverage = {.header.uniqueId = DATA_BLOCK_ID_MIN_MAX};
181 
182  DATA_READ_DATA(&tableMinimumMaximumAverage);
183 
184  for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) {
185  SOE_SetValue(
186  SOE_GetFromVoltage(tableMinimumMaximumAverage.minimumCellVoltage_mV[stringNumber]),
187  SOE_GetFromVoltage(tableMinimumMaximumAverage.maximumCellVoltage_mV[stringNumber]),
188  SOE_GetFromVoltage(tableMinimumMaximumAverage.averageCellVoltage_mV[stringNumber]),
189  stringNumber);
190  }
193 }
194 
195 static float SOE_GetFromVoltage(int16_t voltage_mV) {
196  float soe_perc = 50.0f;
197  /* Variables for interpolating LUT value */
198  uint16_t between_high = 0;
199  uint16_t between_low = 0;
200 
201  /* Cell voltages are inserted in LUT in descending order -> start with 1 as we do not want to extrapolate. */
202  for (uint16_t i = 1u; i < bc_stateOfEnergyLookupTableLength; i++) {
203  if (voltage_mV < bc_stateOfEnergyLookupTable[i].voltage_mV) {
204  between_low = i + 1u;
205  between_high = i;
206  }
207  }
208 
209  /* Interpolate between LUT values, but do not extrapolate LUT! */
210  if (!(((0u == between_high) && (0u == between_low)) || /* cell voltage > maximum LUT voltage */
211  (between_low > bc_stateOfEnergyLookupTableLength))) { /* cell voltage < minimum LUT voltage */
212  soe_perc = MATH_linearInterpolation(
213  (float)bc_stateOfEnergyLookupTable[between_low].voltage_mV,
214  bc_stateOfEnergyLookupTable[between_low].value,
215  (float)bc_stateOfEnergyLookupTable[between_high].voltage_mV,
216  bc_stateOfEnergyLookupTable[between_high].value,
217  (float)voltage_mV);
218  } else if ((between_low > bc_stateOfEnergyLookupTableLength)) {
219  /* LUT SOE values are in descending order: cell voltage < minimum LUT voltage */
220  soe_perc = 0.0f;
221  } else {
222  /* cell voltage > maximum LUT voltage */
223  soe_perc = 100.0f;
224  }
225  return soe_perc;
226 }
227 
228 static void SOE_SetValue(
229  float soeMinimumValue_perc,
230  float soeMaximumValue_perc,
231  float soeAverageValue_perc,
232  uint8_t stringNumber) {
233  /* Update FRAM value */
234  fram_soe.averageSoe_perc[stringNumber] = soeAverageValue_perc;
235  fram_soe.minimumSoe_perc[stringNumber] = soeMinimumValue_perc;
236  fram_soe.maximumSoe_perc[stringNumber] = soeMaximumValue_perc;
237 
238  /* Update database values */
239  soe_tableSoeValues.averageSoe_perc[stringNumber] = soeAverageValue_perc;
240  soe_tableSoeValues.minimumSoe_perc[stringNumber] = soeMinimumValue_perc;
241  soe_tableSoeValues.maximumSoe_perc[stringNumber] = soeMaximumValue_perc;
242 
243  soe_tableSoeValues.maximumSoe_Wh[stringNumber] = SOE_GetStringEnergyFromSoePercentage(soeMaximumValue_perc);
244  soe_tableSoeValues.averageSoe_Wh[stringNumber] = SOE_GetStringEnergyFromSoePercentage(soeAverageValue_perc);
245  soe_tableSoeValues.minimumSoe_Wh[stringNumber] = SOE_GetStringEnergyFromSoePercentage(soeMinimumValue_perc);
246 
247  /* Calculate scaling values depending on EC counting value and current SOE */
248  if (soe_state.sensor_ec_used[stringNumber] == true) {
250 
251  float ecOffset =
253 
254 #if POSITIVE_DISCHARGE_CURRENT == false
255  ecOffset *= (-1.0f); /* negate calculated delta SOE in perc */
256 
257 #endif /* POSITIVE_DISCHARGE_CURRENT == false */
258 
259  soe_state.ecScalingAverage[stringNumber] = fram_soe.averageSoe_perc[stringNumber] + ecOffset;
260  soe_state.ecScalingMinimum[stringNumber] = fram_soe.minimumSoe_perc[stringNumber] + ecOffset;
261  soe_state.ecScalingMaximum[stringNumber] = fram_soe.maximumSoe_perc[stringNumber] + ecOffset;
262  }
263 }
264 
265 static void SOE_CheckDatabaseSoePercentageLimits(DATA_BLOCK_SOX_s *pTableSoe, uint8_t stringNumber) {
266  FAS_ASSERT(pTableSoe != NULL_PTR);
267  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
268 
269  if (pTableSoe->averageSoe_perc[stringNumber] > 100.0f) {
270  pTableSoe->averageSoe_perc[stringNumber] = 100.0f;
271  }
272  if (pTableSoe->averageSoe_perc[stringNumber] < 0.0f) {
273  pTableSoe->averageSoe_perc[stringNumber] = 0.0f;
274  }
275  if (pTableSoe->minimumSoe_perc[stringNumber] > 100.0f) {
276  pTableSoe->minimumSoe_perc[stringNumber] = 100.0f;
277  }
278  if (pTableSoe->minimumSoe_perc[stringNumber] < 0.0f) {
279  pTableSoe->minimumSoe_perc[stringNumber] = 0.0f;
280  }
281  if (pTableSoe->maximumSoe_perc[stringNumber] > 100.0f) {
282  pTableSoe->maximumSoe_perc[stringNumber] = 100.0f;
283  }
284  if (pTableSoe->maximumSoe_perc[stringNumber] < 0.0f) {
285  pTableSoe->maximumSoe_perc[stringNumber] = 0.0f;
286  }
287  return;
288 }
289 
290 /*========== Extern Function Implementations ================================*/
291 
292 extern void SOE_Init(bool ec_present, uint8_t stringNumber) {
294 
295  soe_tableSoeValues.averageSoe_perc[stringNumber] = fram_soe.averageSoe_perc[stringNumber];
296  soe_tableSoeValues.minimumSoe_perc[stringNumber] = fram_soe.minimumSoe_perc[stringNumber];
297  soe_tableSoeValues.maximumSoe_perc[stringNumber] = fram_soe.maximumSoe_perc[stringNumber];
298 
299  /* Limit SOE values [0.0f, 100.0f] */
301 
302  /* Calculate string energy in Wh */
303  soe_tableSoeValues.maximumSoe_Wh[stringNumber] =
305  soe_tableSoeValues.minimumSoe_Wh[stringNumber] =
307  soe_tableSoeValues.averageSoe_Wh[stringNumber] =
309 
310  if (true == ec_present) {
312  soe_state.sensor_ec_used[stringNumber] = true;
313 
314  /* Set scaling values */
315  float ecOffset =
317 
318 #if POSITIVE_DISCHARGE_CURRENT == false
319  ecOffset *= (-1.0f); /* negate calculated delta SOE in perc */
320 
321 #endif /* POSITIVE_DISCHARGE_CURRENT == false */
322 
323  soe_state.ecScalingMinimum[stringNumber] = fram_soe.minimumSoe_perc[stringNumber] + ecOffset;
324  soe_state.ecScalingMaximum[stringNumber] = fram_soe.maximumSoe_perc[stringNumber] + ecOffset;
325  soe_state.ecScalingAverage[stringNumber] = fram_soe.averageSoe_perc[stringNumber] + ecOffset;
326  }
327  soe_state.soeInitialized = true;
329 }
330 
331 void SOE_Calculation(void) {
332  bool continueFunction = true;
333  if (false == soe_state.soeInitialized) {
334  /* Exit if SOE not initialized yet */
335  continueFunction = false;
336  }
337 
338  if (true == continueFunction) {
340  /* Recalibrate SOE via LUT */
342  } else {
343  /* Use energy counting/integrate */
345 
346  for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) {
347  if (false == soe_state.sensor_ec_used[stringNumber]) {
348  /* no energy counting activated -> manually integrate energy */
349  uint32_t timestamp = soe_tableCurrentSensor.timestampCurrent[stringNumber];
350  uint32_t previous_timestamp = soe_tableCurrentSensor.previousTimestampCurrent[stringNumber];
351 
352  /* check if current measurement has been updated */
353  if (soe_state.previousTimestamp[stringNumber] != timestamp) {
354  float timestep_s = (((float)timestamp - (float)previous_timestamp)) / 1000.0f;
355  if (timestep_s > 0.0f) {
356  /* Current in charge direction negative means SOE increasing --> BAT naming, not ROB */
357  float deltaSOE_Wh = ((((float)soe_tableCurrentSensor.current_mA[stringNumber] /
358  1000.0f) * /* convert to A */
359  ((float)soe_tableCurrentSensor.highVoltage_mV[stringNumber][0] /
360  1000.0f)) / /* convert to V */
361  timestep_s) / /* unit: s */
362  3600.0f; /* convert Ws -> Wh */
363 
364 #if POSITIVE_DISCHARGE_CURRENT == false
365  /* negate calculated delta SOE_Wh */
366  deltaSOE_Wh *= (-1.0f);
367 #endif /* POSITIVE_DISCHARGE_CURRENT == false */
368 
369  soe_tableSoeValues.averageSoe_Wh[stringNumber] -= (uint32_t)deltaSOE_Wh;
370  soe_tableSoeValues.minimumSoe_Wh[stringNumber] -= (uint32_t)deltaSOE_Wh;
371  soe_tableSoeValues.maximumSoe_Wh[stringNumber] -= (uint32_t)deltaSOE_Wh;
372 
373  soe_tableSoeValues.averageSoe_perc[stringNumber] =
375  soe_tableSoeValues.minimumSoe_perc[stringNumber] =
377  soe_tableSoeValues.maximumSoe_perc[stringNumber] =
379 
380  /* update timestamp SOE state variable for next iteration */
381  soe_state.previousTimestamp[stringNumber] = timestamp;
382  }
383  } /* end check if current measurement has been updated */
384  } else {
385  /* check if ec measurement has been updated */
386  if (soe_state.previousTimestamp[stringNumber] !=
388  /* Calculate SOE value with current sensor EC value */
389  float deltaSoe_perc =
391  100.0f);
392 
393 #if POSITIVE_DISCHARGE_CURRENT == false
394  /* negate calculated delta SOE_perc */
395  deltaSoe_perc *= (-1.0f);
396 #endif
397  /* Apply EC scaling offset to get actual string energy */
398  soe_tableSoeValues.averageSoe_perc[stringNumber] = soe_state.ecScalingAverage[stringNumber] -
399  deltaSoe_perc;
400  soe_tableSoeValues.minimumSoe_perc[stringNumber] = soe_state.ecScalingMinimum[stringNumber] -
401  deltaSoe_perc;
402  soe_tableSoeValues.maximumSoe_perc[stringNumber] = soe_state.ecScalingMaximum[stringNumber] -
403  deltaSoe_perc;
404 
405  /* Limit SOE values to [0.0, 100.0] */
407 
408  /* Calculate new Wh values */
409  soe_tableSoeValues.maximumSoe_Wh[stringNumber] =
411  soe_tableSoeValues.averageSoe_Wh[stringNumber] =
413  soe_tableSoeValues.minimumSoe_Wh[stringNumber] =
415 
416  /* Update timestamp for next iteration */
417  soe_state.previousTimestamp[stringNumber] =
419  }
420  }
421 
422  fram_soe.averageSoe_perc[stringNumber] = soe_tableSoeValues.averageSoe_perc[stringNumber];
423  fram_soe.minimumSoe_perc[stringNumber] = soe_tableSoeValues.minimumSoe_perc[stringNumber];
424  fram_soe.maximumSoe_perc[stringNumber] = soe_tableSoeValues.maximumSoe_perc[stringNumber];
425  }
426 
427  /* Update database and FRAM value */
430  }
431  }
432 }
433 
434 /*========== Externalized Static Function Implementations (Unit Test) =======*/
soe_counting_cfg.h
Header for SOE configuration.
DATA_BLOCK_CURRENT_SENSOR
Definition: database_cfg.h:209
bc_stateOfEnergyLookupTableLength
uint16_t bc_stateOfEnergyLookupTableLength
Definition: battery_cell_cfg.c:103
SOE_STATE_s::soeInitialized
bool soeInitialized
Definition: soe_counting.c:71
soe_tableCurrentSensor
static DATA_BLOCK_CURRENT_SENSOR_s soe_tableCurrentSensor
Definition: soe_counting.c:92
SOE_Calculation
void SOE_Calculation(void)
calculates state-of-energy (SOE)
Definition: soe_counting.c:331
DATA_BLOCK_MIN_MAX::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:162
SOE_STATE_s::previousTimestamp
uint32_t previousTimestamp[BS_NR_OF_STRINGS]
Definition: soe_counting.c:77
fram_soe
FRAM_SOE_s fram_soe
Definition: fram_cfg.c:71
SOE_Init
void SOE_Init(bool ec_present, uint8_t stringNumber)
initializes startup state-of-energy (SOE) related values
Definition: soe_counting.c:292
bms.h
bms driver header
DATA_WRITE_DATA
#define DATA_WRITE_DATA(...)
Definition: database.h:82
SOE_STATE_s::ecScalingMaximum
float ecScalingMaximum[BS_NR_OF_STRINGS]
Definition: soe_counting.c:75
SOE_GetStringEnergyFromSoePercentage
static uint32_t SOE_GetStringEnergyFromSoePercentage(float stringSoe_perc)
calculates string energy in Wh from passed SOE in percentage
Definition: soe_counting.c:167
DATA_BLOCK_SOX::maximumSoe_perc
float maximumSoe_perc[BS_NR_OF_STRINGS]
Definition: database_cfg.h:495
battery_system_cfg.h
Configuration of the battery system (e.g., number of battery modules, battery cells,...
FRAM_BLOCK_ID_SOE
@ FRAM_BLOCK_ID_SOE
Definition: fram_cfg.h:92
SOE_GetFromVoltage
static float SOE_GetFromVoltage(int16_t voltage_mV)
look-up table for SOE initialization
Definition: soe_counting.c:195
DATA_BLOCK_MIN_MAX::averageCellVoltage_mV
int16_t averageCellVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:164
SOE_STATE_s::ecScalingAverage
float ecScalingAverage[BS_NR_OF_STRINGS]
Definition: soe_counting.c:73
SOE_GetStringSoePercentageFromEnergy
static float SOE_GetStringSoePercentageFromEnergy(uint32_t energy_Wh)
calculates string SOE in percentage from passed string energy in Wh
Definition: soe_counting.c:157
bc_stateOfEnergyLookupTable
const BC_LUT_s bc_stateOfEnergyLookupTable[]
Definition: battery_cell_cfg.c:84
DATA_BLOCK_CURRENT_SENSOR::energyCounter_Wh
int32_t energyCounter_Wh[BS_NR_OF_STRINGS]
Definition: database_cfg.h:230
DATA_BLOCK_SOX::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:489
DATA_BLOCK_SOX::averageSoe_Wh
uint32_t averageSoe_Wh[BS_NR_OF_STRINGS]
Definition: database_cfg.h:497
DATA_BLOCK_CURRENT_SENSOR::current_mA
int32_t current_mA[BS_NR_OF_STRINGS]
Definition: database_cfg.h:214
FAS_ASSERT
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:233
SOE_STATE_s::ecScalingMinimum
float ecScalingMinimum[BS_NR_OF_STRINGS]
Definition: soe_counting.c:74
FRAM_SOE::maximumSoe_perc
float maximumSoe_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:132
DATA_BLOCK_CURRENT_SENSOR::timestampEnergyCounting
uint32_t timestampEnergyCounting[BS_NR_OF_STRINGS]
Definition: database_cfg.h:233
soe_tableSoeValues
static DATA_BLOCK_SOX_s soe_tableSoeValues
Definition: soe_counting.c:91
DATA_BLOCK_ID_MIN_MAX
@ DATA_BLOCK_ID_MIN_MAX
Definition: database_cfg.h:75
foxmath.h
math library for often used math functions
DATA_BLOCK_SOX::maximumSoe_Wh
uint32_t maximumSoe_Wh[BS_NR_OF_STRINGS]
Definition: database_cfg.h:496
DATA_BLOCK_SOX::minimumSoe_perc
float minimumSoe_perc[BS_NR_OF_STRINGS]
Definition: database_cfg.h:494
DATA_BLOCK_CURRENT_SENSOR::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:213
BMS_AT_REST
@ BMS_AT_REST
Definition: bms.h:69
SOE_STRING_ENERGY_Wh
#define SOE_STRING_ENERGY_Wh
Definition: soe_counting_cfg.h:68
BMS_GetBatterySystemState
BMS_CURRENT_FLOW_STATE_e BMS_GetBatterySystemState(void)
Returns current battery system state (charging/discharging, resting or in relaxation phase)
Definition: bms.c:1230
battery_cell_cfg.h
Configuration of the battery cell (e.g., minimum and maximum cell voltage)
DATA_BLOCK_CURRENT_SENSOR::timestampCurrent
uint32_t timestampCurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:218
DATA_BLOCK_MIN_MAX::maximumCellVoltage_mV
int16_t maximumCellVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:167
SOE_STATE_s::sensor_ec_used
bool sensor_ec_used[BS_NR_OF_STRINGS]
Definition: soe_counting.c:72
FRAM_Write
STD_RETURN_TYPE_e FRAM_Write(FRAM_BLOCK_ID_e blockId)
Writes a variable to the FRAM.
Definition: fram.c:101
soe_state
static SOE_STATE_s soe_state
Definition: soe_counting.c:85
MATH_linearInterpolation
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.
Definition: foxmath.c:69
DATA_BLOCK_MIN_MAX
Definition: database_cfg.h:158
DATA_READ_DATA
#define DATA_READ_DATA(...)
Definition: database.h:72
DATA_BLOCK_CURRENT_SENSOR::previousTimestampCurrent
uint32_t previousTimestampCurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:217
DATA_BLOCK_CURRENT_SENSOR::highVoltage_mV
int32_t highVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR]
Definition: database_cfg.h:236
database.h
Database module header.
NULL_PTR
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:66
soe_counting.h
Header for SOE module, responsible for calculation of SOE.
FRAM_Read
STD_RETURN_TYPE_e FRAM_Read(FRAM_BLOCK_ID_e blockId)
Reads a variable from the FRAM.
Definition: fram.c:160
FRAM_SOE::averageSoe_perc
float averageSoe_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:133
SOE_CheckDatabaseSoePercentageLimits
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...
Definition: soe_counting.c:265
DATA_BLOCK_SOX::minimumSoe_Wh
uint32_t minimumSoe_Wh[BS_NR_OF_STRINGS]
Definition: database_cfg.h:498
DATA_BLOCK_MIN_MAX::minimumCellVoltage_mV
int16_t minimumCellVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:165
DATA_BLOCK_ID_CURRENT_SENSOR
@ DATA_BLOCK_ID_CURRENT_SENSOR
Definition: database_cfg.h:76
SOE_STATE_s
Definition: soe_counting.c:70
SOE_RecalibrateViaLookupTable
static void SOE_RecalibrateViaLookupTable(void)
initializes database and FRAM SOE values via lookup table (average, min and max).
Definition: soe_counting.c:179
DATA_BLOCK_SOX::averageSoe_perc
float averageSoe_perc[BS_NR_OF_STRINGS]
Definition: database_cfg.h:493
BS_NR_OF_STRINGS
#define BS_NR_OF_STRINGS
Definition: battery_system_cfg.h:89
SOE_SetValue
static void SOE_SetValue(float soeMinimumValue_perc, float soeMaximumValue_perc, float soeAverageValue_perc, uint8_t stringNumber)
sets SOE value with a parameter between 0.0 and 100.0.
Definition: soe_counting.c:228
FRAM_SOE::minimumSoe_perc
float minimumSoe_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:131
DATA_BLOCK_SOX
Definition: database_cfg.h:485
DATA_BLOCK_ID_SOX
@ DATA_BLOCK_ID_SOX
Definition: database_cfg.h:91
fram.h
Header for the driver for the FRAM module.
DATA_BLOCKHEADER::uniqueId
DATA_BLOCK_ID_e uniqueId
Definition: database_cfg.h:109