Skip to content

Latest commit

 

History

History
75 lines (56 loc) · 3.08 KB

README.md

File metadata and controls

75 lines (56 loc) · 3.08 KB

CAN Bus Data Logger for RaceChrono

This project is a high-speed CAN-Bus datalogger for a BMW Z4 E85. It integrates into the onboard network and feeds data to RaceChrono over Bluetooth Low Energy (BLE).

TODOs

  • High-speed GPS module
  • Upload 3d printed enclosure .stl files and pictures
  • Bluetooth security
  • Update rate improvements
    • Merge CAN messages?
  • XY-Axis acceleration data
    • Formulas/decoding needs to be fixed

BoM

Pictures

img

img

img

Achieving high BLE notification throughput

To achieve high CAN message throughput, the following things should be considered:

  • Choose 2M BLE PHY over 1M or CODED PHY
  • Run freeRTOS CAN and BLE tasks with higher than 0 (IDLE) priority
  • Use a fast CAN ARBID filter function
  • Ensure that there are free BLE transmit buffer available before sending (esp_ble_get_cur_sendable_packets_num)
  • Set the TX power to a high enough setting, depending on distance to phone
  • Filter out uninteresting CAN ARBIDs in hardware
  • Set BLE MTU higher than message size + 4
  • Request HIGH connection priority on the client side

Android connection priority / BLE connection interval

The BLE stack operates on two connection interval values (min, max), which effectively determine the maximum possible update rate for CAN-bus messages transmitted from the ESP32 device to the phone. While we can set the preferred values on the server side with pAdvertising->setMinPreferred(0x06);, it's the client (phone) which ultimately chooses the values. By default, my Android Pixel 4 seems to pick a balanced value resulting in a update rate of ~30-40 Hz. Apps can explicitly request a priority for a given connection docs, picking between 4 presets.

In my experiments I used the nRF Connect app to both log and set BLE parameters. When following these steps, I could significantly increase the observed CAN message rate:

  1. Enable Bluetooth
  2. Open nRF Connect app and connect to data logger
  3. From drop-down, open "Request connection priority" and pick HIGH
  4. Confirm change in logs
  5. Open Racechrono
  6. Start new recoding session
  7. Open sensor menu ^ and confirm "Bluetooth LE CAN-bus" update rate

Here are the different rates observed with different settings:

Connection Prio Data Rate [Hz]
default ~45
HIGH >60
BALANCED ~45
LOW_POWER 7

Credits / References