Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC 0018 - Improved Battery Status Reporting #19

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
f72ae85
RFC 0018 - BATTERY_STATUS v2
hamishwillee Mar 24, 2022
4a719f2
Update text/001x-battery_improvements.md
hamishwillee Mar 30, 2022
496d464
Remove energy_consumed - not required (developer feedback)
hamishwillee Mar 30, 2022
657d762
Remove type and function from v2 battery status
hamishwillee Mar 30, 2022
5c684c6
Remove question on removing the battery type/function (answered)
hamishwillee Mar 30, 2022
8247fbc
Update text/001x-battery_improvements.md
hamishwillee Mar 30, 2022
cdfcac1
Propose updated Battery cell voltage message
hamishwillee Mar 30, 2022
28b23db
Add charge state
hamishwillee Mar 30, 2022
f110cfa
Update text/001x-battery_improvements.md
hamishwillee Mar 30, 2022
3e56f60
Update text/001x-battery_improvements.md
hamishwillee Mar 30, 2022
f15e542
Update text/001x-battery_improvements.md
hamishwillee Mar 30, 2022
05be55e
Add note about duplication
hamishwillee Mar 30, 2022
cc94393
Add question about charge states into questions
hamishwillee Mar 30, 2022
9033cc9
Update 001x-battery_improvements.md
hamishwillee Mar 30, 2022
42cfe84
Update 001x-battery_improvements.md
hamishwillee Mar 30, 2022
dc63056
Propose removal of mode and charging state into fault
hamishwillee Mar 31, 2022
1a2fb83
percent_remaining is a uint8
hamishwillee Apr 6, 2022
8372532
Update text/001x-battery_improvements.md
hamishwillee Apr 6, 2022
57d9d9b
Remove time_remaining
hamishwillee Apr 6, 2022
bfa89c4
Add doc that percent_remaining is proposed as uint8
hamishwillee Apr 6, 2022
660d9c3
Update 001x-battery_improvements.md
hamishwillee Apr 7, 2022
2e63457
change `current` from a `int16_t` (cA) to a `int32_t`
hamishwillee Apr 7, 2022
199a2c6
Update 001x-battery_improvements.md
hamishwillee Apr 7, 2022
1295684
Make current_consumed a uint32
hamishwillee Apr 7, 2022
5e530eb
Clarify temp is "whole battery" not internal electronics
hamishwillee Apr 7, 2022
c8915b8
Add dronecan alignment as a key driver and link to the WIP discussion
hamishwillee Apr 14, 2022
9acf267
Update on handling power monitors
hamishwillee Apr 14, 2022
45c8361
Battery now has status flags
hamishwillee Apr 14, 2022
7f464ed
Missed a couple of faults. Added now
hamishwillee Apr 14, 2022
41a7fb8
Clarify current consumed is from vehicle being powered on
hamishwillee Apr 20, 2022
506de46
Update text/001x-battery_improvements.md
hamishwillee Apr 20, 2022
af11eaf
Update text/001x-battery_improvements.md
hamishwillee Apr 20, 2022
9d17b55
Remove cell fail fault - not needed according to jacob
hamishwillee Apr 20, 2022
abe7dce
Update text/001x-battery_improvements.md
hamishwillee Apr 20, 2022
469e5c3
Update text/001x-battery_improvements.md
hamishwillee Apr 20, 2022
ff245bb
add ids for messages close to smart battery info
hamishwillee Jun 1, 2022
e4e9b57
Add flag to indicate whether values are assumed to be re;ative full b…
hamishwillee Jun 2, 2022
8b9625f
Reserve final value of status flag for later extension
hamishwillee Jun 2, 2022
acc9e73
Update text/001x-battery_improvements.md
hamishwillee Jun 2, 2022
d563499
Update text/001x-battery_improvements.md
hamishwillee Jun 2, 2022
0f678c7
Update text/001x-battery_improvements.md
hamishwillee Jun 2, 2022
8801ef4
Battery might be OK to use during charging
hamishwillee Jun 2, 2022
e5aeab5
Update text/001x-battery_improvements.md
hamishwillee Jun 2, 2022
f84e83b
current to int32
hamishwillee Jun 2, 2022
5d19e49
Add the smart battery standard DS-013
hamishwillee Jun 2, 2022
75bdacc
Typo
hamishwillee Jun 2, 2022
5fb3ff8
MAV_BATTERY_STATUS_FLAGS_READY_TO_USE to MAV_BATTERY_STATUS_FLAGS_NOT…
hamishwillee Jun 3, 2022
ab3d25f
improve description not ready to fly
hamishwillee Jun 3, 2022
5fa4be2
Update text/001x-battery_improvements.md
hamishwillee Sep 21, 2022
6aa86db
Update text/001x-battery_improvements.md
hamishwillee Sep 21, 2022
ce99827
Update text/001x-battery_improvements.md
hamishwillee Sep 21, 2022
8e2deb7
Update text/001x-battery_improvements.md
hamishwillee Oct 12, 2022
b5f65c0
Update text/001x-battery_improvements.md
hamishwillee Oct 12, 2022
ea508a7
Update text/001x-battery_improvements.md
hamishwillee Oct 12, 2022
c25344b
Update text/001x-battery_improvements.md
hamishwillee Oct 13, 2022
12561b9
Update now that SMART_BATTERY_INFO was renamed to BATTERY_INFO
hamishwillee Feb 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions text/001x-battery_improvements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
* Start date: 2022-03-26
* Contributors: Hamish Willee <[email protected]>, ...
* Related issues:
- [16-cell support #1747](https://github.com/mavlink/mavlink/pull/1747)
- [common: added voltage and current multipliers to BATTERY_STATUS #233](https://github.com/ArduPilot/mavlink/pull/233)

hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved

# Summary

This RFC proposes:
- a new `BATTERY_STATUS_V2` message that has a single cumulative voltage value rather than individual cell voltage arrays.
- a new (optional) `BATTERY_VOLTAGES` message that can be scaled to as many cells as needed, and which reports them as faults.
- mechanisms to ease supporting both message types until we can eventually deprecate `BATTERY_STATUS`


# Motivation

The motivation is to:
- reduce the memory required for battery reporting ([anecdotal evidence](https://github.com/ArduPilot/mavlink/pull/233#issuecomment-976197179) indicates cases with 15% of bandwidth on a default RF channel).
- Provide a cleaner message and design for both implementers and consumers.

The [BATTERY_STATUS](https://mavlink.io/en/messages/common.html#BATTERY_STATUS) has two arrays that can be used to report individual cell voltages (up to 14), or a single cumulative voltage, and which cannot be truncated.
The vast majority of consumers are only interested in the total battery voltage, and either sum the battery cells or get the cumulative voltage.
By separating the cell voltage reporting into a separate message the new battery status can be much smaller, and the cell voltages need only be sent if the consumer is actually interested.

# Detailed Design

There are three parts to the design:
1. A more efficient status message
2. A scalable battery voltage message.
3. Mechanisms that allow the new messages to seamlessly coexist with the old one along with eventual deprecation of the older message.

## BATTERY_STATUS_V2

The message is heavily based on [BATTERY_STATUS](https://mavlink.io/en/messages/common.html#BATTERY_STATUS) but:
- removes the cell voltage arrays: `voltages` and `voltages_ext`
- adds `voltage`, the total cell voltage. This is a uint32_t to allow batteries with more than 65V.


```xml
<message id="???" name="BATTERY_STATUS_V2">
<description>Battery information. Updates GCS with flight controller battery status. Smart batteries also use this message, but may additionally send SMART_BATTERY_INFO.</description>
<field type="uint8_t" name="id" instance="true">Battery ID</field>
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
<field type="uint8_t" name="battery_function" enum="MAV_BATTERY_FUNCTION">Function of the battery</field>
<field type="uint8_t" name="type" enum="MAV_BATTERY_TYPE">Type (chemistry) of the battery</field>
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
<field type="int16_t" name="temperature" units="cdegC" invalid="INT16_MAX">Temperature of the battery. INT16_MAX for unknown temperature.</field>
<field type="uint32_t" name="voltage" units="mV" invalid="[UINT32_MAX]">Battery voltage (total).</field>
<field type="int16_t" name="current" units="cA" invalid="UINT16_MAX">Battery current (through all cells/loads). Positive if discharging, negative if charging. UINT16_MAX: field not provided.</field>
<field type="int32_t" name="current_consumed" units="mAh" invalid="-1">Consumed charge, -1: Current consumption estimate not provided.</field>
<field type="int32_t" name="energy_consumed" units="hJ" invalid="-1">Consumed energy, -1: Energy consumption estimate not provided.</field>
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
<field type="int8_t" name="battery_remaining" units="%" invalid="-1">Remaining battery energy. Values: [0-100], -1: Remaining battery energy is not provided.</field>
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
<field type="uint32_t" name="time_remaining" units="s" invalid="UINT32_MAX">Remaining battery time (estimated), UINT32_MAX: Remaining battery time estimate not provided.</field>
<field type="uint8_t" name="charge_state" enum="MAV_BATTERY_CHARGE_STATE">State for extent of discharge, provided by autopilot for warning or external reactions</field>
<field type="uint8_t" name="mode" enum="MAV_BATTERY_MODE">Battery mode. Default (0) is that battery mode reporting is not supported or battery is in normal-use mode.</field>
<field type="uint32_t" name="fault_bitmask" display="bitmask" enum="MAV_BATTERY_FAULT">Fault/health indications. These should be set when charge_state is MAV_BATTERY_CHARGE_STATE_FAILED or MAV_BATTERY_CHARGE_STATE_UNHEALTHY (if not, fault reporting is not supported).</field>
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
</message>
```


Questions:
- It is desirable to move static fields like the `type` (battery chemistry) and `battery_function` out of the new message because they only need to be read once, and afterwards are dead weight.
For this to be OK, the information either has to be non-essential (i.e might never be provided) or guaranteed to be sent in another message (this info is present in [SMART_BATTERY_INFO](https://mavlink.io/en/messages/common.html#SMART_BATTERY_INFO)).
- Is it non-essential?
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
- If it is essential, do we leave it in the message or mandate sending of `SMART_BATTERY_INFO`?
- Do we need all the other fields?
- Are there any other fields missing?


## Battery Voltages

The proposed battery message is below.

This assumes that the reason you might need the individual battery voltages is in order to identify that a particular cell has a significantly different voltage, and is hence in fault.
It simply sends information about which cells are in fault, providing battery manufacturers a way of reporting more detailed debugging information.

```xml
<message id="???" name="BATTERY_VOLTAGE_FAULT">
<description>Battery information. Updates GCS with flight controller battery status. Smart batteries also use this message, but may additionally send SMART_BATTERY_INFO.</description>
<field type="uint8_t" name="id" instance="true">Battery ID</field>
<field type="uint8_t" name="index">Cell index (0 by default). This is iterated for every 64 cells, allowing very large cell fault information. </field>
<field type="uint64_t" name="fault_mask">Fault/health indications. .</field>
</message>
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
```

## Migration/Discovery

`BATTERY_STATUS` consumes significant bandwidth: sending `BATTERY_STATUS_V2` at the same time would just increase the problem.

[
What are options here?
- Add support for either format in QGC/Mission Planner etc.
- Flight stack send `BATTERY_STATUS` but ground station can request BATTERY_STATUS_V2 and turn off BATTERY_STATUS_V2 using SET_INTERVAL?
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
- In a few releases we allow ground stations to set BATTERY_STATUS_V2 by default.
]



# Alternatives

TBD

# Unresolved Questions

TBD

# References
* ?