71 #if ALGO_TICK_ms > ISA_CURRENT_CYCLE_TIME_ms
72 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_1s ((1000u) / ALGO_TICK_ms)
73 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_5s ((5000u) / ALGO_TICK_ms)
74 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_10s ((10000u) / ALGO_TICK_ms)
75 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_30s ((30000u) / ALGO_TICK_ms)
76 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_60s ((60000u) / ALGO_TICK_ms)
77 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_CFG (MOVING_AVERAGE_DURATION_CURRENT_CONFIG_ms / ALGO_TICK_ms)
79 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_1s ((1000u) / ISA_CURRENT_CYCLE_TIME_ms)
80 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_5s ((5000u) / ISA_CURRENT_CYCLE_TIME_ms)
81 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_10s ((10000u) / ISA_CURRENT_CYCLE_TIME_ms)
82 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_30s ((30000u) / ISA_CURRENT_CYCLE_TIME_ms)
83 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_60s ((60000u) / ISA_CURRENT_CYCLE_TIME_ms)
84 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_CFG (MOVING_AVERAGE_DURATION_CURRENT_CONFIG_ms / ISA_CURRENT_CYCLE_TIME_ms)
87 #if ALGO_TICK_ms > ISA_POWER_CYCLE_TIME_ms
88 #define ALGO_NUMBER_AVERAGE_VALUES_POW_1s ((1000u) / ALGO_TICK_ms)
89 #define ALGO_NUMBER_AVERAGE_VALUES_POW_5s ((5000u) / ALGO_TICK_ms)
90 #define ALGO_NUMBER_AVERAGE_VALUES_POW_10s ((10000u) / ALGO_TICK_ms)
91 #define ALGO_NUMBER_AVERAGE_VALUES_POW_30s ((30000u) / ALGO_TICK_ms)
92 #define ALGO_NUMBER_AVERAGE_VALUES_POW_60s ((60000u) / ALGO_TICK_ms)
93 #define ALGO_NUMBER_AVERAGE_VALUES_POW_CFG (MOVING_AVERAGE_DURATION_POWER_CONFIG_ms / ALGO_TICK_ms)
95 #define ALGO_NUMBER_AVERAGE_VALUES_POW_1s ((1000u) / ISA_POWER_CYCLE_TIME_ms)
96 #define ALGO_NUMBER_AVERAGE_VALUES_POW_5s ((5000u) / ISA_POWER_CYCLE_TIME_ms)
97 #define ALGO_NUMBER_AVERAGE_VALUES_POW_10s ((10000u) / ISA_POWER_CYCLE_TIME_ms)
98 #define ALGO_NUMBER_AVERAGE_VALUES_POW_30s ((30000u) / ISA_POWER_CYCLE_TIME_ms)
99 #define ALGO_NUMBER_AVERAGE_VALUES_POW_60s ((60000u) / ISA_POWER_CYCLE_TIME_ms)
100 #define ALGO_NUMBER_AVERAGE_VALUES_POW_CFG (MOVING_AVERAGE_DURATION_POWER_CONFIG_ms / ISA_POWER_CYCLE_TIME_ms)
108 #if ALGO_TICK_ms > ISA_CURRENT_CYCLE_TIME_ms
109 #if MOVING_AVERAGE_DURATION_CURRENT_CONFIG_ms / ALGO_TICK_ms > 60000u / ALGO_TICK_ms
120 #if (MOVING_AVERAGE_DURATION_CURRENT_CONFIG_ms / ISA_CURRENT_CYCLE_TIME_ms) > (60000u / ISA_CURRENT_CYCLE_TIME_ms)
133 #if ALGO_TICK_ms > ISA_POWER_CYCLE_TIME_ms
134 #if (MOVING_AVERAGE_DURATION_POWER_CONFIG_ms / ALGO_TICK_ms) > (60000u / ALGO_TICK_ms)
144 #if (MOVING_AVERAGE_DURATION_POWER_CONFIG_ms / ISA_POWER_CYCLE_TIME_ms) > (60000u / ISA_POWER_CYCLE_TIME_ms)
183 static uint8_t curCounter = 0u;
184 static uint8_t powCounter = 0u;
187 static uint8_t curInit = 0u;
188 static uint8_t powInit = 0u;
189 static uint8_t newValues = 0u;
190 float_t divider = 0.0f;
191 bool validValues =
true;
207 if (validValues ==
true) {
211 int32_t packCurrent = 0;
235 if ((curInit & 0x01u) == 0x01u) {
244 if ((curInit & 0x02u) == 0x02u) {
253 if ((curInit & 0x04u) == 0x04u) {
262 if ((curInit & 0x08u) == 0x08u) {
271 if ((curInit & 0x10u) == 0x10u) {
280 if ((curInit & 0x20u) == 0x20u) {
318 if (powCounter != curPow_tab.
newPower) {
327 if (validValues ==
true) {
330 int32_t packPower = 0;
332 packPower += curPow_tab.
power_W[s];
354 if ((powInit & 0x01u) == 0x01u) {
363 if ((powInit & 0x02u) == 0x02u) {
372 if ((powInit & 0x04u) == 0x04u) {
381 if ((powInit & 0x08u) == 0x08u) {
390 if ((powInit & 0x10u) == 0x10u) {
399 if ((powInit & 0x20u) == 0x20u) {
434 if (newValues == 1u) {
442 #ifdef UNITY_UNIT_TEST
Headers for the configuration of the algorithm module.
#define BS_NR_OF_STRINGS
Number of parallel strings in the battery pack.
#define DATA_READ_DATA(...)
#define DATA_WRITE_DATA(...)
@ DATA_BLOCK_ID_MOVING_AVERAGE
@ DATA_BLOCK_ID_CURRENT_SENSOR
Definition of foxBMS standard types.
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_5s
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_60s
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_CFG
static float_t * pMovingAverageCurrent_30s
static float_t * pMovingAverageCurrent_5s
static float_t * pMovingAveragePower_1s
static float_t * pMovingAveragePowerNew
static float_t * pMovingAveragePower_cfg
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_10s
static float_t * pMovingAverageCurrent_10s
static float_t MEM_EXT_SDRAM powValues[(60000u/ISA_POWER_CYCLE_TIME_ms)+1u]
static float_t * pMovingAveragePower_5s
#define ALGO_NUMBER_AVERAGE_VALUES_POW_60s
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_1s
static float_t * pMovingAverageCurrent_60s
static float_t * pMovingAverageCurrent_cfg
static float_t * pMovingAverageCurrentNew
static float_t MEM_EXT_SDRAM curValues[(60000u/ISA_CURRENT_CYCLE_TIME_ms)+1u]
#define ALGO_NUMBER_AVERAGE_VALUES_POW_CFG
static float_t * pMovingAveragePower_30s
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_30s
static float_t * pMovingAverageCurrent_1s
#define ALGO_NUMBER_AVERAGE_VALUES_POW_10s
#define ALGO_NUMBER_AVERAGE_VALUES_POW_5s
static float_t * pMovingAveragePower_60s
static uint32_t movingAveragePowerLength
#define ALGO_NUMBER_AVERAGE_VALUES_POW_30s
static uint32_t movingAverageCurrentLength
static float_t * pMovingAveragePower_10s
void ALGO_MovAverage(void)
#define ALGO_NUMBER_AVERAGE_VALUES_POW_1s
#define MOVING_AVERAGE_DURATION_POWER_CONFIG_ms
#define MOVING_AVERAGE_DURATION_CURRENT_CONFIG_ms
#define ISA_CURRENT_CYCLE_TIME_ms
#define ISA_POWER_CYCLE_TIME_ms
int32_t current_mA[BS_NR_OF_STRINGS]
DATA_BLOCK_HEADER_s header
uint8_t invalidCurrentMeasurement[BS_NR_OF_STRINGS]
int32_t power_W[BS_NR_OF_STRINGS]
uint8_t invalidPowerMeasurement[BS_NR_OF_STRINGS]
float_t movingAveragePower5sInterval_mA
float_t movingAveragePower1sInterval_mA
float_t movingAverageCurrentConfigurableInterval_mA
DATA_BLOCK_HEADER_s header
float_t movingAverageCurrent5sInterval_mA
float_t movingAverageCurrent30sInterval_mA
float_t movingAveragePower30sInterval_mA
float_t movingAverageCurrent10sInterval_mA
float_t movingAveragePower60sInterval_mA
float_t movingAveragePowerConfigurableInterval_mA
float_t movingAveragePower10sInterval_mA
float_t movingAverageCurrent1sInterval_mA
float_t movingAverageCurrent60sInterval_mA