[Ovmsdev] OVMS Leaf Support

Mark Webb-Johnson mark at webb-johnson.net
Tue Nov 5 20:45:42 HKT 2013


A short update:

I’m working on the code to handle the Leaf PID polling via the CAR-to-EV bus bridge. It seems ok, but I’m trying to make it modular as we are now doing this same sort of polling in quite a few vehicle modules and it seems sensible to centralise it (to save code space and complexity). It is tricky, because of the relay issue, as we need to make the polling frequency configurable depending on states.

I’m making progress and hope to have something within the coming week.

My first version of code is going to output to the DIAG serial port lots of data to tell us what is going on. So, I need testers with a (a) laptop, (b) usb-to-serial converter, (c) Leaf, (d) PICKIT, (e) OVMS module, (f) standard OVMS OBD-II cable. Testing will be flashing the module with a HEX I provide, then putting it in the car and getting a log file of the DIAG port to send me.

Regards, Mark.

On 22 Oct, 2013, at 9:37 pm, Mark Webb-Johnson <mark at webb-johnson.net> wrote:

> Nikki,
> 
> Thanks for detailed explanation.
> 
>> could we put the OVMS into some form of low-power mode, so it doesn't poll the car and drain that 12V battery as quickly?
> 
> Possibly. We haven’t handled that yet, and our tests with it so far have not been very successful. The biggest power draw is the modem. Best we can do is shut that down and delay-loop-spin if 12V gets to low.
> 
>> We can use the 12V monitoring system already built into OVMS to set an early-warning alert if voltages start to drop, right? 
> 
> Yes. The leaf also seems to have 12V level in a can bus signal, which shouldn’t need to be calibrated and may give us a better result.
> 
>> But a quick question: can I run OVMS alongside LEAFSpy, using an ODBII splitter? 
> 
> 
> Hmmm. Without special handling, that would be problematic. We would both end up polling the same things, and one/both of us would get confused.
> 
> I should have thought that we can listen on the bus first, and make sure there are no polling signals for N seconds, before we start polling ourselves. Similarly, if we see a polling signal/reply, we can back off. But, one concern is that in my tests last weekend, I tried a CAN bus logger and OBD-II with leaf spy together, but didn’t see much. All I saw were some replies:
> 
> 1382228933.303 R11 797 02 10 C0 00 00 00 00 00
> 1382229549.511 R11 797 03 22 12 4E 00 00 00 00
> 1382229799.599 R11 797 03 22 11 5D 00 00 00 00
> 1382230050.688 R11 797 03 22 13 2A 00 00 00 00
> 1382230425.777 R11 797 03 22 12 55 00 00 00 00
> 1382230869.926 R11 797 03 22 13 04 00 00 00 00
> 
> so, it looks like I can see someone else polling (and can back off appropriately), but I don’t think I can listen to their replies as if I was polling myself! That would be cool (so long as leaf spy and ovms were polling for the exact same things), and I don’t see why it wouldn’t work, but I just didn’t see that behaviour when I T’ed the bus last weekend.
> 
> Regards, Mark.
> 
> On 22 Oct, 2013, at 4:23 pm, Nikki Gordon-Bloomfield <nikki at aminorjourney.com> wrote:
> 
>> Mark, 
>> 
>> Regarding the 12V drain. As I understand it, the 12V battery gets charged when the car is plugged in and the main traction battery is getting charged. When the car is plugged in and it is NOT charging, the on-board computer wakes up every n seconds and polls its various systems. Because this uses more power than normal 'standby' mode, it quickly drains the battery. If we assume most owners are not going to leave their cars plugged in for days at a time, the issue should be moot, although it's worth playing on the cautious side. 
>> 
>> Instances of 12V drainage in LEAFs are almost exclusively related to cars which have sat plugged in at charging stations for extended periods of time, such as when their owners go on holiday.  Last time I went abroad, I kept my LEAF plugged in, but did the following: 
>> 
>> Left the car on the first night without a full charge. I think SOC was about 25% if I remember correctly. 
>> Set the car's timer to charge every night while I was away with an 80 percent 'limited' charge profile, starting at midnight, and finishing at half-past midnight. 
>> On a standard 16 amp EVSE, this meant that the car slowly charged over the course of the week, getting topped up a little more every night. Because the 12V battery was charged too during that period, I was able to keep it happy also, preventing any horrible 'soft-brick' scenarios.
>> What does this tell us? First, I'm pretty sure the 12V battery DOES get charged when the main traction back gets charged. But when the car is plugged in and not charging, NOTHING gets charged and the 12V battery gets drained at a far faster rate than it would be if it was left alone for a few weeks. 
>> 
>> But I think it also tells us some other important things. 
>> 
>> IN most situations, (everyday ones, at least) 12V battery drain shouldn't be a problem. I'm happy to be the Guinea pig for this one when Kevin gets the OVMS hardware through customs. 
>> The only risk to the car occurs when the car is parked for long periods without being plugged in -- or when it is plugged in but hasn't charged for x hours/days. A work-around here would be to use the parking timer combined with a 'last-charged' timer. If the timer > 24 hours, per say, could we put the OVMS into some form of low-power mode, so it doesn't poll the car and drain that 12V battery as quickly? I know from my Twizy that the OVMS system really does have a very low power drain, so I'm assuming any massive power drains associated with OVMS come from the car's on-board CAN hardware waking up and communicating with the module? 
>> We can use the 12V monitoring system already built into OVMS to set an early-warning alert if voltages start to drop, right? 
>> If done correctly, it's possible to keep the car plugged in for long periods of time, without adversely affecting the 12V battery.  This is a matter of driver education more than anything else. 
>> 
>> I also think it's worth noting that many LEAFs which have had 12V battery issues are ones which have either spent a lot of time sitting on dealer lots, or are regularly left for long periods of time. It's my opinion that like any car, the LEAF benefits from being driven daily… ;)
>> 
>> 
>> As soon as Kevin gets the hardware through customs, I'm willing to give this all a go. But a quick question: can I run OVMS alongside LEAFSpy, using an ODBII splitter? 
>> 
>> Nikki. 
>> 
>> P.S. FYI, Nissan has changed the position of the ODB port on the 2013 model year cars. It's now behind a small panel to the right of the driver's right (left in LHD countries) knee. Orientation is also moved too. Here's a photo of new vs old. 
>> 
>> 
>> 
>> 
>> <IMG_0525.jpeg> -- You'll notice the new car has an extra port too. Not sure what it's for… 
>> 
>> 
>> 
>> <IMG_0528.jpeg> Old port is right under the dash, with the catch-side facing to the driver's left. 
>> 
>> 
>> 
>> On 22 Oct 2013, at 02:11, Mark Webb-Johnson <mark at webb-johnson.net> wrote:
>> 
>>> OK, here's an update...
>>> 
>>> I went through the logs we captured, and had a look at Leaf Spy. I even purchased a copy of Leaf Spy Pro (even though I don't have a Leaf) just as a donation to say thank you to Turbo3 for pushing this approach and working out so much of the mechanics of it.
>>> 
>>> I spent an evening reading through the "Using clone ELM327 Bluetooth OBDII adapter with Leaf" on mynissanleaf.com (all 238 pages of it!), and got a good understanding of the history of where CAN decoding on the Nissan Leaf is, and where it is headed.
>>> 
>>> Bottom line:
>>> 
>>> There are two CAN buses in the Nissan Leaf that are useful to us: the EV CAN bus and the CAR CAN bus.
>>> The standard OVMS OBD-II cable connects to the CAR CAN bus. By passive listening on the bus, we can see some EV information, and all of the car information.
>>> The EV CAN bus is also available on the OBD-II socket. By passive listening on the bus, we can see all the EV information, but little-to-no car information.
>>> OVMS V2 hardware can only connect to one bus.
>>> Someone worked out that active requests for information from the controllers (PID polling, as opposed to passive listening) are bridged. You can request information from a controller on the EV CAN bus, via the CAR CAN bus, and the car will bridge the requests between the buses. This appears to work bi-directionally.
>>> There is a slight nasty in that if the car is off (asleep), active polling the EV controller causes it to wake up and you can hear a little 12V relay click near the front of the car each time you poll. We don't want to poll too fast when the car is asleep (off) and not charging, to avoid wearing out that relay.
>>> The OBD-II connector has 12V power (both switched and non-switched) that we can use for OVMS, powered by an automotive 12V lead acid battery. We do need to take care because apparently that 12V battery is only charged when you drive or once every five days when the car is unplugged (and not at all when the car is plugged in). There is a CAR CAN message to show the 12V battery voltage (and OVMS V2 can also measure directly).
>>> There is 'active discussion' in the community on how things like SOC%, battery capacity, ideal and estimated ranges, should be determined. Nissan made a mess of it, and the users are struggling to agree on a uniform approach to a correct way of doing things.
>>> 
>>> I think our plan of attack should be:
>>> 
>>> Use a standard V2 module, with standard OVMS OBD-II cable, to connect to the CAR CAN bus.
>>> Use passive CAN listening, for the car information (doors, speed, on/off, etc) as much as possible.
>>> Use active CAN polling, bridged to the EV CAN bus, for the EV information that we need.
>>> Agree our own user-centric approach of how to represent capacity, SOC, ideal and estimated ranges.
>>> 
>>> It has been quite frustrating looking at the community documentation for CAN bus messages in the Leaf. The documentation doesn't match what I am seeing, and is not at all clear. A lot of people are sharing, but some seem to be holding back and saying things like "here are some clues to what I've found, so go look for it yourself". Some closed source. Not the way I like to do things.
>>> 
>>> There is one very good thread on the active CAN bus polling, here:
>>> 
>>> http://www.mynissanleaf.com/viewtopic.php?f=44&t=11676
>>> 
>>> A good background read (34 pages) on Leaf CAN bus passive monitoring is here:
>>> 
>>> http://www.mynissanleaf.com/viewtopic.php?f=8&t=4131
>>> 
>>> and I recommend everyone involved in this to read that thread (only 12 pages) to get a good understanding.
>>> 
>>> There are two spreadsheets tracking Leaf CAN bus messages:
>>> 
>>> https://docs.google.com/spreadsheet/ccc?key=0AuDGAXnbchK0dDc4T05oNE04aVZtUzB6S19DT1RwaHc&authkey=CJi03v4F&hl=en_US&authkey=CJi03v4F#gid=0
>>> 
>>> https://docs.google.com/spreadsheet/ccc?key=0An7gtcYL2Oy0dGRaSWl6VTV2eXBQMy1ON2xZSzlMUXc#gid=5
>>> 
>>> So, what I'm going to do now is to setup a framework in the vehicle_nissanleaf module to do passive listening on the CAR CAN bus, and active polling of the information on the EV CAN bus (bridged via CAR CAN bus). Once the framework is done, I'll test it in the local Hong Kong Leaf, and ask you guys to help.
>>> 
>>> I do need one or two people with the following equipment to help out:
>>> 
>>> Good and frequent access to a Nissan Leaf
>>> OVMS v2 Module
>>> OVMS v2 OBD-II cable
>>> PICKIT2 or PICKIT3 programmer
>>> RS232-to-USB adaptor and laptop (or laptop with RS232 port)
>>> 
>>> This is to run the framework in their car, and capture RS232 output from the DIAG port.
>>> 
>>> So, volunteers please.
>>> 
>>> Regards, Mark.
>>> 
>>> On 19 Oct, 2013, at 11:23 pm, Mark Webb-Johnson <mark at webb-johnson.net> wrote:
>>> 
>>>> 
>>>> I met up with a local Leaf owner (George) and spent a few hours in the car logging stuff off the main CAN bus. The car is a 2011 model, I think (the VIN model year is U/V, which makes no sense).
>>>> 
>>>> Good news it that the OVMS cables are fine. The ‘right hand’ ovms obdii cable appears to be the best for the right hand drive nissan leafs. The OBDII connector is under the steering wheel, parallel with the car direction of travel, short side on the left, so using a right-hand cable directs the cable towards the front of the car, which should be easiest for routing.
>>>> 
>>>> I managed to get quite a few log files, using a standard CAN USB adaptor at 512kbps.
>>>> 
>>>> Bad news is I am having trouble correlating lots of the messages against the published spreadsheets of Leaf can bus messages. Some messages are partially correct, but many are missing / don’t match up. The car also seems to go to sleep during charging, although the leaf spy could update the SOC ok. The 0x5b3 SOC+GIDS message wasn’t visible on the bus at all.
>>>> 
>>>> I think we are going to have to use PID polling to get the data we need.
>>>> 
>>>> Regards, Mark.
>>>> 
>>>> On 16 Oct, 2013, at 10:31 pm, Mark Webb-Johnson <mark at webb-johnson.net> wrote:
>>>> 
>>>>> 
>>>>> Anyone feeling brave?
>>>>> 
>>>>> I’ve just committed a nissan leaf module (set vehicle id to NL) that will monitor the can bus and pickup the SOC%. That is all it does at the moment, but it should work.
>>>>> 
>>>>> Regards, Mark.
>>>>> 
>>>>> On 16 Oct, 2013, at 2:49 pm, Nikki Gordon-Bloomfield <nikki at littlecollie.com> wrote:
>>>>> 
>>>>>> I've already messages mark C. Let's hope he has it :) I know he and his husband have done a lot of logging. 
>>>>>> 
>>>>>> Sent from my iPhone
>>>>>> 
>>>>>> On 16 Oct 2013, at 07:02, Robert Sharpe <robert.sharpe at evergreen-consulting.co.uk> wrote:
>>>>>> 
>>>>>>> Hi Mark,
>>>>>>> 
>>>>>>> >I think the fastest way to get this done is for me to do it with a local Leaf owner.
>>>>>>> That sounds like a good idea.
>>>>>>> 
>>>>>>> >Can someone tell me which CarCAN bus message to look for, which byte(s) to access, and how to convert to percentage SOC?
>>>>>>> >The document at https://docs.google.com/spreadsheet/ccc?key=0An7gtcYL2Oy0dGRaSWl6VTV2eXBQMy1ON2xZSzlMUXc#gid=5 suggests ID 5B3 tracks SOH and Gids. But how to convert to percentage SOC?
>>>>>>> 
>>>>>>> Is @nufkin (Mark C) on this list? He has done some analysis of codes.
>>>>>>> There is always the authors of the other projects that read Leaf data.
>>>>>>> 
>>>>>>> Regards,
>>>>>>> Rob
>>>>>>> 
>>>>>>> 
>>>>>>> On Oct 16, 2013, at 6.33AM, Mark Webb-Johnson wrote:
>>>>>>> 
>>>>>>> I think the fastest way to get this done is for me to do it with a local Leaf owner.
>>>>>>> 
>>>>>>> If I can get basic support working, then perhaps someone else (or others) with better knowledge of the Leaf scene, can take over to get the advanced stuff working.
>>>>>>> 
>>>>>>> So, I'm going to try to get some Leaf Spy traces, as well as CAN bus logs for parked, charging and driving. Then, get the basic module working with SOC%, GPS location, door status, drive/park and charge monitor.
>>>>>>> 
>>>>>>> My biggest confusion at the moment is SOC% in the Leaf. There is a lot of talk about gids, etc, but I've never gone into it too deeply.
>>>>>>> 
>>>>>>> Can someone tell me which CarCAN bus message to look for, which byte(s) to access, and how to convert to percentage SOC?
>>>>>>> 
>>>>>>> The document at https://docs.google.com/spreadsheet/ccc?key=0An7gtcYL2Oy0dGRaSWl6VTV2eXBQMy1ON2xZSzlMUXc#gid=5 suggests ID 5B3 tracks SOH and Gids. But how to convert to percentage SOC?
>>>>>>> 
>>>>>>> Regards, Mark.
>>>>>>> 
>>>>>>> On 16 Oct, 2013, at 1:03 pm, Evergreen <robert.sharpe at evergreen-consulting.co.uk">target="_blank">robert.sharpe at evergreen-consulting.co.uk> wrote:
>>>>>>> 
>>>>>>> That's great news.
>>>>>>> 
>>>>>>> Regards,
>>>>>>> Rob
>>>>>>> 
>>>>>>> On 16 Oct 2013, at 06:00, Mark Webb-Johnson <mark at webb-johnson.net">target="_blank">mark at webb-johnson.net> wrote:
>>>>>>> 
>>>>>>> 
>>>>>>> P.S. I'm trying to find a friendly Leaf owner in Hong Kong to co-operate with this. There are 200+ Leafs here, and no carwings coverage at all, but most are in government service and relatively few in private hands.
>>>>>>> 
>>>>>>> I think my fishing expedition on the forums may have come up with a bite. A Hong Kong Leaf owner who is willing to help.
>>>>>>> 
>>>>>>> I'll let you know how it pans out (over the next couple of days), but if I can get access to a local Leaf, getting the basic support working should be much faster.
>>>>>>> 
>>>>>>> Regards, Mark.
>>>>>>> 
>>>>>>> On 15 Oct, 2013, at 1:00 pm, Mark Webb-Johnson <mark at webb-johnson.net">target="_blank">mark at webb-johnson.net> wrote:
>>>>>>> 
>>>>>>> Barry,
>>>>>>> 
>>>>>>> Thanks for the history. I really think we can get what we need from the single car CAN bus.
>>>>>>> 
>>>>>>> I'll extract the relevant sections from the developers guide tonight, and post them here. The first step is to see which of those 'virtual car' pieces of information are available on the car CAN bus, and see if they match-up.
>>>>>>> 
>>>>>>> I really would like to see a dump (and dump) of the car CAN bus, as well as a trace from the leaf spy program. The captioned google docs spreadsheet for leaf can bus messages is quite confusing - it would be good to be able to compare that against what is actually seen on the bus.
>>>>>>> 
>>>>>>> Regards, Mark.
>>>>>>> 
>>>>>>> P.S. I'm trying to find a friendly Leaf owner in Hong Kong to co-operate with this. There are 200+ Leafs here, and no carwings coverage at all, but most are in government service and relatively few in private hands.
>>>>>>> 
>>>>>>> On 15 Oct, 2013, at 11:45 am, Barry Gershenfeld <gbarry42 at gmail.com">target="_blank">gbarry42 at gmail.com> wrote:
>>>>>>> 
>>>>>>> Early development assumed you had to get the EV info from the EV-CAN buss.  Somewhere during the development of Leaf Spy they kept finding desirable info on the car-CAN buss and so eventually determined that all if could be gotten from the car-CAN.  As a bonus, the ELM dongle no longer has to be modified to read the EV buss.
>>>>>>> 
>>>>>>> The original reporting efforts started with the "GID" meter, and the early work involved Gary G. building a data recorder as well as a program to analyze the logs.  I'm sure that's precisely what you have in mind as well.  There were downloadable logs--he invited others to install the analyzer and try to find meaningful messages therein.  But as it was early development, they were probably gotten from the EV-CAN.  I don't know if any more recent logs from the car CAN buss are posted.
>>>>>>> 
>>>>>>> As a matter of fact, I suspect Gary would be happy to have his analyzing program used.  It would be nice output the data into the same format that it uses.  Or at least write a converter.
>>>>>>> 
>>>>>>> I naturally have some interest, being a LEAF owner and PIC hacker.  I'll see if I can make head or tail of the developer's guide.
>>>>>>> 
>>>>>>>  * * *
>>>>>>> 
>>>>>>> On Mon, Oct 14, 2013 at 7:04 PM, Mark Webb-Johnson <mark at webb-johnson.net">target="_blank">mark at webb-johnson.net> wrote:
>>>>>>> Developers guide is here:
>>>>>>> 
>>>>>>> https://github.com/markwj/Open-Vehicle-Monitoring-System/blob/master/docs/OVMS_Development.pdf?raw=true
>>>>>>> 
>>>>>>> I would rather the actual development discussions take place here on this list. A lot of smart people here, with experience getting these vehicle modules working.
>>>>>>> 
>>>>>>> The biggest concern for me is whether we can get everything we need off one CAN bus...
>>>>>>> _______________________________________________
>>>>>>> OvmsDev mailing list
>>>>>>> OvmsDev at lists.teslaclub.hk">target="_blank">OvmsDev at lists.teslaclub.hk
>>>>>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>>>>>>> 
>>>>>>> _______________________________________________
>>>>>>> OvmsDev mailing list
>>>>>>> OvmsDev at lists.teslaclub.hk">target="_blank">OvmsDev at lists.teslaclub.hk
>>>>>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>>>>>>> 
>>>>>>> _______________________________________________
>>>>>>> OvmsDev mailing list
>>>>>>> OvmsDev at lists.teslaclub.hk">target="_blank">OvmsDev at lists.teslaclub.hk
>>>>>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>>>>>>> _______________________________________________
>>>>>>> OvmsDev mailing list
>>>>>>> OvmsDev at lists.teslaclub.hk">target="_blank">OvmsDev at lists.teslaclub.hk
>>>>>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> _______________________________________________
>>>>>>> OvmsDev mailing list
>>>>>>> OvmsDev at lists.teslaclub.hk
>>>>>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>>>>>> _______________________________________________
>>>>>> OvmsDev mailing list
>>>>>> OvmsDev at lists.teslaclub.hk
>>>>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>>>>> 
>>>>> _______________________________________________
>>>>> OvmsDev mailing list
>>>>> OvmsDev at lists.teslaclub.hk
>>>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>>>> 
>>> 
>>> _______________________________________________
>>> OvmsDev mailing list
>>> OvmsDev at lists.teslaclub.hk
>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>> 
>> _______________________________________________
>> OvmsDev mailing list
>> OvmsDev at lists.teslaclub.hk
>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.teslaclub.hk/pipermail/ovmsdev/attachments/20131105/a687c681/attachment-0001.html>


More information about the OvmsDev mailing list