Hi. I am a new user. I have just started using RCP with an OBDLink LX in my 2019 Miata. I would like to be able to include current gear and brake position in my video overlays. I did some searching but no luck. I found the following, I don't know if it is relevant.
https://docs.google.com/spreadsheets/d/1uqwIMof9DdaEv0EkWHXe70XNGt0FGeDxpbMAgfKbbdk/edit?usp=sharing
Comments
There is a "beta" feature in RaceChrono that will allow you to log data from CAN-Bus messages, using an OBDLink brand reader. It is a bit hidden as it's not properly tested and documented. But I guess there's no reason not to try it as you already have the hardware and reverse engineered CAN-Bus messages. Also this thread could act as draft documentation for the feature, and when complete will be moved to the support section.
Background
CAN-Bus is not OBD-II.
The CAN-Bus is a communication bus in your car, used for electronic controller units (ECU) communicating with each other. Such as RPM value from engine ECU to the gauge cluster, or accelerator pedal position to engine ECU. Most new vehicles have CAN-Bus, it's been used in cars since early(ish) 2000's, and nowadays in motorbikes too.
For the CAN-Bus messages to be useful, they can be reverse engineered with right tools (not RaceChrono at the moment), or you might find them already reverse engineered by others. Searching the brand specific internet discussion forums are usually good bet. You will need to know the vehicle specific PID numbers, and the message structures such as byte offset and byte length of the piece of data you're after. Also data scale is helpful when creating the equation.
OBD-II is a diagnostic standard required by law (Europe and USA), used originally for emissions tests. OBD-II can be implemented on top of CAN-Bus or "K-line Bus" for example. Cars sold in Europe and USA since 2001 implement OBD-II, also even some earlier models that were prepared to be sold after 2001. OBD-II is also implemented in motorbikes that meet the EURO5 emissions standard (some other bikes too, but it's kind of rare).
Setup for CAN-Bus logging using OBDLink reader
1) Enable "RaceChrono > Settings > Expert settings > Experimental devices"
2) Add "OBDLink LX/MX/MX+ Bluetooth (CAN-Bus)" from "RaceChrono > Settings > Add other device". Notice do not add it from "Add OBD-II reader", as it will just add an OBD-II reader that will not be used for CAN-Bus.
3) Now a hidden feature is revealed, you can add CAN-Bus channels in "RaceChrono > Settings > Vehicle profile" screen.
Adding CAN-Bus channels
Go to "RaceChrono > Settings > Vehicle profile" and add new CAN-Bus channel. Then fill the fields and save the channel. Then you're ready to test it!
For example the speed channel from your spreadsheet:
1) Channel: Speed
2) PID: 514 (or 0x202)
3) Equation: In the spreadsheet it says scale 1/160 for MPH. So equation "bytesToUint(raw, 2, 2) / 160.0" would get you MPH. But RaceChrono needs meters per second (m/s), and the original value seems to be (kph with 1/100 scale), so working equation will be "bytesToUint(raw, 2, 2) / 360.0".
Tutorial on creating these equations: https://racechrono.com/support/equations
However it leads to a pretty good test of my binary logic to express it as a formula to map the raw values to actual gear. I think I have it, but maybe there is a bug in rcp parsing, it says 'brackets mismatch' but I don't see how. Here is my gear formula:
((G&16)>>4)*1+((G&8)>>3)*2+((((G&16)>>4)^1)&0x1)*((((G&8)>>3)^1)&1)*min(3,max(6,(10-(G&7))))
I think I found a variation for gear that doesn't trigger the bug.
On a separate note, brake pressure isn't working at all. Maybe the PID has changed, my car is a 2019 and the spreadsheet is pre-2019 I believe.
http://www.obdkey.com/vehiclediagnostics.asp#VehicleInfo
I basically only used it as generic OBD dongle...
However, it is unable to keep refreshing the values.
When I enable "Test connection" in "Vehicle profile", the "CAN-Bus channels" show the preview of the values once,, but don't update afterwards. "Use live data" doesn't become available in the "Channel editor". Similarly, when I start a session, the values don't get updated once they are shown.
Same results whether I try multiple different CAN PIDs or just one CAN PID.
Should I grab any logs to help you debug the issue?
Also, is it correct to assume that using the same OBDLink for reading via OBD-II and CAN bus at the same time will never be possible? I've tried that and it appears that the app keeps connecting to one protocol while disconnecting from the other, then switches the protocols and the process repeats.
The current command set does not easily allow OBD-II polling and CAN-Bus monitoring at the same time. On a DIY device it would be easily possible. Or with two readers.
> CAN-Bus monitoring at the same time.
Understood
> Does it work fine when recording a session? So only a problem with the "Test connection"?
>> Similarly, when I start a session, the values don't get updated once they are shown.
Turns out that some of the Ford PIDs still work on Mazdas as well.
I've tested on my gf's ND2, but I presume they will work on ND1 also.
Brake position (%)
OBD-II header: 0x760 (not sure if necessary, what's the default value?)
PID: 0x222b0d
Equation: max(0, bytesToInt(raw, 1, 2)) * 0.67
(You can try other multipliers if you find the number to be too high or too low for you. You can also wrap it into min(100, ...) to limit to 100%.)
Accelerator position (%)
PID: 0x22032b
Equation: B/2
(Surprisingly, the standard OBD PIDs for accelerator communicate values in some weird ranges. This PID gives data in a 0–200 range, but at least that looks deliberate)
These two, along with the standard OBD PIDs for Speed and RPM, should be a very good set of "Fast channels" to use with RaceChrono. Given the limited bandwidth of the OBD protocol, I wouldn't bother adding any other PIDs as "fast" for track/autox logging.
I also found how to read tire pressure, if your Miata has TPMS sensors (I believe earlier model year NDs had indirect TPMS only):
OBD-II header: 0x720
PID: 0x222a05 FL, 0x222a07 FR, 0x222a06 RL, 0x222a08 RR
Equation: B * 1.373
You'll probably want to use these PIDs as "Slow channels", as they don't change that often, and would interfere too much with the more time sensitive data if you make them "Fast channels".
@aol Consider renaming the thread back to "OBD PIDs for ND2 Miatas"
I did not make progress beyond current gear. Kind of lucky I just checked this thread, super excited to try this new stuff! Thanks @timurrrr !
Thank you for your work!!!! I'll try it right away and update my result soon
*update
It works perfectly!! Thank you once again. You are my hero!
Does anyone know of a software that can turn obdlink into a CAN logger on a range of PIDs? Or do I need to hack my own/get a can logger?