Thanks for answering.
I’m stuck with 3.2.1 because I have been unable to compile PixHawk code despite trying multiple times…
The reason for my question is that I have noticed three weaknesses in the APM 3.2.1 FW:
It will ARM when the voltage is below the battery failsafe value. I’m using a 4 Cell battery and the failsafe battery voltage is set to 13V, yet it will arm when the battery voltage is 12.2V.
If the user flies for awhile, disconnects the battery and later reconnect it to fly again, the percentage left resets to 100%, even though the battery is now half empty. This might be OK when flying around the park and the 'copter can make it back to launch, but it isn’t good when flying a longer mission.
I have had a case where a battery suddenly lost a lot of capacity - it was rated at 10,000 mAH, but actually held about half that. The 'copter was on a long mission when I noticed that even though the calculated remaining was 40%, the battery voltage was 12V and falling fast… It did not make it “home” because it was too far away.
I want to add a battery “health” term to the failsafe, so that if the battery voltage is below 13.6V and the remaining percentage is above 80% a FAILSAFE is triggered. Likewise, I want to trigger failsafes if the battery voltage is below 13.2 and the remaining percentage is > 60 and also if the battery voltage is below 12.8 and the percentage is > 40.
Finally, I want to prevent arming when a battery failsafe has been issued.
The addition of these extra conditions should prevent a launch with a partially depleted battery, and should bring the craft home early if a degraded battery is used.
I added a variable “_batt_numcells” that defaults to 4.
In my added code below, I thought that returning a “TRUE” would trigger failsafe and also prevent the craft from arming, but it does not. What am I doing wrong? The following is taken from my modified AP_BattMonitor library.
// check capacity if current monitoring is enabled
if((_monitoring == AP_BATT_MONITOR_VOLTAGE_AND_CURRENT) && (min_capacity_mah > 0) &&
(_pack_capacity - _current_total_mah < min_capacity_mah)) {
return true;
}
// check battery health - Added by Clinquist
if ((_voltage < (_batt_numcells * 3.4f)) && (capacity_remaining_pct() > 80)) {
return true;
}
if ((_voltage < (_batt_numcells * 3.3f)) && (capacity_remaining_pct() > 60)) {
return true;
}
if ((_voltage < (_batt_numcells * 3.2f)) && (capacity_remaining_pct() > 40)) {
return true;
}
// end check battery health