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