Trying to create my first DIY

edited January 2021 in DIY builds
Hi,

I'm new here, but not new to RaceChrono. I'm a very pleased long time user of Pro version. Thank you aol for this great app.

I'm trying to build a simple bluetooth datalogger for my CBR600RR 2008 track bike.
I'm a software engineer and my daily job is coding in Java. I have a very basic skill in electronics, and I am trying to learn it in my free time.

I know that Honda bikes don't support CAN-Bus, they have only K-Line which differs a bit compared to other makes.
The messages have a similar payload compared to CAN-Bus messages and what is where can be found here https://gonzos.net/projects/wp-content/uploads/2015/09/Honda-data-tables.pdf

Right now in my country is freezing, so working in a garage will have to wait. But still I can emulate the data received from K-Line and work with transforming it and sending it to RaceChrono app. I could also work on equations etc. Although I never worked in C++ I think I can manage it.

Couple of questions:

1. What is better, a classic external BT module hooked to one of the serial ports of Arduino board and RFCOMM connection using $RC3 format messages or some Arduino board with built in BLE chip and Bluetooth LE connection using CAN-Bus API?
Which is better in terms of speed and stability? How many messages per second can I expect from both of those methods of communication? (I have a Galaxy S10e if that matters in any of that)

2. I read https://github.com/aollin/racechrono-ble-diy-device/ and saw that you recommend nRF52840 boards as it has more than one hardware serial port, so you wont lose debugging when some breakout board is connected to that only serial port.
The waiting time for Feather nRF52840 Bluefruit LE Adafruit 4516 is really long in Poland due to pandemic, but the Arduino Nano 33 BLE with the same nRF52840 chip is available.
Will this board be good?
Does it have more than at least one hardware serial when connected through USB or is that something that is not chip but board dependent?
Can this type of information be found in datasheet, and if so under what title?

3. Both this Arduino and that Feather board are logic 3.3V. The only K-Line chip that I can get here is L9637D https://www.st.com/resource/en/datasheet/l9637.pdf which is 5V. Will that be a problem, should I search for some Arduino logic 5V board? (this is where my low level of electronics knowledge is a problem)




Comments

  • edited January 2021
    In theory, you could actually do K-Line communication with a "de-dacto standard" ELM327 based Bluetooth OBD-II reader. All that should be required is creating a suitable "Vehicle profile" in RaceChrono settings for it. We did this with Suzuki and AFAIK it's working just fine. I think it could be possible with a K-Line Honda too?

    Basically you could send commands to the OBD-II reader using a terminal, and see what you can extract from the K-Line and how. When that's done, then it would be time to create the Vehicle profile, in which I can help, when I see how to extract the data using a terminal.

    Here's the Suzuki K-Line thread: https://racechrono.com/forum/discussion/comment/10569

    Too bad my rd07a Africa Twin is most probably too old to have K-Line, otherwise I could go test it immediately :)
  • Do you want to add extra sensors? In no, then DIY device would be overkill.

    I have a Honda S2000 what doesn't have can bus. Only a K-line. Carista OBD2 reader works great with it. Your bike probably doesn't have Obd port, but adapter would be pretty easy to build. I'm pretty sure that it would only need 12v, gnd and K-line to work.
  • @_valtsu_ Older bike do not have OBD-II on the K-line bus. The bikes need raw K-line. It works like you say, except the need to create a Vehicle profile (as per my instructions to use a terminal above).
  • @aol Ok. I didn't know that there is different kind of K-line communications. Thanks!
  • edited January 2021
    @_valtsu_, yep, just like the CAN-Bus, the K-line is the lowest level protocol on the bus, that is used internally by the instrument cluster etc. The possible OBD-II protocol is implemented on top of the bus, wether it's K-line or CAN-Bus or something else.
  • edited January 2021
    Yes, I would need to create a Arduino based DIY as I read https://github.com/MagnusThome/RejsaRubberTrac and bought 6 sensors and one potentiometer :
    * 2 Laser distance sensor: VL53L0XV2 (SMBus 3.3V) for front and back suspension travel.
    * 4 Infrared sensors GY-906LLC-DCC MLX90614ESF-DCC (SMBus 3.3V) for both sides of both tires.
    * 1 Linear potentiometer PM9600-9610-9615-DUNKAN for master pump lever travel.

    I will go with Arduino Nano Every + HM-05v2 Bluetooth 2.0 module or Nano 33 BLE as they are available here, so my first questions still stands:
    > What is better - Classic Bluetooth over hardware serial and RFCOMM or integrated BLE and Bluetooth LE connection using CAN-Bus API?

    I read about SparkFun Logic Level Converter - Bi-Directional so I think this will handle the 3.3V - 5V conversion, but I read that it is maybe not even needed on this GitHub project https://github.com/aster94/Keyword-Protocol-2000/blob/master/extras/Images/l9637_wiring.png

    But maybe as a good start I will try with ELM327 so we could create a Vehicle profile for Honda bikes.

    I have some cheap chines clone of ELM327 (as the originals are really hard to get). I read here https://netcult.ch/elmue/HUD ECU Hacker/ that those are bad and:
    "As there are so many problems with chinese ELM327 clones I implemented the ELM327 Terminal.
    Here you can test your adapter by sending commands and studying the responses.
    The screenshot shows that my ELM327 clone sends commands only up to 4 data bytes.
    If I send 5 data bytes or more (like the Slewing commands) there is no response, no error and no prompt.
    I verified on the oscilloscope that the adapter indeed does not send anything.
    The command ATAL is simply ignored although it was answered with a fake 'OK'.
    It is a fraud to sell this crap.
    By the way: It is completely irrelevant if a chinese adapter claims to be version 1.5 or 2.1. They are all crap.
    And I saw people complaining in internet about ELM327 adapters which have even less functionality than mine." so I don't know if this one will work.

    Another thing is that Honda seems to have a different initialization than other makes and also calculates checksum differently https://gonzos.net/projects/ctx-obd/
    So maybe it will not be possible with ELM327 that has hardcoded communication protocol implementation. From gonzos.net site on how he communicated with Honda bike:
    "Set up serial communications at 10400baud. This is a non-standard baud rate, so you can’t use a normal USB to serial adapter, and you can’t use a standard automotive ELM327-based unit because the ELM unit calculates the checksum differently and adds it automatically whether you want it to or not.
    Use the correct message protocol. Honda does not use the standard ISO-9141-2 protocol.
    Use the correct initialisation sequence. Honda does not use the standard ISO initialisation sequence (another reason not to use an ELM unit)."


    So do you think it is still possible to use this chines ELM327 Bluetooth adapter?
    (I'am learing about these protocols everyday, but my knowledge about how those adapters work with those protocols is still very lacking).
    Here is an old topic https://racechrono.com/forum/discussion/945/datalog-from-a-cbr600rr-custom-logger-interaction but I think ELM327 was used as a sniffer with Gear Indicator as communication initiaizer.

    Sorry if I seem to be lazy with all those questions, but getting all this data from different GitHubs, sites and forums and connecting all the dots is still bit to much at my current level.
  • About the Arduino device:
    With Bluetooth serial RFCOMM the code is pretty simple. With BLE it's more complicated because you need to send the sensor data as Can Bus messages. I have built Arduino Uno based device with analog sensors and Bluetooth serial RFCOMM. I had some problems with data logs being out of sync. Otherwise it works great and I think I know how to fix the problem. https://racechrono.com/forum/discussion/1879/my-arduino-based-datalogging-project

    With those devices you are going to use you will need logic level converter. Arduino is running 5v and sending 5V I2C messages.
    Have you considered using microcontroller with 3,3V operating voltage? Then you would only need to use logic level converter with communication to L9637D.
    L9637D datasheet says min. supply voltage 4,5V. I would stick with 5V.

    You could try Arduino Forums to find answers for your questions about the hardware. Of course feel free to ask here.

    I haven't messed with K-line or ELM327 that much so I don't know about that.
  • edited January 2021
    @kaliberr44 If Honda uses non-standard K-line baudrate then ELM327 is not an option.

    I try to avoid the generic brand OBD-II readers, and if I was doing something like this I'd always use the OBDLink MX/MX+, as it has best support for different buses.

    ELM327 chip does not bring you much benefit, if you're going to build a DIY device anyways and you can find some simpler way to connect to the K-line.
  • If you want to have your build smaller and with fewer moving parts, I suggest getting an Arduino device with Bluetooth already on the board.
    Here's a description of what I did with an "Adafruit ItsyBitsy nRF52840 Express" board:
    https://github.com/timurrrr/RaceChronoDiyBleDevice
  • @_valtsu_
    Yes, the boards that I mentioned are 3.3V, so only logic voltage converter will be needed for L9637D.

    @aol
    My research showed that ELM327 does not support custom 10400baud rate, although OP https://racechrono.com/forum/discussion/945/datalog-from-a-cbr600rr-custom-logger-interaction did mange to use is a sniffer. But since I have a cheap chinese clone, I suspect even that wouldn't work. I need inputs for sensors anyway.

    @timurrr
    I saw your libs made by you already and they are very helpful in understanding how it should work.

    Right now I have set Arduino Nano 33 BLE.
    RaceChrono sees my Bluetooth LE CAN-Bus, but I get no data.

    I have 'Experimental devices' turned on.

    Decimal PID in app for brake position (%) is 200, equation bytesToUInt(raw,1,1)/255.0*100
    which if understand correctly should give A6/255.0*100=166/255.0*100=~65

    Bytes that I send are:
    Byte[0] = C8
    Byte[1] = 0
    Byte[2] = 0
    Byte[3] = 0
    Byte[4] = 19
    Byte[5] = A6
    Byte[6] = 0
    Byte[7] = 0
    Byte[8] = E0
    Byte[9] = 0
    Byte[10] = 0
    Byte[11] = 0

    or also tired (I don't know which one will give me PID = 200 DEC since PID is little endian)

    Byte[0] = 0
    Byte[1] = 0
    Byte[2] = 0
    Byte[3] = C8
    Byte[4] = 19
    Byte[5] = A6
    Byte[6] = 0
    Byte[7] = 0
    Byte[8] = E0
    Byte[9] = 0
    Byte[10] = 0
    Byte[11] = 0

    but no luck, RaceChrono always 'Waiting for data...'. What could be an issue?
  • edited January 2021
    OK, managed to fix that.

    I changed the typed characteristics:
    BLECharacteristic canBusMainCharacteristic = BLEByteCharacteristic("0001", BLENotify | BLERead);

    to generic one:
    BLECharacteristic canBusMainCharacteristic = BLECharacteristic("0001", BLENotify | BLERead, 12, false);

    Seems like the BLETypedCharacteristic in has fixed size for length of data. The documentation https://www.arduino.cc/en/Reference/ArduinoBLEBLECharacteristicBLECharacteristic differs from acctual API.
Sign In or Register to comment.