foxBMS  1.0.0
The foxBMS Battery Management System API Documentation
battery_system_cfg.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der
4  * angewandten Forschung e.V. All rights reserved.
5  *
6  * BSD 3-Clause License
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * We kindly request you to use one or more of the following phrases to refer
31  * to foxBMS in your hardware, software, documentation or advertising
32  * materials:
33  *
34  * ″This product uses parts of foxBMS®″
35  *
36  * ″This product includes parts of foxBMS®″
37  *
38  * ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file battery_system_cfg.h
44  * @author foxBMS Team
45  * @date 2019-12-10 (date of creation)
46  * @updated 2021-03-24 (date of last update)
47  * @ingroup BATTERY_SYSTEM_CONFIGURATION
48  * @prefix BS
49  *
50  * @brief Configuration of the battery system (e.g., number of battery
51  * modules, battery cells, temperature sensors)
52  *
53  * @details This files contains basic macros of the battery system in order to
54  * derive needed inputs in other parts of the software. These macros
55  * are all depended on the hardware.
56  *
57  */
58 
59 #ifndef FOXBMS__BATTERY_SYSTEM_CFG_H_
60 #define FOXBMS__BATTERY_SYSTEM_CFG_H_
61 
62 /*========== Includes =======================================================*/
63 #include "general.h"
64 
65 /*========== Macros and Definitions =========================================*/
66 
67 /** Symbolic identifiers for strings with precharge */
72 
73 /**
74  * Symbolic identifiers for strings.
75  * Currently unused.
76  * Added for future compatibility.
77  */
78 typedef enum BS_STRING_ID {
79  BS_STRING0 = 0u,
80  BS_STRING1 = 1u,
81  BS_STRING2 = 2u,
84 
85 /** Define if discharge current are positive negative, default is positive */
86 #define POSITIVE_DISCHARGE_CURRENT (true)
87 
88 /** Number of strings in system */
89 #define BS_NR_OF_STRINGS (3u)
90 
91 /**
92  * @ingroup CONFIG_BATTERYSYSTEM
93  * @brief number of modules in battery pack
94  * @ptype uint
95  */
96 #define BS_NR_OF_MODULES (1u)
97 
98 /**
99  * @ingroup CONFIG_BATTERYSYSTEM
100  * @brief number of battery cells per battery module (parallel cells are
101  * counted as one)
102  * @ptype uint
103  */
104 #define BS_NR_OF_CELLS_PER_MODULE (18u)
105 
106 /**
107  * @ingroup CONFIG_BATTERYSYSTEM
108  * @brief number of battery cells in a parallel cell connection per battery
109  * module
110  * @ptype uint
111  */
112 #define BS_NR_OF_PARALLEL_CELLS_PER_MODULE (1u)
113 
114 #if BS_NR_OF_CELLS_PER_MODULE <= 12u
115 #define BS_MAX_SUPPORTED_CELLS (12u)
116 #elif BS_NR_OF_CELLS_PER_MODULE <= 15u
117 #define BS_MAX_SUPPORTED_CELLS (15u)
118 #elif BS_NR_OF_CELLS_PER_MODULE <= 16u
119 #define BS_MAX_SUPPORTED_CELLS (16u)
120 #elif BS_NR_OF_CELLS_PER_MODULE <= 18u
121 #define BS_MAX_SUPPORTED_CELLS (18u)
122 #elif BS_NR_OF_CELLS_PER_MODULE == 36u
123 #define BS_MAX_SUPPORTED_CELLS (36u)
124 #else
125 #error "Unsupported number of cells per module, higher than 18 and not 36"
126 #endif
127 
128 /**
129  * @def BS_MAX_SUPPORTED_CELLS
130  * @brief Defines the maximal number of supported cells per module
131  */
132 
133 /** Value of the balancing resistors on the slave-board */
134 #define BS_BALANCING_RESISTANCE_ohm (100.0)
135 
136 /**
137  * @def BS_NR_OF_GPIOS_PER_MODULE
138  * @brief Number of GPIOs on the LTC IC
139  * @details - 5 for 12 cell version
140  * - 9 for 18 cell version
141  */
142 #if BS_MAX_SUPPORTED_CELLS == 12u
143 #define BS_NR_OF_GPIOS_PER_MODULE (5u)
144 #else
145 #define BS_NR_OF_GPIOS_PER_MODULE (9u)
146 #endif
147 
148 /**
149  * @ingroup CONFIG_BATTERYSYSTEM
150  * @brief number of temperature sensors per battery module
151  * @ptype int
152  */
153 #define BS_NR_OF_TEMP_SENSORS_PER_MODULE (8u)
154 
155 /** number of (not parallel) battery cells in the system */
156 #define BS_NR_OF_BAT_CELLS (BS_NR_OF_MODULES * BS_NR_OF_CELLS_PER_MODULE)
157 /** number of temperature sensors in the system */
158 #define BS_NR_OF_TEMP_SENSORS (BS_NR_OF_MODULES * BS_NR_OF_TEMP_SENSORS_PER_MODULE)
159 
160 /** number of temperature sensors on each ADC0 channel of the slave-board */
161 #define BS_NR_OF_TEMP_SENSORS_ON_ADC0 (3u)
162 /** number of temperature sensors on each ADC1 channel of the slave-board */
163 #define BS_NR_OF_TEMP_SENSORS_ON_ADC1 (3u)
164 
165 /**
166  * @details - If set to false, foxBMS does not check for the presence of a
167  * current sensor.
168  * - If set to true, foxBMS checks for the presence of a current
169  * sensor. If sensor stops responding during runtime, an error is
170  * raised.
171  */
172 #define CURRENT_SENSOR_PRESENT (false)
173 
174 #if CURRENT_SENSOR_PRESENT == true
175 /**
176  * defines if the Isabellenhuette current sensor is used in cyclic or triggered mode
177  */
178 #define CURRENT_SENSOR_ISABELLENHUETTE_CYCLIC
179 /* #define CURRENT_SENSOR_ISABELLENHUETTE_TRIGGERED */
180 
181 /** Delay in ms after which it is considered the current measurement is not responding anymore. */
182 #define BS_CURRENT_MEASUREMENT_RESPONSE_TIMEOUT_MS (200u)
183 
184 /** Delay in ms after which it is considered the coulomb counting is not responding anymore. */
185 #define BS_COULOMB_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS (2000u)
186 
187 /** Delay in ms after which it is considered the energy counting is not responding anymore. */
188 #define BS_ENERGY_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS (2000u)
189 
190 #endif /* CURRENT_SENSOR_PRESENT == true */
191 
192 /**
193  * @brief Maximum string current limit in mA that is used in the SOA module
194  * to check for string overcurrent
195 * @details When maximum safety limit (MSL) is violated, error state is
196  * requested and contactors will open.
197  */
198 #define BS_MAXIMUM_STRING_CURRENT_mA (10000u)
199 
200 /**
201  * @brief Maximum pack current limit in mA that is used in the SOA module
202  * to check for pack overcurrent
203  * @details When maximum safety limit (MSL) is violated, error state is
204  * requested and contactors will open.
205  */
206 #define BS_MAXIMUM_PACK_CURRENT_mA (10000u * BS_NR_OF_STRINGS)
207 
208 /**
209  * @details - If set to false, foxBMS does not check CAN timing.
210  * - If set to true, foxBMS checks CAN timing. A valid request must
211  * come every 100ms, within the 95-150ms window.
212  */
213 #define CHECK_CAN_TIMING (false)
214 
215 /**
216  * @details - If set to true, balancing is deactivated completely.
217  * - If set to false, foxBMS checks when balancing must be done and
218  * activates it accordingly.
219  */
220 #define BALANCING_DEFAULT_INACTIVE (true)
221 
222 /**
223  * @ingroup CONFIG_BATTERYSYSTEM
224  * @brief Checking if current is in SOF limits of cells.
225  * @details If set to true the current is checked against the SOF limits.
226  * If set to false the current is checked against the constant values
227  * for charging and discharging:
228  * - #BC_CURRENT_MAX_DISCHARGE_MSL_mA
229  * - #BC_CURRENT_MAX_DISCHARGE_RSL_mA
230  * - #BC_CURRENT_MAX_DISCHARGE_MOL_mA
231  *
232  * - #BC_CURRENT_MAX_CHARGE_MSL_mA
233  * - #BC_CURRENT_MAX_CHARGE_RSL_mA
234  * - #BC_CURRENT_MAX_CHARGE_MOL_mA
235  * @ptype bool
236  */
237 #define BMS_CHECK_SOF_CURRENT_LIMITS (true)
238 
239 /**
240  * @ingroup CONFIG_BATTERYSYSTEM
241  * @brief Defines behaviour if an insulation error is detected
242  * @details - If set to true: contactors will be opened
243  * - If set to false: contactors will NOT be opened
244  */
245 #define BMS_OPEN_CONTACTORS_ON_INSULATION_ERROR (false)
246 
247 /**
248  * @ingroup CONFIG_BATTERYSYSTEM
249  * @brief number of high voltage inputs measured by current sensors (like
250  * IVT-MOD)
251  * @ptype int
252  */
253 #define BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR (3u)
254 
255 /**
256  * @ingroup CONFIG_BATTERYSYSTEM
257  * @brief number of voltages measured by MCU internal ADC
258  * @ptype int
259  */
260 #define BS_NR_OF_VOLTAGES_FROM_MCU_ADC (2)
261 
262 /** Number of contactors in addition to string contactors (e.g., PRECHARGE).*/
263 #define BS_NR_OF_CONTACTORS_OUTSIDE_STRINGS (1U)
264 
265 /** Number of contactors. One per string + main and precharge */
266 #define BS_NR_OF_CONTACTORS ((2U * BS_NR_OF_STRINGS) + BS_NR_OF_CONTACTORS_OUTSIDE_STRINGS)
267 
268 /**
269  * @ingroup CONFIG_BATTERYSYSTEM
270  * @brief separation of charge and discharge power line
271  * @ptype select(2)
272  */
273 #define BS_SEPARATE_POWERLINES (1)
274 
275 #if (BS_NR_OF_CONTACTORS > 3) && (BS_SEPARATE_POWERLINES == 0)
276 #error "Configuration mismatch: Can't use only one powerline with more than 3 contactors"
277 #endif /* */
278 
279 #if (BS_NR_OF_CONTACTORS < 4) && (BS_SEPARATE_POWERLINES == 1)
280 #error "Configuration mismatch: Can't use separate powerlines with less than 4 contactors"
281 #endif /* */
282 
283 /**
284  * @brief current threshold for determing rest state of battery. If absolute
285  * current is below this limit value the battery is resting.
286  */
287 #define BS_REST_CURRENT_mA (200)
288 
289 /**
290  * @brief Wait time in 10ms before battery system is at rest. Balancing for
291  * example only starts if battery system is at rest.
292  */
293 #define BS_RELAXATION_PERIOD_10ms (60000u)
294 
295 /**
296  * @brief current sensor threshold for 0 current in mA as the sensor has a
297  * jitter.
298  */
299 #define BS_CS_THRESHOLD_NO_CURRENT_mA (200u)
300 
301 /**
302  * @brief Maximum voltage drop over fuse.
303  * @details If the measured voltage difference between battery voltage
304  * voltage after fuse is larger than this value. It can be concluded,
305  * that the fuse has tripped. The voltage difference can be estimated
306  * by the maximum current and the resistance.
307  * For a Cooper Bussmann 1000A fuse the voltage drop can be estimated
308  * to: I_max = 1000A and P_loss = 206W
309  * -> voltage drop at 1000A roughly 206mV
310  * -> select 500mV because of measurement inaccuracies
311  */
312 #define BS_MAX_VOLTAGE_DROP_OVER_FUSE_mV (500)
313 
314 /**
315  * @brief TODO
316  * @details Set to true if fuse in NORMAL path should be checked. This can only
317  * be done if one dedicated HV measurement is used to monitor the
318  * voltage directly after the fuse. Then a voltage difference between
319  * V_bat and V_fuse indicates a tripped fuse.
320  *
321  * V_bat +------+ V_fuse Precharge/Main+ contactor
322  * -----+---| FUSE |-----+------------/ -----------------
323  * +------+
324  */
325 #define BS_CHECK_FUSE_PLACED_IN_NORMAL_PATH (true)
326 
327 /**
328  * @brief TODO
329  * @details Set to true if fuse in CHARGE path should be checked. This can only
330  * be done if one dedicated HV measurement is used to monitor
331  * voltage directly after the fuse. Then a voltage difference between
332  * V_bat and V_fuse indicates a tripped fuse.
333  *
334  * V_bat +------+ V_fuse Precharge/Charge+ contactor
335  * -----+---| FUSE |-----+------------/ -----------------
336  * +------+
337  */
338 #define BS_CHECK_FUSE_PLACED_IN_CHARGE_PATH (false)
339 
340 /*========== Extern Constant and Variable Declarations ======================*/
341 /** Precharge presence of not for each string */
343 
344 /*========== Extern Function Prototypes =====================================*/
345 
346 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
347 
348 #endif /* FOXBMS__BATTERY_SYSTEM_CFG_H_ */
BS_STRING_ID
BS_STRING_ID
Definition: battery_system_cfg.h:78
general.h
TODO.
BS_STRING1
@ BS_STRING1
Definition: battery_system_cfg.h:80
BS_STRING_WITH_PRECHARGE
@ BS_STRING_WITH_PRECHARGE
Definition: battery_system_cfg.h:69
BS_STRING_PRECHARGE_PRESENT_e
enum BS_STRING_PRECHARGE_PRESENT BS_STRING_PRECHARGE_PRESENT_e
BS_STRING2
@ BS_STRING2
Definition: battery_system_cfg.h:81
BS_STRING_MAX
@ BS_STRING_MAX
Definition: battery_system_cfg.h:82
BS_STRING_PRECHARGE_PRESENT
BS_STRING_PRECHARGE_PRESENT
Definition: battery_system_cfg.h:68
bs_stringsWithPrecharge
BS_STRING_PRECHARGE_PRESENT_e bs_stringsWithPrecharge[BS_NR_OF_STRINGS]
Definition: battery_system_cfg.c:64
BS_STRING_WITHOUT_PRECHARGE
@ BS_STRING_WITHOUT_PRECHARGE
Definition: battery_system_cfg.h:70
BS_STRING0
@ BS_STRING0
Definition: battery_system_cfg.h:79
BS_STRING_ID_e
enum BS_STRING_ID BS_STRING_ID_e
BS_NR_OF_STRINGS
#define BS_NR_OF_STRINGS
Definition: battery_system_cfg.h:89