[Ovmsdev] Calculating Leaf Rated Miles

Tom Saxton tom at idleloop.com
Sun May 8 08:58:58 HKT 2016


I hit send just a little too soon...

Phil just sent me some screenshots from LeafSpy. Despite recommending "around 363" Gids for the nominal full 30 kWh pack, it appears James is actually using 365 to convert Gids to percent. With that value, the 24 and 30 ratios get a little farther apart and the average drops to 0.29604153. That can be approximated with rounding as:

(Gids * 45 + 76) / 152

That has a maximum error of 2 on the 24 kWh Leaf, but at a Gid value of 363, which is way out of range. If I look at 0 to 285 for the 24's and 0 to 370 for the 30's, the maximum absolute error is 1 and the average absolute error is 0.40 and 0.24, resp.

For that formula, uint16_t doesn't overflow until 1455 Gids.

So, that's my recommendation for calculating rated miles for any model Leaf.

   Tom




On 5/7/16, 5:39 PM, "Tom Saxton" <tom at idleloop.com> wrote:

>I think exposing Gids would be fine, but it's not as user friendly as rated miles.
>
>Now that I've looked at it some more, I don't think it matters which model Leaf it is.
>
>The 24 kWh Leaf has an EPA rated range of 84 miles and a nominal full pack has 281 Gids. The 30 kWh Leaf is rated at 107 miles and has a nominal full pack around 363 Gids (that's the value James Pollock, aka Turbo3, the creator of LeafSpy recommended I use to convert Gids to percent for the Plug In America Leaf survey).
>
>Gids *  84 / 281 = Gids * 0.298932
>Gids * 107 / 363 = Gids * 0.294765
>
>Split the difference as 0.296849 which can be approximated very closely and rounded with integer math as:
>
>(Gids * 19 + 32) / 64
>
>That's much closer to the target average than the average is to the two model-specific numbers, and won't overflow uint16_t until 3448 Gids. It has a maximum error of 1 rated mile compared to either the 24- or 30-kWh calculation in floating point and rounded through the range from 0 to 370, and an average absolute error just under 0.39 for both.
>
>The early Leafs had a lower rated range, but that was at least partially because of the methodology used by the EPA. Since the early Leafs has an option to charge to 80%, the EPA took the range with an 80% charge and averaged that with the 100% charge range. That's why Nissan took away the 80% charge option. Or so the story goes.
>
>As an owner of one of those early Leafs, I'd be totally happy with a rated miles calculation based on the later model's rated range.
>
>   Tom
>
>
>On 5/7/16, 4:09 PM, "Tom Parker" <ovmsdev-bounces at lists.teslaclub.hk on behalf of tom at carrott.org> wrote:
>
>>On 05/04/2016 04:13 AM, Tom Saxton wrote:
>>> In C, integer calculations truncates instead of rounding. 99/100 = 0. Adding half of the denominator to the numerator causes the calculation to round up, i.e., (99 + 50) / 100 = 1. That's great for positive values, the case here, but isn't the right thing for negative values. Gary Gidding's original SOC meter didn't round, so that's been the de facto standard in the Leaf world.
>>
>>Thanks for the explanation, I've already removed the 140 and it sounds 
>>like putting it back will move further from Gary's algorithm so I won't 
>>put it back.
>>
>>> As for configuration, I think there's real value in having a pack energy number, like rated miles, that isn't configurable so it can be compared between owners. If the parameters change, I think it should be based on model configuration (which I'm hoping can be determined from the CAN bus), and not from owner configuration.
>>
>>Would it be better to expose the raw number of gids for comparison, so 
>>there's no confusion about what the numbers mean? I've got some 
>>rudimentary historical data reporting that sends the current gids. I 
>>don't think there is a way to see the historical data other than the 
>>HTTP api?
>>
>>I've not yet tried to be compatible with the Twizzy historical format, 
>>and I don't have anything to visualize the data I am sending (I've 
>>mostly used it as a channel for debugging).
>>_______________________________________________
>>OvmsDev mailing list
>>OvmsDev at lists.teslaclub.hk
>>http://lists.teslaclub.hk/mailman/listinfo/ovmsdev




More information about the OvmsDev mailing list