<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
On 02/05/18 01:08, ovms wrote: <br>
<blockquote type="cite"
cite="mid:c0421900-ad2c-43e8-bc03-74595acea9aa@DISKSTATION2">
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #272ad8; background-color: #ffffff;"><strong><span
style="color: #ba2da2;">case</span> 0x50d</strong><span
style="color: #000000;"><strong>:</strong> //Changed this
from 5bc. 50d is the instrument SOC</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"><span
class="Apple-converted-space"> </span> {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"><span
class="Apple-converted-space"> </span> uint16_t nl_gids
= ((uint16_t) d[<span style="color: #272ad8;">0</span>]
<< <span style="color: #272ad8;">2</span>) | ((d[<span
style="color: #272ad8;">1</span>] & <span style="color:
#272ad8;">0xc0</span>) >> <span style="color:
#272ad8;">6</span>);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"><span
class="Apple-converted-space"> </span> <span
style="color: #ba2da2;">if</span> (nl_gids == <span
style="color: #272ad8;">1023</span>)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"><span
class="Apple-converted-space"> </span> {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #008400; background-color: #ffffff;"><span
style="color: #000000;"><span class="Apple-converted-space">
</span></span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"><span
class="Apple-converted-space"> </span> <span
style="color: #ba2da2;">break</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"><span
class="Apple-converted-space"> </span> }</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"><span
class="Apple-converted-space"> </span> uint16_t max_gids
= MyConfig.GetParamValueInt(<span style="color: #d12f1b;">"xnl"</span>,
<span style="color: #d12f1b;">"maxGids"</span>,
GEN_1_NEW_CAR_GIDS);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"><span
class="Apple-converted-space"> </span> <span
style="color: #ba2da2;">float</span> km_per_kwh =
MyConfig.GetParamValueFloat(<span style="color: #d12f1b;">"xnl"</span>,
<span style="color: #d12f1b;">"kmPerKWh"</span>,
GEN_1_KM_PER_KWH);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"><span
class="Apple-converted-space"> </span> <span
style="color: #ba2da2;">float</span> wh_per_gid =
MyConfig.GetParamValueFloat(<span style="color: #d12f1b;">"xnl"</span>,
<span style="color: #d12f1b;">"whPerGid"</span>,
GEN_1_WH_PER_GID);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px
Helvetica; background-color: #ffffff; min-height: 14.0px;"> </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"><span
class="Apple-converted-space"> </span>
m_gids->SetValue(nl_gids);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"><span
class="Apple-converted-space"> </span>
StandardMetrics.ms_v_bat_soc->SetValue(<strong>nl_gids / <span
style="color: #272ad8;">4</span></strong>); //Changed
this so the value is divided by 4.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"> </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;"> </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;
color: #000000; background-color: #ffffff;">SOC now shows
exactly the same in the app as the instrument-panel does, and
is not flapping. (I know the instrument-panel is different
from the true SOC)</p>
</div>
</blockquote>
<br>
I wasn't able to reproduce this. On my car and in the CAN bus
captures I've got, there is no 0x50d frame on the EV bus. Now that
I'm back in the house, I see that 0x50d is present on the Car CAN
bus, but I don't have any data on what's there.<br>
<br>
My notes indicate that 0x55b on the EV bus contains the state of
charge, and I've implemented this at
<a class="moz-txt-link-freetext" href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/compare/master...carrott:nissan-leaf-soc-instrument?expand=1">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/compare/master...carrott:nissan-leaf-soc-instrument?expand=1</a>
along with a configuration option to choose how to show the SOC.<br>
<br>
However 0x55b doesn't work how I expected on my 2016 24kWh car, I
see <br>
<br>
xnl.v.bat.gids 140<br>
xnl.v.bat.soc.instrument 56.3%<br>
xnl.v.bat.soc.newcar 49.8221%<br>
<br>
but the instrument cluster displays 52%. Could it be displaying 56.3
- 5 = 51.3 rounded up to 52?<br>
<br>
Should I be looking at 0x50d on the car bus to faithfully display
what the instrument cluster displays? I'll check tomorrow.<br>
<br>
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".<br>
</body>
</html>