foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
moving_average.c File Reference

moving average algorithm More...

#include "moving_average.h"
#include "algorithm_cfg.h"
#include "database.h"
#include "fstd_types.h"
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
Include dependency graph for moving_average.c:

Go to the source code of this file.

Macros

#define MEM_EXT_SDRAM
 
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_1s   ((1000u) / ISA_CURRENT_CYCLE_TIME_ms)
 
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_5s   ((5000u) / ISA_CURRENT_CYCLE_TIME_ms)
 
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_10s   ((10000u) / ISA_CURRENT_CYCLE_TIME_ms)
 
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_30s   ((30000u) / ISA_CURRENT_CYCLE_TIME_ms)
 
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_60s   ((60000u) / ISA_CURRENT_CYCLE_TIME_ms)
 
#define ALGO_NUMBER_AVERAGE_VALUES_CUR_CFG   (MOVING_AVERAGE_DURATION_CURRENT_CONFIG_ms / ISA_CURRENT_CYCLE_TIME_ms)
 
#define ALGO_NUMBER_AVERAGE_VALUES_POW_1s   ((1000u) / ISA_POWER_CYCLE_TIME_ms)
 
#define ALGO_NUMBER_AVERAGE_VALUES_POW_5s   ((5000u) / ISA_POWER_CYCLE_TIME_ms)
 
#define ALGO_NUMBER_AVERAGE_VALUES_POW_10s   ((10000u) / ISA_POWER_CYCLE_TIME_ms)
 
#define ALGO_NUMBER_AVERAGE_VALUES_POW_30s   ((30000u) / ISA_POWER_CYCLE_TIME_ms)
 
#define ALGO_NUMBER_AVERAGE_VALUES_POW_60s   ((60000u) / ISA_POWER_CYCLE_TIME_ms)
 
#define ALGO_NUMBER_AVERAGE_VALUES_POW_CFG   (MOVING_AVERAGE_DURATION_POWER_CONFIG_ms / ISA_POWER_CYCLE_TIME_ms)
 

Functions

void ALGO_MovAverage (void)
 

Variables

static float_t MEM_EXT_SDRAM curValues [(60000u/ISA_CURRENT_CYCLE_TIME_ms)+1u] = {0.0f}
 
static uint32_t movingAverageCurrentLength = (60000u / ISA_CURRENT_CYCLE_TIME_ms) + 1u
 
static float_t MEM_EXT_SDRAM powValues [(60000u/ISA_POWER_CYCLE_TIME_ms)+1u] = {0.0f}
 
static uint32_t movingAveragePowerLength = (60000u / ISA_POWER_CYCLE_TIME_ms) + 1u
 
static float_t * pMovingAverageCurrentNew = &curValues[0]
 
static float_t * pMovingAverageCurrent_1s = &curValues[0]
 
static float_t * pMovingAverageCurrent_5s = &curValues[0]
 
static float_t * pMovingAverageCurrent_10s = &curValues[0]
 
static float_t * pMovingAverageCurrent_30s = &curValues[0]
 
static float_t * pMovingAverageCurrent_60s = &curValues[0]
 
static float_t * pMovingAverageCurrent_cfg = &curValues[0]
 
static float_t * pMovingAveragePowerNew = &powValues[0]
 
static float_t * pMovingAveragePower_1s = &powValues[0]
 
static float_t * pMovingAveragePower_5s = &powValues[0]
 
static float_t * pMovingAveragePower_10s = &powValues[0]
 
static float_t * pMovingAveragePower_30s = &powValues[0]
 
static float_t * pMovingAveragePower_60s = &powValues[0]
 
static float_t * pMovingAveragePower_cfg = &powValues[0]
 

Detailed Description

moving average algorithm

SPDX-License-Identifier: BSD-3-Clause

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:

  • ″This product uses parts of foxBMS®″
  • ″This product includes parts of foxBMS®″
  • ″This product is derived from foxBMS®″
Author
foxBMS Team
Date
2017-12-18 (date of creation)
Updated
2023-10-12 (date of last update)
Version
v1.6.0
Prefix
ALGO

Definition in file moving_average.c.

Macro Definition Documentation

◆ ALGO_NUMBER_AVERAGE_VALUES_CUR_10s

#define ALGO_NUMBER_AVERAGE_VALUES_CUR_10s   ((10000u) / ISA_CURRENT_CYCLE_TIME_ms)

Definition at line 81 of file moving_average.c.

◆ ALGO_NUMBER_AVERAGE_VALUES_CUR_1s

#define ALGO_NUMBER_AVERAGE_VALUES_CUR_1s   ((1000u) / ISA_CURRENT_CYCLE_TIME_ms)

Definition at line 79 of file moving_average.c.

◆ ALGO_NUMBER_AVERAGE_VALUES_CUR_30s

#define ALGO_NUMBER_AVERAGE_VALUES_CUR_30s   ((30000u) / ISA_CURRENT_CYCLE_TIME_ms)

Definition at line 82 of file moving_average.c.

◆ ALGO_NUMBER_AVERAGE_VALUES_CUR_5s

#define ALGO_NUMBER_AVERAGE_VALUES_CUR_5s   ((5000u) / ISA_CURRENT_CYCLE_TIME_ms)

Definition at line 80 of file moving_average.c.

◆ ALGO_NUMBER_AVERAGE_VALUES_CUR_60s

#define ALGO_NUMBER_AVERAGE_VALUES_CUR_60s   ((60000u) / ISA_CURRENT_CYCLE_TIME_ms)

Definition at line 83 of file moving_average.c.

◆ ALGO_NUMBER_AVERAGE_VALUES_CUR_CFG

#define ALGO_NUMBER_AVERAGE_VALUES_CUR_CFG   (MOVING_AVERAGE_DURATION_CURRENT_CONFIG_ms / ISA_CURRENT_CYCLE_TIME_ms)

Definition at line 84 of file moving_average.c.

◆ ALGO_NUMBER_AVERAGE_VALUES_POW_10s

#define ALGO_NUMBER_AVERAGE_VALUES_POW_10s   ((10000u) / ISA_POWER_CYCLE_TIME_ms)

Definition at line 97 of file moving_average.c.

◆ ALGO_NUMBER_AVERAGE_VALUES_POW_1s

#define ALGO_NUMBER_AVERAGE_VALUES_POW_1s   ((1000u) / ISA_POWER_CYCLE_TIME_ms)

Definition at line 95 of file moving_average.c.

◆ ALGO_NUMBER_AVERAGE_VALUES_POW_30s

#define ALGO_NUMBER_AVERAGE_VALUES_POW_30s   ((30000u) / ISA_POWER_CYCLE_TIME_ms)

Definition at line 98 of file moving_average.c.

◆ ALGO_NUMBER_AVERAGE_VALUES_POW_5s

#define ALGO_NUMBER_AVERAGE_VALUES_POW_5s   ((5000u) / ISA_POWER_CYCLE_TIME_ms)

Definition at line 96 of file moving_average.c.

◆ ALGO_NUMBER_AVERAGE_VALUES_POW_60s

#define ALGO_NUMBER_AVERAGE_VALUES_POW_60s   ((60000u) / ISA_POWER_CYCLE_TIME_ms)

Definition at line 99 of file moving_average.c.

◆ ALGO_NUMBER_AVERAGE_VALUES_POW_CFG

#define ALGO_NUMBER_AVERAGE_VALUES_POW_CFG   (MOVING_AVERAGE_DURATION_POWER_CONFIG_ms / ISA_POWER_CYCLE_TIME_ms)

Definition at line 100 of file moving_average.c.

◆ MEM_EXT_SDRAM

#define MEM_EXT_SDRAM

TODO

Definition at line 69 of file moving_average.c.

Function Documentation

◆ ALGO_MovAverage()

void ALGO_MovAverage ( void  )

moving average function for the algorithm module

Definition at line 182 of file moving_average.c.

Variable Documentation

◆ curValues

float_t MEM_EXT_SDRAM curValues[(60000u/ISA_CURRENT_CYCLE_TIME_ms)+1u] = {0.0f}
static

Definition at line 127 of file moving_average.c.

◆ movingAverageCurrentLength

uint32_t movingAverageCurrentLength = (60000u / ISA_CURRENT_CYCLE_TIME_ms) + 1u
static

Definition at line 128 of file moving_average.c.

◆ movingAveragePowerLength

uint32_t movingAveragePowerLength = (60000u / ISA_POWER_CYCLE_TIME_ms) + 1u
static

Definition at line 151 of file moving_average.c.

◆ pMovingAverageCurrent_10s

float_t* pMovingAverageCurrent_10s = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 159 of file moving_average.c.

◆ pMovingAverageCurrent_1s

float_t* pMovingAverageCurrent_1s = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 157 of file moving_average.c.

◆ pMovingAverageCurrent_30s

float_t* pMovingAverageCurrent_30s = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 160 of file moving_average.c.

◆ pMovingAverageCurrent_5s

float_t* pMovingAverageCurrent_5s = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 158 of file moving_average.c.

◆ pMovingAverageCurrent_60s

float_t* pMovingAverageCurrent_60s = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 161 of file moving_average.c.

◆ pMovingAverageCurrent_cfg

float_t* pMovingAverageCurrent_cfg = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 162 of file moving_average.c.

◆ pMovingAverageCurrentNew

float_t* pMovingAverageCurrentNew = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 156 of file moving_average.c.

◆ pMovingAveragePower_10s

float_t* pMovingAveragePower_10s = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 169 of file moving_average.c.

◆ pMovingAveragePower_1s

float_t* pMovingAveragePower_1s = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 167 of file moving_average.c.

◆ pMovingAveragePower_30s

float_t* pMovingAveragePower_30s = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 170 of file moving_average.c.

◆ pMovingAveragePower_5s

float_t* pMovingAveragePower_5s = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 168 of file moving_average.c.

◆ pMovingAveragePower_60s

float_t* pMovingAveragePower_60s = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 171 of file moving_average.c.

◆ pMovingAveragePower_cfg

float_t* pMovingAveragePower_cfg = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 172 of file moving_average.c.

◆ pMovingAveragePowerNew

float_t* pMovingAveragePowerNew = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 166 of file moving_average.c.

◆ powValues

float_t MEM_EXT_SDRAM powValues[(60000u/ISA_POWER_CYCLE_TIME_ms)+1u] = {0.0f}
static

Definition at line 150 of file moving_average.c.