samsta / BatteryController

GNU General Public License v3.0
0 stars 0 forks source link

Send SMA::BatteryMeasurements message as part of periodic broadcast #8

Open samsta opened 4 years ago

samsta commented 4 years ago

This requires decoding of the Nissan::BatteryStatus message (0x1db) which we haven't decoded until now. The reason we need it is the current as none of the other messages have the current. It also has the voltage, which we could in theory work out by summing the cell voltage, but that seems silly considering we have it readily available.

Temperature is the average of the 3 sensors.

samsta commented 4 years ago

Dammit. I have very little trust in what info we have on 0x1DB (and 0x1DC). The reason is that according to the DBC some fields are most significant bit first, and others are least significant bit first (i.e. in reverse), so there's some inconsistency which to me raises a red flag. It's particularly obvious when looking at 0x1DC which has the max power LSB first and the max charge power MSB first. Huh?!

samsta commented 4 years ago

The implementation is complete to the best of my knowledge, but until we've verified that 0x1DB is correct (see above) I won't close this issue

NiallDarwin commented 4 years ago

CAN captures from the orphan G2 battery & my G1 car are now in the CAN Captures/Leaf Battery dropbox directory. Note that the captures from the car only feature 1DB & 1DC on CAN1. This is the 'EV' CAN network. The Primary CAN network doesn't show those messages. I don't know if Leafspy uses the EV can as well as the Primary CAN or if the data in 1DB & 1DC are interpreted by some other computer (likely the VCU) and re-transmitted in a different form on the Primary CAN

NiallDarwin commented 4 years ago

Leafspy shows up to 4.19A being used when car is on, in 'P' with AC running. Batt voltage of 373V so that's 1562W

samsta commented 4 years ago

G1 Batt in car power on AC on drive up to 40kW primary CAN0 EV CAN1 G1 Batt in car power on AC on drive up to 40kW primary CAN0 EV CAN1.png That seems to match pretty well, up to -105A (assuming negative means out of the battery), so 105A*375V=39.375kW

G1 Batt in car power on AC on then off etc primary CAN0 EV CAN1 G1 Batt in car power on AC on then off etc primary CAN0 EV CAN1.png G2 Battery ex-car no current G2 Battery ex-car no current.png

Would be great to also have a capture when the battery is charging, alongside with the current LeafSpy is showing! Just so we also have a trace with significant current going the other way.

Note that the captures from the car only feature 1DB & 1DC on CAN1. This is the 'EV' CAN network. The Primary CAN network doesn't show those messages

Which one is the one we're going to be using when the battery is out of the car, is it the 'EV' CAN?

NiallDarwin commented 4 years ago

Nice graphing. Is that via SavvyCAN with a dbc loaded?

Would be great to also have a capture when the battery is charging, alongside with the current LeafSpy is showing! Just so we also have a trace with significant current going the other way.

Agree. Will need to make a patch lead so that I can do both but that shouldn't be too hard.

Which one is the one we're going to be using when the battery is out of the car, is it the 'EV' CAN?

Yes, it is the 'EV' CAN

samsta commented 4 years ago

Nice graphing. Is that via SavvyCAN with a dbc loaded?

Yep. There seems to be something weird with the way the 1DB is defined in the DBC so it wasn't as straight-forward as it ought to be. I can smell a bug in SavyCAN, not sure if I can be bothered trying to fix it ;-)