Battery scale computation

I am a little confused about battery scale computation and it’s use in the mc_rate_control module. I see that the scale is computed based on the state of charge (which seems to be the normalised cell_voltage) and the full cell voltage.

While calculating the state of charge of the cell, the internal resistance based voltage drop is added to the cell voltage to get the “true” state of charge. Then, in the rate controller the trust is simply scaled using the computed battery scale.

Now, my battery has an internal resistance of 6 mOhm and therefore has a higher drop in the voltage (than the default). It feels to me that the thrust setpoint is reduced instead of increased to compensate the drop in voltage. However, in the state of charge estimation, if the voltage drop was instead subtracted the scale would be higher leading to a higher thrust setpoint.

I believe this would be ideal for me as I want to use the attitude or rate controller in offboard mode. Please let me know if I am lost or if this is a known issue with a work around.

Thanks in advance!

Hi @nbobbili , would you have a log file to share with us?

It feels to me that the thrust setpoint is reduced instead of increased to compensate the drop in voltage. However, in the state of charge estimation, if the voltage drop was instead subtracted the scale would be higher leading to a higher thrust setpoint.

What you say seems correct, it should certainly not reduce the thrust but increase it when the battery SOC and with it the voltage reduces.

@Christian_Friedrich that may be a topic for you to look into: should we instead of using the raw measured voltage for calculating the battery scale instead base it on the estimated SOC? Or ocv_estimate?

@sfuhrer Correct me if I’m wrong but the way I see it the battery scale already uses the “corrected voltage”, it just does it in a very complicated way.

const float voltage_range = (_params.v_charged - _params.v_empty);

// reusing capacity calculation to get single cell voltage before drop
const float bat_v = _params.v_empty + (voltage_range * _state_of_charge_volt_based);

_scale = _params.v_charged / bat_v;

Could be simplified to:

_scale = _params.v_charged / _cell_voltage_filter_v.getState();

The voltage based SoC simply maps the corrected cell voltage to the range

[_params.v_empty, _params.v_charged]

Using the SoC instead would not change anything unless it is fused with couloumb counting (by setting the battery capacity).

The question is what the battery scale is supposed to accomplish:
Is is supposed to compensate the discharge of the battery or the voltage drops caused by high current?

@nbobbili

It feels to me that the thrust setpoint is reduced instead of increased to compensate the drop in voltage.

That shouldn’t be possible the battery scale is constrained between [1, 1.3], so it should never reduce the setpoint:

if (_scale > 1.3f) { // Allow at most 30% compensation
	_scale = 1.3f;

} else if (!PX4_ISFINITE(_scale) || _scale < 1.f) { // Shouldn't ever be more than the power at full battery
	_scale = 1.f;
}

Hi,

What the pilot needs to see thro’ GCS is near or exact " remaining flight time " Currently my PX4 v1.13.3 shows funny flight time. It goes to flight safe mode within 5 to 6 minutes by indicating " low battery land immediately " whereas i am able to pilot the drone for more than 25 minutes This is after the calibration of the calculated voltage and providing the battery capacity .
May be having mandatory battery capacity and the calculated battery voltage could provide an accurate reading.

CUBE ORANGE PIXHAWK
Herelink v1.0 QGC v4.4.4
Quadcopter
Px4 v 1.13.3
Parameters adjusted on BAT B1.xx only .