6S Power Module
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 toIts 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
Specific Hardware Information (taken from https://uwarg-docs.atlassian.net/wiki/x/HYBXq)
ย Current Roadblocks
Tasks Break Down:
ย Action Items
ย Milestones
Open Questions
What is
REF_SEL
set to for the battery monitoring boards?Are our speculated ports correct?
How should the MCU beacon itself to the FC (i.e. so that the FC is aware that the MCU on the power module is there)?
What should be sent over CAN? Possible options:
ย Reference materials
Relevant protocols
I2C: I2C - Inter-Integrated Circuit
I2C is all about registers (i.e. memory that can be accessed by an address)
Each I2C peripheral has its own register map (i.e. what the registers are used for, such as storing the voltage of a cell)
To read data from a peripheral, you send an address to it, and it will respond with data
To write data to a peripheral, you tell it which address to write to, and what data to write
CAN:
A general description of CAN: https://uwarg-docs.atlassian.net/wiki/x/BgDPlw
DroneCAN: a protocol built on top of CAN to communicate information between drone parts and the FC: DroneCAN
Libcanard: an implementation of DroneCAN for low-end microcontrollers. An example code on how to use it: libcanard/examples/SimpleNode/simple_node.c at master ยท dronecan/libcanard
EFS-Canard: a portable WARG version of the Libcanard library
AP-Periph has some example code on how to send DroneCAN messages when you have a specific type of device (e.g. a battery)
A helpful presentation on CAN: https://docs.google.com/presentation/d/12i6TiUuXQw5mO2u3pq8DMXTD1bCRe8rJtzVZRk6pDz0/edit?usp=sharing
A helpful document on CAN applications: https://uwarg-docs.atlassian.net/wiki/x/AwA8q
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
ย