-
Notifications
You must be signed in to change notification settings - Fork 24
RFC 0018 - Improved Battery Status Reporting #19
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
base: master
Are you sure you want to change the base?
Changes from 17 commits
f72ae85
4a719f2
496d464
657d762
5c684c6
8247fbc
cdfcac1
28b23db
f110cfa
3e56f60
f15e542
05be55e
cc94393
9033cc9
42cfe84
dc63056
1a2fb83
8372532
57d9d9b
bfa89c4
660d9c3
2e63457
199a2c6
1295684
5e530eb
c8915b8
9acf267
45c8361
7f464ed
41a7fb8
506de46
af11eaf
9d17b55
abe7dce
469e5c3
ff245bb
e4e9b57
8b9625f
acc9e73
d563499
0f678c7
8801ef4
e5aeab5
f84e83b
5d19e49
75bdacc
5fb3ff8
ab3d25f
5fa4be2
6aa86db
ce99827
8e2deb7
b5f65c0
ea508a7
c25344b
12561b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,178 @@ | ||||||
* Start date: 2022-03-26 | ||||||
* Contributors: Hamish Willee <hamishwillee@gmail.com>, ... | ||||||
* 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) | ||||||
- [Add MAV_BATTERY_CHARGE_STATE_CHARGING #1068](https://github.com/mavlink/mavlink/pull/1068) | ||||||
|
||||||
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. | ||||||
|
||||||
|
||||||
# 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 proposed message is: | ||||||
|
||||||
```xml | ||||||
<message id="???" name="BATTERY_STATUS_V2"> | ||||||
<description>Battery dynamic information. This should be streamed (nominally at 1Hz). Static battery information is sent in 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Is there a need to support more than 255 batteries? @AlexKlimaj thoughts? Would you ever go bigger than 255 in your box? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope not. That feels like excessive future proofing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean .. maybe ... is it? What if someone wanted to replace autopilot with ardupilot? 🤨 see what I did there I rhymed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dakejahl And you wonder why nobody likes you :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. haha ouch but you're wrong I am beloved. But no in DroneCAN I think it can make sense, probably not mavlink There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah yeah :-). I'm going to say no "right now". Yes this might come back and bite us, but it feels like a waste. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've thought about that one before too..... For mavlink no reason to waste space. |
||||||
<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="uint8_t" name="percent_remaining" units="%" invalid="UINT8_MAX">Remaining battery energy. Values: [0-100], UINT32_MAX: Remaining battery energy is not provided.</field> | ||||||
<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="uint32_t" name="fault_bitmask" display="bitmask" enum="MAV_BATTERY_FAULT">Fault/health/ready-to-use indications.</field> | ||||||
</message> | ||||||
``` | ||||||
|
||||||
With `MAV_BATTERY_FAULT` having the following **additions** (from `MAV_BATTERY_CHARGE_STATE` and `MAV_BATTERY_MODE`): | ||||||
hamishwillee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
```xml | ||||||
<enum name="MAV_BATTERY_FAULT" bitmask="true"> | ||||||
<description>Battery supply status flags (bitmask) indicating battery health and readiness for flight.</description> | ||||||
... | ||||||
<entry value="512" name="BATTERY_FAULT_CHARGING"> | ||||||
<description>Battery is charging. Not ready to use.</description> | ||||||
</entry> | ||||||
<entry value="1024" name="BATTERY_FAULT_AUTO_DISCHARGING"> | ||||||
<description>Battery is auto discharging (towards storage level). Not ready to use.</description> | ||||||
</entry> | ||||||
<entry value="1024" name="BATTERY_FAULT_HOT_SWAP"> | ||||||
hamishwillee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
<description>Battery in hot-swap mode (current limited to prevent spikes that might damage sensitive electrical circuits). Not ready to use.</description> | ||||||
</entry> | ||||||
``` | ||||||
|
||||||
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. | ||||||
- removes `energy_consumed`. This essentially duplicates `current_consumed` for most purposes, and `current_consumed`/mAh is nearly ubiquitous. | ||||||
- removes `battery_function` and `type` (chemistry) as these are present in `SMART_BATTERY_INFO` and invariant. | ||||||
hamishwillee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
```xml | ||||||
<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> | ||||||
``` | ||||||
- A GCS that needs invariant information should read `SMART_BATTERY_INFO` on startup | ||||||
- A vehicle that allows battery swapping must stream `SMART_BATTERY_INFO` (at low rate) to ensure that battery changes are notifie (and ideally also emit it on battery change). | ||||||
hamishwillee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
- Removes [`charge_state`](https://mavlink.io/en/messages/common.html#MAV_BATTERY_CHARGE_STATE) [`mode`](https://mavlink.io/en/messages/common.html#MAV_BATTERY_MODE) | ||||||
```xml | ||||||
<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> | ||||||
``` | ||||||
- The state is almost all inferred from the battery remaining. Traditionally the GCS sets appropriate levels for warning - the battery has a less accurate view on appropriate warning levels for a particular system, making this redundant. The exception is charging status. | ||||||
- The mode is reasonable enough, but can be expressed as a fault "there is a concern with using this battery". | ||||||
|
||||||
|
||||||
|
||||||
#### Questions | ||||||
|
||||||
- Do we need all the other fields? | ||||||
- Are there any other fields missing? | ||||||
- `current_consumed`, `percent_remaining`, `time_remaining` all tell much the same story, and can be estimated from each other. Do we need all of these, and if so which ones? | ||||||
hamishwillee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
- Should we have `MAV_BATTERY_FAULT` for critical level "just before deep discharge"? The battery can know this, and it might prevent over discharge. | ||||||
```xml | ||||||
<entry value="1024" name="BATTERY_FAULT_CRITICAL_LEVEL"> | ||||||
<description>Battery is at critically low level. Undamaged, but not ready to use.</description> | ||||||
</entry> | ||||||
``` | ||||||
- Should we have `MAV_BATTERY_FAULT` summarising "not ready to use"? Simplifies things for GCS/user as unhealthy vs you can't use this at all. | ||||||
```xml | ||||||
<entry value="1024" name="BATTERY_FAULT_NOT_READY"> | ||||||
<description>Battery is not ready/safe to use. Check other bitmasks for reasons.</description> | ||||||
</entry> | ||||||
``` | ||||||
|
||||||
- | ||||||
|
||||||
## Battery Cell Voltages | ||||||
|
||||||
The proposed battery message is: | ||||||
|
||||||
```xml | ||||||
<message id="???" name="BATTERY_CELL_VOLTAGES"> | ||||||
<description>Battery cell voltages. | ||||||
This message is provided primarily for cell fault debugging. | ||||||
For batteries with more than 10 cells the message should be sent multiple times, iterating the index value. | ||||||
It should not be streamed at very low rate (less than once a minute) or streamed only on request.</description> | ||||||
<field type="uint8_t" name="id" instance="true">Battery ID</field> | ||||||
<field type="uint8_t" name="index">Cell index (0 by default). This can be iterated for batteries with more than 12 cells.</field> | ||||||
<field type="uint16_t[12]" name="voltages" units="mV" invalid="[0]">Battery voltage of 12 cells at current index. Cells above the valid cell count for this battery should be set to 0.</field> | ||||||
</message> | ||||||
``` | ||||||
|
||||||
Cell voltages can be used to verify that poorly performing batteries have failing cells, and to providing early warning of longer term battery degradation. | ||||||
It is useful to have long term trace information in logs, but not necessary for this to be at particularly high rate. | ||||||
Therefore the message provides all information about the battery voltages, but is expected to be sent at low rate, or on request. | ||||||
|
||||||
As designed, the message will not be zero-byte truncated (field re-ordering means that the array is last). | ||||||
The message might be modified to make: | ||||||
- `voltages` an extension field. For a 4S battery this would save 12 bytes per message but lose checking. If we do this we might as well mandate "no extension". | ||||||
- `id` and `index` into `uint16_t`. For a 4S battery this would save 10 bytes per message,and retain mavlink checking on field. It would cost 2 additional bytes on every new message. | ||||||
|
||||||
|
||||||
#### Alternatives | ||||||
|
||||||
An alternative is just to send fault information. | ||||||
This assumes that the smart battery is capable of providing the long term trend analysis that can be obtained from logs using the above message. | ||||||
|
||||||
```xml | ||||||
<message id="???" name="BATTERY_CELL_VOLTAGES"> | ||||||
<description>Battery cell fault information.</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> | ||||||
``` | ||||||
|
||||||
## SMART_BATTERY_INFO | ||||||
|
||||||
[SMART_BATTERY_INFO](https://mavlink.io/en/messages/common.html#SMART_BATTERY_INFO) is already deployed and it is not clear if it can be modified. It may be possible to extend. | ||||||
|
||||||
Add note that it must be streamed at a low rate in order to allow detection of battery change, and should also be sent when the battery changes. | ||||||
|
||||||
Questions: | ||||||
- What low rate is OK for streaming? is there another alternative for tracking battery change | ||||||
|
||||||
hamishwillee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
||||||
|
||||||
## Migration/Discovery | ||||||
|
||||||
`BATTERY_STATUS` consumes significant bandwidth: sending `BATTERY_STATUS_V2` at the same time would just increase the problem. | ||||||
|
||||||
The proposal here is that GCS should support both messages for the forseeable future. | ||||||
Flight stacks should manage their own migration after relevant ground stations have been updated. | ||||||
|
||||||
|
||||||
# Alternatives | ||||||
|
||||||
TBD | ||||||
|
||||||
# Unresolved Questions | ||||||
|
||||||
TBD | ||||||
|
||||||
# References | ||||||
|
||||||
* ? | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.