BMW E46 CAN: Difference between revisions

(One intermediate revision by the same user not shown)
Line 1: Line 1:
=Installation=
=Installation=
Integrating with the E46 requires just one cable, tapping into the CAN bus data of the E46's instrument cluster.
==Required parts==
==Pre-made E46 integration cable==
If you want a ready made cable, you can order one from [https://www.autosportlabs.com/product/bmw-e46-integration-cable/ our online store]
[[file:E46_integration_cable.jpg]]
==DIY Cable==
To make your own cable, you'll need the following:


==Things you'll need==
* Crimp tool
* Crimp tool
* Wire cutter
* Wire cutter
Line 7: Line 16:
* Philipps screwdriver
* Philipps screwdriver
* Multimeter
* Multimeter
* 22 gauge solid wire
* 22-26 gauge wire
* RJ 45 (Ethernet) cable, ~6ft
* RJ 45 (Ethernet) cable, ~6ft
* Shrink tubing (optional, electrical tape will work too, but not look as nice)
* Shrink tubing (optional, electrical tape will work too, but not look as nice)
Line 140: Line 149:


==Configure RaceCapture/Pro==
==Configure RaceCapture/Pro==
===Set Baud Rate===
Ensure CAN1 baud rate is set to 500K


===Quick Start E46 configuration===
[[file:Setup_CAN1_500K_baud.png]]
This configuration can be imported into your RaceCapture/Pro system to get you started.
 
Download: [[File:RaceCapturePro_E46_starter_config.zip]] (right-click, save-as)
 
To complete your configuration:
* [[RaceCapture_App_User%27s_Guide#Automatic_Track_Detection_and_configuration|Add your favorite race tracks]] for automatic detection
* [[RaceCapturePro2_TelemetryQuickstart#Enable_Telemetry_and_Device_Id|Set your telemetry device id]] as provided by [http://www.race-capture.com race-capture.com]
 
===Manual Setup===
If you already have an existing, customized configuration, follow these steps to add E46 CAN bus integration.
 
'''[[RaceCapturePro2_OBD2#Enable_CAN_bus|Enable the CAN bus]]''' in your RaceCapture/Pro configuration
 
* Rate is 500kb/s
* Do '''not''' enable OBD-II channels.
 
Add this script to the Scripting section, this will enable Coolant, Oil Temp, Throttle position and brake switch. (More sensors coming soon!)
 
===Script===
<pre>
--This example configured for E46 CAN
-- Automatically starts logging with engine 'on' (RPM triggered)
--how frequently we poll for CAN messages
tickRate = 30
--the CAN baud rate
CAN_baud = 500000
--CAN channel to listen on. 0=first CAN channel, 1=second
CAN_chan = 0
 
--add your virtual channels here
--format addChannel(<name>, <sample rate>, <precision>, <min>, <max>, [units])
tpsId = addChannel("TPS", 10, 0, 0, 100, "%")
tempId = addChannel("EngineTemp", 1, 0, 0, 255, "F")
oilTempId = addChannel("OilTemp", 1, 0, 0, 255, "F")
rpmId = addChannel("RPM", 10, 0, 0, 10000)
steerId = addChannel("Steering", 10, 0, -360, 360, "Deg.")
brakeId = addChannel("BrakeSw", 10, 0, 0, 1)
brakePressId = addChannel("Brake", 10, 0, 0, 255, "Bar")
clutchId = addChannel("Clutch", 10, 0, 0, 1)
lfWheelId = addChannel("LFWheelSpd", 10, 0, 0, 200, "MPH")
rfWheelId = addChannel("RFWheelSpd", 10, 0, 0, 200, "MPH")
lrWheelId = addChannel("LRWheelSpd", 10, 0, 0, 200, "MPH")
rrWheelId = addChannel("RRWheelSpd", 10, 0, 0, 200, "MPH")
gearTempId = addChannel("GearboxTmp", 10, 0, 0, 400, "F")
fuelId = addChannel("Fuel", 1, 0, 0, 100, "%")
extTempId = addChannel("ExtTemp", 1, 0, 0, 120,"F")
 
--Convert C to F
function toF(value)
return value * 1.8 + 32
end
 
--E46 TPS, correct your throttle here for true 100%
function e46_tps(value)
return value + 0.0
end
 
--only start logging / telemetry if engine is running
function rpmFilter(value)
if value > 500 then startLogging() else stopLogging() end
return value
end
 
function brakeFilter(value)
return bit.rshift(bit.band(value, 0x10), 4)
end
 
function clutchFilter(value)
return bit.band(value, 0x01)
end
 
function processWheel(id, data, offset)
  --wheel speed is 13 bits long, little endian
  --low byte high byte
  --76543210 76543210
  --11111111 11111XXX
  local highByte = bit.band(data[offset + 2], 0x1F)
  local lowByte = data[offset + 1]
  local value = highByte * 256 + lowByte
  value = value * 0.0625
  --convert to MPH. comment to keep KPH
  value = value * 0.621371
  setChannel(id, value)
end
 
function processSteering(data)
    local steer = 0
    if data[2] > 127 then
      steer = -1*(((data[2]-128)*256)+data[1])
    else
      steer = (data[2]*256)+data[1]
    end
    setChannel(steerId, (steer*0.045))
end
 
function fuelFilter(value)
  --adjust for 7 bit value
  value = bit.band(value, 0x7F)
  --convert liters to %. tank holds 62.83 liters
  return value / 0.6283
end
 
function extTempFilter(value)
  local temp = bit.band(value, 0x7F)
  if value > 127 then
    temp = -1 * temp
  end
  temp = toF(temp)
  return temp
end
 
----------------------------------------
--customize here for CAN channel mapping
--format is:
--[CAN Id] = function(data) map_chan(<chan_id>, <data>, <CAN offset>, <CAN length>, <multiplier>,
--                                  <adder>, [filter])
----------------------------------------
CAN_map = {
[496] = function(data) processWheel(lfWheelId, data, 0)
                      processWheel(rfWheelId, data, 2)
                      processWheel(lrWheelId, data, 4)
                      processWheel(rrWheelId, data, 6)
        end,
[339] = function(data) map_chan(brakeId, data, 0, 1, 1, 0, brakeFilter) end,
[504] = function(data) map_chan(brakePressId, data, 2, 1, 1, 0) end,
[809] = function(data) map_chan(tpsId, data, 5, 1 , 0.392156863, 0, e46_tps)
                      map_chan(tempId, data, 1, 1, 0.75, -48, toF)
                      map_chan(clutchId, data, 3, 1, 1, 0, clutchFilter)
        end,
[1349] = function(data) map_chan(oilTempId, data, 4, 1, 1, -48, toF) end,
[1083] = function(data) map_chan(gearTempId, data, 0, 1, 1, -55, toF) end,
[790]  = function(data) map_chan(rpmId, data, 2, 2, 0.15625, 0, rpmFilter) end,
[501]  = function (data) processSteering(data) end,
[1555] = function (data) map_chan(fuelId, data, 2, 1, 1, 0, fuelFilter) end,
[1557] = function (data) map_chan(extTempId, data, 3, 1, 1, 0, extTempFilter) end
}
 
function onTick()
    processCAN(CAN_chan)
end
--===========do not edit below===========
function processCAN(chan)
    local msg = 0
    repeat
        local id, e, data = rxCAN(chan, 0)
        if id ~= nil then
            local map = CAN_map[id]
            if map ~= nil then
                map(data)       
            end
        end
        msg = msg + 1
    until id == nil or msg > 100
end
 
--Map CAN channel, little endian format
function map_chan(cid, data, offset, len, mult, add, filter)
    if offset + len > #data then return end
    offset = offset + 1
    local value = 0
    local shift = 1
    while len > 0 do
        value = value + (data[offset] * shift)
        shift = shift * 256
        offset = offset + 1
        len = len - 1
    end
local cv = value * mult + add
if filter ~= nil then cv = filter(cv) end
    setChannel(cid, cv)
end
initCAN(CAN_chan, CAN_baud)
setTickRate(tickRate)
</pre>
 
==Test!==
Once everything is connected, plug in the other end of the RJ45 cable to RaceCapture/Pro, turn it on and turn on your car. Make sure RCP is connected to your tablet and the RaceCapture/App is running.
 
Swipe to the digital dash page and you should see data for Coolant, Oil Temp, Throttle and brake!
 
==Real-Time Telemetry==
Just 4 wires - Power, Ground, CAN+ and CAN- is needed to stream tons of data to [http://www.race-capture.com race-capture.com] for monitoring engine, driver and suspension performance!
 
[[Image:E46_realtime_data.jpg|700px]]


==Troubleshooting==
===E46 CAN bus Preset===
If you don't see any data, verify all connections and splices.
After wiring is complete, load the E46 CAN preset under Setup / CAN Mapping:


If everything is connected connect your laptop to RaceCapture/Pro, open the RaceCapture/App, go to the Scripting section, set Logging Level to debug and select 'Poll logfile'. Check the output for any obvious errors.  
[[file:E46_CAN_preset.png]]


If you are still having issues post your problem on the forums here http://www.autosportlabs.org/viewforum.php?f=20
After loading the preset, write the configuration back to RaceCapture.  


==CAN Channel Mapping==
==Verifying real-time data==
The full CAN bus mapping can be found in our [[CAN_database#BMW_E46|CAN Database]]
Start the engine, and then navigate to Dashboard / Raw Channels View to verify you are receiving data.


==Additional resources==
==Additional resources==

Revision as of 21:44, 28 March 2019

Installation

Integrating with the E46 requires just one cable, tapping into the CAN bus data of the E46's instrument cluster.

Required parts

Pre-made E46 integration cable

If you want a ready made cable, you can order one from our online store

E46 integration cable.jpg

DIY Cable

To make your own cable, you'll need the following:

  • Crimp tool
  • Wire cutter
  • Wire stripper
  • Philipps screwdriver
  • Multimeter
  • 22-26 gauge wire
  • RJ 45 (Ethernet) cable, ~6ft
  • Shrink tubing (optional, electrical tape will work too, but not look as nice)
  • Posi-tap connectors (2) - Do *not* cut the CAN wires during this installation, use wire taps (Posi-taps work very well)
  • Butt connectors (2) for 22 gauge wire
  • Flashlight
  • RaceCapture/Pro with Bluetooth
  • Android tablet
  • An E46 ;)

Estimated Time

2-3 hours, depending on level of wiring experience. The most time consuming part is splicing the CAN, power and ground wires into the RJ45 cable.

RaceCapture/Pro installation (Race / Spec E46)

We recommend installing RaceCapture/Pro on the transmission tunnel to the right of the driver's seat. This is near the center of rotation to get the best effect from the on-board IMU (Accelerometer + Gyro)

RCP install E46.jpg

CAN wires

The CAN+/CAN- wires are located in 2 places: under the driver's side dash above the footrest or in the DME panel. For these instructions it is assumed you are using the wires under the dash.

CAN wire colors are as follows:

  • Yellow/Red = CAN+ (high)
  • Yellow/Brown = CAN- (low)

They are a twisted pair in or attached to the main wiring harness under the driver's side dash above the dead pedal.

Remove bottom of dash

You will have to remove the panel below the steering wheel via 3 philipps screws, a plastic thumb screw (turn 90 degrees and pull) behind the pedals and a press fit plastic screw on the transmission tunnel (pull the tiny center pin out first, then the larger screw).

Once you have removed the panel you should see a large wiring harness above the dead pedal.

Locate CAN wires

Look for a twisted pair of wires that are Yellow/Brown and Yellow/Red like so:

Canwires.jpg

Those are the 2 wires you need to *tap* into, not cut.

Tapping CAN wires

To tap into the wires, you'll first need to tease them apart because they are very tightly wound. Peel back some of the black cloth tape wrapping the harness and gently pull the wires apart. This may take some time. You'll want to have enough room for 2 fingers in between the wires.

Tapping the wires via Posi-taps (recommended) is easy. Pull the top off the Positap, place the wire in it and tighten. Verify you've tapped the wire by loosening and checking for a hole in the wire.

Positaps.png

Once you've tapped both it will most likely look like this:

Can-tapped.jpg

Create CAN wiring for RaceCapture/Pro

Now that you've tapped the CAN wires, cut two 6 foot lengths of solid wire, strip both ends and attach one to CAN+ and CAN-. Make sure to label them or you'll have to keep looking under the dash. Yellow/Brown is CAN- and Yellow/Red is CAN+.

Where you run these two wires is dependent on where RaceCapture/Pro is. You can either run them down the driver's side of the car, next to the dead pedal or find a way to route them into the center dash and out below the CD player/HVAC controls. For these instructions we routed them next to the dead pedal, under the floor mat and taped them onto the transmission tunnel next to the driver hidden away. (Our RaceCapture/Pro was installed on the center rear seat)

Power and ground wiring

Note: You can skip this section if you already have power wired to RaceCapture/Pro and don't want to change it.

RaceCapture/Pro MK1 owners: do not wire in power or ground via CANx module; connect power via terminal block only.

Option #1: OBD-II port power

Using the same cable used for the CAN bus connection you can tap into power on the OBD-II port, for a clean 4 wire connection:

E46 CAN OBD2 power.png


BMW E46 power, ground and CAN bus connections to RaceCapture/Pro
Connection BMW RaceCapture/Pro (RJ45 cable)
+12v Yellow-Red (OBD-II connector) Brown
Ground Brown (OBD-II connector) Orange/White
CAN High Yellow/Red Orange
CAN Low Yellow/Brown Green/White

Note: These color codes assume EIA-T568B RJ45 cable (check printing on the cable to confirm)

Option #2: Center arm-rest power

An easy and convenient source for power is under the coin holder in the center armrest. Pull the cup holder and coin holder out. Beneath them will be a cloth/foam wrapper containing a cellular phone connector. It contains 12v switched power and ground. Pull it gently towards the back of the car, then up to get more slack. Pull apart the foam to get to the wires.

The 12v wire is purple/white, ground is brown. *Note*: there is also a tan wire that looks very similar to brown. Compare the two and pick the darker one.

Splice power and ground wires

You can tap these wires if needed, for these instructions we cut them.

Cut 2 pieces of solid wire about 3ft long or appropriate length needed. Cut the 12v and ground wires and connect them to the wires you just made. Tape or add shrink tubing as necessary. Label the wires 12v and ground.

E46powerground.jpg

CAN Bus connection

In order for RaceCapture/Pro to read CAN data you need to connect the CAN+/CAN- wires to a RJ45 (ethernet cable).

Cut one end off the RJ45 cable and pull apart all the wires.

Identify and label the CAN1 High, CAN1 Low, 12v and ground wires via a multimeter.

For a standard RJ45 cable (EIA T568B) the colors are:

  • Orange: CAN1 High
  • Green/white: CAN1 Low
  • Brown: Power
  • Orange/white: Ground

Use the following diagram:

Canrj45.png

You will end up with something that looks like this:

Rj45labeled.jpg

Once you have identified and labeled the wires, strip them and attach to the CAN wires and power/ground wires from the car. RJ45 wires are very thin, you will want to loop them around the thicker wires and add tape or shrink tubing.

Configure RaceCapture/Pro

Set Baud Rate

Ensure CAN1 baud rate is set to 500K

Setup CAN1 500K baud.png

E46 CAN bus Preset

After wiring is complete, load the E46 CAN preset under Setup / CAN Mapping:

E46 CAN preset.png

After loading the preset, write the configuration back to RaceCapture.

Verifying real-time data

Start the engine, and then navigate to Dashboard / Raw Channels View to verify you are receiving data.

Additional resources