BMW CAN Messaging

Post Reply
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

BMW CAN Messaging

Post by Jack Bauer »

So one problem I have had with my E39 since the AC motor swap are the warning lights on the dash for traction control and abs. With the annual inspection coming soon I figured I had to do something. Also want to swap in an M5 instrument cluster. Initially thought I'd just use a CAN bridge between the inverter and the car but decided to put my almost non existant high level programming skills to the test to see if I could modify the firmware to send some BMW style CAN messages. Worked out very well and learned some interesting things like using unions for swapping between data types. Long way from 6502 assembler:) RPM and temp display working as of now. Mapped the temp to a fixed value for testing but plan to use engine temp for heatsink temp and oil temp for motor temp.

Attached modified stm32_can.cpp for those interested. Probably much neater ways of doing it but works for me:)
Attachments
stm32_can.zip
(5.41 KiB) Downloaded 119 times
2019-10-03 15.40.37.jpg
I'm going to need a hacksaw
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: BMW CAN Messaging

Post by johu »

Aha, I see a need for "speedmod" as I had the same issue on Touran. Below about 600rpm there is now power steering :)
I'm also thinking about a generic way for cycling counters, again same thing on Touran ABS.
Are you sure (Param::speed)*6.4 works? I believe you want FP_TOINT(FP_FROMFLT(6.4) * Param::GetInt(Param::speed))
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: BMW CAN Messaging

Post by Jack Bauer »

I just wrote you an email as I was crashing the processor and banging my head off a wall until I relaised I was multiplying and int with a float and the STM32 dont like that:)
I'm going to need a hacksaw
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: BMW CAN Messaging

Post by Jack Bauer »

And here is an actual working version. Tachometer driven from motor speed and engine temp driven from heatsink temp.
Attachments
stm32_can.zip
(5.42 KiB) Downloaded 136 times
I'm going to need a hacksaw
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: BMW CAN Messaging

Post by johnspark »

Thank you many times JB, i will be able to use your brains yet again...

PS: i have a friend who has BMW software who can turn alarms on and off using conventional BMW stuff if you need that help, cheers.
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: BMW CAN Messaging

Post by johnspark »

JB, Since you are on a BMW roll, wonder if you have thought about the fuel efficiency meter. Equation is something like:
fuel efficiency.PNG
cheers.

so just need car speed, and manufacture CAN message for MAF, -which becomes the inverse of say battery energy consumed per km.


you have probably already thought of this.
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: BMW CAN Messaging

Post by johnspark »

I have looked at the A2 KOM instrument cluster of my BMW e39. I can't find CAN messaging going to this. Instead I have found an RPM signal. I measured that today with a Picoscope and obtained the following signal. I understand this signal goes from the DME MS41.0 ECU to the A2 instrument cluster, so i think i will have to simulate this signal from the inverter.
E39_RPM_DME_To_A2_KOM_InstrumentCluster_Idling_AND_AC_On.PNG
philbrennan
Posts: 52
Joined: Sun Feb 23, 2020 4:21 pm
Location: Maynooth
Been thanked: 7 times

Re: BMW CAN Messaging

Post by philbrennan »

Just as a newbie wonder if I could ask the strategy here. So this is to keep the lights off. Besides that is abs working ok? I'm trying to think about having dsc present and working on my e39, obviously that's a lot more work.
User avatar
Kevin Sharpe
Posts: 1345
Joined: Fri Dec 14, 2018 9:24 pm
Location: Ireland and US
Been thanked: 4 times

Re: BMW CAN Messaging

Post by Kevin Sharpe »

philbrennan wrote: Sun Feb 23, 2020 5:14 pm Just as a newbie wonder if I could ask the strategy here. So this is to keep the lights off. Besides that is abs working ok? I'm trying to think about having dsc present and working on my e39, obviously that's a lot more work.
In Ireland and much of the world the original functionality must work including ABS.
This is a personal post and I disclaim all responsibility for any loss or damage which any person may suffer from reliance on the information and material in this post or any opinion, conclusion or recommendation in the information and material.
philbrennan
Posts: 52
Joined: Sun Feb 23, 2020 4:21 pm
Location: Maynooth
Been thanked: 7 times

Re: BMW CAN Messaging

Post by philbrennan »

Yeah I'm in ireland and I'd expect that once abs unit is kept happy that it will go about its business and you wont get lock ups. That's quite aside from the nct who wont verify its operation apart from the warning light.


For traction control, we need to keep the light off but it's ultimate function will never be validated by the nct or, indeed by emergency accident avoidance. But, I would like to retain its function as any conversion I do I would think will have enough power to break traction. I'd be an enthusiastic driver with a motorsport background but I'd like a car that I could hand to someone else without worrying about it.
So, long winded but I'm thinking worst case, if the asc / dsc was operational, its messages could be actioned by cutting the throttle signal.
User avatar
Kevin Sharpe
Posts: 1345
Joined: Fri Dec 14, 2018 9:24 pm
Location: Ireland and US
Been thanked: 4 times

Re: BMW CAN Messaging

Post by Kevin Sharpe »

philbrennan wrote: Sun Feb 23, 2020 6:41 pm That's quite aside from the nct who wont verify its operation apart from the warning light.
You will need to get the EV through an automotive engineers inspection in Ireland. Obviously, you could fake the operation of the safety systems and invalidate your insurance but that's not something I'd recommend anyone consider.
This is a personal post and I disclaim all responsibility for any loss or damage which any person may suffer from reliance on the information and material in this post or any opinion, conclusion or recommendation in the information and material.
philbrennan
Posts: 52
Joined: Sun Feb 23, 2020 4:21 pm
Location: Maynooth
Been thanked: 7 times

Re: BMW CAN Messaging

Post by philbrennan »

Indeed, and neither would I. Regarding the traction control though, any thoughts there?
User avatar
Kevin Sharpe
Posts: 1345
Joined: Fri Dec 14, 2018 9:24 pm
Location: Ireland and US
Been thanked: 4 times

Re: BMW CAN Messaging

Post by Kevin Sharpe »

philbrennan wrote: Mon Feb 24, 2020 6:45 pm Regarding the traction control though, any thoughts there?
I think a lot depends on your build. Traction control has been implemented in software for the Tesla drive units by Zero EV but AFAIK not in the open source software. In Damien's cars that have a transmission I think it 'just works' because he convinces the car that the ICE is still present. In my VW bus I have a LSD in the Tesla DU which offers mechanical traction control of sorts.

We will be running some CAN courses later in the year if you want some hands on experience :)
This is a personal post and I disclaim all responsibility for any loss or damage which any person may suffer from reliance on the information and material in this post or any opinion, conclusion or recommendation in the information and material.
User avatar
mdrobnak
Posts: 692
Joined: Thu Mar 05, 2020 5:08 pm
Location: Colorado, United States
Has thanked: 1 time
Been thanked: 5 times

Re: BMW CAN Messaging

Post by mdrobnak »

How would you like...working factory traction control? For a low price of $ at my website...it can be yours! (Only half kidding). I do have a product aimed at the E46 chassis, so here we go...

One of the pieces of information that is both well documented and hilariously inaccurate at the same time is BMW E46 CAN messages. The basic stuff is indeed super simple, and you've gotten some of it already. Other pieces, unless you've gotten a good disassembly you'll probably never see the info.

DME 1: (0x 3 1 6)
Byte 0
- Bit 0 Is indeed Ignition Key status (1 for run, 0 for when key is out and you're still in power hold mode. The DME relay is active for a few seconds (I want to say 5 or 7) after keyoff to allow a quick restart if necessary.)
- Bit 2 is ABS / TC messages missed. Set it to 4 if you haven't missed any messages.

So normal operation of Byte 0 for you is 0x5.

Byte 1, 4, 5, 7 are torque values. Byte 1 is target torque with external interventions, 4 is from the 'driver' (but that also includes idle, so that gets to be fun), 7 is target torque without interventions. Byte 5 is frictional torque. These are 0-99.6% (0-254, 255 = error).

You can ignore byte 6. I can't, and it's been the bane of my existence for a while. :D

DME 2: (0x 3 2 9)
Byte 0:
- Multiplexed data stream. 0x3F is data, rest is identifier.
0 -> 0x11 -> CAN version. "11h CAN"
1 -> 0x40 usually...Though I don't see that in your data
2 -> 0x80 usually - 0x86 implies some OBD Drive cycle stuff
3 -> This is where the magic is. 0xD9 is.. 0xD9 & 0x3F = 0x19. 0x19 = 25 Decimal. 25 Decimal * 16 = 400 Nm Tq. This is what the torque values are divided by. "Torque Normalizer" I'm guessing the original car in the 5 series was a 3 Liter M54? (Aka 530i?)
Byte 1 is Coolant Temperature
-B1 is Temp [Temp in C = .75 * hex2dec(byte01) - 48]
-B2 is atmospheric pressure -- mbar = 2x + 597.
-B3
0 - Clutch Switch (1 = engaged)
1 - NONE
2 - NONE
3 - Warmup Bit - If temperature is >= 60 degrees C
4 - Not in Engine Stop or Start state (running)
5 - 7 - Cruise Control bits from Steering Wheel Controls
-B4 Pedal position (00 - FE) // Cruise only
-B5 Pedal position (00-FE). // Max of Cruise or Pedal
-B6 kickdown switch depressed is 4 (bit 2 = 1), Brake light switch error is 2 (bit 1 = 1), Brake pedal depressed is value 1 (bit 0 = 1), (8 is state_cru_can)
-B7 Zero

DME 4: (0x5 4 5)
B0 Check engine light (binary 10), Cruise light (binary 1000), EML (binary 10000), Check gas cap 2002+ cars (hex 40).
B1 Fuel consumption LSB
B2 Fuel consumption MSB. Value is fuel used in Microliters % 65535
B3 Overheat light (binary 1000, Hex 08), (Another oil level is 1), oil level (yellow) 2002+ cars, (binary 0010, hex 02), On M3's 0x10 7K and Up RPM lights, 0x20 6.5K and up RPM lights, 0x40 5.5K and up RPM lights.
B4 Oil Temp [Temp in C = hex2dec(byte04) - 48]
B5 Charge light, 2002+ cars (Binary 0001)
B6 Unused.
B7 Oil Pressure (Red), hex 0x80

And... if you want traction control, you need to listen for the messages on..

ASC 1 (0x 1 5 3):
/* Byte 0 is data bits:
0x01 - ASR Active [Anti-Skid Regulation in German]
0x02 - MSR Active [Engine Drag Torque regulation in German]
0x04 - Active during 'uninit' at poweron. (Torque Intervention not possible?)
0x08 - ?
0x10 - Brake pedal depressed.
0x20 - Active during 'uninit' at poweron. (Torque Intervention not possible?)
0x40 - Active during 'uninit' at poweron.
0x80 - Active during 'uninit' at poweron.

Byte 1 - LSB of Speed } (Bits 3-7)
- Bit 0 - CAN Error?
- Bit 1 - Plausible ASC Control
- Bit 2 - Vehicle Speed Error
Byte 2 - MSB of Speed } (Bits 0-7)
Byte 3 - ASC Torque Intervention (Ignition Angle - "Fast path" - Short interventions)
Byte 4 - ASC Torque Intervention on MSR (Usually 0, but not always - Byte 0 0x02 when non-zero)
Byte 5 - I think this is the compliment of byte 4 during an MSR intervention. (255-Byte4)
Byte 6 - ASC Torque Intervention (Filling - Throttle body based - Long interventions because the short one didn't fix the problem)
Byte 7 - 0x80 normal, 0x02 "Uninit"
*/
Byte 3 and 6 are scaled by..you guessed it..the torque normalizer _you send out_ on 0x3 2 9.

Basically look for it to say ASR active, the requested torque on byte 3, reduce torque command to inverter, report out what you've commanded on 0x3 1 6...and you should have a working traction control.

While other 3rd party manufacturers have put out "Plug and play" kits with pretty terrible quality, I try to get my stuff as correct as possible. Even though this may eat into my sales if someone finds it here, I'm OK with that, as the really hard stuff (SMG gearbox integration) is much harder than this. I've spaced out the IDs to to combat some of these manufacturers finding it. :) So for everyone else, hopefully this info is useful in getting your EV driveline working in your E46 chassis BMW.

-Matt
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: BMW CAN Messaging

Post by Jack Bauer »

That is simply fantastic information. Thank you for sharing. I had intended doing some serious reverse engineering to get this information but you have saved me an absolute ton of work. I'll implement this in the Leaf VCU for the E46 touring and in the new prius inverter going into the E39. I have been working out getting dsc/dbc working on the E65 project also. Why not post a link to your website and I'll pass it around to my BMW friends.
I'm going to need a hacksaw
User avatar
mdrobnak
Posts: 692
Joined: Thu Mar 05, 2020 5:08 pm
Location: Colorado, United States
Has thanked: 1 time
Been thanked: 5 times

Re: BMW CAN Messaging

Post by mdrobnak »

You're welcome. I'm super interested in the E46 touring, as you saw from my project thread. My website is www.drobnaksoftware.com and I have products for Porsche 996/997.1 and E46 (in theory E39 too, but nothing to try that on. ;) ) vehicles. The Porsche stuff has actual usage in various parts of the world, I'm still hacking away at the E46 stuff on my own cars. It all started because someone had a poor product, and I knew I could do better. Turns out that was harder than I thought! But, I think I mostly succeeded, and am close to actually succeeding. Right now I'm one of two people I know of that can control the M3's SMG gearbox, although I still have warning lights unfortunately. (The INPA diagnostics is super detailed - "CAN Error"). The 330's SSG/SMG gearbox is almost done, just need to skip 2nd gear LOL. It's about the details, as it turns out.

I'll see if I can find ABS / DSC stuff for the BN2000 chassis stuff, which is what I think you're working with there on the 7 series. I don't expect to have a lot of customers in that area. :D

-Matt
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: BMW CAN Messaging

Post by Jack Bauer »

Cool. A good friend who did the mechanical work on the custom rear subframe for the tesla drive unit in the E31 has been dreaming about an S54 SMG E30 track car so I've sent him your details.
I'm going to need a hacksaw
philbrennan
Posts: 52
Joined: Sun Feb 23, 2020 4:21 pm
Location: Maynooth
Been thanked: 7 times

Re: BMW CAN Messaging

Post by philbrennan »

holy thread revival. I don't know if this code is in zombieverter yet but I wouldn't mind implementing it myself.
Considering the power available from the 450h motors it would be a nice feature.
Post Reply