Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
The board is organized as shown in the figures below:
The RDDRONE-BMS772 may have test software or no software installed from the factory.
Review this manual to understand what is the latest software and how to update it. There may be more than one option:
PX4/NuttX target
NuttX target
S32K design studio project
Updated as we gain insight into specific applications
As we learn of specific needs for specific use cases they will be noted here:
PX4 BMS specification and working group discusses the potential requirement to provide 5V power to a vehicle before activating the actual battery power supply main outputs. The intent is to allow something on the host to identify the battery characteristics in advance in order to avoid a catastrophic voltage mismatch.
Conceptually there is a need to supply 5V through the CAN /SBUS connectors to allow a host-side processor to power up and query the smart battery (BMS) for compatibility with the drone. (i.e. do not power up a 12S battery on a drone that only is designed for 3S or 4S)
This functionality can be tested with the current revision of the board given a few jumper wires to the CAN/SBUS connectors. As built the +5V power is NC
The 5V supply from the SmartBattery/BMS likely only needs to provide limited current in order to power a small MCU on the host side and not the complete host-side FMU. The small MCU could do the BMS query and then choose to power up the battery if in compliance.
It needs to be determined how does BMS sleep mode or deep sleep mode should work with this operation.
There are other preventative configurations being discussed such as mechanically preventing incompatible battery packs being inserted, and also using host side configuration resistor to signal to the battery what power/voltage the host expects. These may be discussed on the PX4 working group for BMS.
The BMS772 evaluation design includes one RGB led which is intended to flash sequences and colors to show battery status. It has been noted however that some implementations may wish to use 4 LEDS for visual battery gauge status.
Extra LEDs can be accommodated by using the expansion header
Alternative option: I2C bus can be also be used to add an local OLED display.
The BMS772 itself doesn't regulate charging current or voltage, and needs a simple CC/CV charger. It can however balance it's own cells and disconnect the load. This situation could be improved by making a charger that talks with the battery over CAN and helps properly manage current and voltage, or even additional circuitry on board to manage this.
Rev C of RDDRONE-BMS772 inadvertently does not connect the 5V power from one CAN Connector to the next - Between J3 and J20. If needed a jumper wire can be added between J3-Pin 1 and J20Pin-1. This is corrected on Rev D of the board.
Lithium and other batteries are dangerous and must be treated with care.
Lithium and other batteries are dangerous and must be treated with care.
Rechargeable Lithium Ion batteries are potentially hazardous and can present a serious FIRE HAZARD if damaged, defective or improperly used. Larger Lithium batteries and those used for industrial use involving high discharge current and frequent full discharge cycles require special precautions. Do not connect this BMS to a lithium ion battery without expertise and training in handling and use of batteries of this type.
Use appropriate test equipment and safety protocols during development.
NXP has battery emulators that may be used during testing: https://www.nxp.com/design/development-boards/analog-toolbox/6-cell-battery-pack-to-supply-mc33772-evbs:BATT-6EMULATOR
NXP provides the enclosed product(s) under the following conditions:
This reference design is intended for use of ENGINEERING DEVELOPMENT OR EVALUATION PURPOSES ONLY. It is provided as a sample IC pre-soldered to a printed circuit board to make it easier to access inputs, outputs, and supply terminals. This reference design may be used with any development system or other source of I/O signals by simply connecting it to the host MCU or computer board via off-the-shelf cables. Final device in an application will be heavily dependent on proper printed circuit board layout and heat sinking design as well as attention to supply filtering, transient suppression, and I/O signal quality.
The goods provided may not be complete in terms of required design, marketing, and or manufacturing related protective considerations, including product safety measures typically found in the end product incorporating the goods.
Due to the open construction of the product, it is the user's responsibility to take any and all appropriate precautions with regard to electrostatic discharge. In order to minimize risks associated with the customers applications, adequate design and operating safeguards must be provided by the customer to minimize inherent or procedural hazards. For any safety concerns, contact NXP sales and technical support services. Should this reference design not meet the specifications indicated in the kit, it may be returned within 30 days from the date of delivery and will be replaced by a new kit.
NXP reserves the right to make changes without further notice to any products herein. NXP makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does NXP assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages.
Typical parameters can and do vary in different applications and actual performance may vary over time. All operating parameters, including Typical, must be validated for each customer application by customer’s technical experts.
NXP does not convey any license under its patent rights nor the rights of others. NXP products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the NXP product could create a situation where personal injury or death may occur. Should the Buyer purchase or use NXP products for any such unintended or unauthorized application, the Buyer shall indemnify and hold NXP and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges NXP was negligent regarding the design or manufacture of the part.
The RDDRONE-BMS772 is a standalone BMS Reference Design suitable for mobile robotics such as drones and rovers, supporting 3-6 cell batteries. Other portable electronics and equipment, such as scooters, power tools, portable medical devices could also benefit from referencing this design. If higher cell counts are required this could be redesigned to daisy chain multiple BCC chips or switch to a larger cell count BCC.
The device performs ADC conversion on the differential cell voltages and currents. It is capable of very accurate battery charge coulomb counting and battery temperature measurements. Additionally, it communicates with a Flight Management Unit (FMU) through UAVCAN and/or an SMBus.
RDDRONE-BMS772 for Mobile Robotics
The RDDRONE-BMS772 is a standalone BMS Reference Design suitable for mobile robotics such as drones and rovers, supporting 3-6 cell batteries.
Other uses include portable electronics and equipment needing better battery management
eScooters, ebikes
high end power tools
portable medical devices (Pulse oximeter, portable pumps, electric portable refrigerator)
backup battery system
outdoor monitoring/measuring equipment
It is an open hardware and software design and useful leverages components used in general purpose automotive and high-reliability industrial applications. The BCC device performs ADC conversion on the differential cell voltages and currents. It is capable of very accurate battery charge coulomb counting and battery temperature measurements.
Finally, the BMS communicates with a host such as a Drone Flight Management Unit (FMU) through UAVCAN or I2C/SMBus.
The NXP is a 6 cell BCC. If higher cell counts are required this could be redesigned to daisy chain multiple BCC chips or switch to a larger cell count BCC such as the . These parts are all automotive grade Li-Ion battery cell controller IC designed for automotive and industrial applications such as HEV, EV, ESS, UPS systems
The BMS772 also features an . These are rugged M4 core processors part of a scalable family of AEC-Q100 qualified 32-bit Arm® Cortex®-M4F and Cortex-M0+ based MCUs
An NFC Forum-compliant I2C bridge is also onboard and appears as an NFC contactless tag to the external world, and interfaces internally in a simple manner similar to an EEPROM for easy secure query of status or setting of parameters using an external NFC device such as a cell phone. In a practical sense this allows an end user to check multitudes of batteries that may be in storage just by hovering their cell phone over them.
An A1007 is an enhanced version of secure authenticator IC which includes monotonic counters and secure flags. These can be used to prove the battery pack is genuine and has not been tampered with as well as securely count charge cycles, and permanently flag negative events such as over discharge. The Secure Authenticator IC is a secure tamper-resistant authentication IC, which offers a strong cryptographic solution intended to be used by device manufacturers to prove the authenticity of their genuine products
This work is licensed under a .
The RDDRONE-BMS772 integrates the following functions and features:
LiPo Battery from 3s to 6s, with stack voltage ranging from 6V to 26V
ambient temperature range from -20°C to 60°C
measures battery stack and cell voltages with an accuracy of +/-5mV, battery charge or discharge current up to 200A peak and 90A* DC with an accuracy of 1% for the complete chain and cell temperature with an accuracy of +/- 2°C (including AFE, PCB and NTC inaccuracies)
active cell balancing during charging
offers a deep sleep mode (for transportation and storage) with <80μA leakage current, as well as an automatic sleep mode with <200μA current consumption on the battery.
allows authentication of the battery
allows diagnostics to verify the safe operation of the battery
allows CAN, I²C and NFC communication
implements SWD and JTAG debugging interfaces, works with standard Segger J-Link and other debuggers
implements DCD-LZ combined debug and uart console interface for use with PX4 DroneCode and HoverGames platforms
Note: The 90A DC maximum current is obtained only when all MOSFETs and heatsinks are mounted. See Power MOSFETs and heatsinks.
These boards have been designed and optimized for the operating conditions described below. Usage of these boards beyond these conditions can lead to malfunction and damage.
[1] These values are valid for a 4 pairs of power MOSFETs and 4 heatsinks configuration. See Configuring the hardware for more information
Description
Min
Max
Unit
Battery input voltage
6
26
V
Battery charge/discharge current at 25 °C (DC) [1]
-
90
A
Battery charge/discharge current at 25 °C (peak) [1]
-
200
A
Operating ambient temperature
-20
60
°C
The RDDRONE-BMS772 kit includes:
Assembled and tested reference design in anti-static bag
Unmounted cell balancing connectors for 3s, 4s and 6s
To use this BMS772 kit, you will need:
LiPo battery pack
3S to 6S with cell balancing connector - Voltage range of 6V to 26V
Suitable charger for the type of battery
Soldering iron to configure the board
External Thermistor temperature sensor with cable and JST-GH 2-pin connector (optional)
Debugger:
Segger J-Link Mini debugger
PEMicro universal multilink
or other suitable JTAG/SWD debugger
Note: The HoverGames Drone Kit (KIT-HGDRONEK66) and/or FMU Kit (RDDRONE-FMUK66) both include a DCD-LZ adapter and Segger J-Link Mini EDU and an FTDI USBUART-3v3 cable.
By using the DCD-LZ interface and USBUART cable you will also gain access to the command line interface (CLI) of the board.
S32 Design Studio for ARM-based MCUs (recommended)
Alternatively : PX4 or NuttX build environment depending on what code source is used.
PX4/NuttX board target example code (optional, see Software guide)
Note: The RDDRONE-BMS772 board allows to open the charge circuit when the battery is overcharging , to perform cell balancing and to monitor all cell voltages. Therefore the charger does not need to have a cell terminal connector.
Because the RDDRONE-BMS772 board aims to be adaptable for many different battery types, the power connectors are not mounted on the PCB. This allows the user to configure the board with the connectors they choose, or solder battery wires directly to the board.
In a completed application, it is expected that the battery and BMS would be permanently attached. During development it can be prudent to allow disconnection of the battery for safety reasons.
The power connectors footprints on the design correspond to an XT90 hobby type connector such as the DFRobot FIT0588 connector. These types of connectors are readily available at local and online hobby shops and may also be used for soldering typical silicone insulation heavy gauge power wires.
TE connectivity has created a line of UMP (Unmanned Power) connectors specifically for professional high power mobile systems. Some kits ship with this type of connector included as a promotional item.
TE connectivity provides a line "UMP" connectors specifically for professional high power mobile systems.
The RDDRONE-BMS772 board is configurable to fit 3s to 6s battery packs.
Solder jumpers must be soldered in place and the matching JP1 connector must be installed on the board to match your battery cell configuration. Do not operate the board without the correct configuration.
This configuration must be done before using the board
The correct cell terminal connector should be soldered as JP1 on the top side. Connectors for 3s, 4s, and 6s are provided unsoldered in the kit.
the connection to the cell terminal circuit should be done by soldering the correct solder jumpers as given in the table below. All jumpers are open by default
Note: SJ13, SJ14, SJ15 and SJ16 are not used for cell terminal connection. See Shunt resistor and External NFC antenna.
Note: The other jumpers used for cell terminal connection (SJ1 - SJ12) should be open!
Note: The JP1 connector should be soldered on the top side of the board.
The shunt resistor (R1) can be disconnected from the overcurrent protection circuit and the BCC by unsoldering the SJ13 and SJ14 jumpers. Both jumpers are closed by default.
The on-board NTAG5 chip is designed to provide active antenna matching and amplification and will give enhanced performance when the battery is present and providing power. However, for extended range operation, the PCB antenna can be replaced by an SMD coil (L2). The coil is not mounted by default but the recommended part is SDR7045-2R2M. Also note that it is possible to solder wires and attach a remote NFC antenna to the same pads used for L2.
To use the SMD coil, the user must reconfigure the board using the following steps:
remove both 0.75 Ω resistors R93 and R94
solder close SJ15 and SJ16
replace 82pF and 680pF capacitors C72 and C116 by a single 56pF capacitor
The RDDRONE-BMS772 board allows placement of four pairs of power MOSFETs (PSMNR70-30YLH) and four heatsinks (FK 244 08 D2 PAK). Half of them is on the top side of the board and the other half is on the bottom side. By default, only the two pairs of MOSFETs of the top side are mounted.
The user may want to place additional MOSFETs and/or optional heatsinks to their board. This allows to widen the maximum DC current limit as described in the following table:
Note: Exceeding the given current limit can permanently damage the board.
Depending on the application, the user may want to add some optional components onto the RDDRONE-BMS772 board.
External and additional components and their use are detailed in External and additional components.
The board features several NXP ICs:
MC33772: 6-Channel Li-Ion battery cell controller IC designed for automotive and industrial applications such as HEV, EV, ESS, UPS systems. The MC33772 allows ADC conversions on the differential cell voltages and currents as well as coulomb counting and temperature measurements. It features embedded balancing transistors and diagnostics to simplify applications. The device supports standard SPI and transformer isolated daisy chain communication (via MC33664) to an MCU for processing and control
S32K144: AEC-Q100 certified microcontroller for general purpose automotive applications. The S32K144 features an Arm® Cortex®- M4F core, 512 KB of Flash, CAN/CAN-FD controllers, security module complying with SHE specification and is offered in LQFP-48, LQFP-64, LQFP-100 and MAPBGA-100 packages supporting an ambient temperature range from -40°C up to 125°C
UJA1169: Mini high-speed CAN System Basis Chip (SBC) containing an ISO 11898-2:201x (upcoming merged ISO 11898-2/5/6) compliant HS-CAN transceiver and an integrated 5V or 3.3V 250 mA scalable supply (V1) for a microcontroller and/ or other loads. It also features a watchdog and a Serial Peripheral Interface (SPI). The UJA1169 can be operated in very low-current Standby and Sleep modes with bus and local wake-up capability
A1007: A1007 authentication IC is a secure solution built with many tamper resistant features and security countermeasures to deter common invasive and non-invasive attacks
NTAG5: NXP’s NTAG 5 boost shrinks the NFC footprint while adding AES security, so designers can deliver ultra-compact devices for use in IoT, consumer, and industrial applications
The main ICs featured are listed in the table below:
The following figure shows the location of the connectors on the board.
All connectors implemented on RDDRONE-BMS772 are detailed in the table below:
The RDDRONE-BMS772 board can communicate with a host device such as a PX4 Flight controller (FMU) using the SMBus bus (can also be used as a simple I²C bus, connector J18) or the UAVCAN bus (can also be used as a simple CAN bus, connectors J3 and J20).
Note: For further information about UAVCAN, look for enablement in PX4.io software.
There are two ways to program and debug the RDDRONE-BMS772 board:
through the DCD-LZ connector (J19)
through the JTAG connector (J2)
The RDDRONE-BMS772 implements a programmable RGB LED. Various color combination and blink patterns can be used to indicate the state of the battery and system.
The side button is a wake button, it connects the WAKE pin of the SBC to the ground when pressed. The J22 header placed in parallel of the side button can be used as an alternative if an extended or panel mount button is needed.
An optional external temperature sensor can be added onto the RDDRONE-BMS772 board using connector J1. An example of application for this external sensor can be to monitor the cells temperature inside the battery pack.
Some components are included in the design but are not mounted on the RDDRONEBMS772 original board. They are marked "DNP" on the schematics and the BOM. The following table is giving the list of additional components that can be implemented in the design as well as their use:
The following figure shows the location of the test points on the board.
Before first start-up, make sure the board is configured properly:
The board MUST be configured, connectors and solder jumpers need to be soldered and installed to match your exact battery cell count
Solder your power in and power out connectors or wires on the J4 and J5 footprints
Solder the correct cell terminal connector at the JP1 location. Ensure it is correctly positioned and aligned
Configure the board for your application by soldering the corresponding SJxx connectors
Configure the board with additional and/or optional components as described in to fit the application requirements
Once the board is configured properly (see for more details about configuration), it is time to connect the board.
To power on the RDDRONE-BMS772 board, *first* connect the battery to the power input connector (J4) and then the cell terminal connector (JP1). This protects the boards form internal damage due to hot plugging.
Similarly, to disconnect the battery from the board, the cell terminal connector (JP1) should be disconnected first. Then the power input (J4) can be disconnected.
This page will provide all the information needed to flash the BMS
J-Link Commander is used to flash binaries onto the RDDRONE-BMS772 board. The latest (stable) release of the J-Link Software and Documentation Pack is available at the SEGGER website for different operating systems.
The software can only be written to the board using a debugger. The HoverGames drone kit includes a J-Link EDU Mini debugger. To use it, you need to install the J-Link Software Pack.
The debugger can be plugged into the BMS using a small adapter board. This small PCB comes with a 3D printed case that can easily be put together. The J-Link debugger can be connected using an SWD cable. The connectors have to be oriented such that the wires directly go to the side of the board, as shown in the picture below.
While you do not need it right now, the adapter board also has a 6-pin connector for a USB-TTL-3V3 cable, which you can use to access the system console (CLI) of the BMS. The 3D printed case has a small notch on one side of the connector. The USB-TTL-3V3 cable needs to be plugged in such that the black (ground) wire is on the same side as this notch in the case. Make sure the cables are plugged in as shown in the picture below. Connect the 7-pin JST GH to the programming header of the BMS, J19.
A guide for flashing firmware to this board is outlined in one of our consolidated Gitbooks for flashing a multitude of NXP hardware. The link to this Gitbook is below.
Once you're done flashing your board, you may continue to the Accessories and tools for development tutorial.
Note: Hardware configuration of the board is done via 16 jumpers to solder (SJxx). See , and for more details.
Note: The DCD-LZ combines a debug interface with a debug serial console. It is used on RDDRONE-FMUK66 (HoverGames). For more information see the
Configuration
Jumpers connected
Associated JP1 connector
JP1 placement
3s
SJ6, SJ10, SJ11 and SJ12
S4B-XH-A(LF)(SN)
Pin 4 to 7
4s
SJ3, SJ7, SJ11 and SJ12
S5B-XH-A(LF)(SN)
Pin 3 to 7
5s
SJ1, SJ4, SJ8 and SJ12
S6B-XH-A(LF)(SN)
Pin 2 to 7
6s
SJ2, SJ5 and SJ9
S7B-XH-A(LF)(SN)
Pin 1 to 7
Configuration
Maximum DC current
4 pairs of MOSFETs and 4 heatsinks
90A
2 pairs of MOSFETs and 2 heatsinks
70A
2 pairs of MOSFETs and no heatsink
60A
Label | Description | Manufacturer | Reference | Placed or DNP |
JP1 | Cell terminal connector | JST MFG. CO | SxB-XH-A(LF)(SN) | DNP |
J1 | External temperature sensor | JST MFG. CO | SM02B-GHS-TB(LF)(SN) | Populated |
J2 | JTAG debugger | - | E.g.: FTS-105-01-F-D from SAMTEC | Populated |
J3 | CAN bus | JST MFG. CO | SM04B-GHS-TB(LF)(SN) | Populated |
J4 | Battery power input | - | E.g.: FIT0588 from DFRobot | DNP |
J5 | Battery power output | - | E.g.: FIT0588 from DFRobot | DNP |
J6 | Reset jumper | FCI | 68000-202HLF | Populated with jumper mounted |
J18 | SMBus (I²C bus) | JST MFG. CO | SM04B-GHS-TB(LF)(SN) | Populated |
J19 | DCD-LZ debugger | JST MFG. CO | SM07B-GHS-TB(LF)(SN) | Populated |
J20 | Additional CAN bus | JST MFG. CO | SM04B-GHS-TB(LF)(SN) | Populated |
J21 | MCU expansion header | HARWIN INC. | M50-3530842 | DNP |
J22 | Wake jumper | FCI | 68000-202HLF | DNP |
Label | Signal name | Description |
TP1 | OVERCURRENT | Overcurrent signal |
TP2 | AUTH_NFC_SCL | Authentication and NFC I²C bus clock signal |
TP3 | AUTH_NFC_SDA | Authentication and NFC I²C bus data signal |
TP4 | VCC_3V3_SBC | SBC 3.3 V regulator output |
TP5 | RST_N | Reset signal (active low) |
TP6 | CAN_LO | CAN Low signal |
TP7 | CAN_HI | CAN High signal |
TP8 | VCC_3V3_LDO1 | LDO 3.3 V regulator output |
TP9 | SMBUS_SCL | SMBus I²C bus clock signal |
TP10 | SMBUS_SDA | SMBus I²C bus data signal |
TP11 | VBAT_IN | Power input |
TP12 | VBAT_OUT | Power output |
TP13 | GND | Ground reference of the device |
TP14 | N/A | Power switches gate command |
TP15 | N/A | Spare test point. J21[2] pin |
The software example being developed for the RDDRONE-BMS772 board will use a NuttX Real-Time Operating System (RTOS).
Note: NuttX is a real-time operating system (RTOS) with an emphasis on standards compliance and small footprint. Scalable from 8-bit to 32-bit microcontroller environments, the primary governing standards in NuttX are Posix and ANSI standards.
This page will tell you how to use the CLI of the BMS
To use the command line interface, connect the debugger to the BMS using the 7-pin JST-GH connector from the debug adapter board to J19 and plug the USB coming from the debugger converter board into your computer. Open a UART terminal like minicom on a Linux machine or PuTTY or Tera Term for a windows machine.
Type “bms help” to get the help for the CLI. The CLI works only with lowercase commands. The settings are:
115200 Baud
8 data bits
1 stop bit
Label | Description | Reference |
U1 | Battery Cell Controller (BCC) |
U2 | Micro-Controller Unit (MCU) |
U3 | System Basis Chip (SBC) |
U4 | Authentication | A1007 |
U5 | Near-Field Communication (NFC) |
Feature | Description | Label |
Additional MOSFETs | Q3, Q4, Q7, Q8 |
Heatsinks | In order to dissipate more power, four additional heat-sinks can be mounted: two on the top side and two on the bottom side of the board. Recommended part is FK 244 08 D2 PAK | HS1, HS2, HS3, HS4 |
Optional termination resistor network on CAN bus | One 60.4 Ω resistor on each CAN line connected to a 4700 pF capacitor wired to the ground | R49, R50, C66 |
Capacitors on cell measurements connections | A filter can be added to the cell voltage measurements connections, according to the number of cells in use | C6, C12, C18, C22, C26, C29, C34 |
Capacitors on external temperature sensor | If the external temperature sensor is implemented, two capacitors can be added on the external temperature sensor low pass filter for more EMC demanding applications | C49, C54 |
Capacitor on cell balancing connections | Capacitors can be added on the cell balancing circuit for EMC, according to the number of cell in use | C99, C100, C101, C102, C103, C104, C105, C106, C107 |
External NFC antenna | Coil as an alternative option for the PCB NFC antenna for extended range operations | L2 |
Resistor on gate driver RS pin | Resistor to link RS pin on gate driver to MCU | R99 |
MCU expansion header | Additional MCU pins are wired to a 1x8 header slot. Potential to use for local display or additional battery level LEDs | J21 |
Wake jumper | Jumper for SBC wake-up. In parallel of the button | J22 |
Introduction to the nuttx sofware example of the BMS
The example starter software provided with the BMS uses the NuttX RTOS (real-time operating system ) for microcontrollers. NuttX RTOS has an emphasis on being standards compliance and small footprint. Scalable from 8-bit to 32-bit microcontroller environments, the primary governing standards in NuttX are POSIX and ANSI standards. The POSIX compliance on embedded devices is what makes it attractive particularly to developers that are used to programming in a Linux environment.
The NuttX code repository can be found here: https://github.com/NXPHoverGames/RDDRONE-BMS772.
Please follow the step by step instructions in the github readme.md in order to get started with this code. We will update it and provide clarifications there as needed.
This software Guide applies for bms version 3.6-10.0.
SOFTWARE provided is for reference only and should not be considered production ready or used in an end product as-is. It is expressly for the purpose of further development, research and validation by experienced people. Overcharging, undercharging or abusing batteries is dangerous and must be monitored carefully in a safe environment.
This example software was prepared in part as an intern's senior project under the supervision of NXP engineers.
Changes relative to the last release (3.4-9.1)
The changes relative to the last release, release 3.4-9.1, can be found in the table below.
This page will describe the software block diagram of the nuttx example
Figure 1 is the BMS application consisting of several modular parts. Functions from these parts can be called from the BMS application. These parts are tasks that will run semi-parallel (since it is still a single core processor). NuttX scheduler will take care of this aspect for us.
The CLI (command line interface) module is called by running the BMS application from the nuttshell interface with arguments. An explanation of each of the blocks can be found below in the module description section. The CLI module is needed for easy debugging and user interface, while the NFC, Display, UAVCAN, SBC, Bat management and LED state modules are needed for the overall functional requirements.
The BMS application creates the main task wich implements a battery state machine. It calls the functions from the different modules to implement the overall BMS application. This application is called during startup. The application can be called from the nuttshell with various arguments to use it as a CLI.
The command line interface (CLI) module takes care of communication with the user through the NuttX nutshell, it can be used during debugging of the smart battery application or a specific battery under test. The communication is mapped to use a universal asynchronous receiver-transmitter (UART) also known as the root console. The CLI can output messages colors if the ANSI escape sequences are enabled in the terminal.
The application command may be followed by optional arguments such as sleep, deepsleep, wake, reset, help, show, set or get. With the set or get command the user can read and write every value, including the configuration parameter list. These values can be read/written by calling the BMS application followed by a set or get command followed by the name of the variable. In the case of a set command this would instead be followed by the new value of the variable. Try the command “bms help” to see the help of the CLI.
The authentication module will take care of the authentication using the A1007 chip. The A1007 is capable of secure asymmetric key exchange and storage as well as secure monotonic counters and flags for use in such things as counting charge or discharge cycles or permanently flagging under-voltage or over-temperature conditions. This module is not implemented yet. Only verification via I2C is implemented.
The NFC module manages NFC communication. It needs to read all the values and should be able to write the configuration parameter list. It should be able to read the values with a refresh rate of once a second. NFC will allow the user to insert commands like wake, reset, sleep, deepsleep, etc. The updater task will be used to update the data. The NTAG5 chip is capable of operating using energy harvested from the NFC field of a reading device. It can operate in a similar manner to a double ported EEPROM, and NFC records can include standardized messages for HTTP records. In this way the NFC tag could be updated regularly with status information. That information could be added to a URL, and a smartphone would be capable of reading the URL with data attached and rendering a human readable webpage with minimal coding effort. This method removes the need for any custom software on the reading device. This module is not implemented yet. Only verification via I2C is implemented.
The display module manages information presented on an optional local I2C LCD display. This module is not implemented yet.
The UAVCAN module manages UAVCAN communication. UAVCAN V1 protocol is used to relay battery and power usage to the FMU (or host processor). It sends the battery information on a cyclic time interval. It has a task named UAVCAN that will check if data is received and will send the data if needed. The CAN PHY is in the SBC (UJA1169).
The SBC module manages the power of the voltage regulators in the SBC. With this module the SBC can be set in normal mode, standby mode and sleep mode. In the normal mode both V1 (powers the MCU and more) and V2 (powers internal CAN PHY) are powered. In standby mode, V2 is off and in sleep mode both regulators V1 and V2 are off. The sleep mode is needed for the DEEP SLEEP state.
The Bat management (battery management) part is the most important part, it will oversee the whole battery management. It will be used to monitor the battery, the PCB (temperatures) and calculate voltages, temperatures, current, SoC, SoH, average power and more, it will ensure the BCC chip reacts if thresholds are exceeded. Function of this part can be used to drive the gate driver, which allows it to disconnect the battery from the output power connector on the BMS. Because this is such a large part of the system, the Bat management part can create some tasks. These tasks can all access the BCC, the timers and the GPIO.
meas task - this task will oversee the measurements and if triggered do the calculations.
otherCalc task - this task will make sure that once every measurement cycle, the meas task will do the calculations.
sdchar task - this task will oversee the self-discharging.
The LED state module can be used to set the RGB LED. It can set a RGB color on or off, and blink the LEDs at given intervals. If a LED needs to blink a blinker task will be created to ensure it blinks. This module is used to inform the user visually of various states and status.
This module implements the LED states given below
Since different parts need to use the same data, a data library is used to take care of this. This library will make sure it is protected against concurrent usage by multiple tasks.
This page will show the designed state machine and the description of the states from this state machine.
In Figure 2 the main state machine that will be implemented in the BMS application can be seen. This state diagram will be implemented in the BMS application. Below the state machine, in Main state machine explained, the explanation of the states can be found. These states are needed for the requirements and to make a structured way of programming possible.
The SELF TEST state is entered at power-up of the microcontroller. In this state the microcontroller initializes everything and performs the self-test, for example check if communication with a component is possible or check if the set output can be read. If everything is OK, it will go to the INIT state. The LED will be solid red in this state.
The INIT state is typically entered from the SLEEP state. In this state the microcontroller unit (MCU) will wake up and it will verify configurations, fault registers and functions. This is needed because it can enter the INIT state when the user resets from a fault in the FAULT state as well. When everything is OK, it will close the switches if not already closed and proceed to the next state depending on the current direction. The LED will be steady green in this state.
This is the state were the battery operates how it should be, it is being discharged by the drone. Meaning that the power switches are closed. The LED will be blinking green to indicate the state of charge. In this state the BMS performs the following tasks:
Battery voltage, cell voltage and current is measured and calculated every measurement cycle.
SoC and SoH are estimated every measurement cycle.
The UAVCAN BMS battery status will be send over the UAVCAN bus every measurement cycle.
The user can read the BMS status and parameters with NFC and the CLI. The user may change the state to SLEEP.
A timer will monitor if the current is below the sleep current for more than the timeout period. If this happens, it will go to the SLEEP state.
It will monitor if the current flows in the battery and if the current is more than the sleep current for more than the charge detect time, the state will change to the CHARGE state.
If the current is less than the sleep current while the button is pressed for 5 seconds, it will transition to the SELF DISCHARGE state.
During this state the same functions as in the NORMAL state are implemented as well. The charging of the battery is done in different stages and is reflected in the charging state diagram in Figure 3. These are the states and their description:
CHARGE START: in this state the charging will begin, and a timer will start. The LED will be blue to indicate charging. After a set time (default two minutes) or if the voltage of one of the cells reaches the cell overvoltage level (to make sure there is no cell overvoltage error) the state will change to CHARGE WITH CB.
CHARGE WITH CB: in this state the cell balancing (CB) function will be activated. This function will calculate the cell balance minutes per cell, which is based on the cell voltages, the difference compared to the lowest cell voltage, the balance resistor and the ocv-slope. The formula to calculate this balance time is: Balance minutes = (Vcell- Vcell_min)Rbal/(Vcell * ocvslope). Other than this calculated time, the BMS will check if the voltage of a cell that is being balanced, has reached the desired voltage as well. When the voltage of one of the cells reaches the cell overvoltage level or the charging current is less than the charge complete current, the state will change to the RELAXATION state. The LED will stay blue and will blink if cell balancing is active. Balancing is finished if all the cell balance minutes are expired.
RELAXATION: in this state the power switches are set open, disconnecting the battery from the charger. The battery will relax for the specified relax time (default five minutes). During this relaxing, the cells can still be balanced since this happens with a low balancing current. At the end of the relaxation period, the system will check whether the balancing is finished. If balancing is not finished, the BMS will re-estimate the balance minutes. If balancing is done and the highest cell voltage is lower than the cell overvoltage minus the voltage margin, it will return to the CHARGE WITH CB state to continue charge process. If the highest cell is within this margin, the charging is complete, and it will go to the CHARGE COMPLETE state. To make sure it won’t endlessly go through this cycle with the CHARGE WITH CB state (this can happen if the end of charge current is met but the voltage requirement is not met), after 5 times it will not check if the highest cell voltage is within this margin and will go to the CHARGE COMPLETE state as well.
CHARGE COMPLETE: in this state, the charging is done, and the LED will be steady green. The power switches will remain open and if the charger is disconnected it will go to the SLEEP state after the defined period of time.
If at any time the current flows from the battery to the output and this current is higher than the sleep current, the BMS transitions to the NORMAL mode. If a charger is disconnected, the state will transition to the SLEEP state. If the go to deep sleep command has been given or the button is pressed and hold for five seconds there are two options: If one cell voltage is less than the storage voltage it will complete charging until each cell has reached the storage voltage, after this is done the BMS will transition to the SELF DISCHARGE state and this will transition to the DEEP SLEEP state. The other option is that no cell voltage is less than the storage voltage, than the BMS will transition to the SELF DISCHARGE state.
The sleep state is typically entered when the current is very low for an amount of time. The power switches will be closed to make sure the battery could be used. If any threshold is met during a cyclic measurement or the button is pressed, it will wake the MCU and the BMS will transition to the INIT state to check status. If the button is pressed for five seconds, the state will change to the SELF DISCHARGE state, in order to go to the DEEP SLEEP state. If the t-sleep-timeout happens the BMS will go to the SELF DISCHARGE state and will discharge the battery to storage level. After this it will go to the DEEP SLEEP state. Periodically, the MCU will wake up to go to the OCV state to measure the OCV. In this state the LED will be off. In a later release, this state is used to preserve power. The CAN communication is disabled, but the user can communicate with the BMS using NFC or the CLI, this will wake the MCU. When this happens the AFE will wake up as well to ensure real time information.
The OCV state will allow to record the latest open cell voltage (OCV) of the battery which is used in the state of charge (SoC) computation. Cyclically the Battery will enter this mode when the Battery stays in the SLEEP state. The period the system will go from the SLEEP state to the OCV state will depend on the time since the battery has entered the SLEEP state in the first place, without going to another state except the OCV state. The time to enter the OCV state will gradually increase each time with 50% from the set begin time until the set end time is reached. If for example the set begin time is five minutes and the set end time is twenty-four hours, it will take fifteen times to have a period of is twenty-four hours. When entering this mode, the MCU will wake up the AFE and measure. The LED will blink green. After it has calibrated the SoC, it will go to the SLEEP state again.
The FAULT state is entered when a critical fault that requires the battery switches to be opened has been detected (over-current, over-voltage, cell over-temperature). But only in extreme cases, to prevent sudden power outage on devices like flying drones. To exit this FAULT state the user can manually force the BMS to go to the INIT state via the reset fault command with the CLI or by activating the push button. If there is an undervoltage fault, it will transition to the DEEP SLEEP state after the t-fault-timeout time. With the flight-mode-enable and the i-flight-mode parameter, the user can make sure that the power will not be disconnected in this state. The LED will blink red in this state if the output is disconnected and will be solid red if the output isn’t disconnected.
This state is used to discharge the cells to the cell storage voltage in order to improve its life duration, when storing the battery for long time. In this mode, the power switches are open, the MCU is on and the CB function is activated. When the storage voltage is reached for each cell or if cells have a lower voltage, it will transition to the DEEP SLEEP state. CAN communication is disabled. To get a better SoC estimation, the OCV is measured and this will update the SoC measurement of the battery. The LED will blink dark blue in this state. To exit this state and to go back to the INIT state, the button needs to be pressed.
This state is used for transportation and storage. In this state; the power switches are open, disconnecting the battery, all protections are turned off, there are no cyclic measurements are done, the LED is off, and it will set everything to sleep or off to ensure the lowest power usage. Only the button can wake everything in this state. When the button is pressed it will transition to the INIT state. If configuration parameters have changed, it will save the parameters to flash to make sure they are loaded at startup.
If the application requires more power, two pairs of back to back MOSFETs can be added on the bottom side of the board. Corresponding part is PSMNR70-30YLH. See
Item | Description |
Power on self-test | More components are tested at startup (NTAG5, A1007), with better output on terminal. |
NuttX version | Upgraded to NuttX version 10.0 (stable release). |
Sense resistor test | Added a test that will detect if the sense resistor is connected to the measurement input. |
Negative input for unsigned variables | The CLI will notify you and will not set the variable when a negative number is entered for an unsigned variable. |
self-test state | The self-test is only done at startup, made it a separate state (not only init state anymore). |
LED color | LED is now solid red in the self-test state. |
SoC calibration | Added the OCV state to calibrate the state of charge when in sleep mode. Added the SoC calibration to the self-discharge state. |
CLI set parameter | Fixed that using the CLI, variables can’t be set with more than its variable type can hold. |
uv fault to deepsleep | Added that when an undervoltage occurs, it will go to the deepsleep mode after some time to protect the battery. |
Reboot | Added the reboot command to the CLI to reboot the microcontroller. |
Flight-mode | Added the flight-mode-enable and i-flight-mode parameters. This can be used to not cut the power to the FMU and motors in flight. |
a-factory | After setting the factory capacity, the BMS will recalculate and set the full charge capacity and end of charge current as well. |
Floating point variables | The floating point variables are better limited now. |
Charge to deepsleep | Added that if the button is hold for five seconds in the charge state, it will go to deepsleep. |
NFC | Is hard-powered down with GPIO. |
Discharge to storage | After a long time-out, the BMS will discharge to storage level and go to the deepsleep state. |
CLI syntax | Some wrong syntaxes are now fixed in the CLI. |
CLI help messages | Improved the help message if the wrong number of cells are attached/inserted. |
Wrong messages | The wrong BMS undertemperature detected message if the sensor is disabled has been fixed. The first “pin rising edge BCC_FAULT” message has been deleted. |
Message limit | Limited the number of “Rising edge BCC_FAULT” and “clearing CC overflow” messages. |
CLI color messages | Added functions for the green (good), yellow (warning) and red (error) messages. |
BCC com errors | This will not be reset (wrongly), but it will be counted and with 255 errors it will reset it correctly. |
UAVCAN | New message of the draft of the UAVCAN V1 standard message is implemented. |
Data struct | Added the unit and type string to the data struct. Added floating point accuracy to the floating point limitations. |
Parameters | Added the t-sleep-timeout, i-charge-nominal, i-out-nominal, i-flight-mode, battery-type, flight-mode-enable and m-mass. Changed the model-id to uint64_t, t-fault-timeout to use with uv to go to the deepsleep state, t-ocv-cyclic0 and t-ocv-cyclic1 are implemented, changed the uavcan-subject-id to 3 different parameters for each message: uavcan-ess-sub-id, uavcan-bs-sub-id and uavcan-bp-sub-id. v-cell-margin is default 50mV instead of 30mV. ocv-slope is in mV/Amin instead of V/Amin. |
State diagram | Added LED indication, Added SELF TEST state, added button hold to the charge to self-discharge state transition, Added SLEEP_TIMEOUT to the sleep to self-discharge state transition, FAULT_TIMEOUT used for transition to go to deepsleep with an undervoltage. |
Charge state diagram | Added LED indication and added button hold to the charge to self-discharge state transition. |
Cell balancing | The cell balancing is not only based on the cell voltage compared to the desired voltage, but it is based on the calculated estimated cell balance minutes as well. |
State | LED state |
Self-test | Red |
Deep sleep | Off (after 1 sec white) |
Sleep | Off |
Wake-up | Green |
Normal | Green blinking (with state indication) 1 blink 0-40% 2 blinks 40-60% 3 blinks 60-80% 4 blinks 80-100% |
Fault | Red blinking (Output disconnected) Red (Output connected) |
Charging | Dark blue |
Charging done | Light blue |
Balancing/self-discharge | Dark blue blinking |
NFC communication | Yellow blinking |
Charger connected at startup | Red-blue blinking |
This page will describe how to use the CLI
To view the help of the commands of the bms, type "bms help" in the terminal (CLI). Than you will see this window:
When you type "bms help parameters", you will get a list with all the parameters with its unit, if it is Read Only (RO) or Read Write (RW) and what the data type is it. These are useful parameter properties that help with filling in parameters correctly.
The "bms help show-meas" command shows you which parameters you can view in cyclically in the CLI when the measurement happens. These commands should be used with the "bms show". To show them all, use "bms show all 1". if you want the measurements to be outlined and updated at the top of your terminal, use "bms show top 1". Keep in mind that if this is active, it could be that typed in characters disappear in this update.
The BMS uses VT100 escape sequences to update the terminal. In order to see this, make sure your terminal emulation program (like PuTTY or minicom) has VT100 mode enabled.
To get a single parameter value, you could use the bms get command. If for example you would like to get the state of charge, type "bms get s-charge" in the terminal. It will provide you with the value and its unit. If you want to check a lot of parameters, use the "bms get all" command, this will give you the full list of parameters, with the value and its unit. When you wish to load the parameters from flash, type "bms load".
To adjust parameter values, you need to use the bms set command. If for example you would like to set the number of cells to 4, you need to enter the following command: "bms set n-cells 4". To make sure parameters are saved to flash, type "bms save". If you would like to set the default parameters, type "bms default".
To get out of the FAULT state the BMS needs to reset the FAULT, type "bms reset". To get in the SLEEP state (if you are able to enter it), type "bms sleep". To wake-up from the sleep state, type "bms wake". To go to the DEEP_SLEEP state, type "bms deepsleep", it could be that it first self-discharges.
This page will explain some start-up messages, what to do when first using the BMS
When first starting the BMS with the latest software the command line interface could look like the code snipping at the end of the page.
You can see that the version number is: bms3.6-10.0. this comes after "BMS version: ". Than it will begin doing self-tests.
START means it will start testing that part or component
PASS means that the test succeeded
FAIL means the test did not succeed
Be sure to check the error messages as it could help finding out what is wrong, some errors explain why it went wrong and how you could fix it. It could be that you will get these messages:
These messages mean that the CRC of the saved data (the parameters) in flash doesn't match. This could happen when nothing is saved or when a new program is flashed in the microcontroller (and thus cleared the flash). Than it could be that you get the message "NVMS registers don't have the right value!". This means a register in the SBC needs to be written, but before this could take effect, it needs to restart the SBC, "Restarting!" is stated when it does this. Since the SBC supplies the microcontroller with its power, the microcontroller will restart as well.
It could be that you get the message that the stackvoltage is too different from sum of cells, so there is a wrong n_cells number. This means that the actual connected cells are different than the entered number of cells (n-cells). The BMS will calculate what the amount of cell need to be, so to fix this, you can copy the command, like "bms set n-cells 6" from the example below. You can always configure the correct number of cells by typing "bms set n-cells x" where x the number of cells of the battery, that can be 3-6. After that type "bms reset" or press the button to reset the fault.
You will get a warning if the battery temperature sensor is not enabled, "WARNING: battery temperature sensor is disabled!". To enable the battery temperature sensor see How to enable the battery temperature sensor.
"BMS main loop!" means the BMS has entered the main loop and will continue according to the main state diagram.
Each time the BMS enters a new mode, it will output this with "<mode> mode".
Here we can see an example of the startup text from the CLI:
It is highly recommended that you check each parameters in Parameters of the BMS and make sure to configure each parameter. Use "bms get all" to get each parameter and it's value, so you could configure each one for your battery. Some parameters you would like to configure are:
a-rem (the remaining capacity)
the BMS does a guess on what the remaining charge is based on a OCV(open cell voltage)/SoC (state of charge) table from one specific battery, but every battery is different.
a-full (the full charge capacity of the battery)
while charging the BMS will calculate this based on a-rem)
model-name (the name of the battery)
n-cells (the amount of cells of the battery)
a-factory (the factory capacity of the battery)
i-charge-full (the end of charge current of the battery (could be 10% from i-charge-max))
i-charge-max (the maximum charge current)
sensor-enable (to enable the battery temperature sensor)
This page will explain which temperature sensor you need and how to enable it.
By default the temperature sensor is not enabled. To configure the temperature sensor to be used, this temperature sensor need to be connected to J1 using a 2-pin JST-GH connector. The maximum length of the cable that leads to the temperature sensor is 20cm. This temperature sensor needs to be a 10k NTC, like the NTCLE100E3103JB0 from Vishay. With the CLI type:
“bms set sensor-enable 1”.
this will enable the temperature sensor measurement to be done together with the rest of the measurements in the BMS software.
The BMS is not able to limit the current. It can only disconnect the battery from the output. For charging make sure a current limited power source is used and set the limitation to the right value. The BMS is not able to limit the voltage. For charging, the charge voltage should be limited as well.
The standard balancing current is only 50mA for one cell. This means it could take some time before balancing is done if the battery pack very unbalanced.
To get more information about the charging process see CHARGE state on the BMS application state machine page.
PX4.io is a flight stack or vehicle management software for mobile robotic vehicles such as drones and rovers which operates with NuttX as an underlying operating system. There will be a build target for the RDDDRONE-BMS772 that is a minimal PX4 functionality target board.
The same NuttX BMS software will be ported to this minimal functionality PX4 target with the intent that some users may perfer to operate in the PX4 ecosystem since it is well maintained. Over time the software developer may wish to take advantage of PX4 functions relating to MAVLINK, uORB messaging services, authentication or other.
PX4 target is a work in progress. Please check back here for updates. We are expecting to have this available September/2020
This page will show how the realization has been done. It will use diagrams to show how some of the parts were designed and it will describe each part in more detail.
In the main source file, the BMS main can be found, this is the BMS application. This function will initialize each part and start the main loop task. This task will implement the battery main state machine. In the main source code, the state is changed. If for example flight mode is enabled, when the drone is in the air, and there is an under voltage, the state should not cut the power. Meaning that the state will not transition to the fault mode, but only report the fault in the status flags. In this source file there is a function to handle a changed parameter as well. This function will call functions from the needed parts to do something with the parameter that is changed. If for example a configuration changed, such that a configuration of the BCC needs to change, it will call the right function from the Bat management part to change the configuration of the BCC as well.
There is a lot of data that is needed or set by different tasks. Because it is not wise to move this big chunk of data through all the tasks there needs to be some sort of shared memory. Because NuttX is POSIX compliance there are shared memory functions that could be used. But for these shared memory functions a memory management unit (MMU) is needed and this microcontroller does not have an MMU. That is why the whole data management will be made in a data source file. This makes sure the data is only made once but is not global. With functions the data can be read or written, and these functions ensures protection against multiple threads accessing the data at the same time. These functions can be seen in Figure 4.
To protect the data from multiple threads trying to access it at the same time, a mutex is used. A mutex is an object that can be locked and unlocked in an atomic operation. Meaning that if both threads want to lock the mutex, the threads cannot lock the same mutex at the same time. A mutex is needed to prevent data race. The other thread needs to wait until it is available.
The big data chuck is in a struct, together with a parameter info array. This array supports a fast access of the data type, the minimum, the maximum and the address of the data. This ensures it is faster to get and set data than with a switch.
If a variable is changed with the set parameter function, that function will set that variable and value in a global array. So, the task can access it. And it will increase a semaphore for the task to handle the change. This is done in a callback function to the main. This task is waiting for an available semaphore. A semaphore is an integer variable that can be increased and decreased in an atomic operation. It looks like a mutex because the thread will wait if the semaphore is not positive and tries to decrease it if positive.
In NuttX there is a nuttshell, this is the UART communication with the MCU. In this nuttshell, applications can be called with and without arguments. There arguments will be given to the function it calls, in this case the BMS main. This means that a CLI can be created with calling the application with some arguments.
This CLI that is made, can be used by calling the BMS application in the nuttshell with a command and optionally 2 arguments for that command. When this happens the BMS main is called. Meaning that this main needs to be resistant against multiple calls, this should not restart the BMS application because than the battery power will be cut.
If there are commands given when calling the BMS application, the CLI process commands function will be called to handle it. It will parse the command and optionally the arguments and check if the inputs are valid. If it is valid, it will act based on which command has been given. The flowchart can be seen in Figure 5.
In order to set a color to the RGB LED, the set led color function should be used. The flowchart of this function can be found in Figure 6. Because this function can be used from different tasks, a mutex will be locked before it checks if the color and if blink is already set. This function will set the semaphore to start or stop the blink sequence. It will skip the semaphore timed wait function to ensure the blink sequence restarts if needed. It will begin with the new color. This function will use the NuttX userled functions.
In order to use a GPIO in NuttX, these GPIO’s need to be defined in the board file and the board specific GPIO file. This will create devices for each GPIO pin. To use the GPIO in the application an IOCTL call needs to be used. IOCTL means input-output control and it is a device specific system call.
The IOCTL is used to give commands to a driver to control a device, in this case the GPIO pins. But for an IOCTL to work an open file descriptor needs to be given. This is obtained by giving the path to the device as a string. This is too much work to do in the application for setting or reading a GPIO, that is why a GPIO BMS application driver is made. This will make sure that a GPIO can be read or written with simple write/read pin functions and a define to indicate the pin.
The Bat management part can be used to monitor the battery and control the gate. Because the Bat management part is quite large there are other source files made to help with the BCC, to keep it organized. Like monitoring, to take care of measurements and configuration, to take care of the whole configuration for the BCC. For the main to implement the state machine, functions are made to let the main implement the functionality. Some functions are made to enable the measurements, to check for faults, to self-discharge etc.
The meas task is created to do the manual measurements with the BCC and calculate the variables. Because the BCC will not check for an over current, the current needs to be read and calculated every time continuously to be compared with the current threshold. For short circuit protection there is a hardware circuit. The rest of the measurements will only be read and calculated if a semaphore is available. An extra task called otherCalc task is created to increase this semaphore each time the other measurement data is required to be known. This is needed at period T_meas. If the semaphore is increased, the meas task will decrease the semaphore, read the other registers and calculate battery voltage, battery current, cell voltages, the temperatures, remaining charge, the average power and set them. Then it will signal back to the main that the measurements are done. The sequence of the meas task can be seen in Figure 7. The sem_wait and sem_post functions are called consecutively in the endless loop, this is used to start and stop the task with a function from the main.
After the semaphore is increased, the otherCalc task will suspend for the remaining time. This can be seen in Figure 8. Gettime() returns the time from the start of the whole application. To make sure the cyclic measurements does not drift, the time before the loop starts and the period T_meas are gained. The target time is calculated by adding the period with the previous target time. If T_meas should change, this is updated in the sequence using a global variable. This is left out of the sequence diagram because it is too detailed. If the semaphore is increased, the end time is gained. The difference of the target time and the end time give the time that the task needs to sleep.
To calculate the state of charge, the coulomb counter is used. The coulomb counter register holds the sum of the measured currents (until read). There is another register that holds the number of samples in the coulomb counter register. The average current is calculated by dividing the sum of the currents by the number of samples. When the time is known for which the average current is calculated, the difference in charge can be calculated with the following formula: . The new remaining charge is calculated by adding the difference in charge with the old remaining charge. The state of charge can then be calculated by dividing the FCC by the remaining charge.
In order to provide the average power consumption over a time period of ten seconds, a constant moving average is taken. This moving average is constructed by removing the oldest measurement and adding the new measurement, which is than divided by the amount of measurements. This way the average will only be of the last ten seconds. In order to be memory efficient, the measurements used in the moving average will be sub-sampled if the measurement period is configured as less than one second. This way maximum ten old measurements need to be known. Measurements are not lost when sub-sampling, because the BCC chip will remember an average of it.
The BCC chip will take care of fault monitoring for the over voltage, under voltage, over temperature and under temperature. It will set the fault pin high when there is an error. If this happens it will trigger an interrupt in the main and it will check what fault happened. The main can than act on the fault. This ensures that the main is in control of what happens.
Since the user can change configurations in run time, sometimes a configuration needs to be changed in the BCC as well. When there is a change in the configuration, this is set with the setParameter function and a task in the main source file will handle the change. This function will call a function to handle the change in the bat management part. In this part it will call the right function from the configuration source file to change the configuration of the BCC.
Since the charging state machine and the main state machine is implemented in the main, but it needs information that is from the bat management part, a callback function will be used to give this information to the main if needed. This way the task to implement the state machine is not constant polling for information but will react if the information changes. This will ensure that this task is not always active, and the resources are used for other tasks.
The SBC part is used to control the power of voltage regulators V1 (The most used 3.3V) and V2 (CAN PHY). With the setSbcMode() function the mode of the SBC can be set. In the normal mode both V1 and V2 are active, in the standby mode V2 is off, turning off the CAN transceiver and in the sleep mode both V1 and V2 are off, turning off almost the whole BMS board. In Figure 9 the simplified flowchart of this function can be seen.
In the beginning of the project everything was designed towards UAVCAN V0. Later in the project it was clear that UAVCAN V0 will not work in NuttX. But there was a new version of the UAVCAN protocol, version one (V1).
Within NXP, a solution has been made to make the UAVCAN V1 protocol in NuttX. In this new version, the battery info standard as stated in V0 was not specified. This is a problem since the BMS should eventually communicate over UAVCAN. And since more companies were interested in a battery info standard. A draft standard has been made. This standard has been proposed to a company that is working together with NXP and other companies to make UAVCAN V1 standards for drones. This standard is still being developed. Because the company would like to see an example working with UAVCAN, a snapshot of the draft protocol was taken, and this has been implemented with the BMS.
This part works with a UAVCAN task that waits (it sleeps until a CAN transceiver signal comes in) for an incoming UAVCAN transmission or a signal from the main that new data needs to be send. When new data needs to be sent, it will put the data that needs to be sent in the transmit buffer. It will check if the transmit buffer if it is filled and transmit the data if it is. Then it will wait for an incoming transmission again. To see this message see Table 2 or the flowchart see Figure 10.
Table 2: Battery status UAVCAN message
Table 3: BMSStatus UAVCAN message status values
There was too little time to realize these parts before the end of the graduation report. These will be added when there is time left at the end.
Type
Bits
Name
Def.
Unit
Description
Uint4
4
heartbeat
NaN
-
Readiness and the health
Float32[2]
64
temperature_min_max
NaN
C
The minimum and maximum readings of the pack temperature sensors.
Float32[2]
64
cell_voltage_min_max
NaN
V
The minimum and maximum readings of the cell voltages.
Float32
16
available_charge
NaN
C
The estimated electric charge currently stored in the battery.
uint8
8
Error
0
-
Error status.
The MC33772B Battery Cell Controller (BCC) comes with a SW package. This package contains embedded SDK SW driver for NXP’s Battery Cell Controller products and example projects for S32K144 MCU and S32 Design Studio for Arm Version 2018.R1. It exists in a Lite and a Full version:
The Lite version is implemented and used in the NUTTX-PX4 software. It allows controlling the BCC and performing its main tasks, as: measuring Cell Terminal (CT) voltages, current, temperatures, analog inputs, etc.. It is available on NXP.com
The Full version complements the Lite version by adding diagnostics and safety to it. This package can be useful for users wanting to add a safety layer on their applications. It is available under NDA on Docstore
This page shows the parameters of the BMS.
This page will describe the variables of the BMS. There are 3 kind of parameters
The BMS variables
The BMS configuration parameters
The hardware parameters
The BMS variables give the variables of the BMS, like the voltages, currents and temperatures. The BMS configuration parameters are the parameters that could be used to configure the BMS, like the battery parameters, BMS parameters and more. The hardware parameters could be used to keep track of the parameters of the hardware parameters, like the maximum current that is limited by the MOSFETs power dissipation.
In the console (CLI) type "bms get all" to get all the parameters and its current value.
If you want more information about the parameters type "bms help parameters" in the console (CLI).
A line means this is not implemented yet.
* these parameters will only be implemented during startup of the BMS
** this parameter is always reset to 0 at startup and can't be saved
Parameter
Unit
Datatype
Description
Default
RO/RW
No
c-batt
C
float
The temperature of the external battery temperature sensor
0
RO
0
v-out
V
float
The voltage of the BMS output
0
RO
1
v-batt
V
float
The voltage of the battery pack
0
RO
2
i-batt
A
float
The last recorded current of the battery
0
RO
3
i-batt-avg
A
Float
The average current since the last
measurement (period t-meas)
0
RO
4
s-out
-
bool
This is true if the output power is enabled
0
RO
5
p-avg
W
float
Average power consumption over the last
10 seconds
0
RO
6
e-used
Wh
float
Power consumption since device boot
0
RO
7
a-rem
Ah
float
Remaining capacity in the battery
0
RW
8
a-full
Ah
float
Full charge capacity, predicted battery capacity when it is fully charged. Falls with aging
4.6
RW
9
t-full
h
float
Charging is expected to complete in this
time; zero if not charging
0
RO
10
s-flags
-
uint8_t
This contains the status flags as
described in BMS_status_flags_t
255
RO
11
s-health
%
uint8_t
Health of the battery in percentage, use
STATE_OF_HEALTH_UNKNOWN = 127
if cannot be estimated
127
RO
12
s-charge
%
uint8_t
Percentage of the full charge 0, 100.
0
RO
13
batt-id
-
uint8_t
Identifies the battery within this vehicle,
0 - primary battery.
0
RW
14
model-id
-
uint64_t
Model id, set to 0 if not applicable
0
RW
15
model-name
-
Char[32]
Battery model name, model name is a
human-readable string that normally
should include the vendor name, model
name and chemistry
"BMS
test"
RW
16
v-cell1
V
float
The voltage of cell 1
0
RO
17
v-cell2
V
float
The voltage of cell 2
0
RO
18
v-cell3
V
float
The voltage of cell 3
0
RO
19
v-cell4
V
float
The voltage of cell 4
0
RO
20
v-cell5
V
float
The voltage of cell 5
0
RO
21
v-cell6
V
float
The voltage of cell 6
0
RO
22
c-afe
C
float
The temperature of the analog front end
0
RO
23
c-t
C
float
The temperature of the transistor
0
RO
24
c-r
C
float
The temperature of the sense resistor
0
RO
25
n-charges
-
uint16_t
The number of charges done
0
RW
26
n-charges-full
-
uint16_t
The number of complete charges
0
RW
27
Parameter
Unit
Datatype
Description
Default
RO/RW
No
n-cells
-
uint8_t
Number of cells used in the BMS board
3
RW
28
t-meas
ms
uint16_t
Cycle of the battery to perform a complete battery measurement and SOC estimation can only be 10000 or a whole division of 10000 (For example: 5000, 1000, 500)
1000
RW
29
t-ftti
ms
uint16_t
Cycle of the battery to perform diagnostics (Fault Tolerant Time Interval)
1000
RW
30
t-cyclic
s
uint8_t
Wake up cyclic timing of the AFE (after front end) during sleep mode
1
RW
31
i-sleep-oc
mA
uint8_t
Overcurrent threshold detection in sleep mode that will wake up the BMS and also the threshold to detect the battery is not in use
30
RW
32
v-cell-ov
V
float
Battery maximum allowed voltage for one cell. Exceeding this voltage, the BMS will go to fault mode
4.2
RW
33
v-cell-uv
V
float
Battery minimum allowed voltage for one cell. Going below this voltage, the BMS will go to the fault mode (followed by deep-sleep after t-fault-timeout)
3
RW
34
c-cell-ot
C
float
Over temperature threshold for the cells. Going over this threshold and the BMS will go to FAULT mode
45
RW
35
c-cell-ot-charge
C
float
Over temperature threshold for the cells during charging. Going over this threshold and the BMS will go to FAULT mode
40
RW
36
c-cell-ut
C
float
Under temperature threshold for the cells. Going under this threshold and the BMS will go to FAULT mode
(-20)
RW
37
c-cell-ut-charge
C
float
Under temperature threshold for the cells during charging. Going under this threshold during charging and the BMS will go to FAULT mode
0
RW
38
a-factory
Ah
float
Battery capacity stated by the factory
4.6
RW
39
t-bms-timeout
s
uint16_t
Timeout for the BMS to go to SLEEP mode when the battery is not used
600
RW
40
t-fault-timeout
s
uint16_t
After this timeout, with an under voltage fault the battery will go to DEEPSLEEP mode to preserve power. 0 sec is disabled
60
RW
41
t-sleep-timeout
h
uint8_t
When the BMS is in sleep mode for this period it will go to the self-discharge mode, 0 if disabled
24
RW
42
t-charge-detect
s
uint8_t
During NORMAL mode, if the battery current is positive for more than this time, then the BMS will go to CHARGE mode
1
RW
43
t-cb-delay
s
uint8_t
Time for the cell balancing function to start after entering the CHARGE mode
120
RW
44
t-charge-relax
s
uint16_t
Relaxation after the charge is complete before going to another charge round
300
RW
45
i-charge-full
mA
uint16_t
Current threshold to detect end of charge sequence
50
RW
46
i-charge-max
A
float
Maximum current threshold to open the switch during charging
4.6
RW
47
i-charge-nominal
A
float
Nominal charge current (informative only)
4.6
RW
48
i-out-max
A
float
Maximum current threshold to open the switch during normal operation, if not overruled
60
RW
49
i-out-nominal
A
float
Nominal discharge current (informative only)
60
RW
50
i-flight-mode
A
uint8_t
Current threshold to not disable the power in flight mode
5
RQ
51
v-cell-margin
mV
uint8_t
Cell voltage charge margin to decide or not to go through another topping charge cycle
50
RW
52
t-ocv-cyclic0
s
int32_t
OCV measurement cyclic timer start (timer is increase by 50% at each cycle)
300
RW
53
t-ocv-cyclic1
s
int32_t
OCV measurement cyclic timer final value (limit)
86400
RW
54
c-pcb-ut
C
float
PCB ambient temperature under temperature threshold
-20
RW
55
c-pcb-ot
C
float
PCB ambient temperature over temperature threshold
45
RW
56
v-storage
V
float
The voltage what is specified as storage voltage for a cell
3.8
RW
57
ocv-slope
mV/ Amin
float
The slope of the OCV curve. This will be used to calculate the balance time
5.3
RW
58
batt-eol
%
uint8_t
Percentage at which the battery is end-of-life and shouldn’t be used anymore Typically between 90%-50%
80
RW
59
battery-type
-
uint8_t
The type of battery attached to the BMS. 0 = LiPo, 1 = LiFePo4 (could be extended). Wil change ov, uv, v-storage, OCV/SoC table if charged during runtime.
0
RW
60
sensor-enable
-
bool
This variable is used to enable or disable the battery temperature sensor, 0 is disabled, 1 is enabled
0
RW
61
self-discharge-enable
-
bool
This variable is used to enable or disable the SELF_DISCHARGE state, 0 is disabled, 1 is enabled
1
RW
62
flight-mode-enable
-
bool
This variable is used to enable or disable flight mode, is used together with i-flight-mode.
0
RW
63
uavcan_node_static_id*
-
uint8_t
This is the node ID of the UAVCAN message
255
RW
64
uavcan-ess-sub-id*
-
uint16_t
This is the subject ID of the energy source state UAVCAN message (1...100Hz)
4096
RW
65
uavcan-bs-sub-id*
-
uint16_t
This is the subject ID of the battery status UAVCAN message (1Hz)
4096
RW
66
uavcan-bp-sub-id*
-
uint16_t
This is the subject ID of the battery parameters UAVCAN message (0.2Hz)
4096
RW
67
uavcan-fd-mode*
-
uint8_t
If true CANFD is used, otherwise classic CAN is used
0
RW
68
uavcan-bitrate*
bit/s
int32_t
The bitrate of classical can or CAN FD arbitration bitrate
1000000
RW
69
uavcan-fd-bitrate*
bit/s
int32_t
The bitrate of CAN FD data bitrate
4000000
RW
70
Parameter
Unit
Datatype
Description
Default
RO/RW
No
v-min
V
uint8_t
Minimum stack voltage for the BMS board to be fully functional
6
RW
71
v-max
V
uint8_t
Maximum stack voltage allowed by the BMS board
26
RW
72
i-peak
A
uint16_t
Maximum peak current that can be measured by the BMS board
200
RW
73
i-max
A
uint8_t
Maximum DC current allowed in the BMS board (limited by power dissipation in the MOSFETs)
60
RW
74
i-short
A
uint16_t
Short circuit current threshold (typical: 550A, min: 500A, max: 600A)
500
RW
75
t-short
us
uint8_t
Blanking time for the short circuit detection
20
RW
76
i-bal
mA
uint8_t
Cell balancing current under 4.2V with cell balancing resistors of 82 ohms
50
RW
77
m-mass
kg
float
The total mass of the (smart) battery
0
RW
78