foxBMS  1.2.0
The foxBMS Battery Management System API Documentation
soe_counting.c File Reference

SOE module responsible for calculation of SOE. More...

#include "soe_counting.h"
#include "battery_cell_cfg.h"
#include "battery_system_cfg.h"
#include "soe_counting_cfg.h"
#include "bms.h"
#include "database.h"
#include "foxmath.h"
#include "fram.h"
Include dependency graph for soe_counting.c:

Go to the source code of this file.

Data Structures

struct  SOE_STATE
 

Macros

#define MAXIMUM_SOE_PERC   (100.0f)
 
#define MINIMUM_SOE_PERC   (0.0f)
 

Typedefs

typedef struct SOE_STATE SOE_STATE_s
 

Functions

static uint32_t SOE_GetStringEnergyFromSoePercentage (float stringSoe_perc)
 calculates string energy in Wh from passed SOE in percentage More...
 
static float SOE_GetStringSoePercentageFromEnergy (uint32_t energy_Wh)
 calculates string SOE in percentage from passed string energy in Wh More...
 
static void SOE_RecalibrateViaLookupTable (DATA_BLOCK_SOX_s *pSoeValues)
 initializes database and FRAM SOE values via lookup table (average, min and max). More...
 
static float SOE_GetFromVoltage (int16_t voltage_mV)
 look-up table for SOE initialization More...
 
static void SOE_SetValue (DATA_BLOCK_SOX_s *pSoeValues, float soeMinimumValue_perc, float soeMaximumValue_perc, float soeAverageValue_perc, uint8_t stringNumber)
 sets SOE value with a parameter between 0.0 and 100.0. More...
 
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 if outside of this range. More...
 
void SOE_Init (DATA_BLOCK_SOX_s *pSoeValues, bool ec_present, uint8_t stringNumber)
 initializes startup state-of-energy (SOE) related values More...
 
void SOE_Calculation (DATA_BLOCK_SOX_s *pSoeValues)
 periodically called algorithm to calculate state-of-energy (SOE) More...
 

Variables

static SOE_STATE_s soe_state
 
static DATA_BLOCK_CURRENT_SENSOR_s soe_tableCurrentSensor = {.header.uniqueId = DATA_BLOCK_ID_CURRENT_SENSOR}
 

Detailed Description

SOE module responsible for calculation of SOE.

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
2020-10-07 (date of creation)
Updated
2021-08-06 (date of last update)
Prefix
SOE

Definition in file soe_counting.c.

Macro Definition Documentation

◆ MAXIMUM_SOE_PERC

#define MAXIMUM_SOE_PERC   (100.0f)

defines for maximum and minimum SOE

Definition at line 81 of file soe_counting.c.

◆ MINIMUM_SOE_PERC

#define MINIMUM_SOE_PERC   (0.0f)

Definition at line 82 of file soe_counting.c.

Typedef Documentation

◆ SOE_STATE_s

typedef struct SOE_STATE SOE_STATE_s

This structure contains all the variables relevant for the SOX.

Function Documentation

◆ SOE_Calculation()

void SOE_Calculation ( DATA_BLOCK_SOX_s pSoeValues)

periodically called algorithm to calculate state-of-energy (SOE)

Parameters
[out]pSoeValuespointer to SOE database entry

Definition at line 355 of file soe_counting.c.

Here is the call graph for this function:

◆ SOE_CheckDatabaseSoePercentageLimits()

static void SOE_CheckDatabaseSoePercentageLimits ( DATA_BLOCK_SOX_s pTableSoe,
uint8_t  stringNumber 
)
static

Check if all database SOE percentage values are within [0.0, 100.0] Limits SOE values to limit values if outside of this range.

Parameters
[in,out]pTableSoepointer to database struct with SOE values
[in]stringNumberstring that is checked

Definition at line 285 of file soe_counting.c.

◆ SOE_GetFromVoltage()

static float SOE_GetFromVoltage ( int16_t  voltage_mV)
static

look-up table for SOE initialization

Parameters
[in]voltage_mVcell voltage of battery cell
Returns
SOE value in percentage [0.0 - 100.0]

Definition at line 208 of file soe_counting.c.

Here is the call graph for this function:

◆ SOE_GetStringEnergyFromSoePercentage()

static uint32_t SOE_GetStringEnergyFromSoePercentage ( float  stringSoe_perc)
static

calculates string energy in Wh from passed SOE in percentage

Parameters
[in]stringSoe_percstring SOE in percentage [0.0, 100.0]
Returns
returns corresponding string energy in Wh

Definition at line 179 of file soe_counting.c.

◆ SOE_GetStringSoePercentageFromEnergy()

static float SOE_GetStringSoePercentageFromEnergy ( uint32_t  energy_Wh)
static

calculates string SOE in percentage from passed string energy in Wh

Parameters
[in]energy_Whstring energy in Wh
Returns
returns corresponding string SOE in percentage [0.0, 100.0]

Definition at line 168 of file soe_counting.c.

◆ SOE_Init()

void SOE_Init ( DATA_BLOCK_SOX_s pSoeValues,
bool  ec_present,
uint8_t  stringNumber 
)

initializes startup state-of-energy (SOE) related values

Parameters
[out]pSoeValuespointer to SOE database entry
[in]ec_presenttrue if current sensor EC message received, false otherwise
[in]stringNumberstring addressed

Definition at line 311 of file soe_counting.c.

Here is the call graph for this function:

◆ SOE_RecalibrateViaLookupTable()

static void SOE_RecalibrateViaLookupTable ( DATA_BLOCK_SOX_s pSoeValues)
static

initializes database and FRAM SOE values via lookup table (average, min and max).

Parameters
[out]pSoeValuespointer to SOE database entry

Definition at line 191 of file soe_counting.c.

Here is the call graph for this function:

◆ SOE_SetValue()

static void SOE_SetValue ( DATA_BLOCK_SOX_s pSoeValues,
float  soeMinimumValue_perc,
float  soeMaximumValue_perc,
float  soeAverageValue_perc,
uint8_t  stringNumber 
)
static

sets SOE value with a parameter between 0.0 and 100.0.

limits the SOE value to 0.0 respectively 100.0 if a value outside of the allowed SOE range is passed. Updates local fram and database struct but does NOT write them

Parameters
[out]pSoeValuespointer to SOE database enty
[in]soeMinimumValue_percSOE min value to set
[in]soeMaximumValue_percSOE max value to set
[in]soeAverageValue_percSOE average value to set
[in]stringNumberstring addressed

Definition at line 241 of file soe_counting.c.

Here is the call graph for this function:

Variable Documentation

◆ soe_state

SOE_STATE_s soe_state
static
Initial value:
= {
.soeInitialized = false,
.sensorEcUsed = {REPEAT_U(false, STRIP(BS_NR_OF_STRINGS))},
.ecScalingAverage = {REPEAT_U(0.0f, STRIP(BS_NR_OF_STRINGS))},
.ecScalingMinimum = {REPEAT_U(0.0f, STRIP(BS_NR_OF_STRINGS))},
.ecScalingMaximum = {REPEAT_U(0.0f, STRIP(BS_NR_OF_STRINGS))},
.previousTimestamp = {REPEAT_U(0u, STRIP(BS_NR_OF_STRINGS))},
}
#define BS_NR_OF_STRINGS
#define STRIP(x)
Definition: general.h:274
#define REPEAT_U(x, n)
Macro that helps to generate a series of literals (for array initializers).
Definition: general.h:262

contains the state of the SOE estimation

Definition at line 89 of file soe_counting.c.

◆ soe_tableCurrentSensor

DATA_BLOCK_CURRENT_SENSOR_s soe_tableCurrentSensor = {.header.uniqueId = DATA_BLOCK_ID_CURRENT_SENSOR}
static

local copies of database tables

Definition at line 100 of file soe_counting.c.