Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added e46 config and wiki #7

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions can_db/e46.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,30 @@ The CAN bus is not available at the OBD-II port, so it must be tapped into behin
The easiest places to do this are either behind the intrument cluster or at the steering angle sensor,
which is located at the base of the steering column near the firewall.

![Steering Angle Sensor Plug](../images/e46_sensor_plug.jpg)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great photo, makes it clear where the harness is.

I just pushed 56a8228 with a re-compressed version of that photo.
Sorry I grew up in dial-up time, and still trying to save a few kB when possible 😄
You can now remove the file from this PR.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(please do keep the reference in the .md file though!)


A simple plug-in harness can be made by cutting both sides of this connector and a few inches of wiring
timurrrr marked this conversation as resolved.
Show resolved Hide resolved
from a donor car at the salvage yard. Constant and switched power can also be found at this connector.
from a donor car at the salvage yard. The CAN-H and CAN-L are the Yellow/Black and Yellow/Brown wires, respectively.
Constant/switched power and ground can also be found at this connector. The harness pictured does not include the
power/ground.

![CAN bus harness](../images/e46_harness.jpg)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's very hard to see the wire colors on that photos, presumably due to incandescent light source?
Can you try to take a photo outside in bright sunlight, or a similar light source?

Also I'd appreciate it if you can shrink/compress the file to be <300 kB.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't have GIMP/Photoshop to shrink/compress the photo please let me know and I can help with that.


## Recommended CAN IDs:

Channel name | CAN ID | Equation | Notes
------------ | --- | -------- | -----
Accelerator position (%) | 809 | `F * 100 / 255` |
Accelerator position (%) | 809 | `F / 2.54` |
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm, why 2.54 instead of 2.55?
I presume the max value of F is 255?

Brake position (%) | 809 | `G & 1 * 100` | Brake pressures are not available on the main CAN bus, so this is just an on/off signal from the brake switch.
Steering angle | 501 | `if(b & 0x80, 0 - ((b & 0x7f)<<8) \| a, (b<<8) \| a) * 0.04394` | Positive value = turning right. You can swap the equation in the if statement if you prefer it the other way around.
Steering angle | 501 | `if(B & 0x80, -1, 1) * bitsToUIntLe(raw, 0, 15) * 0.04394` | Positive value = turning right. You can swap the equation in the if statement if you prefer it the other way around.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I ended up flipping positive/negative in the BRZ/86 equations to match how RaceChrono visualizes the steering angle. You may also want to do left=positive.

Speed | 339 | `bitsToUIntLe(raw, 11, 13) / 16 * 0.277778` | You may want to check the multiplier against an external GPS device, especially if running larger/smaller diameter tires
Engine RPM | 790 | `((D<<8) \| C) / 6.4` |
Engine RPM | 790 | `bytesToUIntLe(raw, 2, 2) / 6.4` |
Coolant temperature | 809 | `B * 0.75 - 48.373` |
Engine oil temperature | 1349 | `E - 48.373` |
Air temperature | 1557 | `D` |
Clutch position (%) | 809 | `D & 1 * 100` | on/off signal from the clutch switch
Fuel level (l) | 1555 | `C & 0x7f` |
Odometer | 1555 | `((B<<8) \| A) *10000` |
Odometer | 1555 | `bytesToUIntLe(raw, 0, 2) * 10000` |

Below is a table with a few more data channels that might be useful for more
detailed analysis. When adding more channels, be aware that it will increase
Expand All @@ -30,7 +36,7 @@ update rate of the more essential channels, due to limited Bluetooth bandwidth.
However, the communication protocol in RaceChrono is smart enough to optimize
Bluetooth usage if multiple channels share the same CAN ID. As a general rule,
if a new channel has the same CAN ID as an existing channel (such as "Throttle
position" using the same CAN ID 320 as "Accelerator position"), then adding it
position" using the same CAN ID 809 as "Accelerator position"), then adding it
should not affect the update rates. Adding a channel based on a new CAN ID (such
as "Wheel speed FL") will likely affect the update rates of all other channels.

Expand Down
1 change: 1 addition & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ uint8_t getUpdateRateDivider(uint32_t can_id);
// following lines:
//#include "configs/ft86_gen1.h"
//#include "configs/ft86_gen2.h"
//#include "configs/e46.h"

// Once you read all the comments and address what they asked of you, please
// uncomment the nest line:
Expand Down
30 changes: 15 additions & 15 deletions configs/e46.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,71 @@
// (1999-2005 model years).

#if !defined(RACECHRONO_BIY_BLE_DEVICE_E46_H)
#define RACECHRONO_BIY_BLE_DEVICE_E46_H)
#define RACECHRONO_BIY_BLE_DEVICE_E46_H

uint8_t getUpdateRateDivider(uint32_t can_id) {
// This is sent over the CAN bus 140 times per second and carries:
// vehicle speed
// Let's go for ~10 per second
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so low? It's one of the most important data channels.
I suggest at least 20 updates per second for the vehicle speed.

I use 25 on 86's.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was having throughput issues in testing and settled on 10Hz. I think this can be tuned further.

if (can_id == 0x153) {
return 14;
if (can_id == 339) {
return 7;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update the comment above to say 20 per second?

}

// This is sent over the CAN bus 140 times per second and carries:
// individual wheel speeds
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. Also, consider merging these two ifs together.

// we want ~10.
if (can_id == 0x1F0) {
return 14;
if (can_id == 496) {
return 7;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

}

// This is sent over the CAN bus 100 times per second and carries:
// engine RPM
// we want ~10.
if (can_id == 0x1F0) {
return 10;
if (can_id == 790) {
return 5;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

}

// This is sent over the CAN bus 100 times per second and carries:
// Steering angle
// we want ~10.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it useful to have the steering angle updated more frequently, as it greatly simplifies synchronizing data to video.
But given that in this CAN bus most of the high-speed data channels seem to be on separate IDs, I can imagine that you run out of bandwidth sooner than I do on my 86...
I trust your judgement here, just wanted to bring up the data/video sync concern.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't consider the sync issues. Bandwidth is certainly a concern. I'm hoping this can be improved with a different processor/radio (esp32?)

if (can_id == 0x1F5) {
return 10;
if (can_id == 501) {
return 5;
}

// This is sent over the CAN bus 100 times per second and carries:
// Coolant temp
// Ambient pressure
// Throttle Position
// we want ~10.
if (can_id == 0x329) {
return 10;
if (can_id == 809) {
return 5;
}

// This is sent over the CAN bus 100 times per second and carries:
timurrrr marked this conversation as resolved.
Show resolved Hide resolved
// oil temp
// we want ~1.
if (can_id == 0x545) {
if (can_id == 1349) {
return 100;
}

// This is sent over the CAN bus 5 times per second and carries:
// odometer
// fuel level
// we want ~1.
if (can_id == 0x613) {
if (can_id == 1555) {
return 5;
}

// This is sent over the CAN bus 5 times per second and carries:
// ambient air temp
// we want ~1.
if (can_id == 0x615) {
if (can_id == 1557) {
return 5;
}

// OBD responses should be rare, don't limit them at all if we're listening to
// them.
if (can_id > 0x700) {
if (can_id > 1792) {
return 1;
}

Expand Down
Binary file added images/e46_harness.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/e46_sensor_plug.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.