66 #if ALGO_TICK_ms > ISA_CURRENT_CYCLE_TIME_ms
67 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_1s ((1000u) / ALGO_TICK_ms)
68 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_5s ((5000u) / ALGO_TICK_ms)
69 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_10s ((10000u) / ALGO_TICK_ms)
70 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_30s ((30000u) / ALGO_TICK_ms)
71 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_60s ((60000u) / ALGO_TICK_ms)
72 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_CFG (MOVING_AVERAGE_DURATION_CURRENT_CONFIG_ms / ALGO_TICK_ms)
74 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_1s ((1000u) / ISA_CURRENT_CYCLE_TIME_ms)
75 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_5s ((5000u) / ISA_CURRENT_CYCLE_TIME_ms)
76 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_10s ((10000u) / ISA_CURRENT_CYCLE_TIME_ms)
77 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_30s ((30000u) / ISA_CURRENT_CYCLE_TIME_ms)
78 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_60s ((60000u) / ISA_CURRENT_CYCLE_TIME_ms)
79 #define ALGO_NUMBER_AVERAGE_VALUES_CUR_CFG (MOVING_AVERAGE_DURATION_CURRENT_CONFIG_ms / ISA_CURRENT_CYCLE_TIME_ms)
82 #if ALGO_TICK_ms > ISA_POWER_CYCLE_TIME_ms
83 #define ALGO_NUMBER_AVERAGE_VALUES_POW_1s ((1000u) / ALGO_TICK_ms)
84 #define ALGO_NUMBER_AVERAGE_VALUES_POW_5s ((5000u) / ALGO_TICK_ms)
85 #define ALGO_NUMBER_AVERAGE_VALUES_POW_10s ((10000u) / ALGO_TICK_ms)
86 #define ALGO_NUMBER_AVERAGE_VALUES_POW_30s ((30000u) / ALGO_TICK_ms)
87 #define ALGO_NUMBER_AVERAGE_VALUES_POW_60s ((60000u) / ALGO_TICK_ms)
88 #define ALGO_NUMBER_AVERAGE_VALUES_POW_CFG (MOVING_AVERAGE_DURATION_POWER_CONFIG_ms / ALGO_TICK_ms)
90 #define ALGO_NUMBER_AVERAGE_VALUES_POW_1s ((1000u) / ISA_POWER_CYCLE_TIME_ms)
91 #define ALGO_NUMBER_AVERAGE_VALUES_POW_5s ((5000u) / ISA_POWER_CYCLE_TIME_ms)
92 #define ALGO_NUMBER_AVERAGE_VALUES_POW_10s ((10000u) / ISA_POWER_CYCLE_TIME_ms)
93 #define ALGO_NUMBER_AVERAGE_VALUES_POW_30s ((30000u) / ISA_POWER_CYCLE_TIME_ms)
94 #define ALGO_NUMBER_AVERAGE_VALUES_POW_60s ((60000u) / ISA_POWER_CYCLE_TIME_ms)
95 #define ALGO_NUMBER_AVERAGE_VALUES_POW_CFG (MOVING_AVERAGE_DURATION_POWER_CONFIG_ms / ISA_POWER_CYCLE_TIME_ms)
103 #if ALGO_TICK_ms > ISA_CURRENT_CYCLE_TIME_ms
104 #if MOVING_AVERAGE_DURATION_CURRENT_CONFIG_ms / ALGO_TICK_ms > 60000u / ALGO_TICK_ms
115 #if (MOVING_AVERAGE_DURATION_CURRENT_CONFIG_ms / ISA_CURRENT_CYCLE_TIME_ms) > (60000u / ISA_CURRENT_CYCLE_TIME_ms)
127 #if ALGO_TICK_ms > ISA_POWER_CYCLE_TIME_ms
128 #if (MOVING_AVERAGE_DURATION_POWER_CONFIG_ms / ALGO_TICK_ms) > (60000u / ALGO_TICK_ms)
138 #if (MOVING_AVERAGE_DURATION_POWER_CONFIG_ms / ISA_POWER_CYCLE_TIME_ms) > (60000u / ISA_POWER_CYCLE_TIME_ms)
177 static uint8_t curCounter = 0u;
178 static uint8_t powCounter = 0u;
181 static uint8_t curInit = 0u;
182 static uint8_t powInit = 0u;
183 static uint8_t newValues = 0u;
184 float divider = 0.0f;
185 bool validValues =
true;
201 if (validValues ==
true) {
205 int32_t packCurrent = 0;
229 if ((curInit & 0x01u) == 0x01u) {
238 if ((curInit & 0x02u) == 0x02u) {
247 if ((curInit & 0x04u) == 0x04u) {
256 if ((curInit & 0x08u) == 0x08u) {
265 if ((curInit & 0x10u) == 0x10u) {
274 if ((curInit & 0x20u) == 0x20u) {
312 if (powCounter != curPow_tab.
newPower) {
321 if (validValues ==
true) {
324 int32_t packPower = 0;
326 packPower += curPow_tab.
power_W[s];
348 if ((powInit & 0x01u) == 0x01u) {
357 if ((powInit & 0x02u) == 0x02u) {
366 if ((powInit & 0x04u) == 0x04u) {
375 if ((powInit & 0x08u) == 0x08u) {
384 if ((powInit & 0x10u) == 0x10u) {
393 if ((powInit & 0x20u) == 0x20u) {
428 if (newValues == 1u) {
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
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_5s
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_60s
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_CFG
static float * pMovingAveragePower_10s
static float MEM_EXT_SDRAM powValues[(60000u/ISA_POWER_CYCLE_TIME_ms)+1u]
static float * pMovingAverageCurrent_10s
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_10s
static float * pMovingAveragePower_1s
static float * pMovingAverageCurrent_5s
#define ALGO_NUMBER_AVERAGE_VALUES_POW_60s
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_1s
static float * pMovingAverageCurrent_1s
#define ALGO_NUMBER_AVERAGE_VALUES_POW_CFG
static float * pMovingAveragePower_5s
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_30s
static float MEM_EXT_SDRAM curValues[(60000u/ISA_CURRENT_CYCLE_TIME_ms)+1u]
static float * pMovingAverageCurrentNew
#define ALGO_NUMBER_AVERAGE_VALUES_POW_10s
static float * pMovingAveragePower_cfg
#define ALGO_NUMBER_AVERAGE_VALUES_POW_5s
static float * pMovingAveragePower_30s
static uint32_t movingAveragePowerLength
#define ALGO_NUMBER_AVERAGE_VALUES_POW_30s
static float * pMovingAveragePower_60s
static float * pMovingAveragePowerNew
static float * pMovingAverageCurrent_30s
static float * pMovingAverageCurrent_cfg
static uint32_t movingAverageCurrentLength
static float * pMovingAverageCurrent_60s
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 movingAveragePower1sInterval_mA
float movingAveragePower10sInterval_mA
float movingAveragePower60sInterval_mA
float movingAveragePower30sInterval_mA
DATA_BLOCK_HEADER_s header
float movingAverageCurrentConfigurableInterval_mA
float movingAverageCurrent10sInterval_mA
float movingAverageCurrent1sInterval_mA
float movingAverageCurrent5sInterval_mA
float movingAverageCurrent30sInterval_mA
float movingAverageCurrent60sInterval_mA
float movingAveragePower5sInterval_mA
float movingAveragePowerConfigurableInterval_mA