How to get battery mAh/km from the data flash logs?

HI all,
I would like to tune my quad’s cruise speed in loiter mode to get maximum efficiency for max endurance and long flights but i couldn’t find any entry in a tree?

It would be nice to get a efficiency trace along with GPS speed to find the best possible speed for best possible efficiency. I know if one is using live telemetry into mission planner, then mAh/km is available. But please suggest me how can i do with the data flash logs as i am not using live telemetry into the mission planner? Thanks.

Nice question.
There are some maths that give the best efficincy with the speed, but changes a lot with the drag coefficient which is difficult to calculate precisely (at least without a wind tunnel). The lower the Cd, the higher the optimum speed.
There is also an influence of the payload. Also the higher the payload, the higher the optimum speed. (But the overall flying time will be lower).
For standard builds you will find this value between 5-8 m/s. With MP you can easily make one circuit at different speeds and find your best efficient flight for your build.

Yappu telemetry calculates and displays efficiency in speed/mah.

@ andresrc Yes that’s why i want to determine the fastest speed where drag and speed combo gives me best efficiency. In normal OSD i can get mah/km but unfortunately its not available on DJI digital FPV.I designed my quad with a drag in mind and it cruises at 12m/s (43km/hr) @ around 10 amps on 4S on a calm day.It uses DJI motors and Props and home built balsa frame using arched sticks for maximum stiffness and light weight.

@dkemxr Thanks.I will look into yaapu.But it would be nice to have that info with mission planner using data flash logs.

May be Michael can add this feature.

in MP while in the air monitor “battery_mahperkm”

Yes, you can test easily, but I think that 12 m/s is closer to performance than efficiency. I think that around 8 m/s you will get further distances while still keeping relative high speed.

Thanks Michael for chiming in!!

Yes I have used that feature on plane where I have full telemetry on MP via dragonlink but my quad doesn’t have full telemetry back.

So I would like to extract mAH/km from dataflash logs.

you will have to generate it yourself from the DF log.
this assumes you have battery monitoring install as well as a gps

use the pos message to calculate the 3d vector, integrate it to get distance.

Hi Michael,

Myself and others have also wanted to look at this in the logs for both multicopter and fixed wing aircraft for along time.

Assuming the current and speed are measured and logged, would it be possible to add these “calculated” values as a display option in the log viewer please ?

Displaying them in the log viewer also has the advantage that it can show you the average over the data window as well so it takes out shorter period variations that you might see whilst watching it live in the HUD.

What would be even better is Watt Hours / km otherwise you are ignoring the change in battery voltage from beginning to end.

This would be an awesome addition to MP !!

Thanks,
JRandle

For the lazy guy you can calculate the distance by multiplying the ground speed GPS.Spd[m/s] and a time constant. The other parameter needed is BAT.Curr[A].

something like:

BAT.Curr[A] * 1000. [mA/A] / GPS.Spd [m/s] * (3600[s/h] / 1000 [m/km] ) --> Eff[mAh/km]

or simpler written down:

1000 * BAT.Curr / (3.6 * GPS.Spd) = Eff

Edit: fix units

1 Like

i actualy added something similar already - anyone want to confirm the maths??

3 Likes

Many thanks Michael !! This is a great addition!! especially for a hobbyist like me where some complex mathematical calculations goes over head:)

Now we have both options. mah/km and watt hr/km!! and we can get average values instantly!!

In my plane’s log, i graphed both.Average mah/km is 89.12mah/km and 0.95 watt hr/km.I was gliding down where you see very low consumption.

Here is mah/km

and here is watt hr/km

@Michael_Oborne Cool!! You already had a very similar idea. :slightly_smiling_face:

Regarding the math. From my point of view it should be equivalent. Maybe I am not the most qualified one to confirm the math. As you can see in the edit’s above I was struggling a little bit with math too. :blush:

Looking at the OSD code the calculations seems fine.

A first look on some logs gave the numbers as expected.

May I have suggestion? It’s just a “nice to have”.
The condition of a plane/vehicle standing still (e.g. after landing) creates the situation of dividing to near zero GPS.Spd and screws up the scaling of the graph. See below:

A constrain similar to line 1623 of the OSD code should tame the effect.
The calculations are still fine. By zoom in I found the numbers as expected.

PS: Thank you very much for all the effort!!! :+1: :+1:

Hi Michael,

After figuring out where I can modify the plot definitions by my own :smile: I was able to make a comparison.

As guessed by myself the calculations seem to be more or less equivalent.

Here are the plots.

Your calculations create this plot:

It looks like my “lazy guy” calculations create a nicer plot. The simpler math avoids the discretisation steps used by the function “delta”. See the yellow marked area.

Last but not least:
The very best of this exercise. Now I can make my own pull downs. :+1: I am able to add the “nice to have constrain” mentioned in my earlier post. A way to apply this is circled in red on the first plot. The lower speed constrain may not useful for everybody.

The code changes are shown below and can be found here. mavgraphsMP.zip (1.3 KB)

Thank’s for the hint!!!

Thanks to everyone who has worked on this. I think it will be a very useful tool.

One point that I noted was people seem to be using GPS speed. Whilst this might be appropriate for multi-rotors, airpseed would be more appropriate for aircraft with an air speed sensor, which would be the majority.

Using airspeed for these calculations would also greatly speed up the testing process for finding the most efficient speed to fly an aircraft at, because it takes out the effect of the wind on the testing, meaning that testing can be done in a much wider range of weather conditions.

Maybe the options in the log viewer could state whether it was mah/km (GPS) or mah/km (Airspeed) and the same for Watt Hours/km (GPS) and Watt Hours/km (Airspeed) ??

Thanks again,
JRandle