foxBMS - Unit Tests  1.2.0
The foxBMS Unit Tests API Documentation
moving_average.c File Reference

moving average algorithm More...

#include "moving_average.h"
#include "database.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 ()
 

Variables

static float 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 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 * pMovingAverageCurrentNew = &curValues[0]
 
static float * pMovingAverageCurrent_1s = &curValues[0]
 
static float * pMovingAverageCurrent_5s = &curValues[0]
 
static float * pMovingAverageCurrent_10s = &curValues[0]
 
static float * pMovingAverageCurrent_30s = &curValues[0]
 
static float * pMovingAverageCurrent_60s = &curValues[0]
 
static float * pMovingAverageCurrent_cfg = &curValues[0]
 
static float * pMovingAveragePowerNew = &powValues[0]
 
static float * pMovingAveragePower_1s = &powValues[0]
 
static float * pMovingAveragePower_5s = &powValues[0]
 
static float * pMovingAveragePower_10s = &powValues[0]
 
static float * pMovingAveragePower_30s = &powValues[0]
 
static float * pMovingAveragePower_60s = &powValues[0]
 
static float * 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
2021-09-08 (date of last update)
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 73 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 71 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 74 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 72 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 75 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 76 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 89 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 87 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 90 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 88 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 91 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 92 of file moving_average.c.

◆ MEM_EXT_SDRAM

#define MEM_EXT_SDRAM

TODO

Definition at line 61 of file moving_average.c.

Function Documentation

◆ ALGO_MovAverage()

void ALGO_MovAverage ( void  )

moving average function for the algorithm module

Definition at line 173 of file moving_average.c.

Variable Documentation

◆ curValues

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

Definition at line 118 of file moving_average.c.

◆ movingAverageCurrentLength

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

Definition at line 119 of file moving_average.c.

◆ movingAveragePowerLength

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

Definition at line 142 of file moving_average.c.

◆ pMovingAverageCurrent_10s

float* pMovingAverageCurrent_10s = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 150 of file moving_average.c.

◆ pMovingAverageCurrent_1s

float* pMovingAverageCurrent_1s = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 148 of file moving_average.c.

◆ pMovingAverageCurrent_30s

float* pMovingAverageCurrent_30s = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 151 of file moving_average.c.

◆ pMovingAverageCurrent_5s

float* pMovingAverageCurrent_5s = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 149 of file moving_average.c.

◆ pMovingAverageCurrent_60s

float* pMovingAverageCurrent_60s = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 152 of file moving_average.c.

◆ pMovingAverageCurrent_cfg

float* pMovingAverageCurrent_cfg = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 153 of file moving_average.c.

◆ pMovingAverageCurrentNew

float* pMovingAverageCurrentNew = &curValues[0]
static

Pointer for current moving average calculation

Definition at line 147 of file moving_average.c.

◆ pMovingAveragePower_10s

float* pMovingAveragePower_10s = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 160 of file moving_average.c.

◆ pMovingAveragePower_1s

float* pMovingAveragePower_1s = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 158 of file moving_average.c.

◆ pMovingAveragePower_30s

float* pMovingAveragePower_30s = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 161 of file moving_average.c.

◆ pMovingAveragePower_5s

float* pMovingAveragePower_5s = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 159 of file moving_average.c.

◆ pMovingAveragePower_60s

float* pMovingAveragePower_60s = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 162 of file moving_average.c.

◆ pMovingAveragePower_cfg

float* pMovingAveragePower_cfg = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 163 of file moving_average.c.

◆ pMovingAveragePowerNew

float* pMovingAveragePowerNew = &powValues[0]
static

Pointer for power moving average calculation

Definition at line 157 of file moving_average.c.

◆ powValues

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

Definition at line 141 of file moving_average.c.