BMS772 integration

In this tutorial you will learn how to integrate the BMS772 into the B3RB.

NOTE:

this notebook is under development.

It is important to take precautions when working with batteries:

  • Before connecting a battery to the BMS, test it first using a power supply which has current limiting enabled. See section: Setup validation. This is to avoid damage that could occur because of bad soldering, a short of some kind or swapped wires.

  • LiPo batteries can be dangerous and catch on fire. When first plugging in a LiPo battery, please do it outdoors in an area that is fire-safe. Have a fire extinguisher nearby.

Introduction

The RDDRONE-BMS772 is a standalone BMS reference design supporting 3 to 6 cell batteries.

The General Purpose MCU S32K144 provides great flexibility and communication to a PX4 based FMU via UAVCAN or I2C/SMBus. More information about the board can be found in references [1][2].

The BMS will be integrated in the system following the wiring diagram below:

Hardware setup

For setting up the hardware, we need:

  • prepare the 3D printed mount

  • solder connectors and make cables

  • solder the balance leads and make its extension cable

  • prepare a battery emulator setup

Prepare the 3D printed mount for the RDDRONE-BMS772 board

This particular 3D print will allow the RDDRONE-BMS772 to connect to the pre-production version of MR-B3RB lower chassis metal frame. Future versions may not need this adapter, or may be able to just use standoff's directly.

Solder connectors and make cables

We recommend pluggable cable connectors as shown below. Follow these images for guidance. Some XT60 connectors have a "back shell" to also help cover the solder joints. The backshell is preferable.

Balance leads connection

Because of the limited space on the B3RB. it is preferable to use a balancing leads connector that points upward. This will better clear the PDB that is adjacent to this board, and allow you to more easily plug in the battery's balancing cable later. Solder the white balance connector as shown below:

If you cannot obtain a vertical balance lead connector, while sub-optimal, the right angle connector that ships with the board may be modified to stand upright by removing the tabs at the rear. Be extra careful about the correct orientation and alignment

Balance leads extension cable

You will also need to make an extension cable for the balance leads connector. The leads that typically come as part of the battery is quite short. The suggested cable length is approximately 17cm.

The extension cable can act as a fuse. While the wires in the picture below are thin, they can blow up in case of short circuit, the a battery damage could be avoided.

Setup validation - emulating a battery

In this section we will prepare a setup to emulate the battery using a power supply. For this setup we need:

  • 4 x 1kΩ resistors

  • 2 wires: one black and one red

  • Female balance leads connector with wires

Here are the steps:

  1. Connect the female balance leads connector with wires and cut them to make them short.

  2. Solder the resistors in series then solder two cables in both sides (black and red) as depicted in the picture above. Please make sure that the sides of the black and red wires are similar to the picture.

  3. connect Black and red wires of the battery cells emulator to - and + input from the power supply.

  4. Set the voltage in your power supply to 12V, then plug the input port to the power supply and the output port to the load that you are powering.

Software setup in the BMS

You can compile a binary from this GitHub repository: https://github.com/NXPHoverGames/RDDRONE-BMS772 or flash the existing binary https://github.com/NXPHoverGames/RDDRONE-BMS772/blob/main/Binary/nuttx.bin (follow these instructions).

Activate the cyphal can and setup the can id:

nsh> bms set can-mode cyphal
nsh> bms set cyphal-node-static-id 100
nsh> bms save
nsh> reboot

Software setup in NavQP

In this section, we present three methods to display received messages via CAN:

  • using yakut CLI

  • using pycyphal library

  • using pycyphal library and ROS2

Prepare environment variables and DSDL namespace

Before the three next steps, you need to prepare the environment variables and add the DSDL namespace as follow:

mkdir -p ~/.cyphal
wget https://github.com/OpenCyphal/public_regulated_data_types/archive/refs/heads/master.zip -O dsdl.zip
unzip dsdl.zip -d ~/.cyphal
mv -f ~/.cyphal/public_regulated_data_types*/* ~/.cyphal
export UAVCAN__NODE__ID=42 
export UAVCAN__CAN__IFACE=socketcan:can0
export UAVCAN__CAN__MTU=8
export CYPHAL_PATH=/home/user/.cyphal

Using Yakut CLI

Yakút is a simple cross-platform command-line interface (CLI) tool for diagnostics and debugging of Cyphal networks. (For more information refer to [3])

The BMS772 software is already publishing three messages:

  • type: reg.udral.physics.electricity.SourceTs_0_1, port: 4096

  • type: reg.udral.service.battery.Status_0_2, port: 4097

  • type: reg.udral.service.battery.Parameters_0_3, port: 4098

Print published Cyphal message in a terminal:

# yakut sub --with-metadata port:type
# Run the following commands in separate terminals

yakut sub --with-metadata 4096:reg.udral.physics.electricity.sourcets
yakut sub --with-metadata 4097:reg.udral.service.battery.status
yakut sub --with-metadata 4098:reg.udral.service.battery.parameters 

Using pycyphal library

First, clone the following repository:

git clone git@github.com:mounalbaccouch-nxp/BMS_cyphalcan.git

Run the script to print the received cyphal messages:

cd BMS_cyphalcan
python3.10 cyphal_bms_print_status.py

Using pycyphal library and ROS2

Clone the following repository:

git clone git@github.com:mounalbaccouch-nxp/BMS_cyphalcan.git

Run the ros2 node:

cd BMS_cyphalcan
python3.10 cyphal_bms_ros2-pub_status.py

Print the topic:

ros2 topic echo /battery_state

Once the topic is publishing battery state messages, we can display it in Foxglove. Fist add the topic to the while listed topics in robot.launch.py file

In your PC, download the following layout file and add it to Foxglove studio:

You should see two different tabs: one tab General for displaying the B3RB topics and one tab Battery for displaying the battery status raw data:

References

[1] BMS gitbook: https://nxp.gitbook.io/rddrone-bms772/software-guide-px4/introduction

[2] https://www.nxp.com/design/design-center/designs/smart-battery-management-for-mobile-robotics:RDDRONE-BMS772

[3] https://github.com/OpenCyphal/yakut

Last updated