User avatar
garygid
Gold Member
Posts: 12466
Joined: Wed Apr 21, 2010 8:10 am
Delivery Date: 29 Mar 2011
Leaf Number: 000855
Location: Laguna Hills, Orange Co, CA

Re: LEAF CANbus decoding. (Open discussion)

Sun Jun 12, 2011 12:39 pm

Success!
Our FIRST drive while recording all three CAN-buss messages, AND seeing the changing data on the laptop's screen (on the CAN-Do "dashboard"). [EV-CAN, CAR-CAN, and AV-CAN messages.]

Equipment:
1. An "OBD" cable, ending with
2. Power, Ground, and two CAN signals (H & L) on a 9-pin "D" female connector. [One for each CAN buss]
3. An AVR-CAN Development Board for the Atmel AT90CAN128 (not 228, sorry) micro-processor. [One for each CAN buss]
4. An RS232 to USB connection (to a virtual Comm/TTY Port in in the PC). [one for each channel]
5. The CAN-Do program, version 1.3.3 or later.
6. Laptop or Netbook running XP or Vista (or Win7?).

Note: I bought a 4-port RS232 to one USB adapter that seems to work very well.
Last edited by garygid on Mon Jun 13, 2011 6:57 am, edited 1 time in total.
See SOC/GID-Meter and CAN-Do Info
2010 Prius
2011 LEAF, 2014 Tesla S85
2018 & 2019 Tesla Model 3
PU: SDG&E
Solar PV: 33 x 225W -> 7 kW max AC
Craigslist: Xm5000Li Electric Motorcycle

sparky
Posts: 725
Joined: Fri Apr 23, 2010 10:55 am
Delivery Date: 08 Jan 2011
Location: SoCal

Re: LEAF CANbus decoding. (Open discussion)

Sun Jun 12, 2011 10:17 pm

(Edited to fix error with 0x1DB byte field description)
Had a little time to play with the CAN codes today;

Based on turbo2ltr's hints and some info from Groundloop, Gary, Robert and others, looked at the ID 0x1DA.

Bytes D4 & D5 behave like RPM, when scaled. I logged data while on a drive. plotted the "RPM" field. Since the LEAF is a direct drive EV, we can go from RPM straight to MPH or even use it as an odometer as I show in the plot below.
Integrate the time-tagged, "RPM" field (blue curve) and scale to the gear ratio and tire dimensions to get miles traveled (red curve). Compares perfectly with odometer reading for this trip.
Putting the LEAF in reverse works too, RPMs go negative.
Image


Next I looked at ID 0x1DB:
Three things of interest. This field seems to commutate through 0,1,2,3 identifiers. I wonder if this is identifies different battery pack "strings". The numbers track pretty well with some leading and lagging during high loads. But, I may be reading too much into the 0,1,2,3 thing.
Image



A portion of the 8 bytes behave like current to/from the battery edit:(D1D2); positive when charging and regen and negative when sitting with car "ON" or driving. "Volts" seem to reside in Byte D3 and the upper 2 bits of D4.
Direct correlation with acceleration/deceleration as shown in plot. I plotted a short segment of a drive where I got on the freeway and then took the next exit off.

My scaling for current and Volts is a total guess. First plot is "Amps" second is "Volts". Notice the 1/RC exponential voltage sag during regions of high power draw and voltage recovery during regen... seems plausible.

Image



Image


Still looking through the IDs for more hints... too much data...good times.
Last edited by sparky on Mon Jun 13, 2011 3:06 pm, edited 1 time in total.

GroundLoop
Posts: 1725
Joined: Mon Sep 13, 2010 9:31 pm

Re: LEAF CANbus decoding. (Open discussion)

Sun Jun 12, 2011 10:30 pm

I'm ordering up an AT90 board this week.

I have to say the Serial LCD has been a real disappointment. It's too slow for a rapid (bar graph) display, frequently gets corrupted at 9600bps, and needs delays inserted between most commands.

I'm going back to the standard 4-bit Hitachi displays.

Aside from that, I do have a crude SOC gauge in my car now, showing 98.5% :)

GroundLoop
Posts: 1725
Joined: Mon Sep 13, 2010 9:31 pm

Re: LEAF CANbus decoding. (Open discussion)

Sun Jun 12, 2011 10:41 pm

sparky, nice plots and research!

The idea of a single message rotating through battery strings (0/1/2/3) is very interesting.
I may have to collect data differently.

User avatar
garygid
Gold Member
Posts: 12466
Joined: Wed Apr 21, 2010 8:10 am
Delivery Date: 29 Mar 2011
Leaf Number: 000855
Location: Laguna Hills, Orange Co, CA

Re: LEAF CANbus decoding. (Open discussion)

Sun Jun 12, 2011 10:46 pm

Great work and graphs! :D

I will add these four values (Pack Volts and Amps, Speed/RPM and Trip-Distance) to my Dashboard tomorrow afternoon.

If you send me one of your Car-CAN message Log files, I will try to add reading support for that format in CAN-Do.

Also, I will try to reproduce the results from the data in my own Car-CAN buss logs.

Do the RPM (1DA) messages come at nice regular intervals so that "integrating" the indicated speed gives an accurate distance, or does one need to multiply by varying time intervals?

Again, super work!
Thanks, GaryG
See SOC/GID-Meter and CAN-Do Info
2010 Prius
2011 LEAF, 2014 Tesla S85
2018 & 2019 Tesla Model 3
PU: SDG&E
Solar PV: 33 x 225W -> 7 kW max AC
Craigslist: Xm5000Li Electric Motorcycle

User avatar
garygid
Gold Member
Posts: 12466
Joined: Wed Apr 21, 2010 8:10 am
Delivery Date: 29 Mar 2011
Leaf Number: 000855
Location: Laguna Hills, Orange Co, CA

Re: LEAF CANbus decoding. (Open discussion)

Sun Jun 12, 2011 10:49 pm

There are a number of other messages that have a 0, 1, 2, 3 rotation.

Finding a 4 x 12 would be the number of modules, with two cell-pairs per module.
See SOC/GID-Meter and CAN-Do Info
2010 Prius
2011 LEAF, 2014 Tesla S85
2018 & 2019 Tesla Model 3
PU: SDG&E
Solar PV: 33 x 225W -> 7 kW max AC
Craigslist: Xm5000Li Electric Motorcycle

GroundLoop
Posts: 1725
Joined: Mon Sep 13, 2010 9:31 pm

Re: LEAF CANbus decoding. (Open discussion)

Sun Jun 12, 2011 11:49 pm

garygid wrote:S
3. An AVR-CAN Development Board for the Atmel AT90CAN228 micro-processor. [One for each CAN buss]
After hitting all my supplier sites, I have to conclude that this is a typo, and not some new hot Atmel CAN board with twice the flash. Aw. :(

User avatar
garygid
Gold Member
Posts: 12466
Joined: Wed Apr 21, 2010 8:10 am
Delivery Date: 29 Mar 2011
Leaf Number: 000855
Location: Laguna Hills, Orange Co, CA

Re: LEAF CANbus decoding. (Open discussion)

Mon Jun 13, 2011 6:59 am

Yes, 128, not 228 ... I fixed the post. Thanks, GL :D
See SOC/GID-Meter and CAN-Do Info
2010 Prius
2011 LEAF, 2014 Tesla S85
2018 & 2019 Tesla Model 3
PU: SDG&E
Solar PV: 33 x 225W -> 7 kW max AC
Craigslist: Xm5000Li Electric Motorcycle

sparky
Posts: 725
Joined: Fri Apr 23, 2010 10:55 am
Delivery Date: 08 Jan 2011
Location: SoCal

Re: LEAF CANbus decoding. (Open discussion)

Mon Jun 13, 2011 7:29 am

garygid wrote:Great work and graphs! :D
I will add these four values (Pack Volts and Amps, Speed/RPM and Trip-Distance) to my Dashboard tomorrow afternoon.
If you send me one of your Car-CAN message Log files, I will try to add reading support for that format in CAN-Do.
Also, I will try to reproduce the results from the data in my own Car-CAN buss logs.

Do the RPM (1DA) messages come at nice regular intervals so that "integrating" the indicated speed gives an accurate distance, or does one need to multiply by varying time intervals?

Again, super work!
Thanks, GaryG
My pleasure!
I don't know how useful the distance estimator is. I mostly used it as a check of my interpretation of that data field (and 'cuz it was fun). I wasn't sure about the regularity of the 1DA packet so, I integrated as a function of my CAN time packets. But, I think your CAN reader has that built in. Also, I don't really generate "Car-CAN" messages but my own flavor (per Robert's very useful source code mod) that I prefer for debugging with Python. So, I doubt my logged data is much help at this point. Everything comes across the RS232<->USB in the same format (binary, with cksum syncing) but gets parsed into ID-based files in human readable ASCII.
As you noted, there's a lot of 0,1,2,3 action. Seems to be in nearly every 0x1XX packet I examine.

User avatar
garygid
Gold Member
Posts: 12466
Joined: Wed Apr 21, 2010 8:10 am
Delivery Date: 29 Mar 2011
Leaf Number: 000855
Location: Laguna Hills, Orange Co, CA

Re: LEAF CANbus decoding. (Open discussion)

Mon Jun 13, 2011 7:38 am

For trial plotting of 2-byte data "values" in CAN-Do, I intend to add the following:

1. D?, where the ? is a number 1 to 8 selecting a data byte, 0 for zero value
2. Mhh is two hex digits to Mask the selected data value
3. Sn is one signed decimal digit to shift (multiply by 2^n) the value before combining

Something like:
D4 MFF S0 + D3 M07 S8
(low 3 bits of D3 followed by all 8 bits of D4 => an 11-bit value)
or
D4 MC0 S-6 + D3 M3F S2
(low 6 bits of D3 with high 2 bits of D4 => an 8-bit value)

Then scale the graph by letting the user select the MAX and MIN values. If either is zero, the data could auto-scale.

Probably I need to add a selection of "signed" or "two's compliment" type values.
See SOC/GID-Meter and CAN-Do Info
2010 Prius
2011 LEAF, 2014 Tesla S85
2018 & 2019 Tesla Model 3
PU: SDG&E
Solar PV: 33 x 225W -> 7 kW max AC
Craigslist: Xm5000Li Electric Motorcycle

Return to “LEAF CANBus”