From 518bc1b165d8c045c202994d98009855befdd86b Mon Sep 17 00:00:00 2001 From: Tony Cabello Miguel <> Date: Fri, 16 Apr 2021 07:49:25 +0200 Subject: [PATCH] Small doc enhancements --- docs/Battery.md | 10 ++++++++++ src/main/sensors/current.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/Battery.md b/docs/Battery.md index 188f15148a..d0b8a6decc 100644 --- a/docs/Battery.md +++ b/docs/Battery.md @@ -175,6 +175,16 @@ amperage_meter_scale = (Imax - Imin) * 100000 / (Tmax + (Tmax * Tmax / 50)) = 205 amperage_meter_offset = Imin * 100 = 280 ``` +Measuring Imax requires a battery and an ESC that can both deliver and support max current for the duration of the measurement, so it's prone to big inaccuracies. Alternatively, current can be measured at a much lower throttle position and be taken into account in the calculations. + +Following the previous example, if we measured an Ibench current of 6A at 30% of throttle (1255 in the motors tab because (0.3*(max_throttle-1000))+1000)) +``` +Tbench = Tmax * bench_throttle = 850 * 0.3 = 255 +amperage_meter_scale = (Ibench - Imin) * 100000 / (Tbench + (Tbench * Tbench / 50)) + = (6 - 2.8) * 100000 / (255 + (255 * 255 / 50)) + = 205 +amperage_meter_offset = Imin * 100 = 280 +``` #### Tuning Using Battery Charger Measurement If you cannot measure current draw directly, you can approximate it indirectly using your battery charger. However, note it may be difficult to adjust `amperage_meter_offset` using this method unless you can diff --git a/src/main/sensors/current.c b/src/main/sensors/current.c index fb24339dc3..f339e3aad0 100644 --- a/src/main/sensors/current.c +++ b/src/main/sensors/current.c @@ -191,7 +191,7 @@ void currentMeterVirtualRefresh(int32_t lastUpdateAt, bool armed, bool throttleL throttleOffset = 0; } - int throttleFactor = throttleOffset + (throttleOffset * throttleOffset / 50); // FIXME magic number 50, 50hz? + int throttleFactor = throttleOffset + (throttleOffset * throttleOffset / 50); // FIXME magic number 50. Possibly use thrustLinearization if configured. currentMeterVirtualState.amperage += throttleFactor * (int32_t)currentSensorVirtualConfig()->scale / 1000; } updateCurrentmAhDrawnState(¤tMeterVirtualState.mahDrawnState, currentMeterVirtualState.amperage, lastUpdateAt);