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...
Loading...
Loading...
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
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 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 .
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
If you just received your board, and want to jump to how to configure the jumpers and connectors for your specific battery
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
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 need to provide 5V power to a drone before activating the actual battery power supply. The intent is to allow the host to identify the battery characteristics to avoid a catastrophic 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 battery 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
Not clear if the battery can be asleep then woken up with a button press to supply power.
The 5V supply MAY only need 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.
May be a trend toward 4 LEDS to show battery gauge status visually. We have one RGB led which we intend to flash a sequence and color to show battery status
Extra LEDs could be added on the expansion header
The BMS 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.
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.
For disambiguation:
"Power in" (J4) is where your physical battery will connect.
Individual balancing leads will connect to JP1 "Cell Terminal"
The BMS board and Physical battery connected together can now be considered a "smart battery with BMS"
"Power out J5 represents the connection of your "smart battery with BMS" to the outside world.
The board is organized as shown in the figures below:
The RDDRONE-BMS772 kit includes:
Assembled and tested reference design in anti-static bag
Unmounted cell balancing connectors for 3s, 4s and 6s
CAN Bus Termination Resistor (DRONE-CAN-TERM)
4-pin JST-GH to 4-pin JST-GH 300mm cable
Power input and power output connectors
Quick start guide
External thermistor with cable
Small display
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.
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
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 Management Unit (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 external display could be used to display important (battery) information. This display can be connected to J23, the I²C master bus. This header could be supplied with 3.3V (D34) or 5V (D35, default populated). By switching the diode, 3.3V or 5V could be used.
These displays work at both 3.3V and 5V. Software has been prepared but requires connection to the 3.3V domain (D34)
Double check the pinout configuration as they occasionally differ. Most use 1-GND, 2-
VCC, 3-SCL, 4-SDA and will connect directly to header J23 without modification.
Example of 0.91 inch OLED display using SSD1306 I2C display controller
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.
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
Some recent versions of the board may include a small common
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
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 slave 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 |
J23 | I²C master bus | FCI | 68000-204HLF | Populated |
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 |
TP16 | BCC_MISO | BCC SPI MISO line |
TP17 | BCC_CS | BCC SPI chip select |
TP18 | BCC_SCLK | BCC SPI clock signal |
TP19 | BCC_MOSI | BCC SPI MOSI line |
TP20 | SBC_CS | SBC SPI chip select |
TP21 | SBC_MISO | SBC SPI MISO line |
TP22 | SBC_MOSI | SBC SPI MOSI line |
TP23 | SBC_SCLK | SBC SPI clock signal |
TP24 | VCC_HARVEST | The VOUT pin of the NTAG (voltage harvest) |
TP25 | N/A | Connected to J18[1] of SMBus connector |
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
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.
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 additional battery level LEDs, emergency button, etc. | J21 |
Wake jumper | Jumper for SBC wake-up. In parallel of the button | J22 |
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.
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.
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 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: 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.
This page will describe how to get the UAVCAN BMS messages with the UCAN board
Connect the UAVCAN device (like the RDDRONE-UCANS32K146) to the BMS using JST GH 4 pin connectors with 1 on 1 wires. End the CAN bus with a 120Ω terminator resistor between CAN high and CAN low.
Connect the UCAN board with a USB-TTL-3V3 cable to the laptop.
Install the can utils with the following terminal command:
sudo apt install can-utils
Install python 3.7 with the following terminal command:
sudo apt install python3.7
Install pyuavcan with the following terminal command:
python3.7 -m pip install pyuavcan
Start the deamon on UART <-> SLCAN to use SLCAN0 use the command (for ttyUSB1):
sudo slcand -o -s8 -t sw -S 115200 /dev/ttyUSB1
Keep in mind that in this case the UART of the UCAN board needs to be connected to ttyUSB1. You can check which USB it is by disconnecting the USB-TTL-3V3 cable connected to the UCAN board, write “ls /dev” in the terminal, connect the USB cable and write “ls /dev” again. Only the USB of the UCAN board should be added in the list. If not check if the USB connection of your virtual machine is passed through.
Enable the interface (up)(same as ifup can0 in nuttx) write the following command:
sudo ip link set up slcan0
Clone the cannode v1 tools:
git clone
Make sure the sub modules are in the git repository write the following command in the cannode-v1_tools directory:
git submodule update --init
Find this line in print_bmsstatus_topic.py:
media = pyuavcan.transport.can.media.socketcan.SocketCANMedia('can0', mtu=8)
Change it to the right can device, for example:
media = pyuavcan.transport.can.media.socketcan.SocketCANMedia('slcan0', mtu=8)
Run the pyuavcan tool by typing the following in a terminal where the print_bmsstatus_topic.py file is located:
python3.7 print_bmsstatus_topic
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
Note: SJ13, SJ14, SJ15 and SJ16 are not used for cell terminal connection. See and .
External and additional components and their use are detailed in .
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 |
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: bms4.0-10.1. 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). To fix this, check what the current n-cells value is with "bms get n-cells" and make sure it corresponds with the number of cells in the attached battery. To configure the correct number of cells type "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. In version 3.4 there is something wrong, n_cells should be n-cells.
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.
If you see the text that the BCC overvoltage set to <number>mV. That number should be slightly higher than the actual set cell-ov in the software. This is because the overvoltage threshold register of the BCC is an 8-bit register, compared to the floating point variable in the software this has a lot less resolution. The value in the BCC is set slightly higher to not falsely trigger on it, but have it as a backup trigger since the software will react on the overvoltage as well with the measured cell voltage.
It could be that you see the following line: "NOTICE: Disabling 5V regulator (CAN transceiver) briefly!". This happens when the SBC needs to switch modes, because it can only be done in the standby mode where the 5V regulator is disabled.
"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"
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.
It is advisable to insert the correct OCV/SoC table for the battery.
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 describe the task priorities of the BMS
The tasks of the BMS have different priorities, this is needed because some tasks/activities are more important than others. For example, one needs to react fast on a fault, so the system needs to prioritize a fault above blinking the LED. The BMS uses the NuttX preemption, which means that lower priority tasks get interrupted by a higher priority task. The task priorities can be seen in Figure 4.
When one of the BCC functions is called (via the spiwrapper), the task is locked so it can’t switch tasks. This way it makes sure it will execute the function OK, otherwise there could be CRC errors or NULL responses.
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 4.0-10.1.
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.
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 in 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 can be used to read all kind of parameters. It should be able to read the values with a refresh rate of once a second. The updater task will be used to update the data. It can operate in a similar manner to a double ported EEPROM, and NFC records can include standardized messages for HTTP or text records. In this way the NFC tag could be updated regularly with status information. That information could be added to text message, and a smartphone would be capable of reading the message with data attached with minimal coding effort. This method removes the need for any custom software on the reading device.
SMBus is an alternative way to communicate information to the FMU. The BMS could be seen as an I2C slave device. Reading from specified registers returns the BMS data. Things like voltages, temperatures, state of charge, average current could all be read from these registers. The SMBus needs to be enabled with the variable in order to work.
The display module manages information presented on an optional local I2C LCD display (e.g. SSD1306 type). 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). The UAVCAN legacy message V0 can be used as well. 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 and 5V) 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 SBC provides a watchdog.
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. These are the tasks: These are the sub-tasks:
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. Table 1: LED states
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 can be found. This state diagram will be implemented in the BMS application.
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. If a watchdog reset has occurred not every self-test will be done to make sure the power is not turned off. 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 120sec) 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 estimated 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 estimated balance time is: Estimated 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, it will go to the RELAXATION state. The LED will stay blue and will blink if cell balancing is active. Balancing is finished if all the calculated cell balance minutes are expired or it has reached the lowest cell voltage.
RELAXATION: in this state the power switches are set open, disconnecting the battery from the charger. The MCU will be put in a very low power run (VLPR) mode, SBC in standby mode and the BCC to measure only at 10Hz. This will reduce the power in this state. The battery will relax for the specified relax time (default 300 sec). 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 done. If balancing is not finished, the BMS will re-estimate the balance minutes. If balancing is finished 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 the 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. If the lowest cell voltage decreases again below the cell overvoltage minus the recharge voltage margin, it will go to the CHARGE WITH CB state again. The power switches will remain open and if the charger is disconnected it will go to the SLEEP state after the defined period of 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 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. This SLEEP state is used to preserve power. The MCU will be in VLPR mode, the SBC in standby mode, the BCC in sleep mode with measurement on to check for a sleep overcurrent and other faults. 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. In this state the LED will be off.
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 has been detected (over-current, over-voltage, cell over-temperature) and requires the battery switches to be opened. 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. If the s-in-flight parameter is high, it will not disconnect the power except when i-peak-max threshold is reached. The LED will blink red in this state if the output is disconnected and will be solid red if the output isn’t disconnected. The s-in-flight parameter is high if the i-batt-avg (1s) is higher than i-flight-mode and the i-batt-avg (1s) is less than the i-out-max AND the flight-mode-enable is high. The s-in-flight will be low again when: the i-batt-10s-avg is lower than the i-flight-mode and the i-batt-avg (1s) is less than the i-flight-mode. OR s-in-flight will be low when the flight-mode-enable is set to 0 OR when there is a i-batt-avg (1s) charge current higher than the i-sleep-oc ((1s_current_avg - i-sleep-oc) > 0). If the BMS is in the FAULT state and s-in-flight will become false, the gate will be disconnected if not already done .
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 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 done, the LED is off, and it will set everything to sleep or off to ensure the lowest power usage (<100uA). Only the button can wake everything in this state. When the button is pressed it will transition to the SELF_TEST state. If configuration parameters have changed, it will save the parameters to flash to make sure they are loaded at startup.
This chapter 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 as seen in Figure 8. In the main source code, the state is changed. In this source file there is a function to handle a changed parameter as well. This function will call other 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. In the main loop, the watchdog is kicked as well. So if this is not done in time, it will reset the MCU.
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 5.
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 the mutex 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 large 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 6.
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 7. 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. An input pin can be an interrupt pin, on an interrupt it will generate a signal that will queue the action for the handler. Keep in mind that these signals can be very intrusive.
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 overcurrent, the current needs to be read and calculated every time 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 8. 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 9. 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: ∆Q=I_avg*∆t. 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 overvoltage, undervoltage, 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 10 the simplified flowchart of this function can be seen. Besides power regulators, the SBC has a watchdog, which is used to reset the MCU if it doesn’t kick the watchdog within the set time, this is done via the NRST pin.
Table 2: Energy source 0.1 UAVCAN V1
Table 3: Battery status 0.2 UAVCAN V1
Table 4: Battery parameter 0.3 UAVCAN V1
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 the flowchart see Figure 10. There is a UAVCAN V1 message set implemented. Which is a snapshot of the UAVCAN V1 with WIP DS-015. This consists of 3 messages, the energy source, the battery status and the battery parameters. These messages can be seen in Table 2, Table 3 and Table 4. For more information about UAVCAN V1, see and the battery service.
State
LED state
Self-test
Red
Deep sleep
Off (after 1 second white LED on)
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
Blue
Charging done
Green
Balancing/self-discharge
Blue blinking
Charger connected at startup
Red-blue blinking
Type | Name | Unit | Description |
Uint56 | timestamp.microsecond | us | The number of microseconds that have passed since some arbitrary moment in the past. UNKNOWN = 0.Float32 |
Float32 | source.power.current | A | Battery current. |
Float32 | source.power.voltage | V | Battery voltage. |
Float32 | source.energy | J | A pessimistic estimate of the amount of energy that can be reclaimed from the source in its current state. |
Float32 | source.full_energy | J | A pessimistic estimate of the amount of energy that can be reclaimed from a fresh source (a fully charged battery) under the current conditions. |
Type | Name | Unit | Description |
Uint2 | heartbeat.readiness* | - | SLEEP = 0, STANDBY = 2, ENGAGED = 3. |
Uint2 | heartbeat.health* | - | SLEEP = 0, STANDBY = 2, ENGAGED = 3. |
Float32[2] | temperature_min_max | K | The minimum and maximum readings of the pack temperature sensors. |
Float32 | available_charge | C | The estimated electric charge currently stored in the battery. |
Uint8 | error* | - | Error status. NONE = 0, BAD_BATTERY = 10, NEEDS_SERVICE = 11, BMS_ERROR = 20, CONFIGURATION = 30, OVERDISCHARGE = 50, OVERLOAD = 51, CELL_OVERVOLTAGE = 60, CELL_UNDERVOLTAGE = 61, CELL_COUNT = 62, TEMPERATURE_HOT = 100, TEMPERATURE_COLD = 101. |
Float16[<=255] | cell_voltages | V | The voltages of individual cells in the battery pack. |
Type | Name | Unit | Description |
Uint64 | unique_id | - | Unique number. |
Float32 | mass | Kg | The total mass of the battery. |
Float32 | design_capacity | C | Design capacity. |
Float32 | design_cell_voltage_min_max | V | Factory cell voltages. |
Float32 | discharge_current | A | The discharge current. |
Float32 | discharge_current_burst | A | The burst discharge current at least for 5 seconds.. |
Float32 | charge_current | A | The charge current. |
Float32 | charge_current_fast | A | The fast charge current. |
Float32 | charge_termination_treshold | A | End-of-charging current. |
Float32 | charge_voltage | V | Total charging voltage. |
Uint16 | cycle_count | - | The amount of cycles. |
Uint16 | Void16 | - | Was cell count. |
Uint7 | state_of_health_pct | % | The state of health. |
Uint8 | technology.value | - | Battery chemistry 110 = LiPo, 111 = LiFePO4. |
Float32 | nominal_voltage | V | The nominal battery voltage. |
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.
This page will have information about the UAVCAN communication
Connect the UAVCAN device (like the RDDRONE-UCANS32K146) to the BMS using 2x JST-GH 4 pin connectors with 1 on 1 wires. End the CAN bus with a 120Ω terminator resistor between CAN high and CAN low.
Make sure you Connect the UCAN board with a USB-TTL-3V3 cable to the laptop.
Install the can utils with the following terminal command:
o sudo apt install can-utils
Install python 3.7 with the following terminal command:
o sudo apt install python3.7
Install pyuavcan with the following terminal command:
o python3.7 -m pip install pyuavcan
Start the deamon on UART <-> SLCAN to use SLCAN0 use the command (for ttyUSB1): o sudo slcand -o -s8 -t sw -S 115200 /dev/ttyUSB1
Keep in mind that in this case the UART of the UCAN board needs to be connected to ttyUSB1. One can check which USB it is by disconnecting the USB-TTL-3V3 cable connected to the UCAN board, write “ls /dev” in the terminal, connect the USB cable and write “ls /dev” again. Only the USB of the UCAN board should be added in the list. If not check if the USB connection of the used virtual machine is passed through.
Enable the interface (up)(same as ifup can0 in nuttx) write the following command: o sudo ip link set up slcan0
Clone the cannode v1 tools:
o git clone
Make sure the sub modules are in the git repository write the following command in the cannode-v1_tools directory:
o git submodule update --init
Find this line in print_battery_service.py:
o media = pyuavcan.transport.can.media.socketcan.SocketCANMedia('vcan0', mtu=8)
Change it to the right can device, for example:
o media = pyuavcan.transport.can.media.socketcan.SocketCANMedia('slcan0', mtu=8)
Run the pyuavcan tool by typing the following in a terminal where the print_bmsstatus_topic.py file is located:
o python3.7 print_battery_service
Check if the subject IDs of the messages are correct
Uavcan_es_sub_id should be 4096.
Uavcan_bs_sub_id should be 4097.
Uavcan_bp_sub_id should be 4098.
Check if the node id of the BMS is not 225
o In the CLI of the BMS type “bms get uavcan-node-static-id”, if this is 255, it needs to be changed to another value (like 12). Do this with “bms set uavcan-node-static-id 12”
o After that save it and reboot the bms with “bms save” and “reboot”.
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.
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 NUTT-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
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 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.
A line means this is not implemented yet.
*these parameters will only be implemented during startup of the BMS
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 (defaults))
0
RO
4
i-batt-10s-avg
A
float
The 10s rollling average current, updated each 1s with T_meas 1000 (ms)
0
RO
5
s-out
-
bool
This is true if the output power is enabled
0
RO
6
s-in-flight
-
bool
This is true if the system is in flight (with flight-mode-enable and i-flight-mode)
0
RO
7
p-avg
W
float
Average power consumption over the last
10 seconds
0
RO
8
e-used
Wh
float
Power consumption since device boot
0
RO
9
a-rem
Ah
float
Remaining capacity in the battery
0
RW
10
a-full
Ah
float
Full charge capacity, predicted battery capacity when it is fully charged. Falls with aging
4.6
RW
11
t-full
h
float
Charging is expected to complete in this
time; zero if not charging
0
RO
12
s-flags
-
uint8_t
This contains the status flags as
described in BMS_status_flags_t
255
RO
13
s-health
%
uint8_t
Health of the battery in percentage, use
STATE_OF_HEALTH_UNKNOWN = 127
if cannot be estimated
127
RO
14
s-charge
%
uint8_t
Percentage of the full charge 0, 100
0
RO
15
batt-id
-
uint8_t
Identifies the battery within this vehicle,
0 - primary battery.
0
RW
16
model-id
-
uint64_t
Model id, set to 0 if not applicable
0
RW
17
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
18
v-cell1
V
float
The voltage of cell 1
0
RO
19
v-cell2
V
float
The voltage of cell 2
0
RO
20
v-cell3
V
float
The voltage of cell 3
0
RO
21
v-cell4
V
float
The voltage of cell 4
0
RO
22
v-cell5
V
float
The voltage of cell 5
0
RO
23
v-cell6
V
float
The voltage of cell 6
0
RO
24
c-afe
C
float
The temperature of the analog front end
0
RO
25
c-t
C
float
The temperature of the transistor
0
RO
26
c-r
C
float
The temperature of the sense resistor
0
RO
27
n-charges
-
uint16_t
The number of charges done
0
RW
28
n-charges-full
-
uint16_t
The number of complete charges
0
RW
29
Parameter
Unit
Datatype
Description
Default
RO/RW
No
n-cells
-
uint8_t
Number of cells used in the BMS board
3
RW
30
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
31
t-ftti
ms
uint16_t
Cycle of the battery to perform diagnostics (Fault Tolerant Time Interval)
1000
RW
32
t-cyclic
s
uint8_t
Wake up cyclic timing of the AFE (after front end) during sleep mode
1
RW
33
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
34
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
35
v-cell-uv
V
float
Battery minimum allowed voltage for one cell. Going below this voltage, the BMS will go to fault mode (followed by deepsleep after t-fault-timeout)
3
RW
36
v-cell-nominal
V
float
Battery nominal voltage for one cell. will be used for energy calculation
3.7
RW
37
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
38
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
39
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
40
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
41
a-factory
Ah
float
Battery capacity stated by the factory
4.6
RW
42
t-bms-timeout
s
uint16_t
Timeout for the BMS to go to SLEEP mode when the battery is not used.
600
RW
43
t-fault-timeout
s
uint16_t
After this timeout, with an undervoltage fault the battery will go to DEEPSLEEP mode to preserve power. 0 sec is disabled.
60
RW
44
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
45
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
46
t-cb-delay
s
uint8_t
Time for the cell balancing function to start after entering the CHARGE mode
120
RW
47
t-charge-relax
s
uint16_t
Relaxation time after the charge is complete before going to another charge round.
300
RW
48
i-charge-full
mA
uint16_t
Current threshold to detect end of charge sequence
50
RW
49
i-system
mA
uint8_t
Current of the BMS board itself, this is measured (as well) during charging, so this needs to be subtracted
40
RW
50
i-charge-max
A
float
Maximum current threshold to open the switch during charging
9.2
RW
51
i-charge-nominal
A
float
Nominal charge current (informative only)
4.6
RW
52
i-out-max
A
float
Maximum current threshold to open the switch during normal operation, if not overruled
60
RW
53
i-peak-max
A
float
Maximum peak current threshold to open the switch during normal operation, can't be overruled
200
RW
54
i-out-nominal
A
float
Nominal discharge current (informative only)
60
RW
55
i-flight-mode
A
float
Current threshold to not disable the power in flight mode
5
RW
56
v-cell-margin
mV
uint8_t
Cell voltage charge margin to decide or not to go through another topping charge cycle
50
RW
57
v-recharge-margin
mV
uint16_t
Cell voltage charge complete margin to decide or not to do a battery re-charge, to keep the cell voltages at max this much difference with the cell-ov
200
RW
58
t-ocv-cyclic0
s
int32_t
OCV measurement cyclic timer start (timer is increase by 50% at each cycle)
300
RW
59
t-ocv-cyclic1
s
int32_t
OCV measurement cyclic timer final value (limit)
86400
RW
60
c-pcb-ut
C
float
PCB Ambient temperature under temperature threshold
-20
RW
61
c-pcb-ot
C
float
PCB Ambient temperature over temperature threshold
45
RW
62
v-storage
V
float
The voltage what is specified as storage voltage for a cell
3.8
RW
63
ocv-slope
mV/A.min
float
The slope of the OCV curve. This will be used to calculate the balance time
5.3
RW
64
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
65
battery-type
-
uint8_t
The type of battery attached to it. 0 = LiPo, 1 = LiFePo4, 2 = LiFeYPo4. Could be extended. Will change OV, UV, v-storage, OCV/SoC table if changed runtime
0
RW
66
sensor-enable
-
bool
This variable is used to enable or disable the battery temperature sensor, 0 is disabled, 1 is enabled
0
RW
67
self-discharge-enable
-
bool
This variable is used to enable or disable the SELF_DISCHARGE state, 0 is disabled, 1 is enabled
1
RW
68
flight-mode-enable
-
bool
This variable is used to enable or disable flight mode, is used together with i-flight-mode
0
RW
69
emergency-button-enable
-
bool
This variable is used to enable or disable the emergency button on PTE8
0
RW
70
smbus-enable
-
bool
This variable is used to enable or disable the SMBus update
0
RW
71
uavcan_node_static_id*
-
uint8_t
This is the node ID of the UAVCAN message
255
RW
72
uavcan-es-sub-id*
-
uint16_t
This is the subject ID of the energy source UAVCAN message (1...100Hz)
4096
RW
73
uavcan-bs-sub-id*
-
uint16_t
This is the subject ID of the battery status UAVCAN message (1Hz)
4097
RW
74
uavcan-bp-sub-id*
-
uint16_t
This is the subject ID of the battery parameters UAVCAN message (0.2Hz)
4098
RW
75
uavcan-legacy-bi-sub-id*
-
uint16_t
This is the subject ID of the battery info legacy UAVCAN message (0.2 ~ 1Hz)
65535
RW
76
uavcan-fd-mode*
-
uint8_t
If true CANFD is used, otherwise classic CAN is used
0
RW
77
uavcan-bitrate*
bit/s
int32_t
The bitrate of classical can or CAN FD arbitration bitrate
1000000
RW
78
uavcan-fd-bitrate*
bit/s
int32_t
The bitrate of CAN FD data bitrate
4000000
RW
79
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
80
v-max
V
uint8_t
Maximum stack voltage allowed by the BMS board
26
RW
81
i-range-max
A
uint16_t
Maximum current that can be measured by the BMS board
300
RW
82
i-max
A
uint8_t
Maximum DC current allowed in the BMS board (limited by power dissipation in the MOSFETs)
60
RW
83
i-short
A
uint16_t
short circuit current threshold (typical: 550A, min: 500A, max: 600A)
500
RW
84
t-short
us
uint8_t
Blanking time for the short circuit detection
20
RW
85
i-bal
mA
uint8_t
Cell balancing current under 4.2V with cell balancing resistors of 82 ohms
50
RW
86
m-mass
kg
float
The total mass of the (smart) battery
0
RW
87