foxBMS - Unit Tests  1.3.0
The foxBMS Unit Tests API Documentation
battery_system_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 battery_system_cfg.h
44  * @author foxBMS Team
45  * @date 2019-12-10 (date of creation)
46  * @updated 2022-05-30 (date of last update)
47  * @version v1.3.0
48  * @ingroup BATTERY_SYSTEM_CONFIGURATION
49  * @prefix BS
50  *
51  * @brief Configuration of the battery system (e.g., number of battery
52  * modules, battery cells, temperature sensors)
53  *
54  * @details This files contains basic macros of the battery system in order to
55  * derive needed inputs in other parts of the software. These macros
56  * are all depended on the hardware.
57  *
58  */
59 
60 #ifndef FOXBMS__BATTERY_SYSTEM_CFG_H_
61 #define FOXBMS__BATTERY_SYSTEM_CFG_H_
62 
63 /*========== Includes =======================================================*/
64 #include "general.h"
65 
66 /*========== Macros and Definitions =========================================*/
67 
68 /** Symbolic identifiers for strings with precharge */
69 typedef enum {
73 
74 /**
75  * Symbolic identifiers for strings.
76  * Currently unused.
77  * Added for future compatibility.
78  */
79 typedef enum {
80  BS_STRING0 = 0u,
81  BS_STRING1 = 1u,
82  BS_STRING2 = 2u,
85 
86 /** Define if discharge current is seen as positive or negative */
87 #define POSITIVE_DISCHARGE_CURRENT (true)
88 
89 /** */
90 /**
91  * @ingroup CONFIG_BATTERYSYSTEM
92  * @brief Number of parallel strings in the battery pack
93  * @details For details see
94  * <a href="../../../../introduction/naming-conventions.html" target="_blank">Naming Conventions</a>.
95  * Implementation detail: The number of parallel strings cannot exceed
96  * #REPEAT_MAXIMUM_REPETITIONS unless the implementation of the
97  * repetition macro is adapted.
98  * @ptype uint
99  */
100 #define BS_NR_OF_STRINGS (1u)
101 
102 /* safety check: due to implementation BS_NR_OF_STRINGS may not be larger than REPEAT_MAXIMUM_REPETITIONS */
103 #if (BS_NR_OF_STRINGS > REPEAT_MAXIMUM_REPETITIONS)
104 #error "Too large number of strings, please check implementation of REPEAT_U()."
105 #endif
106 
107 /**
108  * @ingroup CONFIG_BATTERYSYSTEM
109  * @brief number of modules in a string
110  * @details For details see
111  * <a href="../../../../introduction/naming-conventions.html" target="_blank">Naming Conventions</a>.
112  * @ptype uint
113  */
114 #define BS_NR_OF_MODULES_PER_STRING (1u)
115 
116 /**
117  * @ingroup CONFIG_BATTERYSYSTEM
118  * @brief number of cells per module
119  * @details number of cells per module, where parallel cells are
120  * counted as one cell block.
121  * For details see
122  * <a href="../../../../introduction/naming-conventions.html" target="_blank">Naming Conventions</a>.
123  * @ptype uint
124  */
125 #define BS_NR_OF_CELL_BLOCKS_PER_MODULE (18u)
126 
127 /**
128  * @ingroup CONFIG_BATTERYSYSTEM
129  * @brief number of battery cells in a parallel cell connection per battery
130  * module
131  * @details For details see
132  * <a href="../../../../introduction/naming-conventions.html" target="_blank">Naming Conventions</a>.
133  * @ptype uint
134  */
135 #define BS_NR_OF_PARALLEL_CELLS_PER_MODULE (1u)
136 
137 #if BS_NR_OF_CELL_BLOCKS_PER_MODULE <= 12u
138 #define BS_MAX_SUPPORTED_CELLS (12u)
139 #elif BS_NR_OF_CELL_BLOCKS_PER_MODULE <= 15u
140 #define BS_MAX_SUPPORTED_CELLS (15u)
141 #elif BS_NR_OF_CELL_BLOCKS_PER_MODULE <= 16u
142 #define BS_MAX_SUPPORTED_CELLS (16u)
143 #elif BS_NR_OF_CELL_BLOCKS_PER_MODULE <= 18u
144 #define BS_MAX_SUPPORTED_CELLS (18u)
145 #elif BS_NR_OF_CELL_BLOCKS_PER_MODULE == 36u
146 #define BS_MAX_SUPPORTED_CELLS (36u)
147 #else
148 #error "Unsupported number of cells per module, higher than 18 and not 36"
149 #endif
150 
151 /**
152  * @def BS_MAX_SUPPORTED_CELLS
153  * @brief Defines the maximal number of supported cells per module
154  */
155 
156 /** Value of the balancing resistors on the slave-board */
157 #define BS_BALANCING_RESISTANCE_ohm (100.0)
158 
159 /**
160  * @def BS_NR_OF_GPIOS_PER_MODULE
161  * @brief Number of GPIOs on the LTC IC
162  * @details - 5 for 12 cell version
163  * - 9 for 18 cell version
164  */
165 #if BS_MAX_SUPPORTED_CELLS == 12u
166 #define BS_NR_OF_GPIOS_PER_MODULE (5u)
167 #else
168 #define BS_NR_OF_GPIOS_PER_MODULE (9u)
169 #endif
170 
171 /**
172  * @ingroup CONFIG_BATTERYSYSTEM
173  * @brief number of temperature sensors per battery module
174  * @ptype int
175  */
176 #define BS_NR_OF_TEMP_SENSORS_PER_MODULE (8u)
177 
178 /** number of battery cells in the system */
179 #define BS_NR_OF_CELL_BLOCKS_PER_STRING (BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_CELL_BLOCKS_PER_MODULE)
180 /** number of temperature sensors in a string */
181 #define BS_NR_OF_TEMP_SENSORS_PER_STRING (BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_TEMP_SENSORS_PER_MODULE)
182 /** number of temperature sensors in the battery system */
183 #define BS_NR_OF_TEMP_SENSORS (BS_NR_OF_TEMP_SENSORS_PER_STRING * BS_NR_OF_STRINGS)
184 
185 /** number of temperature sensors on each ADC0 channel of the slave-board */
186 #define BS_NR_OF_TEMP_SENSORS_ON_SADC0 (3u)
187 /** number of temperature sensors on each ADC1 channel of the slave-board */
188 #define BS_NR_OF_TEMP_SENSORS_ON_SADC1 (3u)
189 
190 /**
191  * @details - If set to false, foxBMS does not check for the presence of a
192  * current sensor.
193  * - If set to true, foxBMS checks for the presence of a current
194  * sensor. If sensor stops responding during runtime, an error is
195  * raised.
196  */
197 #define CURRENT_SENSOR_PRESENT (false)
198 
199 #if CURRENT_SENSOR_PRESENT == true
200 /**
201  * defines if the Isabellenhuette current sensor is used in cyclic or triggered mode
202  */
203 #define CURRENT_SENSOR_ISABELLENHUETTE_CYCLIC
204 /* #define CURRENT_SENSOR_ISABELLENHUETTE_TRIGGERED */
205 
206 /** Delay in ms after which it is considered the current measurement is not responding anymore. */
207 #define BS_CURRENT_MEASUREMENT_RESPONSE_TIMEOUT_MS (200u)
208 
209 /** Delay in ms after which it is considered the coulomb counting is not responding anymore. */
210 #define BS_COULOMB_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS (2000u)
211 
212 /** Delay in ms after which it is considered the energy counting is not responding anymore. */
213 #define BS_ENERGY_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS (2000u)
214 
215 #endif /* CURRENT_SENSOR_PRESENT == true */
216 
217 /**
218  * @brief Maximum string current limit in mA that is used in the SOA module
219  * to check for string overcurrent
220 * @details When maximum safety limit (MSL) is violated, error state is
221  * requested and contactors will open.
222  */
223 #define BS_MAXIMUM_STRING_CURRENT_mA (10000u)
224 
225 /**
226  * @brief Maximum pack current limit in mA that is used in the SOA module
227  * to check for pack overcurrent
228  * @details When maximum safety limit (MSL) is violated, error state is
229  * requested and contactors will open.
230  */
231 #define BS_MAXIMUM_PACK_CURRENT_mA (10000u * BS_NR_OF_STRINGS)
232 
233 /**
234  * @ingroup CONFIG_BATTERYSYSTEM
235  * @brief Define if interlock feedback should be discarded or not
236  * @details True: interlock feedback will be discarded
237  * False: interlock feedback will evaluated
238  */
239 #define BS_IGNORE_INTERLOCK_FEEDBACK (false)
240 
241 /**
242  * @details - If set to false, foxBMS does not check CAN timing.
243  * - If set to true, foxBMS checks CAN timing. A valid request must
244  * come every 100ms, within the 95-150ms window.
245  */
246 #define CHECK_CAN_TIMING (true)
247 
248 /**
249  * @details - If set to true, balancing is deactivated completely.
250  * - If set to false, foxBMS checks when balancing must be done and
251  * activates it accordingly.
252  */
253 #define BALANCING_DEFAULT_INACTIVE (true)
254 
255 /**
256  * @ingroup CONFIG_BATTERYSYSTEM
257  * @brief Checking if current is in SOF limits of cells.
258  * @details If set to true the current is checked against the SOF limits.
259  * If set to false the current is checked against the constant values
260  * for charging and discharging:
261  * - #BC_CURRENT_MAX_DISCHARGE_MSL_mA
262  * - #BC_CURRENT_MAX_DISCHARGE_RSL_mA
263  * - #BC_CURRENT_MAX_DISCHARGE_MOL_mA
264  *
265  * - #BC_CURRENT_MAX_CHARGE_MSL_mA
266  * - #BC_CURRENT_MAX_CHARGE_RSL_mA
267  * - #BC_CURRENT_MAX_CHARGE_MOL_mA
268  * @ptype bool
269  */
270 #define BMS_CHECK_SOF_CURRENT_LIMITS (true)
271 
272 /**
273  * @ingroup CONFIG_BATTERYSYSTEM
274  * @brief Defines behaviour if an insulation error is detected
275  * @details - If set to true: contactors will be opened
276  * - If set to false: contactors will NOT be opened
277  */
278 #define BMS_OPEN_CONTACTORS_ON_INSULATION_ERROR (false)
279 
280 /**
281  * @ingroup CONFIG_BATTERYSYSTEM
282  * @brief number of high voltage inputs measured by current sensors (like
283  * IVT-MOD)
284  * @ptype int
285  */
286 #define BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR (3u)
287 
288 /**
289  * @ingroup CONFIG_BATTERYSYSTEM
290  * @brief number of voltages measured by MCU internal ADC
291  * @ptype int
292  */
293 #define BS_NR_OF_VOLTAGES_FROM_MCU_ADC (2)
294 
295 /** Number of contactors in addition to string contactors (e.g., PRECHARGE).*/
296 #define BS_NR_OF_CONTACTORS_OUTSIDE_STRINGS (1U)
297 
298 /** Number of contactors. One per string + main and precharge */
299 #define BS_NR_OF_CONTACTORS ((2U * BS_NR_OF_STRINGS) + BS_NR_OF_CONTACTORS_OUTSIDE_STRINGS)
300 
301 /**
302  * @brief current threshold for determing rest state of battery. If absolute
303  * current is below this limit value the battery is resting.
304  */
305 #define BS_REST_CURRENT_mA (200)
306 
307 /**
308  * @brief Wait time in 10ms before battery system is at rest. Balancing for
309  * example only starts if battery system is at rest.
310  */
311 #define BS_RELAXATION_PERIOD_10ms (60000u)
312 
313 /**
314  * @brief current sensor threshold for 0 current in mA as the sensor has a
315  * jitter.
316  */
317 #define BS_CS_THRESHOLD_NO_CURRENT_mA (200u)
318 
319 /**
320  * @brief Maximum voltage drop over fuse.
321  * @details If the measured voltage difference between battery voltage
322  * voltage after fuse is larger than this value. It can be concluded,
323  * that the fuse has tripped. The voltage difference can be estimated
324  * by the maximum current and the resistance.
325  * For a Cooper Bussmann 1000A fuse the voltage drop can be estimated
326  * to: I_max = 1000A and P_loss = 206W
327  * -> voltage drop at 1000A roughly 206mV
328  * -> select 500mV because of measurement inaccuracies
329  */
330 #define BS_MAX_VOLTAGE_DROP_OVER_FUSE_mV (500)
331 
332 /**
333  * @brief TODO
334  * @details Set to true if fuse in NORMAL path should be checked. This can only
335  * be done if one dedicated HV measurement is used to monitor the
336  * voltage directly after the fuse. Then a voltage difference between
337  * V_bat and V_fuse indicates a tripped fuse.
338  *
339  * V_bat +------+ V_fuse Precharge/Main+ contactor
340  * -----+---| FUSE |-----+------------/ -----------------
341  * +------+
342  */
343 #define BS_CHECK_FUSE_PLACED_IN_NORMAL_PATH (true)
344 
345 /**
346  * @brief TODO
347  * @details Set to true if fuse in CHARGE path should be checked. This can only
348  * be done if one dedicated HV measurement is used to monitor
349  * voltage directly after the fuse. Then a voltage difference between
350  * V_bat and V_fuse indicates a tripped fuse.
351  *
352  * V_bat +------+ V_fuse Precharge/Charge+ contactor
353  * -----+---| FUSE |-----+------------/ -----------------
354  * +------+
355  */
356 #define BS_CHECK_FUSE_PLACED_IN_CHARGE_PATH (false)
357 
358 /**
359  * \defgroup open wire check configuration
360  * @details If open-wire check is performed, depending on the AFE
361  * implementation, cell voltages and temperatures are not updated
362  * and thus old values can be transmitted on the CAN bus. Check
363  * time is dependent on module configuration and external
364  * capacitance. Activate open-wire check with care! See the AFE
365  * implementation for details.
366  * @{
367  */
368 /** enable open-wire checks during standby */
369 #define BS_STANDBY_PERIODIC_OPEN_WIRE_CHECK (false)
370 
371 /** Periodic open-wire check time in STANDBY state in ms */
372 #define BS_STANDBY_OPEN_WIRE_PERIOD_ms (600000)
373 
374 /** open-wire check in normal mode (set to true or false) */
375 #define BS_NORMAL_PERIODIC_OPEN_WIRE_CHECK (false)
376 
377 /** Periodic open-wire check time in NORMAL state in ms */
378 #define BS_NORMAL_OPEN_WIRE_PERIOD_ms (600000)
379 
380 /** open-wire check in charge mode (set to true or false) */
381 #define BS_CHARGE_PERIODIC_OPEN_WIRE_CHECK (false)
382 
383 /** Periodic open-wire check time in CHARGE state in ms */
384 #define BS_CHARGE_OPEN_WIRE_PERIOD_ms (600000)
385 
386 /** Periodic open-wire check time in ERROR state in ms */
387 #define BS_ERROR_OPEN_WIRE_PERIOD_ms (30000)
388 /**@}*/
389 
390 /*========== Extern Constant and Variable Declarations ======================*/
391 /** Precharge presence of not for each string */
393 
394 /*========== Extern Function Prototypes =====================================*/
395 
396 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
397 
398 #endif /* FOXBMS__BATTERY_SYSTEM_CFG_H_ */
BS_STRING_PRECHARGE_PRESENT_e bs_stringsWithPrecharge[BS_NR_OF_STRINGS]
#define BS_NR_OF_STRINGS
Number of parallel strings in the battery pack.
BS_STRING_PRECHARGE_PRESENT_e
@ BS_STRING_WITHOUT_PRECHARGE
@ BS_STRING_WITH_PRECHARGE
BS_STRING_ID_e
@ BS_STRING2
@ BS_STRING1
@ BS_STRING0
@ BS_STRING_MAX
General macros and definitions for the whole platform.