/
6S Power Module

6S Power Module

Project repo: GitHub - UWARG/efs-can-power-module: WARG 6s power module firmware with DroneCAN interface supported

Specifications (from the EE Team)

Overall Hardware Architecture (taken from https://uwarg-docs.atlassian.net/wiki/x/AoCsmQ )

Background

The drone uses a battery pack containing 12 cells, where 2 groups of 6 cells are each connected in series (hence 6S).

Each group of 6 cells is connected to a battery monitoring circuit (shortened as BMC later).

This circuit measures:

  • The voltage of each cell

  • The current delivered by the group

    • This is done by forcing the battery to deliver current through a resistor with a tiny resistance. This resistor, called a shunt/shunt resistor, follows Ohmโ€™s law: V=IR

    • This implies that I=V/R, which means that the current passing through a shunt is equal to its voltage (which can be measured easily), divided by its resistance (which is a known constant).

And it sends:

We are not exactly sure of everything yet.

  • Battery-related information relating to the voltages and currents

  • The voltage and current information are sent as 2 analog signals, which our microcontroller converts to digital ones via an Analog-to-Digital Converter (ADC).

  • Some other information is sent via the I2C protocol

Description

  • MCU (STM32xX) in the top right is the microcontroller that we are writing the code to

  • Its job is to translate the messages it receives from the BQ76925 6s LiPo Battery Monitor boards and send the corresponding messages to the flight controller (FC) using the CAN protocol

    • The flight controller we are using is a Pixhawk 4, which runs the Ardupilot firmware

    • Because battery voltages and currents will change over time, the โ€œtranslationโ€ is continuous

The FC needs this information to make other decisions, e.g. if a part is consuming too much power, or when to land

Specific Hardware Information (taken from https://uwarg-docs.atlassian.net/wiki/x/HYBXq)

308fff19-3cb7-4e74-b29c-ef6484d78e5b-0000.png
MCU Schematics

ย Current Roadblocks

Tasks Break Down:

ย Action Items

Initialize the Battery Monitoring Circuit using I2C
Read battery data using the specified ports

ย Milestones

Understand project specifications
Understand the I2C protocol
Understand the CAN protocol
Understand DroneCAN
etc.

Open Questions


ย Reference materials

Relevant protocols

Project Resources

Battery Monitoring Circuit

Datasheet: BQ76925

  • Addressing: all I2C addresses are calculated using the formula

    ADDRESS = 0x20 + REG_ADDR

Where ADDRESS is the real address to read/write to, and REG_ADDR is the register address mentioned on the datasheet, from 0x00 to 0x1F.
Remember this distinction between the real and register addresses. All I2C addresses you see after this point will be register addresses.

Source: Datasheet, 8.5.1.1 I2C Addressing

  • Selecting the cell for the VCOUT pin:
    To select the cell to measure the voltage of:

    // Write to the register address: REG_ADDR = 0x01 // With data: DATA = 0x10 + CELL

Where CELL is the cell number. CELL=0x0 refers to cell 1, CELL=0x1 refers to cell 2, and so on, up to CELL=0x5referring to cell 6.

Source: Datasheet, 8.6.1 Register Descriptions (Tables 6 to 8)

  • Reference voltage selection:

    // Write to the register address: REG_ADDR = 0x04 // With data: DATA = REF_SEL

Where REF_SEL can be set to 0 or 1, with the following effects on the BMC pins:

Table 14. Reference Voltage Selection

REF_SEL

VREF (V)

VCOUT Gain (V)

VIOUT Voltage Range (V)

REF_SEL

VREF (V)

VCOUT Gain (V)

VIOUT Voltage Range (V)

0

1.5

0.3

0.25 - 1.25

1

3.0

0.6

0.5 - 2.5

Yes, itโ€™s true that you could also enable CRC with this memory address. To do that, add 0x80 to DATA above.

We havenโ€™t decided whether we want CRC though, so right now weโ€™ll use the default optionโ€ฆ which is โ€œdisabledโ€œ.

Source: Datasheet, 8.6.1 Register Descriptions (Tables 13 and 14)

  • Cell Voltage Monitoring

Several values can be accessed through the I2C interface:

Value to access

I2C register address

Data bit locations

Value to access

I2C register address

Data bit locations

VCn_GC_4 [n=1]

0x17

6

VCn_GC_4 [n=2]

0x17

4

VCn_GC_4 [n=3]

0x18

6

VCn_GC_4 [n=4]

0x18

4

VCn_GC_4 [n=5]

0x18

2

VCn_GC_4 [n=6]

0x18

0

VCn_OC_4 [n=1]

0x17

7

VCn_OC_4 [n=2]

0x17

5

VCn_OC_4 [n=3]

0x18

7

VCn_OC_4 [n=4]

0x18

5

VCn_OC_4 [n=5]

0x18

3

VCn_OC_4 [n=6]

0x18

1

VREF_OC_5

0x1b

2

VCn_GAIN_CORR

ย 

ย 

Source: Datasheet, 8.3.2.2 Cell Voltage Monitoring

Up-to-date electrical schematics from the EE team

Project 6s Power Module (Ask the EE team for access)

Receiving incoming messages (Polling/Interrupt/DMA)

We are going to receive messages from an external device (the BMC), but we canโ€™t predict when we will receive them. There are 3 solutions to this:

  • Polling: repeatedly checking whether a message was received using a loop. If a message gets detected, it gets processed, then the loop continues. This is a purely software solution.

    • Advantages:

      • Very easy to implement

      • You donโ€™t need to worry about race conditions (when multiple pieces of code unintentionally access and modify some variable at the same time)

    • Disadvantages:

      • Extremely inefficient. The loop eats up most of the microcontrollerโ€™s computational resources, which it needs for many other tasks.

  • Interrupt: when a message gets received, it triggers a hardware interrupt. This causes all other processes to stop. Then the message gets processed, and the other processes resume after that. STM32 microcontrollers support many internal interrupts (for common events like receiving an I2C message), and external interrupts (triggered by a GPIO pin).

    • Advantages:

      • More efficient than polling

    • Disadvantages:

      • You need to be careful about race conditions

      • Still needs the microcontroller for data reception

  • Direct Memory Access (DMA): Similar to an interrupt, except the peripheral writes its message directly to the microcontrollerโ€™s memory. Then it signals the microcontroller that a new message came.

    • Advantages:

      • Most efficient for large messages

    • Disadvantages:

      • You need to be careful about race conditions

      • Less efficient than regular interrupts for small messages

ย 

Related content