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

Conversation

jawillis
Copy link

@jawillis jawillis commented Jul 1, 2022

No description provided.

Copy link
Owner

@timurrrr timurrrr left a comment

Choose a reason for hiding this comment

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

Overall looks good, just suggesting some minor corrections and a couple of minor questions.

Thanks a lot for your work!

can_db/e46.md Show resolved Hide resolved
can_db/e46.md Outdated

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

Choose a reason for hiding this comment

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

Does this equation correctly calculate the sub-% values, or should you change to 100.0?
Alternatively, I'd just write this as a shorter F / 2.55.

can_db/e46.md Outdated
------------ | --- | -------- | -----
Accelerator position (%) | 809 | `F * 100 / 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.
Copy link
Owner

Choose a reason for hiding this comment

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

Is this the same as if(B & 0x80, -1, 1) * bitsToUIntLe(raw, 0, 15) * 0.04394 ?

Strange that they didn't use the two's complement for negative values.

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.

}

// 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.

configs/e46.h Show resolved Hide resolved
can_db/e46.md Outdated
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
Copy link
Owner

Choose a reason for hiding this comment

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

CAN ID 320 for "Accelerator position" is an 86 thing, please update with something more relevant for E46.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, a cut-and-paste casualty. Will change.

can_db/e46.md Outdated
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.
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` |
Copy link
Owner

Choose a reason for hiding this comment

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

bytesToUIntLe(raw, 2, 2) / 6.4?

can_db/e46.md Outdated
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` |
Copy link
Owner

Choose a reason for hiding this comment

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

bytesToUIntLe(raw, 0, 2) * 10000?

@@ -0,0 +1,76 @@
// Customizations for BMW e46
Copy link
Owner

Choose a reason for hiding this comment

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

Please add
//#include "configs/e46.h"
to config.h between lines 22 and 23.

@jawillis
Copy link
Author

jawillis commented Jul 2, 2022

Thanks for your feedback! I'll apply and test these changes next week when I'm back home.

@jawillis
Copy link
Author

I've addressed your review comments, except for the ones related to update rates since I have not been able to get better rates with my existing nRF52-based setup. I will revisit those values when I have the ESP32 version fully tested.

@@ -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!)


## 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.

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?

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

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

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.

@timurrrr
Copy link
Owner

Overall looks good, just a couple of minor comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants