foxBMS - Unit Tests  1.4.1
The foxBMS Unit Tests API Documentation
sof_trapezoid.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
38  * - ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file sof_trapezoid.h
44  * @author foxBMS Team
45  * @date 2020-10-07 (date of creation)
46  * @updated 2022-10-27 (date of last update)
47  * @version v1.4.1
48  * @ingroup APPLICATION
49  * @prefix SOF
50  *
51  * @brief Header for SOX module, responsible for current derating calculation
52  *
53  */
54 
55 #ifndef FOXBMS__SOF_TRAPEZOID_H_
56 #define FOXBMS__SOF_TRAPEZOID_H_
57 
58 /*========== Includes =======================================================*/
59 #include "sof_trapezoid_cfg.h"
60 
61 /*========== Macros and Definitions =========================================*/
62 /**
63  * struct definition for 4 different values: in two current directions (charge,
64  * discharge) for two use cases (peak and continuous)
65  */
66 typedef struct {
67  float continuousChargeCurrent_mA; /*!< maximum current for continues charging */
68  float peakChargeCurrent_mA; /*!< maximum current for peak charging */
69  float continuousDischargeCurrent_mA; /*!< maximum current for continues discharging */
70  float peakDischargeCurrent_mA; /*!< maximum current for peak discharging */
72 
73 /**
74  * struct definition for calculating the linear SOF curve. The SOF curve is
75  * voltage, temperature and charge/discharge dependent.
76  */
77 typedef struct {
78  float slopeLowTemperatureDischarge; /*!< low temperature dependent derating slope for discharge current */
79  float offsetLowTemperatureDischarge; /*!< discharge current offset for low temperature dependent derating */
80  float slopeHighTemperatureDischarge; /*!< high temperature dependent derating slope for discharge current */
81  float offsetHighTemperatureDischarge; /*!< discharge current offset for high temperature dependent derating */
82 
83  float slopeLowTemperatureCharge; /*!< low temperature dependent derating slope for charge current */
84  float offsetLowTemperatureCharge; /*!< charge current offset for low temperature dependent derating */
85  float slopeHighTemperatureCharge; /*!< high temperature dependent derating slope for charge current */
86  float offsetHighTemperatureCharge; /*!< charge current offset for high temperature dependent derating */
87 
88  float slopeUpperCellVoltage; /*!< upper cell voltage derating slope for charge and discharge current */
89  float offsetUpperCellVoltage; /*!< charge/discharge current offset for upper voltage derating */
90  float slopeLowerCellVoltage; /*!< lower cell voltage derating slope for charge and discharge current */
91  float offsetLowerCellVoltage; /*!< charge/discharge current offset for lower voltage derating */
92 } SOF_CURVE_s;
93 
94 /*========== Extern Constant and Variable Declarations ======================*/
95 
96 /*========== Extern Function Prototypes =====================================*/
97 /**
98  * @brief initializes the area for SOF (where derating starts and is fully
99  * active).
100  * @details Pseudocode for linear function parameter extraction with 2 points:
101  * - slope = (y2 - y1) / (x2-x1)
102  * - offset = y1 - (slope) * x1
103  * - function y= slope * x + offset
104  */
105 extern void SOF_Init(void);
106 
107 /**
108  * @brief triggers SOF calculation
109  * @details TODO
110  */
111 extern void SOF_Calculation(void);
112 
113 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
114 #ifdef UNITY_UNIT_TEST
116  int16_t minimumCellVoltage_mV,
117  int16_t maximumCellVoltage_mV,
118  SOF_CURRENT_LIMITS_s *pAllowedVoltageBasedCurrent,
119  const SOF_CONFIG_s *pConfigLimitValues,
120  SOF_CURVE_s *pCalculatedSofCurves);
122  int16_t minimumCellTemperature_ddegC,
123  int16_t maximumCellTemperature_ddegC,
124  SOF_CURRENT_LIMITS_s *pAllowedTemperatureBasedCurrent,
125  const SOF_CONFIG_s *pConfigLimitValues,
126  SOF_CURVE_s *pCalculatedSofCurves);
128  SOF_CURRENT_LIMITS_s voltageBasedLimits,
129  SOF_CURRENT_LIMITS_s temperatureBasedLimits);
130 #endif /* UNITY_UNIT_TEST */
131 #endif /* FOXBMS__SOF_TRAPEZOID_H_ */
void SOF_Calculation(void)
triggers SOF calculation
void TEST_SOF_CalculateVoltageBasedCurrentLimit(int16_t minimumCellVoltage_mV, int16_t maximumCellVoltage_mV, SOF_CURRENT_LIMITS_s *pAllowedVoltageBasedCurrent, const SOF_CONFIG_s *pConfigLimitValues, SOF_CURVE_s *pCalculatedSofCurves)
void TEST_SOF_CalculateTemperatureBasedCurrentLimit(int16_t minimumCellTemperature_ddegC, int16_t maximumCellTemperature_ddegC, SOF_CURRENT_LIMITS_s *pAllowedTemperatureBasedCurrent, const SOF_CONFIG_s *pConfigLimitValues, SOF_CURVE_s *pCalculatedSofCurves)
SOF_CURRENT_LIMITS_s TEST_SOF_MinimumOfTwoSofValues(SOF_CURRENT_LIMITS_s voltageBasedLimits, SOF_CURRENT_LIMITS_s temperatureBasedLimits)
void SOF_Init(void)
initializes the area for SOF (where derating starts and is fully active).
Header for SOF configuration.
float continuousDischargeCurrent_mA
Definition: sof_trapezoid.h:69
float continuousChargeCurrent_mA
Definition: sof_trapezoid.h:67
float offsetLowTemperatureDischarge
Definition: sof_trapezoid.h:79
float offsetHighTemperatureCharge
Definition: sof_trapezoid.h:86
float slopeHighTemperatureDischarge
Definition: sof_trapezoid.h:80
float offsetHighTemperatureDischarge
Definition: sof_trapezoid.h:81
float offsetUpperCellVoltage
Definition: sof_trapezoid.h:89
float slopeHighTemperatureCharge
Definition: sof_trapezoid.h:85
float slopeUpperCellVoltage
Definition: sof_trapezoid.h:88
float offsetLowerCellVoltage
Definition: sof_trapezoid.h:91
float slopeLowerCellVoltage
Definition: sof_trapezoid.h:90
float offsetLowTemperatureCharge
Definition: sof_trapezoid.h:84
float slopeLowTemperatureDischarge
Definition: sof_trapezoid.h:78
float slopeLowTemperatureCharge
Definition: sof_trapezoid.h:83