Curious-Ninja Logo
  • Home
  • Projects
    • Aviation
      • King Air Guides
    • BMW E46
      • K/I-Bus Interface
    • IT
      • UserLogos
  • Blog
  • About me
  • Contact
Curi0us Ninja Logo
31 May2015

Arduino & BMW K/I-Bus Interface – Technical Details

May 31, 2015. Written by ninja. Posted in Blog, BMW E46, E46 K-bus, Projects

*** Project: Arduino & BMW K/I-Bus Interface ***
** Intro located here ***

Background:

The K-Bus is a standard bus protocol for BMW car electronics. In other words, it is a way for devices within the car to communicate with each other. The K-bus is a serial communications bus in which all connected control units can send as well as receive information over a single wire. Since the K-bus has available only one single line yet it transmits data in both directions, data are transmitted in half-duplex mode – it is possible to only transmit or receive at any one time.

The I/K buses handle information/multimedia peripherals. The I-Bus is known as the “Instrumentation-Bus” and the K-Bus is the “Karosserie-Bus” – Karosserie is German for “Body”. Initially the I-Bus was introduced on the E31 as the information bus. The E31 version of the I-Bus was used for body electronics and driver information systems. With the introduction of the E38, the I-Bus is now referred to as the instrumentation bus. The K-Bus was added to the E38 along with the I-Bus. Models without Navigation or IKE will use the K-Bus only. Both of these bus systems are technically identical, the only difference is their use by model. From this point forward they will be referred to as the I/K-Bus and differences will be pointed out separately.

Most of the information in this article comes directly from the PDF files in the resources & downloads section (Under the “K-Bus Structure” and “Resources” folders). The most informative being the one named “IBUSInsideDRAFTREV5.pdf”.

On the BMW E46, the following control units are on the I/K-Bus:

– GM5, General Body Module
– AHL, Adaptive headlights
– PDC, Parking Distance Controller
– CDC, CD Changer
– EWS, Electronic Immobilizer
– MFL, Multi-function steering wheel
– MM, Mirror memory, 1x Driver and 1x Passenger
– IHKA, Heating and A/C Control module
– RAD, Radio
– SM, Seat Memory, 1x Driver and 1x Passenger
– IKE, Instrument Cluster Electronics
– MRS, Multiple-restraint system (Airbag module)
– LCM, Light Control Module
– LSZ, Light switch cluster
– TPCS, Tire Pressure Control System
– SHD, Sunroof Control Module
– RLS, Rain/Light Sensor

The bus’ physical layer is an open collector setup – pulled high (+12v) by the bus and pulled low by the talker. This means that the normal voltage on the wire while the bus is idle is +12V (the battery voltage, or Vbatt). A bit is transmitted by pulling low or shorting the bus with the ground momentarily. This is the reverse of many digital signals where the normal voltage is 0V and is raised high (Vmax which in this case is Vbatt or +12v) to send a bit.

Serial communications on the bus are 9.6Kbps, 8 data bits, Even parity, and 1 stop bit. (9600, 8E1).

Any device can start sending when the bus is idle, but if it discovers that the line is pulled low without doing it itself, it has to abort. The I/K-Bus is always active when terminal R (Ignition) is switched on. If the bus line is quiet for more than 60 seconds, all of the control modules will go into Sleep Mode.

Control units that provide the I/K-Bus operating voltage (Master controllers) are:
On E38 and E39/E53 High version vehicles:
• The LCM is the Main (master) Controller of the I-Bus. The IKE and MID/BMBT are Stand-by Controllers.
• The GM is the Main (master) Controller of the K-Bus.
• The IKE is the bus “gateway”

On E46, E52 and E39/E53 Base version vehicles:
• The GM is the Master Controller for vehicles equipped with only the K-Bus.
• The LCM/LSZ is the Stand-by Controller.

Each module on the I/K-Bus is informed by a message from the Master Controller as to the ready status of all of the other connected modules. The modules polled are according to the coding of the Master Controller. Every 30 seconds after Terminal R is switched on, each module on the bus line is polled.

I/K-Bus Packet Structure:

The information sent over the bus is configured serially. Each message consists of:
1. Transmitter address (8 bit Source ID)
2. Length of data (number of following message bytes)
3. Receiver address (8 bit Destination ID)
4. Detailed description of message (maximum 32 bytes of data)
5. Summary of transmitted information (check sum)

The XOR checksum byte is used to check the integrity of the message. The receiver will compare that value with its own computation, and if not equal, will reject the packet.

 packet_structure

Messages:

I have collected several documents from various sources that contain many examples of I/K-Bus messages – these can all be found on my resources & downloads page (Under the “K-Bus Structure” folder). 

Analyzing the bus for specific messages is very easy by using the NavCoder software. 
To use NavCoder, you must find a way to connect the I/K-Bus to your laptop. You can either use the Resler’s I-Bus interface (Click Here for integration instructions), or a USB to TTL serial converter along with the TH3122 Arduino interface (Click Here for integration instructions).

 Project Continued:
• Intro
• Technical Details
• Schematic Description
• Resources & Downloads
• Programming
• Integration
• Messages

Continue Reading 3 Comments

31 May2015

Arduino & BMW K/I-Bus Interface – Intro

May 31, 2015. Written by ninja. Posted in Blog, BMW E46, E46 K-bus, Projects

*** Project: Arduino & BMW K/I-Bus Interface ***

This project was born because I chose to do a simple task the hard way. I have a hard-wired radar detector in my E46 BMW – an Escort Redline. The wiring kit includes an alert LED which flashes whenever the radar detector picks up a police radar band. The LED was the perfect brightness during day time, but was a ridiculously bright eye sore in the night time. Instead of simply using a photo-resistor to solve this issue, I decided I wanted to use the already available light sensor in the car.

The Rain/Light Sensor is mounted on on the top center of the windshield. It’s purpose is to:

1) Detect rain on the windshield to automatically turn on the wipers and set a proper wiper speed
2) Detect ambient lighting to control automatic headlight operation

It turns out the Rain/Light Sensor is connected to the cars’ internal serial communications bus. This is when I discovered the world of the BMW I/K-Bus. 

The K-Bus is a standard bus protocol for automobile electronics. In other words, it is a way for devices within a car to communicate with each other. On the BMW, there are several devices on this bus. These include: 
• Radio  • MFW Steering wheel buttons • CD Changer  • Light Control Module  • etc

There are many possibilities when you are able to read and transmit on this bus. 

Some examples of what’s possible by reading and writing from/to the I/K-Bus:

• Read misc sensor data (speed, temperatures, RLS, etc), and perform actions based on the data
• Control the radio unit, air conditioning, windshield wipers, etc
• Write text to the instrument cluster or the radio LCD displays
• Open/Close windows, sunroof, and trunk either manually or automatically based on any inputs 
• Lock/Unlock doors either manually or automatically based on any inputs 
• Control interior and exterior lighting either manually or automatically based on any inputs 
• Control mirror and seat position (Including memory positions)
• Use inactive Multi-Function Steering wheel buttons for misc commands

The technical details of the bus can be found on the Technical Details page.

Planning the interface:

I decided to build my K-bus interface using an Arduino. For the record, I am not a software programmer. I’m only familiar with web based languages – PHP, HTML, CSS, etc. So i decided to take this opportunity to learn a bit of C++. 

Before we get started, I should mention that there are several K-bus interfaces out there that convert the bus to RS-232 serial. This allows you to connect the I/K-bus directly to a PC/Laptop and then use software such as NavCoder to read the bus communications. The software even allows you to send your own custom HEX messages – if you know what you’re doing. This setup is VERY helpful in decoding the bus messages that you’re interested in. The most popular interface to use is the “Rolf Resler” interface, found here. In the future I will make a write-up on how to wire up the resler interface to the K-bus wiring below the radio, and use it with NavCoder for debugging purposes.

To be able to read and transmit on the K-bus via an Arduino we will need to build an interface circuit to convert the +/- 12V bus signals into something the Arduino can understand (+/- 5V TTL levels). After some research, I have found several online articles where people have used transceiver chips such as the MCP2004, MCP2025, or the TH8080. Some had event built their entire interface circuit from basic transistors, not using a chip at all. 

I did quite a bit of research to be able to put this together – so keep in mind a lot of this info came from other users’ blogs and forums posts. I will list all my sources and give credit towards the bottom of this write-up. 

For my physical layer, I decided to go with the Melexis TH3122 transceiver IC. The chip connects to the the K-Bus, Ground, and the cars’ +12 volts and even outputs a regulated +5 volts to power other components (the Arduino!). It even has sleep/wake features, as well as a form of collision detection. The only drawback for the home hobbyist is that it only comes in a surface mount SOIC16 package. I was able to get a “SOIC to DIP” adaptor from digikey – more info on this in the Bill of Materials (BOM) below. 

It turns out the TH3122 isn’t too readily available – digikey does not carry this IC. I was able to buy a couple from eBay. 
Below is the schematic I created using Eagle PCB software – it is based on schematics from reslers’ interface as well as from Neiland, with some help from ian332isport.

 

Schematic TH3122 To ARDUINO

 

 The description of this circuit can be found here.

Putting things together:

Assuming you already own an Arduino (I used an UNO R3 replica, from 16Hertz), the Bill of Materials (BOM) is: 

 • Diode 1N4148    • Resistor 10 ohms    • Capacitors: 1uF 47uF 100pF    • Melexis TH3122 IC    • SOIC to 16DIP adaptor    • Small breadboard    • Breadboard wires    • USB to TTL serial converter (optional but recommended)

Tools/Equipment:

 • Soldering iron (for the TH3122 IC)

Links & details for Bill of Materials items are shown in the excel sheet below (Available in the resources & downloads section, “Physical Layer” folder).

I soldered the TH3122 onto my SOIC to 16DIP adaptor, then assembled the Arduino breadboard according to my schematic.

The USB to TTL converter is very useful for debugging I/K-Bus messages using software serial. I am using pins 7 and 8 on the arduino. FYI, the signals must be crossed – Tx on arduino to Rx on the converter. Pin 7 on the arduino will be Rx and 8 is Tx. You can use any serial monitor software for debugging – I personally prefer PuTTy.

Photos for reference:

arduino kbus bom
arduino kbus interface
arduino kbus interface
arduino kbus th
arduino kbus th3122

The next step is to program the Arduino..

 Project Continued:
• Intro
• Technical Details
• Schematic Description
• Resources & Downloads
• Programming
• Integration
• Messages

Sources & Credit:

I’d like to make a shout-out to ian332isport, from the Arduino forums, for the much needed support with coding the Arduino.
He provided the base program I started with when working on this project.
My other sources and links for this project are located in the resources & downloads section.

Continue Reading No Comments

  • 1
  • 2
  • 3
NEW POSTS
  • King Air quickGuides December 29, 2018
  • Arduino & BMW I/K Bus Interface – Operation & Testing November 19, 2017
  • Arduino & BMW I/K Bus Interface – Programming – v0.1.0 beta April 11, 2016
  • Arduino & BMW I/K Bus Interface – Programming – v0.0.1 alpha April 10, 2016
  • UserLogos & Fast Dial August 10, 2015
ARCHIVES
  • December 2018
  • November 2017
  • April 2016
  • August 2015
  • July 2015
  • May 2015
TAGS
arduino bmw bmw e46 bmw i-bus bmw k-bus c++ chrome communications c plus plus details diy downloads e46 electronics fast dial firefox i-bus integration k-bus messages navcoder programming projects schematic serial speed dial technical testing userlogos wiring
Built with HTML5 and CSS3 - Curious.Ninja
  • Home
  • Projects
    • Aviation
      • King Air Guides
    • BMW E46
      • K/I-Bus Interface
    • IT
      • UserLogos
  • Blog
  • About me
  • Contact