## Help me find capacity bars in 0x5BC

Dala
Forum Supporter
Posts: 287
Joined: Sun Oct 28, 2018 11:24 am
Delivery Date: 01 Jan 2015
Leaf Number: 316851
Location: Finland
Contact: Website

### Help me find capacity bars in 0x5BC

Could someone give me a helping pointer towards where to get the outer capacity bars in 0x5BC?

Two example frames from a 2015 Leaf (with 3 as mux).
0x17 c0 f0 64 c9 03 02 d0

0x17 c0 50 64 c8 03 03 fc

The excel sheet says:
"The battery capacity gauge (the bars outside the fuel gauge) is controlled by a muxed field, when 0x5BC bits 32-35 (ie the low nibble of the 5th byte) is 0x3, 0x5BC bits 16-19 (ie the low nibble of the 3rd byte) contains the capacity bars."

This doesn't make any sense to me. If I assume the Byte goes from 0-7, here is where the muxed is
0x17 c0 f0 64 c9 03 02 d0

Then the capacity bars should be in
0x17 c0 f0 64 c9 03 02 d0

The high nibble of this section is HEX: F == DEC = 15, which makes no sense since it's at 12/12 capacity bars. What am I missing?!

danrjones
Posts: 810
Joined: Wed Apr 17, 2019 8:02 am
Delivery Date: 17 Jun 2019
Location: Ridgecrest, CA

### Re: Help me find capacity bars in 0x5BC

Is it nibble or bit swapped?

Based on your description I'm assuming the 0x17 is the message number, as you are not counting the 17 as message bytes? (see at the end)

Bits indeed start at zero but if I say the 16th bit is would actually be bit location 15.
Starting at the 16th bit (bit 15) I see 0011 in "c0f064", ignoring the "17"
But if its swapped it would then be 1100. That happens to be 12. But......

But if we include the 17 as part of the message, hence "17c0f0", then wouldn't you need to include the 17 in the muxed message as well?
The 5th byte of the original message "17 c0 50 64 c8 03 " is actually "c8"
Or from "17 c0 f0 64 c9 03 02 d0" the 5th byte is "c9"

That's the way I always learned it - in other words your first byte is bit 0-7 and so on.
2018 Leaf SV Pearl White with Tech and All Weather, Purchased New on 5/3/19

Noal
Posts: 2
Joined: Mon Aug 13, 2018 4:35 am
Location: Moscow, Mordor

### Re: Help me find capacity bars in 0x5BC

Dala wrote:
Thu Sep 19, 2019 5:37 am
The excel sheet says:
"The battery capacity gauge (the bars outside the fuel gauge) is controlled by a muxed field...

Where do you get this excel sheet?
Cannot find it. Only seemingly older versions without that info

Dala
Forum Supporter
Posts: 287
Joined: Sun Oct 28, 2018 11:24 am
Delivery Date: 01 Jan 2015
Leaf Number: 316851
Location: Finland
Contact: Website

### Re: Help me find capacity bars in 0x5BC

I did it!

Turns out there are some major differences in 0x5BC between the ZE0 and AZE0-1
1. The 2011 LBC sends this message at 500ms interval. On the 2015 LBC, this message is sent much quicker, at an 100ms interval.
2. The location for capacity bars is not what the Excel suggested. On the 2015 LBC, the capacity (and charge bars) are set in frame[2]4-7. The multiplex signal is also different, it is controlled by frame[4]0-3, which alternates between 8/9

3. The LBC achieves some sort of backwardscompatible mode by writing charge bars for 5 messages (5x100ms), and then switches to capacity bars for 5 messages (5x100ms)
4. Here is a picture of the success 100% Soh, manipulated to 9cap, 51% battery, manipulated to 10/12bars

For some reason, the capacity bars are "15" when 12/12. If you write 11, it seems to do (11/15)*12=8,8=9 bars shown.
Also the charge bars have an 1-offset, here in the picture I've written it to 11, but it shows 10.

I will update the excel, it is in github, I have made some commits in my own branch, and will push to the master soon.
https://github.com/dalathegreat/leaf_can_bus_messages