baradhili / leaf_can_bus_messages

Leaf can bus message decoding
GNU General Public License v3.0
9 stars 50 forks source link

Is there a way to read the dashboard charge (0-100%)? #2

Open eabase opened 4 years ago

eabase commented 4 years ago

I'm trying to find the place (CANbus code) to read the "fuel" gauge shown on the dashboard. Is there a way to read this value? (We already know how to read SoC.)

dalathegreat commented 4 years ago

I have yet to figure this one out. I would also like to know this, so that I could add more chargebars with an upgraded battery.

I have tried modifying the high nibble frame[3] on 5BC, when the mux == 3. This caused the chargebars to jump, so it's somewhere there atleast.

In the meantime you can estimate it. You can use the GIDs number and divide it by 12. 24kWh has ~280 gids full, 30kWh has ~360 gids full. So an example would be (120/280)*12=5.14 = 5 bars active

eabase commented 4 years ago

@dalathegreat Hi Daniel, Thanks for quick answer! Yeah, we tried a bunch of stuff, but could not find a reliable up-to-date info source...

This caused the chargebars to jump...

Perhaps, I wasn't clear. We would like to get the percentage (in %) and don't really care how many "bars" there are. We made some tests and found that, when compared to LeafSpy SoC % the Dashboard % is off by some linear coefficient until a certain point (~60%), then it's off by another coefficient, and then (probably) again by another around 95-100%... We lost some data as we had to switch back and forth from LeafSpy and our own OBD reader.

In the meantime you can estimate it.

We haven't found how to read the GIDs yet...AFAIK. (I'll have to check.)
We have a Nissan Leaf 2018 with a 40 kWh battery pack. I read somewhere, that would mean ~500 GIDs... for a new & full pack. But then I read somewhere else that it could range between 425 - 500...

Then I guess it would also be useful to read the currentBattery (Ah).

baradhili commented 4 years ago

They do often refer to it as the "guessometer" :)... My thought was that there was some smarts in the dashboard to render the fuel bars..

On Thu, 19 Sep 2019 at 21:51, eabase notifications@github.com wrote:

@dalathegreat Hi Daniel, Thanks for quick answer! Yeah, we tried a bunch of stuff, but could not find a reliable up-to-date info source...

This caused the chargebars to jump...

Perhaps, I wasn't clear. We would like to get the percentage (in %) and don't really care how many "bars" there are. We made some tests and find that the Dashboard % is off by some linear coefficient until a certain point (~60%), then it's off by another coefficient, and then (probably) again by another around 95-100%... We lost some data as we had to switch back and forth from LeafSpy and our own OBD reader.

In the meantime you can estimate it.

We haven't found the GIDs yet...AFAIK. (I'll have to check.) We have a Nissan Leaf 2018 with a 40 kWh battery pack. I read somewhere, that would mean ~500 GIDs... for a new & full pack. But then I read somewhere else that it could range between 425 - 500...

Then I guess it would also be useful to read the currentBattery (Ah).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

dalathegreat commented 4 years ago

@eabase Ok, then it is more simple :) Plug in Leafspy to the car, and read the number of gids when the car is fully charged. then there is no question wheter its 400 or 500.

The gids are found in the frist 10bits of the 0x5BC on the EV-CAN. You can def use these :)

There is also a SOC here case 0x55B: //Check what SOC the LBC reports (10 bits, all 8bits from frame[0], and 2 bits from frame[1] 0xC0) LBC_StateOfCharge = (frame.data[0] << 2) | ((frame.data[1] & 0xC0) >> 6);

eabase commented 4 years ago

Hmm, looking again, I don't quite get your example.

In the meantime you can estimate it. You can use the GIDs number and divide it by 12. 24kWh has ~280 gids full, 30kWh has ~360 gids full. So an example would be (120/280)*12=5.14 = 5 bars active

There you say divide by 12, yet you multiply...

Ok, we have: SOC, GID. Where does the 120 and 12.24 kWh come from?
(Are they also read from the CANbus?)

dalathegreat commented 4 years ago

Sorry for confusing you. If you have found SoC from 0x55B frame, then use that! It's in percentage already.

If you want to use GIDs from 0x5BC, here is how to calculate the charge percentage from GIDs Say you measure 250gids, then you can take (250measured/500total)=0,5=50%

But the internally calculated value from the battery is the easiest to use (found in 0x55B, the first 10bits). The dash uses it's own percentage, that comes from the VCM.

eabase commented 4 years ago

The dash uses it's own percentage, that comes from the VCM.

That's actually what we want!

(What is "VCM"? Where do those values come from? Can they be read from the dashboard class of the Nissan specific CAN messages?)

eabase commented 4 years ago

Just to clarify for everyone, here's how our dashboard looks: Nissan_Leaf_2018_dash_batt_stat_1

So as for the "bars" mentioned above, I'm not sure which bars they are talking about, because the bars look totally different on other Leaf models where they usually go from 1-12. Here there are many more (20).

Also, counting "bars" in the picture above we see:

So what exactly do the gray highlighted bars represent?

eabase commented 4 years ago

OT Warning:

After having looked at the Excel sheets, I realize that there are 2 CAN buses!

  1. The Car CAN bus
  2. The EV CAN bus

We're reading SOC from the CAR CAN with 0x7BB. How do we access and read the EV CAN to get the 0x5BC?

baradhili commented 4 years ago

I think there is actually 3 busses altogether..

On Mon, 23 Sep 2019 at 22:02, eabase notifications@github.com wrote:

OT Warning:

After having looked at the Excel sheets, I realize that there are 2 CAN buses!

The Car CAN bus The EV CAN bus

We're reading SOC from CAR a CAN with 0x7BB. How do we accessa and read the EV CAN to get the 0x5BC?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

-- Bret Watson Director IT Interim Management Pty Ltd T/A TICM Mob: +61 (0)41 33 03 840 Email:bret@IT-Interim.Management "The contents of this e-mail transmission are intended solely for the named recipient(s), may be confidential, and may be privileged or otherwise protected from disclosure in the public interest. The use, reproduction, disclosure or distribution of the contents of this e-mail transmission by any person other than the named recipient(s) is prohibited. If you are not a named recipient please notify the sender immediately."

baradhili commented 4 years ago

All 3 get presented at the centre console I think there is a way to get to them via the OBD II connector

On Mon, 23 Sep 2019 at 22:02, eabase notifications@github.com wrote:

OT Warning:

After having looked at the Excel sheets, I realize that there are 2 CAN buses!

  1. The Car CAN bus
  2. The EV CAN bus

We're reading SOC from CAR a CAN with 0x7BB. How do we accessa and read the EV CAN to get the 0x5BC?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/baradhili/leaf_can_bus_messages/issues/2?email_source=notifications&email_token=AAFC2FEGMDRP33J5I7Q2QNLQLDEAHA5CNFSM4IYIOTHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7K6YRQ#issuecomment-534113350, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFC2FCWAZ7C4RVMRGYGQVLQLDEAHANCNFSM4IYIOTHA .

-- Bret Watson Director IT Interim Management Pty Ltd T/A TICM Mob: +61 (0)41 33 03 840 Email:bret@IT-Interim.Management "The contents of this e-mail transmission are intended solely for the named recipient(s), may be confidential, and may be privileged or otherwise protected from disclosure in the public interest. The use, reproduction, disclosure or distribution of the contents of this e-mail transmission by any person other than the named recipient(s) is prohibited. If you are not a named recipient please notify the sender immediately."

dalathegreat commented 4 years ago

image Here's the EV-CAN

eabase commented 4 years ago

That explains it. We don't have pins 12,13 on our OBD2 dongle.

@dalathegreat ~Where can we find out more about that info? (Where/how did you find it?)~

I think from HERE. :+1:

Another cool comment on the previous page:

I've been spending heaps of time getting to know the Nissan Leaf CAN system. Here is a compressed version, to quickly get you started with debugging the LEAF CAN system.

The LEAF uses standard 11-bit frames. Bus speed is 500kbps. There are 4x CAN buses available, CARcan, EVcan, QCcan and AVcan. We are only interested in the EVcan for correcting battery upgrades. Message speed in ms is 10/20/40/60/100/103/500/512 depending on which bus and message you look at. Stuff like amperages and voltages need to be communicated extremely quickly (10ms), but lower priority stuff like sending stuff to the instrument cluster is 50x slower (500ms)

The EVcan bus is extremely tolerant to errors. You can pause communication, and the car triggers limp mode, and on resuming communication the errors are cleared. Reverse engineering by simply modifying and seeing what happens is totally doable!

Lets take a closer look at frame 0x5BC on the EVcan, it contains much good stuff and is sent every 500ms from the LBC->VCM

A 0x5BC Frame, captured with CANrunner from my 24/30kWh brute-force battery LBC
HEX: 0x17 c0 f0 64 c9 03 02 d0
DEC: 23 192 240 100 201 3 2 208
‭BIN: 00010111‬ 10000001 11110000 1100100 11001001 0011 ‭0010 11010000

The Battery Gauge display on the instrument cluster is powered by the GIDs signal (the first 10 bits of 0x5BC). The km estimate that the Guess-O-Meter spits out is also linked to the available GIDs. From example frame (BIN 1011110 = 94 DEC) for 94 GIDs available!

0x5BC bits 36-39 (the high nibble of the 5th byte) affects the battery charge gauge, lower numbers mean more bars. This section probably contains how much one GID is worth OR some degradation offset.

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. Changing this value directly manipulates the number of bars displayed, the value on the can bus is literally the number of bars. From example frame (BIN 1100 = 12 DEC) 12 capacity bars available!

baradhili commented 4 years ago

Thats a challenge.. I know the 2018 series has a different centre console, looks like it also has different CAN layout.. I will look at splitting the data into model years.. as I suspect things changed over time anyway

eabase commented 4 years ago

@dalathegreat I noticed that some values are duplicated over different CAN buses. For example the SOC. So is there any hope that some of the values you mentioned in the EVcan, might alse be found in the CARcan?

dalathegreat commented 4 years ago

@dalathegreat I noticed that some values are duplicated over different CAN buses. For example the SOC. So is there any hope that some of the values you mentioned in the EVcan, might alse be found in the CARcan?

Sorry, no clue, I have yet to start investigate the CARcan. Easiest to take logs and start playing back messages and looking for the SOC/GIDS/etc.

opit commented 3 years ago

image Here's the EV-CAN

I took a photo of the port and 12/13 are not populated on a 2018 Leaf.

2018:

2014:

I am currently struggling to get any signal on the 2018 port. The standard CAN pins are completely dark. 12V+ is working and car is starting and driving. I measured 60 Ohm resistance between CanH & CanL on both 2018 and 2014.

dalathegreat commented 3 years ago

@opit the 2018+ port is firewalled, so no passive messages floating on the bus. You need to send request messages in order to get something out!

opit commented 3 years ago

@opit the 2018+ port is firewalled, so no passive messages floating on the bus. You need to send request messages in order to get something out!

Yes, thanks! I spliced the CAN line going to the battery box and got a message dump from there.

I posted the dump here in case it is useful for someone: https://openinverter.org/forum/viewtopic.php?f=13&t=1321&p=21572#p21572

Pezzella commented 3 months ago

@eabase did you manage to get your brute force upgrade to give the correct info on the dashboard?

I'm currently going through the process myself to get the instrumentation to function properly

eabase commented 3 months ago

Hi @Pezzella Unfortunately, I Haven't been working on this since my last comment.

ilataniuk commented 2 months ago

Hi folks, did anyone realise how to change dash soc on Leaf 2018+ ? like for Leaf 2014-2017 via changing value in byte#4 in 0x1db frame