[Ovmsdev] Battery capacity metrics (for the Leaf, and in general)

Anko Hanse anko_hanse at hotmail.com
Sun Feb 24 13:34:21 HKT 2019

Well done, the best possible solution!

I had been searching for a way to directly get the battery capacity from the can bus, but had not found one. Hence my search for alternatives via the VIN.
Even if I do a google now on 'leaf can bus 59e' I don't get useful hits. And no finds in the canmsgs google docs either...  Makes me wonder what docs you have access to...

Your solution means we could now completely get rid of the max_gids setting, and rework the code to use m_battery_energy_capacity instead. 
Also agree with your comment to remove the need for the modelyear setting by either just sending 2 command messages to the TCU or analysing its behaviour prior to sending the commands.

As for the web-interface, we might want to still display the detected battery capacity there, just not as a changeable setting but as readonly info.

-----Original Message-----
From: Robin O'Leary <ovmsdev at caederus.org> 
Sent: Sunday, 24 February 2019 12:42 PM
To: OVMS Developers <ovmsdev at lists.openvehicles.com>
Subject: [Ovmsdev] Battery capacity metrics (for the Leaf, and in general)

Prompted by the recent discussion about auto-detecting Leaf battery pack size, I was looking at the somewhat convoluted way the Leaf code is currently dealing with battery charge level and capacity to see why it was thought necessary in the first place.

The Leaf's BMS gives us both an estimate of battery energy currently available (which we quaintly called "xnl.v.b.gids" and didn't convert to standard units), and estimated total battery energy capacity (which wasn't available at all).  Perhaps this was discouraged by the lack of standard metrics for energy (*), which I find this quite surprising, given that these two values are so useful in basic calculations like:

	range = (energy available) / (driving efficiency) or
	charge time = (energy capacity - available) / (charge rate)

So here is a pull request to expose those values as Leaf-specific metrics:

  m_battery_energy_capacity	Float	"xnl.v.b.e.capacity"	kWh
  m_battery_energy_available	Float	"xnl.v.b.e.available"	kWh


But I would go further and suggest that these deserve to be standard metrics so other vehicle modules can also report their own equivalent values.  My hope is that we can then start improving the accuracy of range and charge time estimates for all vehicles; most already attempt one or both in their own ways, some more sophisicated than others.  At least basing everything on standard energy units means there is a better chance that work already done by one model might be useful to another.


(*) The only related standard metric I can see is ms_v_bat_cac, which is a measure of battery charge capacity (in Amp.hours), rather than energy.
Although closely related, charge is less convenient to work with, as most calculations will also need to account for varying pack voltage.

More information about the OvmsDev mailing list