[Ovmsdev] Leaf 2016 30Kwh flapping SOC

Robin O'Leary ovmsdev at caederus.org
Thu May 3 17:25:34 HKT 2018

On Wed, May 02, 2018 at 11:55:19PM +1200, Tom Parker wrote:
> My notes indicate that 0x55b on the EV bus contains the state of charge, and
> I've implemented this at https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/compare/master...carrott:nissan-leaf-soc-instrument?expand=1
> along with a configuration option to choose how to show the SOC.

Comments on this:


A purely stylistic point: Many Leaf CAN packets contain several values,
some of which may be valid while others have an "undefined" value
(typically all-1s).  So I think it's better not to "break" out of the
case this:

+      uint16_t soc10 = ((uint16_t) d[0] << 2) | ((d[1] & 0xc0) >> 6);
+      if (soc10 == 1023)
+        {
+        // ignore invalid data seen during startup
+        break;
+        }
because there may be other valid values in the same packet that won't be
processed (there aren't in this case, but when I was adding new metrics,
there were situations where this occurred).

Better to say:

+      uint16_t soc10 = ((uint16_t) d[0] << 2) | ((d[1] & 0xc0) >> 6);
+      if (soc10 != 1023) // ignore invalid data seen during startup
+        {
+          float soc = soc10 / 10.0;
+          m_soc_instrument->SetValue(soc);

For choosing which to display:

+          if (MyConfig.GetParamValueBool("xnl", "soc.instrument", false)) {
+            StandardMetrics.ms_v_bat_soc->SetValue(soc);

> Assuming we get this working, should we default to using the instrument
> cluster state of charge, or the "new car" state of charge? I'm guessing we
> should go with the instrument cluster value, which is a change from previous
> behavior on the leaf but is in keeping with Mark's "re-implement the broken
> calculations by the car".

Instead of creating a new option, could we not use whether or not the
existing "newCarAh" option is set?  It needs to be set to a correct
value in order for the old method to work, and people who don't set it
would just get the dash version.

I would hazard a guess that most people won't have set newCarAh, so the
displayed value will slightly increase for them (depending how degraded
their battery is).  But it seems likely that most people won't notice
the change of behaviour, and if they do, they either won't mind or will
be motivated to get it back by setting newCarAh.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20180503/d60bdd02/attachment-0002.sig>

More information about the OvmsDev mailing list