paparazzi-devel
[Top][All Lists]

[Paparazzi-devel] Optimized current estimate

 From: Reto Büttner Subject: [Paparazzi-devel] Optimized current estimate Date: Fri, 25 Feb 2011 22:11:22 +0100

```Hi guys,

the linear current estimate used in standard paparazzi code is very
imprecise. It can be calibrated for a certain operating point to work
satisfactory. But with different flight patterns it remains very
imprecise, as the current curve is very non-linear. I use a
superellipse as an approximate (electrical.c):

float x;
float a;
float b;
float n;

#if defined MILLIAMP_AT_FULL_THROTTLE && defined COMMAND_THROTTLE
/* electrical.current = ((float)commands[COMMAND_THROTTLE]) *
((float)MILLIAMP_AT_FULL_THROTTLE) / ((float)MAX_PPRZ); */
a = 1;
b = (float)MILLIAMP_AT_FULL_THROTTLE;
n = 1.2; /* This defines nonlinearity (1 = linear) */
x = ((float)commands[COMMAND_THROTTLE]) / ((float)MAX_PPRZ);
/* electrical.current = x * b; */ /* linear */
electrical.current = b - pow((pow(b,n)-pow((b*x/a),n)), (1/n));
/* Superellipse */
#endif

I got good results in many real flights including various flight
patterns. The deviation to the precisely measured recharged energy is
less than 5%. Now I really can use the full battery capacity without
requiring a current sensor.

If someone else could test this, maybe make the code a bit prettier
and integrate it into electrical.c on git.

Cheers,
Reto

```