-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Fixed reporting of battery voltages in uORB #14151
Conversation
FYI @AlexKlimaj |
One issue I see with this is that uavcan does not transmit the number of cells. So the uavcan battery driver would need the N cells param set by the user. |
@julianoes Thanks for asking, like @ItsTimmy describes nicely the difference is that before my fix it wasn't possible to report the real cell voltages via MAVLink and with this pr it's just populating them with fake divided by cell count values for the main power module ADC source that does not allow cell voltage measurement. I think the real solution is to
because if I get a cell voltage report I presume it's a cell voltage and not a calculated value and check for if all cell voltages "by accident" have exactly the same value to know it's not real cell voltages. Nevertheless, I think we should merge this pr as an in between solution to fix multi battery reporting. Can I quickly put some finishing touches and you review them? |
@ItsTimmy What about reporting one cell voltage the whole battery if cell voltage measurement is not supported? Would that work? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would do it this way: https://github.com/PX4/Firmware/compare/pr-battery-cell-voltages The rest of the fields is already zeroed in the reset.
@MaEtUgR I guess I don't really understand it. Would you mind just doing the change that you suggest? |
It's a private branch but I can open a new pr based on my branch if that's ok with @ItsTimmy |
I opened one as a possible replacement: #14533 |
Describe problem solved by this pull request
The
Battery
library does not populate the fieldvoltage_cell_v
ofbattery_status
uORB message, because the analog power monitor and INA226 power monitor cannot measure individual cells. To get around this, themavlink
module populated theBATTERY_STATUS
MAVLink message by dividing the total voltage by the number of cells. This was fixed in #13936, so themavlink
module now uses thevoltage_cell_v
field of thebattery_status
uORB message.The issue now is that the MAVLink
BATTERY_STATUS
message does not have a field for total voltage, only for individual cell voltages. However,SYS_STATUS
only has one field for battery voltage. So, to report the voltage of multiple batteries to the ground station, multiple instances ofBATTERY_STATUS
are sent. Therefore, to properly report the status of multiple batteries, one of two things must happen:BATTERY_STATUS
message must be populatedtotal_voltage
field toBATTERY_STATUS
Describe your solution
This PR replicates the old behavior, of dividing the total voltage by the number of cells. However, this is now done in the
Battery
library rather than in themavlink
module, so it only affects power monitors that were not measuring individual cell voltage anyway.As discussed in #13936, this is not ideal, because it can give the impression that every cell is fine, even if one is dying. There should be a discussion about the best way to solve this issue. This PR just gives one possible solution.
Describe possible alternatives
The
BATTERY_STATUS
MAVLink message could be changed to add atotal_voltage
field, so that any power monitor can reliably report only the information that it actually measures.Test data / coverage
This was tested on both a v5x with INA226 power monitors and a Pixhawk 4 with analog power monitors. In both cases, two different batteries with 2 different cell counts were used. The uORB
battery_status
message, and MAVLinkBATTERY_STATUS
message, and the voltage reported in the AGS UI were all verified.