<p dir="ltr">This is mine</p>
<p dir="ltr">Also  I note that with that new message decode I'm still not seeing any battery level reported just 0. I'll try to debug when I get a chance </p>
<div class="gmail_quote">On 9 May 2014 14:42, "Mark Webb-Johnson" <<a href="mailto:mark@webb-johnson.net">mark@webb-johnson.net</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Tom, Nigel,<div><br></div><div>What OBDII-OVMS cable are you guys using - left or right? I would like to see if they are easily modded to switch to EV CAN bus.</div><div><br></div><div>Regards, Mark.</div>
<div><br><div><div>On 9 May, 2014, at 3:55 pm, Nigel Jones <<a href="mailto:nigel@cherrybyte.me.uk" target="_blank">nigel@cherrybyte.me.uk</a>> wrote:</div><br><blockquote type="cite"><div dir="ltr">Just a quick FYI. I reconnected the OVMS this morning (with the modified code) and it's up and running. I can't check SOC as I'm in the office & not by car but it looks as if my build at least worked. That's helpful for debugging/making progress ;-)</div>


<div class="gmail_extra"><br><br><div class="gmail_quote">On 9 May 2014 01:26, Tom Saxton <span dir="ltr"><<a href="mailto:tom@idleloop.com" target="_blank">tom@idleloop.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div style="word-wrap:break-word;font-size:14px;font-family:Calibri,sans-serif"><div>Hi Nigel,</div><div><br></div><div>Some comments on your comments...</div><div><br></div><div>When the Leaf shuts down probably depends on when the weakest battery module voltage drops below some threshold rather than on the total energy remaining in the pack. So, when it stops will vary by vehicle, conditions, and history. I believe the 6 Gids number came from Tony Williams exhaustive experimentation with early Leafs. If you're driving down to single-digit Gids, you're past the point where the car can accurately predict when it's going to stop.</div>


<div><br></div><div>Basing the car_SOC on Gids will have the effect of showing smaller numbers for a full charge as the pack loses capacity. To me this is far preferable to the so-called "True SOC" that will show 100% even when the pack has lost half its capacity. Gids are available on both the Car and EV bus.</div>


<div><br></div><div>The EPA range only changed significantly when Nissan removed the 80% charge option. In order for Leaf owners to be able to compare numbers between vehicles, I think it's vital that the conversion from Gids to percent and Gids to ideal miles be invariant across years and models. Ideal miles is an energy measure stated it units that are move convenient than Gids or percent. If it's to be usable as an energy unit, it has to be the same across all Leafs, and not a customizable mapping.</div>


<div><br></div><div>It's great to have someone digging into the Leaf implementation of OVMS. Good luck sleuthing!</div><span><font color="#888888"><div><br></div><div>   Tom</div></font></span><div><div>

<div><br></div><span><div>On 5/8/14, 11:54 AM, "Nigel Jones" <<a href="mailto:nigel@cherrybyte.me.uk" target="_blank">nigel@cherrybyte.me.uk</a>> wrote:</div><div><br></div><div dir="ltr"><div>
A few thoughts</div>
<div><br></div><div> * When I tested my leaf the car shutdown at 3 GIDS - I think the exact point may depend on cell voltage. I have no idea what the > 2013 MY leaf shows as % on the dash when the car stops, it might be good to get similar to this - but the above is a great 1st pass.</div>


<div><br></div><div> * The car_SOC will drop as the car ages/battery life goes down. I think ideally we'd want to offer similar feedback to the in-car display - but I'm aware this isn't on the car can, we need the other message for that</div>


<div><br></div><div> * The EPA range differs by MY - a feature (like in the TR code?) may allow this to be configured. This may help with other differences too</div><div><br></div><div> * Good point about car vs ev can when it comes to what's live. I'm used to leafdd which is on the ev can and is thus able to always display charge etc.  It would be really useful, but then given that once charging stops even the ev can isn't available, any active control (heat/charge etc) is not going to be possible with ovms?</div>


<div><br></div><div> * Agree on Hx etc... & custom data...  the key enabler here is being able to read ev can as above -- either via picking up data from another pin, or by sw bridging<br></div><div><br></div><div> * first step (only limited time) I'll build test Mark's latest commit with Tom's update<br>


</div><div><br></div><div>* second step - understand the polling framework and try to read data from EVcan - say % charge</div><div><br></div><div>* third step - look at cable mod & in addition to above see if I can read some data from car can</div>


<div><br></div><div>Slow progress - the embedded side is new to me & limited time but hope i can help :-)</div><div><br></div><div>Nigel.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 7 May 2014 03:15, Tom Saxton <span dir="ltr"><<a href="mailto:tom@idleloop.com" target="_blank">tom@idleloop.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div style="font-family:Calibri,sans-serif;font-size:14px">Mark,</div>

<div style="font-family:Calibri,sans-serif;font-size:14px"><br></div><div style="font-family:Calibri,sans-serif;font-size:14px">You're too quick!</div><div style="font-family:Calibri,sans-serif;font-size:14px">

<br></div><div style="font-family:Calibri,sans-serif;font-size:14px">I neglected the other end of the mapping. Since the car stops around 6 Gids, we should map 6 Gids to 0 ideal miles. So:</div><div style="font-family:Calibri,sans-serif;font-size:14px">


<br></div><div style="font-family:Calibri,sans-serif;font-size:14px"><div><font face="Andale Mono"> case 0x5b3:</font></div><div><span style="font-family:'Andale Mono'">   // get raw Gids</span></div>

<div><span style="font-family:'Andale Mono'">   car_idealrange = (((int)can_databuffer[4]&0x01)<<8) + can_databuffer[5];</span></div><div><span style="font-family:'Andale Mono'">   </span><span style="font-family:'Andale Mono'">// convert Gids to percent</span></div>


<div><span style="font-family:'Andale Mono'">   car_SOC = (car_idealrange * 100 + 281/2) / 281;</span></div><div><span style="font-family:'Andale Mono'">   // convert Gids to EPA rated miles: 6 Gids -> 0 IM, 281 Gids -> 84 IM</span></div>


<div><font face="Andale Mono">   car_idealrange = ((car_idealrange-6) * 84 + </font><span style="font-family:'Andale Mono'">(281-6)/2</span><font face="Andale Mono">) / (281-6);</font></div><div><font face="Andale Mono">   break;</font></div>


</div><div style="font-family:Calibri,sans-serif;font-size:14px"><font face="Andale Mono"><br></font></div><div style="font-family:Calibri,sans-serif;font-size:14px"><div>Historically the bottom end mapping is not done when converting Gids to percent SOC. I mixed feelings about doing a better job vs. following community expectations. Since people in the community aren't doing a fixed ideal miles calculation, I think it's OK to do it the more correct way.</div>


</div><div style="font-family:Calibri,sans-serif;font-size:14px"><br></div><div><font face="Calibri,sans-serif">The car_SOC calculation will be fine. All the math with be done with 16-bit ints because car_idealrange forces it. The result may be a couple of points over 100, but it will always easily fit in an unsigned char.</font></div>


<div><font face="Calibri,sans-serif"><br></font></div><div><font face="Calibri,sans-serif">On the EV CAN vs. Car CAN bus issue, I wasn't aware that the Car CAN isn't live during charging. That's not good! LeafSpy demonstrates that we can get everything interesting from Car CAN. Has anyone demonstrated that all interesting values are available from the EV CAN? I suppose it doesn't matter if using the Car CAN won't let OVMS monitor charging.</font></div>


<div><font face="Calibri,sans-serif"><br></font></div><div><font face="Calibri,sans-serif">Given all that, I have to say the EV CAN is looking like the way to go for OVMS, but we'll need to figure out how to get at least a few key things like the odometer which aren't known to exist on the EV CAN.</font></div>


<span><font color="#888888"><div style="font-family:Calibri,sans-serif;font-size:14px"><br></div><div style="font-family:Calibri,sans-serif;font-size:14px">   Tom</div></font></span><div>

<div><div style="font-family:Calibri,sans-serif;font-size:14px"><br></div><span style="font-family:Calibri,sans-serif;font-size:14px"><div><div>On 5/6/14, 6:23 PM, "Mark Webb-Johnson" <<a href="mailto:mark@webb-johnson.net" target="_blank">mark@webb-johnson.net</a>> wrote:</div>


</div><div><br></div><div><div style="word-wrap:break-word">Tom,<div><br></div><div>I just committed this:</div><div><br></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="Andale Mono"><span style="font-size:14px">index 1e17f34..2b695ec 100644</span></font></div>


<div><font face="Andale Mono"><span style="font-size:14px">--- a/vehicle/OVMS.X/vehicle_nissanleaf.c</span></font></div><div><font face="Andale Mono"><span style="font-size:14px">+++ b/vehicle/OVMS.X/vehicle_nissanleaf.c</span></font></div>


<div><font face="Andale Mono"><span style="font-size:14px">@@ -92,7 +92,9 @@ BOOL vehicle_nissanleaf_poll1(void)</span></font></div><div><font face="Andale Mono"><span style="font-size:14px">         }</span></font></div>


<div><font face="Andale Mono"><span style="font-size:14px">     case 0x5b3:</span></font></div><div><font face="Andale Mono"><span style="font-size:14px">       // Rough and kludgy</span></font></div><div><font face="Andale Mono"><span style="font-size:14px">-      car_SOC = ((((int)can_databuffer[5]&0x01)<<1) + ((int)can_databuffer[6])) / 3;</span></font></div>


<div><font face="Andale Mono"><span style="font-size:14px">+      car_idealrange = (((int)can_databuffer[4]&0x01)<<8) + can_databuffer[5]; // raw Gids</span></font></div><div><font face="Andale Mono"><span style="font-size:14px">+      car_SOC = (car_idealrange * 100 + 140) / 281; // convert Gids to percent</span></font></div>


<div><font face="Andale Mono"><span style="font-size:14px">+      car_idealrange = (car_idealrange * 84 + 140) / 281;</span></font></div><div><font face="Andale Mono"><span style="font-size:14px">       break;</span></font></div>


<div><font face="Andale Mono"><span style="font-size:14px">     }</span></font></div><div><font face="Andale Mono"><span style="font-size:14px">   return TRUE;</span></font></div></blockquote></div><div><br></div><div>



But, perhaps too simplistic (due to car_SOC being unsigned char). The car_idealrange is unsigned int, so it may be ok.</div><div><br></div><div>What is your thinking regarding the EV bus vs CAN bus decision?</div><div><br>


</div><div>Regards, Mark.</div><div><br><div><div><div>On 7 May, 2014, at 9:13 am, Tom Saxton <<a href="mailto:tom@idleloop.com" target="_blank">tom@idleloop.com</a>> wrote:</div><br><blockquote type="cite"><div style="word-wrap:break-word;font-size:14px;font-family:Calibri,sans-serif">


<div>Mark,</div><div><br></div><div>That's exactly what I proposed with the code that converts Gids to EPA rated miles; scale 281 Gids to 84 EPA miles.</div><div><br></div><div>Still, Leaf nerds will want to see raw Gids, SOH, and Hx so having a way to display those sorts of values will be great.</div>


<div><br></div><div>   Tom</div><div><br></div><span><div>On 5/6/14, 5:48 PM, "Mark Webb-Johnson" <<a href="mailto:mark@webb-johnson.net" target="_blank">mark@webb-johnson.net</a>> wrote:</div><div><br></div>


<div><div style="word-wrap:break-word">Tom,<div><br></div><div>In general, I think it best to keep the original meaning of the standardised messages and values. So, 'ideal' range is some standardised measure of ideal range (based on EPA or whatever the manufacturer suggests) and 'estimated' range is based on prior driving habits (or some more realistic estimate).</div>


<div><br></div><div>For per-vehicle custom information (such as GIDs), I've been meaning to add something to allow that for some time. It is actually fairly simple - include a callback hook in the vehicle.{h,c} functions to allow the vehicle to output vehicle-specific custom data. I've been thinking we can use protocol messages '0' through '9' for this custom information, so it gets through to the Apps. The apps themselves can use a custom tab to display this in a vehicle-specific manner.</div>


<div><br></div><div>Regards, Mark.</div><div><br><div><div><div>On 7 May, 2014, at 7:16 am, Tom Saxton <<a href="mailto:tom@idleloop.com" target="_blank">tom@idleloop.com</a>> wrote:</div><br><blockquote type="cite">


<div style="word-wrap:break-word;font-size:14px;font-family:Calibri,sans-serif"><div>OVMS reports 0% SOC and sends out panicked low battery messages when it's not getting a valid SOC message from the CAN bus. I get this when I screw up the vehicle setting, which is set via the MODULE command. The first thing I'd do is make sure the vehicle type is set correctly. You can see it from the smartphone app on the Vehicle Info screen, look at the Car line. For my set up I see:</div>


<div><br></div><div>Car: 2.6.5/TR/V2</div><div><br></div><div>This says the car is running firmware version 2.6.5, the car type is TR (Tesla Roadster), and it's V2 hardware.</div><div><br></div><div>You can get the same info by texting MODULE? to the car, which returns the VehicleID, VehicleType, Units (miles or km), and the notifications setting.</div>


<div><br></div><div>For the Leaf, you should see NL as the vehicle type.</div><div><br></div><div>Which CAN bus OVMS reads depends on how the cable is wired. I believe the group consensus is that reading from the CAR CAN bus is the best strategy since we know LeafSpy is able to get everything from the that bus.</div>


<div><br></div><div>The code in vehicle_nissanleaf.c that decodes data from message 0x5b3 looks like it's trying to pull out the Gid values scaled down to work as a rough SOC %, but it looks like the array offsets are off by one. Dividing by 3 is a rough approximation to multiplying by 100 and dividing by 281 to get the standard conversion from Gids to percent.</div>


<div><br></div><div><div>    case 0x5b3:</div><div>      // Rough and kludgy</div><div>      car_SOC = ((((int)can_databuffer[5]&0x01)<<1) + ((int)can_databuffer[6])) / 3;</div><div>      break;</div></div><div>


<br></div><div>Here's a sample message from our Leaf:</div><div><br></div><div>5B3 69 BE FF FF FC DD 53 0A</div><div><br></div><div>When I captured that message, I was reading 221 = 0xDD Gids. Both the Leaf message decoder spreadsheet and the OVMS can_databuffer array start indexing bytes at 0, so byte zero is 0x69, byte 1 is 0xBE, etc.  Using the Leaf message decoder spreadsheet, I believe the Gids calculation is: take the low bit of byte 4, shift left by 8 into 16 bits then add byte 5:</div>


<div><br></div><div>    (((int)0xFC&0x01)<<8) + 0xDD = 0xDD = 221.</div><div><br></div><div>So I think the code to extract Gids from CAR CAN message 0x5B3 is:</div><div><br></div><div>    (((int)can_databuffer[4]&0x01)<<8) + can_databuffer[5]</div>


<div><br></div><div>My thought is that the Gids value should be stored in car_idealrange. Like Gids, the ideal range on the Roadster is an estimate of the state of charge in absolute energy units. An ideal mile is 225.4 Wh; a Gid is 80 Wh. The UI on the Smartphone app will have to change, or Gids will have to be scaled.</div>


<div><br></div><div>I propose this:</div><div><br></div><div>      car_idealrange = (((int)can_databuffer[4]&0x01)<<8) + can_databuffer[5]; // raw Gids</div><div>      car_SOC = (car_idealrange * 100 + 140) / 281; // convert Gids to percent</div>


<div><br></div><div>Optionally, we could do the same thing with Gids that Tesla did to compute ideal miles. The EPA said the Roadster's range is 244 miles, so Tesla equated that with the nominal full capacity of a new Roadster battery, and thus the ideal miles was created. To do the same for the Leaf, take the EPA rating of 84 miles (after Nissan eliminated the 80% charge to get rid of the EPA's stupidity in taking the range to be the average of the 100% and 80% charge levels). After using the raw gids to compute the SOC percent, convert to EPA rated miles:</div>


<div><br></div><div>    car_idealrange = (car_idealrange * 84 + 140) / 281;</div><div><br></div><div>We can also get the SOH value out of message 0x5B3. According to the spreadsheet, it's the top seven bits in byte one, so</div>


<div><br></div><div>   soh = can_databuffer[1] >> 1;</div><div><br></div><div>For my sample message above, that's 0xBE >> 1 = 0x5F = 95, which agrees with the SOH reported by LeafSpy when I did that data capture.</div>


<div><div><br></div><div>BTW, SOH and Hx appear to be different, but perhaps related. I'm trying to figure that out. I suspect SOH is just the Hx value rounded, but I have some data from the Plug In America Leaf survey which contradicts that. The value in message 0x5BE doesn't have enough bits to be the higher resolution Hx.</div>


<div><br></div><div>   Tom</div><div><br></div></div><span><div>On 5/6/14, 11:39 AM, "Nigel Jones" <<a href="mailto:nigel@cherrybyte.me.uk" target="_blank">nigel@cherrybyte.me.uk</a>> wrote:</div><div><br>


</div><div dir="ltr">I have the OVMS module running in my car so found an hour tonight to start looking through the source - sorry it's taking a while to catch up, so forgive the newbie questions too......<div><br></div>


<div>

One thing I noticed is that I'm getting a 0% state of charge indication, and regular texts saying my battery is low (for testing I setup the sim with unlimited texts.....). I see there was a commit last year which used some of the data from the spreadsheet at </div>


<div><br></div><div><a href="https://docs.google.com/spreadsheet/ccc?key=0An7gtcYL2Oy0dGRaSWl6VTV2eXBQMy1ON2xZSzlMUXc#gid=0" target="_blank">https://docs.google.com/spreadsheet/ccc?key=0An7gtcYL2Oy0dGRaSWl6VTV2eXBQMy1ON2xZSzlMUXc#gid=0</a></div>


<div><br></div><div>which I found references from the nissan leaf forum discussion at</div><div><a href="http://www.mynissanleaf.com/viewtopic.php?f=44&t=4131&start=340" target="_blank">http://www.mynissanleaf.com/viewtopic.php?f=44&t=4131&start=340</a></div>


<div><br></div><div>If I'm not mistaken the OVMS currently reads the CAR CanBus ? </div><div><br></div><div>There's an indication in the spreadsheet that CAN message 0x5b3 contains SOC information - but in fact the spreadsheet refers to it as SOH. I have a leafDD and I think this is also known as the Hx figure -- ie it seems to vary with battery age/capacity -- mine for example is down to around 82%, but it is not current state of charge, so I don't think decoding that will help?</div>


<div><br></div><div>GIDs are what I use in daily driving as they are absolute. The sheet suggests that figure might be retrievable from this message, but then most people would only see a % of 95% for example as life is lost? Is that's what's wanted? I suspect not for the overall SOC figure.</div>


<div><br></div><div>I can't see much else decoded yet (I was looking for low hanging fruit!) on the CAR canbus - instead most work was done on the EV canbus, including looking at state of charge etc.</div><div><br></div>


<div>So the question comes how to bridge the data from that bus onto the CAR can. There was reference to this previously on the list at </div><div><br></div><div><a href="http://lists.teslaclub.hk/pipermail/ovmsdev/2013-October/001712.html" target="_blank">http://lists.teslaclub.hk/pipermail/ovmsdev/2013-October/001712.html</a></div>


<div><br></div><div>It would appear the way to get any of the EV can data is to actively request the data. I can see examples of CAN data requests in the tesla module but haven't yet figured how I might for example retrieve CAN msg 0x5bb for example (it's one of the ones to try). I can also see the developers guide p24 which refers to writing on the bus. I'm also wary of the need to be careful in making active requests rather than the easier passive monitoring! Can anyone point me to an example of how I might do this? I'd make that call from the ticker functions? and then handle it in the poll right? </div>


<div><br></div><div>Apologies if this is all covered in the nissan leaf forum thread - I have 39 pages to read now...</div><div><br></div><div>Thanks</div><div>Nigel.</div><div><a href="mailto:nigel@cherrybyte.me.uk" target="_blank">nigel@cherrybyte.me.uk</a><br clear="all">


<div><br></div>-- <br>----<br>Nigel Jones
</div></div>
_______________________________________________
OvmsDev mailing list
<a href="mailto:OvmsDev@lists.teslaclub.hk" target="_blank">OvmsDev@lists.teslaclub.hk</a><a href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a></span></div>





_______________________________________________<br>OvmsDev mailing list<br><a href="mailto:OvmsDev@lists.teslaclub.hk" target="_blank">OvmsDev@lists.teslaclub.hk</a><br><a href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br>


</blockquote></div><br></div></div></div></div>_______________________________________________
OvmsDev mailing list
<a href="mailto:OvmsDev@lists.teslaclub.hk" target="_blank">OvmsDev@lists.teslaclub.hk</a><a href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a></span></div>





_______________________________________________<br>OvmsDev mailing list<br><a href="mailto:OvmsDev@lists.teslaclub.hk" target="_blank">OvmsDev@lists.teslaclub.hk</a><br><a href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br>


</blockquote></div><br></div></div></div></div>_______________________________________________
OvmsDev mailing list
<a href="mailto:OvmsDev@lists.teslaclub.hk" target="_blank">OvmsDev@lists.teslaclub.hk</a><a href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a></span></div>


</div></div><br>_______________________________________________<br>
OvmsDev mailing list<br><a href="mailto:OvmsDev@lists.teslaclub.hk" target="_blank">OvmsDev@lists.teslaclub.hk</a><br><a href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br>


<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>----<br>Nigel Jones
</div>
_______________________________________________
OvmsDev mailing list
<a href="mailto:OvmsDev@lists.teslaclub.hk" target="_blank">OvmsDev@lists.teslaclub.hk</a>
<a href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a>
</span></div></div></div>
<br>_______________________________________________<br>
OvmsDev mailing list<br>
<a href="mailto:OvmsDev@lists.teslaclub.hk" target="_blank">OvmsDev@lists.teslaclub.hk</a><br>
<a href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>----<br>Nigel Jones
</div>
_______________________________________________<br>OvmsDev mailing list<br><a href="mailto:OvmsDev@lists.teslaclub.hk" target="_blank">OvmsDev@lists.teslaclub.hk</a><br><a href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br>
</blockquote></div><br></div></div><br>_______________________________________________<br>
OvmsDev mailing list<br>
<a href="mailto:OvmsDev@lists.teslaclub.hk">OvmsDev@lists.teslaclub.hk</a><br>
<a href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br>
<br></blockquote></div>