Info on BMW hybrid battery packs?

User avatar
bobby_come_lately
Posts: 465
Joined: Sun May 03, 2020 5:39 am
Location: Manchester, UK
Has thanked: 33 times
Been thanked: 36 times
Contact:

Re: Info on BMW hybrid battery packs?

Post by bobby_come_lately »

Having slept on this I think pilt is right: might be safer to do direct control of the contactors rather than relying on a code base we don't really understand. Going to rewire my plug like you have Outlandish to control them from outside.

How are you driving them? Or are you doing it manually for now?
OutlandishPanda
Posts: 50
Joined: Fri Jun 26, 2020 7:25 pm
Location: West Sussex, UK
Been thanked: 2 times

Re: Info on BMW hybrid battery packs?

Post by OutlandishPanda »

bobby_come_lately wrote: Thu Nov 12, 2020 3:02 pm How are you driving them? Or are you doing it manually for now?
IMG_7811.jpg
My plan was to trace the mosfets and high side transistors that drive the three contactors as in the photo and find the microprocessor connections. Break these, solder in flying leads suitably secured and drive with the Teensy via SimpBMS - modified. Its not that simple though because some of them need high and low sides driven so may need some additional electronics if I run out of pins on the Teensy 3.2. Seems a shame not use the electronics that is robust and appropriate for the contactors and also the connectors etc. There are uncoated test points on the PCB so I'm hoping I can solder directly to these and just remove a few resistors to break the connection to the main micro.

Anyone tried that? Otherwise, I'll just connect with external mosfets to SimpBMS in the normal way.
pilt
Posts: 15
Joined: Tue Jul 14, 2020 9:03 pm
Been thanked: 3 times

Re: Info on BMW hybrid battery packs?

Post by pilt »

Hi,

Has anyone worked out a schematic for the sbox pcb?

I have made a little progress, if you send frame 0x300 with the first byte set to 0x9f (rest of bytes to 0xFF) it will turn "ON" the small blue relay on the PCB. It makes a very quiet, but nice noise.... (sending 0x5F turns it back "OFF")

Anyone worked out what is does? I wonder if it selects the voltage measurement between pre-fuse and post fuse. Looks like i might have to draw the schematic out.
OutlandishPanda
Posts: 50
Joined: Fri Jun 26, 2020 7:25 pm
Location: West Sussex, UK
Been thanked: 2 times

Re: Info on BMW hybrid battery packs?

Post by OutlandishPanda »

Hi pilt, interesting. That is a 1kV instrumentation read relay. One end seems to be connected to the 5 pin ICs on the board above which I can't identify (opto isolators maybe) and the other end to the blue capacitor and 10 leg transformer (?) below it across the isolation space. I wonder if it is something do to with the "Monitoring the high-voltage electrical system for insulation faults" test?

May I ask, what techniques did you use to find that function? I'm keen to learn. Thanks!
OutlandishPanda
Posts: 50
Joined: Fri Jun 26, 2020 7:25 pm
Location: West Sussex, UK
Been thanked: 2 times

Re: Info on BMW hybrid battery packs?

Post by OutlandishPanda »

newTIS said on this

"Insulation monitoring
The insulation monitoring system is used for continuously checking the insulation resistance of the high-voltage system. It is operated by the MME battery management electronics. Insulation monitoring is active during driving if the high-voltage system is switched on, and is active after the vehicle has been stopped if the high-voltage system is switched off. This means it is possible to determine whether an insulation fault is located internally, within the high-voltage battery unit, or externally, within the high-voltage electrical system.

If an insulation fault (fault threshold) is identified, a Check Control message, "High-voltage system fault" (ID 586), is displayed in the instrument cluster:"

ID 210 gives pure battery volts, 220 seem to contain DC bus volts but changes also with battery terminal volts. I wonder if switching your relay on makes any difference to what 220 contains?
pilt
Posts: 15
Joined: Tue Jul 14, 2020 9:03 pm
Been thanked: 3 times

Re: Info on BMW hybrid battery packs?

Post by pilt »

Hi,

Worked out what that bit did using the Fuzzing function in savvyCAN by sending 0x300.

Tried with 0x100 but no luck, probably because it has a message count and CRC so need to so something more custom to generate. But it could also be it's not seeing any high voltage so it may not do anything
sprocketman
Posts: 49
Joined: Tue Jan 21, 2020 7:58 pm
Location: Cumbria, UK

Re: Info on BMW hybrid battery packs?

Post by sprocketman »

pilt wrote: Wed Nov 11, 2020 7:22 pm
OutlandishPanda wrote: Wed Nov 11, 2020 5:40 pm pilt, thanks, I will certainly look at the additional 12V line. I think we will need CRCs understood to get it to respond to inputs like Tom reverse engineered for the modules. I'm not assuming that is possible unless we have logs on this can line in a working vehicle, which will be a challenge I guess?
Yes a CAN log of a working vehicle would make it easy :) , but I suspect we are all working with batteries not in cars, so unless someone wants to hire a BMW e we will have to play! If we can work out the CRC (if it is even a CRC) then we should be able to see what each bit does and maybe get lucky. I will check the simpBMS code, maybe the crc is the same

The big risk if we get the Sbox to control the contactors is we dont know if there is any internal logic that could open the contactors in an attempt to protect the battery (could be a hardcoded current limit for example...) This could be very bad if we dont know about this and this happens when we dont expect it!
I have a can log from a working vehicle. PM me and i will send it.
sprocketman
Posts: 49
Joined: Tue Jan 21, 2020 7:58 pm
Location: Cumbria, UK

Re: Info on BMW hybrid battery packs?

Post by sprocketman »

pilt wrote: Thu Nov 12, 2020 10:04 pm Hi,

Has anyone worked out a schematic for the sbox pcb?

I have made a little progress, if you send frame 0x300 with the first byte set to 0x9f (rest of bytes to 0xFF) it will turn "ON" the small blue relay on the PCB. It makes a very quiet, but nice noise.... (sending 0x5F turns it back "OFF")

Anyone worked out what is does? I wonder if it selects the voltage measurement between pre-fuse and post fuse. Looks like i might have to draw the schematic out.
Try these and see what happens (should be on) Precharge first.
Get data from ID: 300 34 4A 98 6 0 0 80 61
Get data from ID: 300 35 4E 0 0 0 0 0 64

Get data from ID: 300 3D 46 59 86 65 18 96 61
Get data from ID: 300 35 7A 59 96 65 59 96 65
Get data from ID: 300 37 82 59 96 65 59 96 65
Get data from ID: 300 37 36 59 86 61 59 96 65
sprocketman
Posts: 49
Joined: Tue Jan 21, 2020 7:58 pm
Location: Cumbria, UK

Re: Info on BMW hybrid battery packs?

Post by sprocketman »

OutlandishPanda wrote: Wed Nov 11, 2020 5:40 pm Hi sprocketman, I'd not suggest connecting 8 modules to the voltage measurement connector of the S-Box (three thin orange wires), that will probably exceed its capabilities significantly! No problem with the current sensor on its own up to the capabilities of the module I expect. There are lots of resistors in series in that measurement system that presumably for a potential divider for the A2D. You can get the voltages from the modules. Just a thought!

pilt, thanks, I will certainly look at the additional 12V line. I think we will need CRCs understood to get it to respond to inputs like Tom reverse engineered for the modules. I'm not assuming that is possible unless we have logs on this can line in a working vehicle, which will be a challenge I guess?

bobby_come_lately, OK great, will be good to see others experiences with this.
Hi,
I didnt think about the voltage divider it might be too high for that. I have only been using the contactors but i will see if its ok when i get chance.
pilt
Posts: 15
Joined: Tue Jul 14, 2020 9:03 pm
Been thanked: 3 times

Re: Info on BMW hybrid battery packs?

Post by pilt »

OutlandishPanda wrote: Wed Nov 11, 2020 6:13 am So, the CAN bus is 500KBPS and I've found a good correlation with CAN ID 220 for battery volts on the battery side of the contactors.

This is preliminary but seemed to work out for turning ID220 in to volts:

Code: Select all

   //ID220 DC Bus Volts pure
            a=((float)(256*(int)(canMsg.data[2])+canMsg.data[1]))/256.0*p1;
            b=(((float)(canMsg.data[0]))/256.0)*(p2/p3);
            c=(((float)(canMsg.data[6]))/256.0)*(p4/p5);
            volts220=a+b+c;
With parameters:

Code: Select all

float p1=64.0;
float p2=p1;
float p3=256.0;
float p4=p1;
float p5=1024.0;
I'd be really grateful if others could try that and validate or adjust. Those parameters seemed "plausible" so hopefully that is about right? I'm new to this CAN reverse engineering.

Attached is my spreadsheet of working out the above from the raw log if that is any help to validate what I found. This has all the IDs logged, but only calculating on ID220.

I used a UK mains rectifier and high voltage capacitor to charge up to 300VDC and let it discharge through a resistor, then disconnected it when I saw 15V on my meter so I had known voltages in the log to compare to.
Hi OutlandishPanda,

I connected up my Sbox to the pack last night to see if i could check the voltage reading. In my box, it appears the voltage reading is stored in CAN message Ox210 byte 0 to 3.

Conversion is:

byte[3]<<16 | byte[1]<<8 | byte[0]

So in my case:

210,false,Rx,0,8,AD,62,04,80,05,D1,23,BA,

becomes: 0x0462AD = 287405
scaling is 0.001
giving 287.405V
WIth my fluke multimeter i measure 287.5

Your scaling to voltage from 0x220 cannot be quite correct as you use a byte from byte 6 as well as 0,1and 2. In the CAN standard, if you look at how a .dbc file is created, signals are only placed across sequential bytes.

What tool are you using to view the CAN messages? I can post up a .dbc file with the conversion defined and you should be able to test it at other voltages to confirm?
OutlandishPanda
Posts: 50
Joined: Fri Jun 26, 2020 7:25 pm
Location: West Sussex, UK
Been thanked: 2 times

Re: Info on BMW hybrid battery packs?

Post by OutlandishPanda »

Hi pilt, thanks so much for checking that. I think you are correct - I've now removed the use of byte 6 and it made little difference really. I think I included it because it did seem to smooth the shape when I zoomed in, but could be completely wrong to include it.

When you were testing 210, what was the contactor status? Looking at them separately, I thought that 210 was reading the DC Bus voltage and 220 was reading battery volts but I could have had that swapped because I was not with the pack. But when I applied a voltage to them both at the same time, such as with the contactor closed, I got strange readings in 220. It could be it was just not happy not being properly connected to the pack. Soon, I will re-fit it to the pack and test again. What do you get from 220?

I'm using a rather poor Arduino based simple logger. I've taken your advice though and set up SavvyCAN and A0RET code on an ESP32 so should be in a better position soon to get some good readings once I've connected that up. Thanks.

https://github.com/collin80/A0RET
https://docs.macchina.cc/a0-docs

I think with your and Sprocketman's work we should be able to get to a useful unit with this S-Box.
pilt
Posts: 15
Joined: Tue Jul 14, 2020 9:03 pm
Been thanked: 3 times

Re: Info on BMW hybrid battery packs?

Post by pilt »

Hi,

This was connected to the battery pack, so 0x210 must be battery pack voltage as my contactors were open. I have not got them to close yet, so 0x220 must be post contactors.

Anway I have made a .dbc file that contains this info. As of yet current scaling is not clear.

I have also found a bit in message 0x510 that shows the status of the KL30C (contactor supply on pin 14)

https://github.com/Pilt2013/Sbox
sprocketman
Posts: 49
Joined: Tue Jan 21, 2020 7:58 pm
Location: Cumbria, UK

Re: Info on BMW hybrid battery packs?

Post by sprocketman »

I am not sure if I am collecting all the can messages as there are a few errors. I might try the other can bus and see if there are different messages on that one.
I am using an arduino to collect this info. I couldn't get savvy cam to work
Do you have any tips.
Regards

Andrew
OutlandishPanda
Posts: 50
Joined: Fri Jun 26, 2020 7:25 pm
Location: West Sussex, UK
Been thanked: 2 times

Re: Info on BMW hybrid battery packs?

Post by OutlandishPanda »

I got SavvyCan working on an ESP32 using the links I posted above for A0RET. There are other hardware option in Collin’s area. I think it is 32 bit hardware focused?
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Info on BMW hybrid battery packs?

Post by clanger9 »

What sort of Arduino? I put some notes on CAN data collection with Arduino One, Due and Teensy in the wiki:
https://openinverter.org/wiki/Getting_s ... th_CAN_bus
sprocketman
Posts: 49
Joined: Tue Jan 21, 2020 7:58 pm
Location: Cumbria, UK

Re: Info on BMW hybrid battery packs?

Post by sprocketman »

clanger9 wrote: Fri Nov 20, 2020 7:39 pm What sort of Arduino? I put some notes on CAN data collection with Arduino One, Due and Teensy in the wiki:
https://openinverter.org/wiki/Getting_s ... th_CAN_bus
I am triying to get the Ardunio Due to work. i havebeen through the WIKI page a few times but the ardunio program wont run with out errors. Anybody got an idea where I am going wrong?

Using library due_can at version 2.0.1 in folder: C:\Users\Andrew\Documents\Arduino\libraries\due_can
Using library SdFat at version 2.0.1 in folder: C:\Users\Andrew\Documents\Arduino\libraries\SdFat
Using library SPI at version 1.0 in folder: C:\Users\Andrew\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\libraries\SPI
Using library due_wire in folder: C:\Users\Andrew\Documents\Arduino\libraries\due_wire (legacy)
Using library Wire_EEPROM in folder: C:\Users\Andrew\Documents\Arduino\libraries\Wire_EEPROM (legacy)
Using library can_common at version 0.3.0 in folder: C:\Users\Andrew\Documents\Arduino\libraries\can_common
Using library mcp2515 at version 0.3.1 in folder: C:\Users\Andrew\Documents\Arduino\libraries\mcp2515
exit status 1
'CAN_COMMON' has not been declared
Invalid library found in C:\Users\Andrew\Documents\Arduino\libraries\Servo: no headers files (.h) found in C:\Users\Andrew\Documents\Arduino\libraries\Servo
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Info on BMW hybrid battery packs?

Post by clanger9 »

Hmm, it should work.

That message points to a problem with your Servo library. Maybe move C:\Users\Andrew\Documents\Arduino\libraries\Servo to somewhere else & try again?

Here's my compiler output:

Code: Select all

Multiple libraries were found for "MCP2515.h"
 Used: /Users/paul/OneDrive/Arduino/libraries/MCP2515
 Not used: /Users/paul/OneDrive/Arduino/libraries/CAN
Using library due_can at version 2.1.6 in folder: /Users/paul/OneDrive/Arduino/libraries/due_can 
Using library can_common at version 0.3.0 in folder: /Users/paul/OneDrive/Arduino/libraries/can_common 
Using library SdFat at version 2016.7.24 in folder: /Users/paul/OneDrive/Arduino/libraries/SdFat 
Using library SPI at version 1.0 in folder: /Users/paul/Library/Arduino15/packages/arduino/hardware/sam/1.6.12/libraries/SPI 
Using library due_wire in folder: /Users/paul/OneDrive/Arduino/libraries/due_wire (legacy)
Using library Wire_EEPROM in folder: /Users/paul/OneDrive/Arduino/libraries/Wire_EEPROM (legacy)
Using library MCP2515 at version 0.3.1 in folder: /Users/paul/OneDrive/Arduino/libraries/MCP2515 
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Info on BMW hybrid battery packs?

Post by clanger9 »

Ah, I think I found it: you need to upgrade your due_can library to 2.1.6.
https://github.com/collin80/due_can

My bad - I missed this library from the guide. Now fixed.
sprocketman
Posts: 49
Joined: Tue Jan 21, 2020 7:58 pm
Location: Cumbria, UK

Re: Info on BMW hybrid battery packs?

Post by sprocketman »

Hi,

Thanks

I still have a few errors? do i have too many files?

i have loads of these errors:-

C:\Users\Andrew\AppData\Local\Temp\arduino_build_355774\sketch\can_common.cpp.o:C:\Users\Andrew\AppData\Local\Temp\arduino_build_355774\sketch/can_common.cpp:349: first defined here
C:\Users\Andrew\AppData\Local\Temp\arduino_build_355774\libraries\can_common\can_common.cpp.o: In function `CAN_COMMON::watchForRange(unsigned long, unsigned long)':



exit status 1

Error compiling for board Arduino Due (Native USB Port).

I cant list them all
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Info on BMW hybrid battery packs?

Post by clanger9 »

Hi sprocketman,

Will send you a PM to avoid hijacking the thread...
OutlandishPanda
Posts: 50
Joined: Fri Jun 26, 2020 7:25 pm
Location: West Sussex, UK
Been thanked: 2 times

Re: Info on BMW hybrid battery packs?

Post by OutlandishPanda »

sprocketman wrote: Mon Nov 16, 2020 9:24 pm
Try these and see what happens (should be on) Precharge first.
Get data from ID: 300 34 4A 98 6 0 0 80 61
Get data from ID: 300 35 4E 0 0 0 0 0 64

Get data from ID: 300 3D 46 59 86 65 18 96 61
Get data from ID: 300 35 7A 59 96 65 59 96 65
Get data from ID: 300 37 82 59 96 65 59 96 65
Get data from ID: 300 37 36 59 86 61 59 96 65
Hi Sprocketman,

Did you get SavvyCAN working? I've had great success with an ESP32 module using WiFi and a Li-ION battery holder built in for a truly wireless connection.

The above CAN messages didn't work for me but the sBox is not connected to the pack. I did have pin 14 connected to 12V. I can get pilt's commands to work the reed relay:

"0x300 with the first byte set to 0x9f (rest of bytes to 0xFF) it will turn "ON" the small blue relay on the PCB. It makes a very quiet, but nice noise.... (sending 0x5F turns it back "OFF")"

I've also tried lots of Fuzzing on ID 0x300 to no effect other than the reed relay getting very busy. No contactor action.

Under what conditions did you record the pre-charge contactor coming in? Can you share the whole log please? I wonder if I'm missing something. Maybe I could replay the whole log?

Pilt, I have been able to get to what seem to be correct current measurements using these dbc settings, building on from your work and shared dbc file:
sBox CAN Current dbc test1.PNG
Needed a bit length of 25 and signed integer. I've tested to almost 100A and -100A with my PTC heater rig and is accurate against my multimeter at +- 10A. Very happy with that. Thanks for your help pilt.
sBox CAN Current test1.PNG
Some progress!
sprocketman
Posts: 49
Joined: Tue Jan 21, 2020 7:58 pm
Location: Cumbria, UK

Re: Info on BMW hybrid battery packs?

Post by sprocketman »

OutlandishPanda wrote: Sat Dec 12, 2020 7:30 am
sprocketman wrote: Mon Nov 16, 2020 9:24 pm
Try these and see what happens (should be on) Precharge first.
Get data from ID: 300 34 4A 98 6 0 0 80 61
Get data from ID: 300 35 4E 0 0 0 0 0 64

Get data from ID: 300 3D 46 59 86 65 18 96 61
Get data from ID: 300 35 7A 59 96 65 59 96 65
Get data from ID: 300 37 82 59 96 65 59 96 65
Get data from ID: 300 37 36 59 86 61 59 96 65
Hi Sprocketman,

Did you get SavvyCAN working? I've had great success with an ESP32 module using WiFi and a Li-ION battery holder built in for a truly wireless connection.

The above CAN messages didn't work for me but the sBox is not connected to the pack. I did have pin 14 connected to 12V. I can get pilt's commands to work the reed relay:

"0x300 with the first byte set to 0x9f (rest of bytes to 0xFF) it will turn "ON" the small blue relay on the PCB. It makes a very quiet, but nice noise.... (sending 0x5F turns it back "OFF")"

I've also tried lots of Fuzzing on ID 0x300 to no effect other than the reed relay getting very busy. No contactor action.

Under what conditions did you record the pre-charge contactor coming in? Can you share the whole log please? I wonder if I'm missing something. Maybe I could replay the whole log?

Pilt, I have been able to get to what seem to be correct current measurements using these dbc settings, building on from your work and shared dbc file:

sBox CAN Current dbc test1.PNG

Needed a bit length of 25 and signed integer. I've tested to almost 100A and -100A with my PTC heater rig and is accurate against my multimeter at +- 10A. Very happy with that. Thanks for your help pilt.

sBox CAN Current test1.PNG

Some progress!
t
Hi,

Yes i got it working. Send me a PM and i will send you a capture I think ID 112 is the ID to look at but i dont get much time to test with the darkness of winter.

Regards

Andrew
User avatar
bobby_come_lately
Posts: 465
Joined: Sun May 03, 2020 5:39 am
Location: Manchester, UK
Has thanked: 33 times
Been thanked: 36 times
Contact:

Re: Info on BMW hybrid battery packs?

Post by bobby_come_lately »

pilt wrote: Wed Nov 18, 2020 10:19 pm Hi,

This was connected to the battery pack, so 0x210 must be battery pack voltage as my contactors were open. I have not got them to close yet, so 0x220 must be post contactors.

Anway I have made a .dbc file that contains this info. As of yet current scaling is not clear.

I have also found a bit in message 0x510 that shows the status of the KL30C (contactor supply on pin 14)

https://github.com/Pilt2013/Sbox
Thanks for sharing this DBC file. I got it up and running in SavvyCan this afternoon and made a couple of tweaks based on the following messages. Version attached works beautifully.
Attachments
Sbox.zip
(574 Bytes) Downloaded 124 times
StarshipOne
Posts: 1
Joined: Mon Jan 11, 2021 9:11 am

Re: Info on BMW hybrid battery packs?

Post by StarshipOne »

Happy new year and thank you for the amount of work you share under this forum!

I own a BMW X5 40e PHEV and I would like to increase the HV battery size in order to achieve at least 40km of range (I estimate 12kwh of usable battery). From your huge experience with phev batteries, I kindly ask for your advice: what battery should I add or swap in order to have a decent 40km EV range?
sprocketman
Posts: 49
Joined: Tue Jan 21, 2020 7:58 pm
Location: Cumbria, UK

Re: Info on BMW hybrid battery packs?

Post by sprocketman »

StarshipOne wrote: Mon Jan 11, 2021 10:10 am Happy new year and thank you for the amount of work you share under this forum!

I own a BMW X5 40e PHEV and I would like to increase the HV battery size in order to achieve at least 40km of range (I estimate 12kwh of usable battery). From your huge experience with phev batteries, I kindly ask for your advice: what battery should I add or swap in order to have a decent 40km EV range?
its not that easy. Depends how good you are at electronics etc?
Post Reply