paparazzi-devel
[Top][All Lists]

## Re: [Paparazzi-devel] Optimized current estimate

 From: Felix Ruess Subject: Re: [Paparazzi-devel] Optimized current estimate Date: Tue, 1 Mar 2011 09:15:54 +0100

Hi Reto,

thats nice!
I added that to electrical: http://bit.ly/ekcAP1

You can change the default non-linearity of 1.2 by defining

<section name="BAT">
<define name="MILLIAMP_AT_FULL_THROTTLE" value="20000" unit="mA"/>
<define name="CURRENT_ESTIMATION_NONLINEARITY" value="1.3"/>
..
</section>

Cheers, Felix

On Fri, Feb 25, 2011 at 10:11 PM, Reto Büttner <address@hidden> wrote:
>
> 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
>
> _______________________________________________
> Paparazzi-devel mailing list