5. Important Switches in Code¶
5.1. System Relevant Switches¶
three important switches are defined.
#define CURRENT_SENSOR_PRESENT TRUE
is by default set to
TRUE. In this configuration, the
will go into an error state during startup if no current sensor is detected.
The switch must be set to
FALSE for foxBMS to start without current
#define CHECK_CAN_TIMING TRUE
is set to
TRUE by default. In this configuration, the
will go into an error state if no requests are made periodically per CAN with
a period of 100ms. When the switch is set to
FALSE, the check is not made.
#define BALANCING_DEFAULT_INACTIVE TRUE
is set to
TRUE by default. This prevents any balancing. In order for
balancing to be possiblem the switch must be set to
5.2. Battery Cell Relevant Switches¶
Safe Operating Area for the cells is defined:
- Upper and lower voltage
- Upper and lower temperature for charging
- Upper and lower temperature for discharging
- Upper current for charging and discharging
The battery cell capacity is also defined with
#define BC_CAPACITY 3500
The unit is mAh.
5.3. Deactivating Cell Tests¶
embedded-software\mcu-primary\src\engine\config\diag_cfc.c, the structure
allows disabling the checks made by the
diag module. Disabling is made by replacing
Important checks are:
Setting the cell limits is safety relevant and must be done with care.
Working without configuring the right battery cell voltage limits is dangerous and should never be done when real batteries are connected, since they may burn and explode when overcharged or shorted.
5.4. Using Current Counter from Current Sensor¶
Current-counting can now be made using the current sensor. foxBMS will detect automatically if the corresponding data is being sent by the current sensor. If yes, the hardware current-counter from the sensor is used. If not, the software integrator is used.
5.5. Defining the Convention for the Current Direction¶
Two functions have been defined in
embedded-software\mcu-primary\src\general\config\batterycell_cfg.h to test
the current direction conveniently.
The first one
gets the current from the database and returns
BS_CURRENT_DISCHARGE if a
discharge current is flowing throug the battery,
The second one
functions the same way. The only difference is that is does not get the current value from the database but uses the value passed to the function.
POSITIVE_DISCHARGE_CURRENT is used to define the current
- if set to
TRUE, discharge currents are positive
- if set to
FALSE, charge currents are positive
This define affect the calculation in the
SOX module too.
5.6. Complete List of Switches¶
A complete list of switches can be found here:
The online version of the latest released version is found here:
This documentation always points to the latest realsed version on Github and the local changes can not be found in that online version.
If the project was compiled locally, this documentation can be accesed here:
This only exists after building the documentation locally. If this was not done, the link will not work.