LEAF CAN 101 tutorial?

My Nissan Leaf Forum

Help Support My Nissan Leaf Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

kevinleaf

Well-known member
Joined
Jun 3, 2013
Messages
178
I am reading thru these thread and it has a ton of great information. Obviously people have been working very hard to get the information out of the car and to the community and I for one really appreciate it!

I'm trying to write an app to get and display one specific piece of info from the car but I am a bit overwhelmed with all the info here. I'll be connecting to the car with the Bluetooth ELM327 and my computer or an Android device. Is there like a "Leaf CAN 101" description I can read? I am an adept and experienced programmer. Assume I am looking for SOC to start with. From the spreadsheet I can see it is "55b" but I don't know where to put this. I was hoping for something as simple as:
1. Establish connection to the car
2. Issue this command(s) to initialize and verify connection
3. Be sure you get XYZ as a response
4. Send this command
5. Response looks like ZYX. Decode by getting bytes 2,3,4 and do "this" to them.

Thanks in advance!
 
First, you really need the ELM327 tutorial.
Apparently using it is not the easiest thing to do.

Accessing the CAN bus directly, one can listen to all the traffic
(CAN Messages), or watch for a message with a specific Message ID
(or a specific set of MsgIDs). Or, with more knowledge, one can
write to the CAN bus, possibly disturbing the car.

Writing a CAN Message (the MsgID and the associated data carefully
chosen) could just spoof an existing message, in an attempt to modify
the vehicle's operation, or send an "expected" query, expecting one or more
messages as a response. For example, the Query & Response is used to
get data that does not otherwise appear in the CAN message stream,
like all the 96 cell-pair voltages.

Of course, being cautious is always wise.
 
As a safety precaution, sending messages to the car's CAN bus is
usually best experimented with while the car is not moving.

Turbo3, TickTock, and others have done a lot of fine work and
investigations, but it takes a lot of reading these threads to
understand what they have done. Turbo3 has done the most
work with the ELM imitations, and TickTock's Canary generally
reads the CAN buses, but also uses the Query & Response
methods that were discovered in the past year or so, I believe.

The Canary can be used to log the CAN bus activity, and create
CAN-Do compatible log files. It is based on the Mbed, while
we have continued to use the AVR-CAN board for multi-CAN
logging.

We are making progress in understanding the Tesla S
when charging from the SuperCharger. We have logged
the LEAF's use of the Quick Charger, and believe that
we understand most of the normal charging conversation.
With the Tesla S, we still have a lot of investigation to do,
but we have observed the VIN while using the SC, and on
the OBD's CAN bus.
 
Thanks Gary!
First, you really need the ELM327 tutorial
Does such a tutorial exist? This would be very helpful. I do intend on focusing my efforts on the ELM327, for now at least.

When I started to try to modify existing Android and Java centric OBD-II libraries I realized I didn't really know what I was doing. I understand that sending the wrong messages can cause issues and I definitely don't want to break my car.
 
This makes a lot more sense now. I have written the basics of an app to read the CAN bus and now have a LOT more respect for the work everyone has done here. This stuff is hard, and very hard to get working reliably and repeatably.

On the ELM327 I've basically set the messages to listen for and read the data that flows back as quick as I can. I do:
ATZ to reset
ATE0 to turn echo off
ATH1 to turn headers on (better for making sure the data I get back is what I asked for)
ATCAF0 to turn auto-formatting on (the LEAF does not send the data in a way the ELM327 can auto-format)
ATDP to return the protocol (its always ISO 15765-4 (CAN 11/500) but this is just a good sanity check)
ATCF 5B3 to say I want just message 5B3
ATCM 7FF to mask the data I don't want
ATMA to start the flow of data

I got a nice flow of data now. This is starting to make a little more sense now.

I can see a stream back like:
5B3 78 C8 FF F4 A0 41 F0 8A
5B3 78 C8 30 D8 A0 41 F0 8A
5B3 78 C8 30 D8 A0 41 F0 8A
5B3 78 C8 FF FC A0 41 F0 8A
5B3 78 C8 FF FC A0 41 F0 8A
5B3 78 C8 FF F0 A0 41 F0 8A
5B3 78 C8 FF F0 A0 41 F0 8A
5B3 78 C8 FF F4 A0 41 F0 8A

If I am interpreting this right the 78 C8 together are the SOH but this doesn't seem to make sense, since 78C8 is 30,920. I thought GIDs would be the 5th byte but the current value in my car is more than 15. So I guess I am interpreting this wrong. Any guidance the community can give me would be appreciated. Figuring out this one example will help me in reading the spreadsheet better for other values.

Thanks!
 
^^^
Woah. Didn't realize the commands were like Hayes modem AT commands. I remember the days of ATDT, ATH, ATZ, the optimal init string, etc.
 
yeah keep in mind this is for the ELM327 interface. It does seem pretty arcane.

Full specs of the ELM327 are here:
http://www.elmelectronics.com/DSheets/ELM327DS.pdf" onclick="window.open(this.href);return false;
 
kevinleaf said:
yeah keep in mind this is for the ELM327 interface. It does seem pretty arcane.

Full specs of the ELM327 are here:
http://www.elmelectronics.com/DSheets/ELM327DS.pdf" onclick="window.open(this.href);return false;
Wow. Interesting. I've only skimmed a few pages.

I never looked into the ELM work on Priuschat but I wonder if what RobH (I've met him before) at http://priuschat.com/threads/elm327-usb-vehicle-obd-2-scanner-tool.83427/#post-1164888" onclick="window.open(this.href);return false; says is true...
Any "ELM" tool that costs less than about $75 can't possibly have a genuine ELM chip in it. ELM chips go for $30 each. The cheaper ones are probably all "ELM Compatible" protocol, based on the earliest version of the genuine ELM chip that wasn't copy protected.
 
I don't doubt that all the super-cheapo chips out there are knock-offs. I bought my bluetooth plus ELM327 adaptor for around $10. It works.

There is plenty of discussion elsewhere on this message boards on the ELM327's. I'd like to focus on the topic here. PM me if you would like a bluetooth ELM327 to play around with. I bought a few, expecting some to be faulty.
 
You can learn a lot about interpretation of the EV-bus data by
downloading my CAN-Do progran, a Log of the EV-CAN bus
in the LEAF, and a recipe file. Use the link in my signature.

Did you find the spreadsheet listing the "discovered" CAN MsgIDs
and the assumed meaning of some of the data bytes?
 
I believe I have the right spreadsheet:
https://docs.google.com/spreadsheet/ccc?key=0An7gtcYL2Oy0dGRaSWl6VTV2eXBQMy1ON2xZSzlMUXc#gid=1" onclick="window.open(this.href);return false;
it is just a little confusing to interpret. For example for the 5B3 message I see SOH is byte 1 and its noted as 7:1 but I don't know what that means. Now I believe this means bits 1 to 7 of this byte. So I take the C8 value I got and right shift it on bit to get 64 which gives me 100 as SOH

More later. Hard to figure anything out here with babies crying...
 
Back
Top