foxBMS  1.3.0
The foxBMS Battery Management System API Documentation
bms_cfg.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 bms_cfg.h
44  * @author foxBMS Team
45  * @date 2020-02-24 (date of creation)
46  * @updated 2022-05-30 (date of last update)
47  * @version v1.3.0
48  * @ingroup ENGINE_CONFIGURATION
49  * @prefix BMS
50  *
51  * @brief bms driver configuration header
52  */
53 
54 #ifndef FOXBMS__BMS_CFG_H_
55 #define FOXBMS__BMS_CFG_H_
56 
57 /*========== Includes =======================================================*/
58 #include "general.h"
59 
60 #include "ftask_cfg.h"
61 
62 /*========== Macros and Definitions =========================================*/
63 
64 /** ID to send a message without request */
65 #define BMS_REQ_ID_NOREQ (0u)
66 
67 /** ID to request the STANDBY state via CAN */
68 #define BMS_REQ_ID_STANDBY (3u)
69 
70 /** ID to request the NORMAL state via CAN */
71 #define BMS_REQ_ID_NORMAL (1u)
72 
73 /** ID to request the CHARGE state via CAN */
74 #define BMS_REQ_ID_CHARGE (2u)
75 
76 /**
77  * @brief Functions searching for next string return this value if no further
78  * string is available */
79 #define BMS_NO_STRING_AVAILABLE (255u)
80 
81 /**
82  * @brief TODO
83  * @details This define MUST represent the cycle time of the task in which
84  * context the functions run, e.g., if the #BMS_Trigger() is running
85  * in the 10 ms task then the define must be set to 10.
86  * This sets the minimum time between two subsequent executed
87  * states/substates.
88  * Define is only used for compile-time assertion, it has no
89  * programatic influence on the actual code.
90  */
91 #define BMS_STATEMACHINE_TASK_CYCLE_CONTEXT_MS (10u)
92 
93 #if BMS_STATEMACHINE_TASK_CYCLE_CONTEXT_MS != FTSK_TASK_CYCLIC_10MS_CYCLE_TIME
94 #error "Invalid BMS configuration. Make sure that BMS timing is configured correctly!"
95 #endif
96 
97 /**
98  * @brief BMS statemachine short time definition in #BMS_Trigger() calls
99  * until next state/substate is processed
100  */
101 #define BMS_STATEMACH_SHORTTIME (1u)
102 
103 /**
104  * @brief BMS statemachine medium time definition in #BMS_Trigger() calls
105  * until next state/substate is processed
106  */
107 #define BMS_STATEMACH_MEDIUMTIME (5u)
108 
109 /**
110  * @brief BMS statemachine long time definition in #BMS_Trigger() calls until
111  * next state/substate is processed
112  */
113 #define BMS_STATEMACH_LONGTIME (10u)
114 
115 /** Time in #BMS_Trigger() calls to wait after closing a string */
116 #define BMS_TIME_WAIT_AFTER_STRING_CLOSED (20u)
117 
118 /** Time in #BMS_Trigger() calls to wait after opening a string */
119 #define BMS_TIME_WAIT_AFTER_OPENING_STRING (10u)
120 
121 /**
122  * @brief Timeout in #BMS_Trigger() calls when closing a string after which
123  * the state machines goes to error if the string still has not closed
124  */
125 #define BMS_STRING_CLOSE_TIMEOUT (500u)
126 
127 /** Timeout in #BMS_Trigger() calls to wait after opening a string */
128 #define BMS_STRING_OPEN_TIMEOUT (1000u)
129 
130 /**
131  * @brief Max voltage difference in mV between two strings to allow
132  * closing the next string
133  */
134 #define BMS_NEXT_STRING_VOLTAGE_LIMIT_MV (3000)
135 
136 /** Max average string current to allow closing next string */
137 #define BMS_AVERAGE_STRING_CURRENT_LIMIT_MA (20000)
138 
139 /** Delay after closing precharge in #BMS_Trigger() calls */
140 #define BMS_TIME_WAIT_AFTER_CLOSING_PRECHARGE (100u)
141 
142 /** Delay after opening precharge in #BMS_Trigger() calls */
143 #define BMS_TIME_WAIT_AFTER_OPENING_PRECHARGE (50u)
144 
145 /**
146  * @brief Time to wait in #BMS_Trigger() calls after precharge opened because
147  * precharge failed
148  */
149 #define BMS_TIME_WAIT_AFTERPRECHARGEFAIL (300U)
150 
151 /**
152  * @brief Timeout in 1*10ms to wait before re-entering to precharge
153  * @details Prevents mechanical close/open timer cycle in case the control
154  * units sends incorrect state requests.
155  */
156 #define BMS_OSCILLATION_TIMEOUT (1000u)
157 
158 /** Number of allowed tries to close contactors */
159 #define BMS_PRECHARGE_TRIES (3u)
160 
161 /** Precharge threshold limit on voltage (in mV) */
162 #define BMS_PRECHARGE_VOLTAGE_THRESHOLD_mV (1000LL) /* mV */
163 
164 /** Precharge threshold limit on current (in mA) */
165 #define BMS_PRECHARGE_CURRENT_THRESHOLD_mA (50) /* mA */
166 
167 /**
168  * @details Time to wait after contactors opened because precharge failed in
169  * #BMS_Trigger() calls
170  */
171 #define BMS_STATEMACH_TIMEAFTERPRECHARGEFAIL (100u)
172 
173 /**
174  * @details Timeout in #BMS_Trigger() calls when closing precharge after which
175  * the state machines goes to error if precharge still has not closed
176  */
177 #define BMS_PRECHARGE_CLOSE_TIMEOUT (500u)
178 
179 /**
180  * @details Timeout in #BMS_Trigger() calls when opening precharge after which
181  * the state machines goes to error if precharge still has not opened
182  */
183 #define BMS_PRECHARGE_OPEN_TIMEOUT (500u)
184 
185 /*========== Extern Constant and Variable Declarations ======================*/
186 
187 /*========== Extern Function Prototypes =====================================*/
188 
189 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
190 
191 #endif /* FOXBMS__BMS_CFG_H_ */
Task configuration header.
General macros and definitions for the whole platform.