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

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

#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 "state_estimation.h"
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
Include dependency graph for soe_counting.c:

Go to the source code of this file.

Data Structures

struct  SOE_STATE_s
 

Macros

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

Functions

static uint32_t SOE_GetStringEnergyFromSoePercentage (float_t stringSoe_perc)
 calculates string energy in Wh from passed SOE in percentage More...
 
static float_t SOE_GetStringSoePercentageFromEnergy (uint32_t energy_Wh)
 calculates string SOE in percentage from passed string energy in Wh More...
 
static void SOE_RecalibrateViaLookupTable (DATA_BLOCK_SOE_s *pSoeValues)
 initializes database and FRAM SOE values via lookup table (average, min and max). More...
 
static float_t SOE_GetFromVoltage (int16_t voltage_mV)
 look-up table for SOE initialization More...
 
static void SOE_SetValue (DATA_BLOCK_SOE_s *pSoeValues, float_t soeMinimumValue_perc, float_t soeMaximumValue_perc, float_t soeAverageValue_perc, uint8_t stringNumber)
 sets SOE value with a parameter between 0.0 and 100.0. More...
 
static void SOE_CheckDatabaseSoePercentageLimits (DATA_BLOCK_SOE_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 SE_InitializeStateOfEnergy (DATA_BLOCK_SOE_s *pSoeValues, bool ec_present, uint8_t stringNumber)
 initializes startup state-of-energy (SOE) related values More...
 
void SE_CalculateStateOfEnergy (DATA_BLOCK_SOE_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
2023-10-12 (date of last update)
Version
v1.6.0
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 85 of file soe_counting.c.

◆ MINIMUM_SOE_PERC

#define MINIMUM_SOE_PERC   (0.0f)

Definition at line 86 of file soe_counting.c.

Function Documentation

◆ SOE_CheckDatabaseSoePercentageLimits()

static void SOE_CheckDatabaseSoePercentageLimits ( DATA_BLOCK_SOE_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 289 of file soe_counting.c.

◆ SOE_GetFromVoltage()

static float_t 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 212 of file soe_counting.c.

Here is the call graph for this function:

◆ SOE_GetStringEnergyFromSoePercentage()

static uint32_t SOE_GetStringEnergyFromSoePercentage ( float_t  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 183 of file soe_counting.c.

◆ SOE_GetStringSoePercentageFromEnergy()

static float_t 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 172 of file soe_counting.c.

◆ SOE_RecalibrateViaLookupTable()

static void SOE_RecalibrateViaLookupTable ( DATA_BLOCK_SOE_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 195 of file soe_counting.c.

Here is the call graph for this function:

◆ SOE_SetValue()

static void SOE_SetValue ( DATA_BLOCK_SOE_s pSoeValues,
float_t  soeMinimumValue_perc,
float_t  soeMaximumValue_perc,
float_t  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 entry
[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 245 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 = {GEN_REPEAT_U(false, GEN_STRIP(BS_NR_OF_STRINGS))},
.ecScalingAverage = {GEN_REPEAT_U(0.0f, GEN_STRIP(BS_NR_OF_STRINGS))},
.ecScalingMinimum = {GEN_REPEAT_U(0.0f, GEN_STRIP(BS_NR_OF_STRINGS))},
.ecScalingMaximum = {GEN_REPEAT_U(0.0f, GEN_STRIP(BS_NR_OF_STRINGS))},
.previousTimestamp = {GEN_REPEAT_U(0u, GEN_STRIP(BS_NR_OF_STRINGS))},
}
#define BS_NR_OF_STRINGS
Number of parallel strings in the battery pack.
#define GEN_REPEAT_U(x, n)
Macro that helps to generate a series of literals (for array initializers).
Definition: general.h:250
#define GEN_STRIP(x)
Definition: general.h:261

contains the state of the SOE estimation

Definition at line 93 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 104 of file soe_counting.c.