Yet another CAN module - Shiftlights, MDrive, NBT and more

superwofy

Corporal
Jan 18, 2021
130
195
0
Hi all,

I've made (and am currently using) another CAN injection module for my N54 335i.
Unlike my previous modules, this one has access to both PTCAN and KCAN.
While the code is quite specific for my particular car, some of the CAN message logic may be useful. The DCT shiftlights might be interesting to some as this can easily be added to 6MT cars (as I have done).

I use it to:
  • Emulate K-CAN2 for NBT support.
    • Donor VIN is obtained after every boot when Terminal R is ON.
    • Sport displays are populated with PT-CAN torque data from the DME.
  • Control MDrive settings from iDrive.
    • Control DME throttle map with the M button.
    • Control DTC/DSC OFF with the M button.
    • Control EDC mode with the M button.
    • Control Servotronic mode with the M button - through SVT70 module.
    • Control AHL swivel speed mode (sport/comfort) with the M button.
    • Control the exhaust flap position with the M button.
    • Control ASD with the M button.
    • Display M Drive settings menu when holding M button (CIC only)
  • Display Shiftlights - including startup animation and sync with the M3 KOMBI variable redline.
  • Display a needle sweep animation on startup.
  • Display the Launch Control flag (6MT-MHD).
  • Control Centre console buttons and associated LED (POWER, DSC OFF).
  • Fold/Un-fold mirrors when locking/unlocking.
  • Un-dim electrochromic exterior mirrors when indicating at night.
  • Move driver's seat back when exiting car.
  • Indicate when the trunk is opened by remote (flash hazards).
    • Visual signal for locking/unlocking must be ON.
  • Indicate when the car is locked and the lock button is pressed (flash hazards).
    • Car must be locked for at least 10s and Visual signal for locking/unlocking must be ON.
  • Force sleep mode (KL30G OFF) by holding remote lock button for 20s - for testing.
  • Immobilize the engine with a fuel pump cut-off until the M button is pressed X times.
    • If engine is started without releasing this immobilizer, alarm will sound once engine stalls.
    • Can be disabled persistently by first deactivating then, holding the POWER and DSC OFF buttons for 10s with the ignition ON.
  • Display Front fog lights ON (for M3 clusters that lack the symbol).
  • Audibly warn when reverse gear is engaged.
  • Audibly warn when the hood is opened.
  • Create a HDC function similar to the one in xDrive cars.
  • Display a CC error when pressing the Auto Start-stop button instead of a blank button. OR
  • Switch on the reversing camera when pressing the Auto Start-stop button.
  • Carry out one more wipe cycle after washing the windscreen.
  • Have intermittent wipers work alongside rain sensing.
    • Push the stalk down and hold for 1.3s to turn on intermittent mode.
    • AUTO, stalk pushed up 1 and stalk pushed up 2 disable intermittent mode.
  • Enable use of FXX K-CAN1 controller with CIC.
  • Enable use of FXX VSW01 (VideoSWitch) module with NBT.
  • Enable use of FXX NIVI2/3 module.
  • Enable full diagnosis and coding of SVT70 module.
  • Turn on heated seats below a set temperature.
  • Turn on heated steering below a set temperature.
  • Automatically turn off PDC when parked and pulling handbrake.
  • Automatically activate tow view rear view camera option when close to an obstacle.
  • Close the exhaust flap before engine start to reduce start noise.
  • Reduce audio volume when opening doors. Restore when closing.
  • Dim corresponding front DRL when indicator is on.
  • Turn on corresponding front fog light when steering angle threshold is exceeded.

As always, code, photos, videos, board etc. on Github https://github.com/superwofy/E9X-M-CAN-Integration-Module
 
Last edited:

Hotter

Specialist
Jan 23, 2021
93
7
0
Hi all,

I've made (and am currently using) another CAN injection module for my N54 335i.
Unlike my previous modules, this one has access to both PTCAN and KCAN.
While the code is quite specific for my particular car, some of the CAN message logic may be useful. The DCT shiftlights might be interesting to some as this can easily be added to 6MT cars (as I have done).

I use it to:
  • Control Mdrive throttle map (IKM0S)
  • Control DTC with M button (Stock DSC90)
  • Control EDC with M button
  • Display Shiftlights - including a startup animation
  • Control M3 Centre console buttons and associated LEDs (POWER, DSC OFF)
  • Display Front fog lights on with a separate LED in the light switch cluster
  • Enable FXX KCAN1 CIC controllers
  • Turn on heated seats below a set temperature
I'm currently working on adding the logic to control the exhaust flap solenoid too.
As always, code, photos, videos, board etc. on Github https://github.com/superwofy/E9X-M-CAN-Integration-Module
Amazing work!
Do you have a video how does Shiftlights "startup animation" look like?
 

superwofy

Corporal
Jan 18, 2021
130
195
0
Last edited:
  • Like
Reactions: Torgus

superwofy

Corporal
Jan 18, 2021
130
195
0
I now added synchronization between the variable redline and shiftlights.
The shiftlights will be displayed when reving to/past the redline setpoint in the KOMBI.
 
  • Like
Reactions: LMB335is

bosolanu

Private
Dec 7, 2020
48
13
0
Hi mate, @superwofy , just wanted to thank you for sharing all your work, you rock.

I'm building something very similar with what you're doing right now.
I've retrofitted EDC and M3 cluster on my 330i and while it works, I'm building a similar module to help with MDM, MDrive, shiftlights and many others.
Hope you don't mind I forked pretty much every repo you have, in case they disappear, haha.
 

superwofy

Corporal
Jan 18, 2021
130
195
0
Hi mate, @superwofy , just wanted to thank you for sharing all your work, you rock.

I'm building something very similar with what you're doing right now.
I've retrofitted EDC and M3 cluster on my 330i and while it works, I'm building a similar module to help with MDM, MDrive, shiftlights and many others.
Hope you don't mind I forked pretty much every repo you have, in case they disappear, haha.
Hey! Glad you're enjoying them! Where did you put your front acceleration sensors? I put mine on furniture T brackets on the brake pipe holders :tearsofjoy:.


I know at this point I'm sort of spamming this forum - apologies for that. But, I feel like this project is now complete. I've already managed to do more with it that I initially hoped.

The latest addition I'd like to tell people about is full MDrive integration. You can change the settings from iDrive and they are stored in the module.
Behind the scenes I did more too, the SVT70 firmware is modified to toggle Sport/Normal, the MSD81 is also modified to ignore 0x315 and 0x1D9/399.

idrive-settings.jpg

kombi-m.jpg
 
  • Like
Reactions: Torgus and wheela

bosolanu

Private
Dec 7, 2020
48
13
0
Hey! Glad you're enjoying them! Where did you put your front acceleration sensors? I put mine on furniture T brackets on the brake pipe holders :tearsofjoy:.


I know at this point I'm sort of spamming this forum - apologies for that. But, I feel like this project is now complete. I've already managed to do more with it that I initially hoped.

The latest addition I'd like to tell people about is full MDrive integration. You can change the settings from iDrive and they are stored in the module.
Behind the scenes I did more too, the SVT70 firmware is modified to toggle Sport/Normal, the MSD81 is also modified to ignore 0x315 and 0x1D9/399.
Phew, the front acceleration sensors don't have a definitive position at the moment, although I drove for 3k km already.
I've bolted them with the same bolt as for the coolant reservoir on the right and under the air filter on the left :tearsofjoy:. I already made some supports for them just didn't get the time to fixed the on the car, was thinking to put them in the original location but I'd have to take the wings down to drill and rivet or weld the supports.

I know at this point I'm sort of spamming this forum - apologies for that.
It's always a pleasure to read your posts so no worries. I should posts some things myself, just felt it's not ready to be shown yet.

The latest addition I'd like to tell people about is full MDrive integration.
Exactly this is what drove me to start creating the module as well. Unfortunately I still have the N53 engine on the car at the moment so nothing to do with that "Power" button :)

I'm using this for the module btw, regular Arduinos couldn't handle the traffic on the bus and I broke my Leonardo somehow.

I have EPS on my car, that'll be the next step after I complete this one, how to make servotronic work on it and how to customise the amount of assistance provided.

P.S. You're not using DSCM90 right? I'm aiming to get MDM working on mine.
 
  • Like
Reactions: wheela

AzNdevil

Lieutenant
Staff member
Nov 4, 2016
602
286
0
Hong Kong
props for posting this. i think this would be a perfect candidate to be ported to a esp32 as they can run on the arduino framework and it already has a canbus controller so you only need to add a cheap canbus transceiver to handle the canbus side of things

since esp32 has wifi, there is potential to add a webserver and allow for things like shiftlight customization

if i ever get my car to run properly and theres enough interest, i can probably fork the repo and port it
 
  • Like
Reactions: Torgus

bosolanu

Private
Dec 7, 2020
48
13
0
Hey @superwofy, I've adapted your code to work with PlatformIO and a Teensy 4.1 as a board. It can be checked here: https://github.com/opais/MDrive-teensy
It's still very much work in progress, I'm, trying to resolve some issues tonight.

@NikolayBG Yes, that can easily be done, the CAN message you send is read by DSC module, even if you don't have DSCM it can be done.

One problem I have right now, is how to turn on the (M) light in the Kombi.
 

bosolanu

Private
Dec 7, 2020
48
13
0
It seems I can't turn that m light on at all.
Tried all codings on kombi, tried with the 399 can message, might be that the Ikm0s software is sending something.

I have M3 - DSC(tried with 1M as well), m3 jbbf, m3 kombi, m3 SZL, even frm from an m3, whole car was coded as M3 comp package.

I'll ask in the other thread as well.
 

superwofy

Corporal
Jan 18, 2021
130
195
0
It seems I can't turn that m light on at all.
Tried all codings on kombi, tried with the 399 can message, might be that the Ikm0s software is sending something.

I have M3 - DSC(tried with 1M as well), m3 jbbf, m3 kombi, m3 SZL, even frm from an m3, whole car was coded as M3 comp package.

I'll ask in the other thread as well.

Yes, the MSD is sending MDrive off:
58712 0x399 DLC: 6 Data: 0xE5 0x03 0x00 0xFF 0xCF 0xFF

It'll look something like that where 0xCF means off, 0xDF is on. (with ST_MDRIVE only!)

To disable it all you have to do is flip the MDrive logic off in the DME. lc_var_spt_swi at 0x4CD1D set to 00. https://github.com/superwofy/E9X-M-...9X-M-CAN-Integration-Module/program-notes.ino
 

ShocknAwe

Captain
Jan 24, 2018
1,585
1
809
0
Charleston, SC
Ride
N54/3 1er ///Mutt
Wow what an amazing thread. Gonna have to read back through everything and figure out what I need to do to start implementing this on my E82, but I'm an absolute idiot when it comes to electronics and coding.

Thanks for your effort!
 
  • Like
Reactions: wheela

NikolayBG

Lurker
Sep 11, 2022
11
0
0
@NikolayBG Yes, that can easily be done, the CAN message you send is read by DSC module, even if you don't have DSCM it can be done.

One problem I have right now, is how to turn on the (M) light in the Kombi.
@bosolanu , Thank you for your response!

As you can tell from my questions, this stuff is way from my knowledge and understanding. All I want to do is to have the opportunity to completely turn off and on the DSC.

But how do you connect/intercept to the CANBUS and send massages to the DSC (through KOMBI, JBBF or.., I don’t have iDrive, not sure if this maters)? Can this happen through OBD port for early models (07.2007).

I think, I can’t flash MDSC because:
coding the m firmware to the dsc might not work on cars thats are pre 2007/09

Maybe I can reach you by email or so, not to spoil the thread?
 

Hotter

Specialist
Jan 23, 2021
93
7
0
1) I haven't fully read all of your code, but it looks like PT-CAN communication *might* be required to turn on the shift lights? Is this correct? I just want to turn on the LEDs based on my RPM. Hopefully this can be done with KCAN only.
I believe KCAN should be enough for shift lights, but do you have M3 cluster with Shift Lights?

2) Have you thought about adding seat occupancy detection for turning on your passenger heated seat automatically? Any chance you found the KCAN message for passenger seat occupancy? Maybe this is not on KCAN?
I think it should be also on KCAN as its a "body" CAN.
 

superwofy

Corporal
Jan 18, 2021
130
195
0
Hi @superwofy

I had to post here instead of PM, because I just made my account for this forum.

My cluster project is here: https://github.com/alexvnesta/BMW_GAUGE_COLOR
Admittedly not super clean like your box install.

I have a few questions about your code / findings with the DCT shift lights

1) I haven't fully read all of your code, but it looks like PT-CAN communication *might* be required to turn on the shift lights? Is this correct? I just want to turn on the LEDs based on my RPM. Hopefully this can be done with KCAN only.

2) Have you thought about adding seat occupancy detection for turning on your passenger heated seat automatically? Any chance you found the KCAN message for passenger seat occupancy? Maybe this is not on KCAN?

3) Any chance you could provide a little bit more info about how the DCT shift light can messages work? I really like the way loopybunny explains the can messages.

For example, he has something that looks like this.

It includes the Can ID, packet length, and what each byte does in both hex and decimal.

Additionally he has examples of how to parse the packets.

I could keep digging through all of your code an figure this out, but if you wouldn't mind providing me with this information here, I would definitely appreciate it and I'm sure others would too.

Loopybunny example:

1) No, PT-CAN is not required. The message *is* generated on PT-CAN in the M3 by the DME and forwarded by the JBE onto KCAN as this is what the KOMBI is connected to. You can bypass this by broadcasting straight to KCAN - that's what I do in the code.

2) I have not, sorry. Seat occupancy is connected to MRS and it is on the KCAN - so if the message is broadcast, then it must be on the KCAN.

3) I will detail it a bit more here but I really recommend you look at the code and try to reproduce it instead.


This is what I know about ARB-ID 0x206:

The first bit of the first byte specifies speed of the operation. 0 - 0xF, 0xF is the slowest.
Second bit is the operation itself. I've found that:
2 seq, 5 off, 6 seq, 0xA flash, 0xE seq. Where 'seq' means one element lights up and after another lights up and another etc.

I don't know what the second byte does. I only use it for the first segment, and I've taken it straight from the M3 trace I collected. It might also be related to the speed/time of the operation.


The values I use are:

{0x86, 0x3E} - Begins by turning on the first segment.
{0xF6, 0} - More rapidly fill out the remaining segments.
{0x0A, 0} - Flash the lights.
{0x05, 0} - Turn them off.

Watch this video to get a better idea of what I mean: https://github.com/superwofy/E9X-M-CAN-Integration-Module/raw/main/Video/standstill shiftlight demo.mp4
 

superwofy

Corporal
Jan 18, 2021
130
195
0
Thank you @superwofy. That info helps out a ton. I hope I have some time to get the lights working these next couple weeks. I will share if I find any more info that might be useful.

No worries. As is, the code for shiftlight activation can be copied pretty easily. I may take the functionality and implement it into a separate module for a friend that requested this feature. If I do that, there'll be a github repo for it.
 
  • Like
Reactions: Begood69