Reading from CAN bus with OBDLink MX and RaceChrono
Update
You can now using an OBDLink MX or MX+ to read CAN-bus data into RaceChrono Pro. Use this to add brake pressure and steering angle to the data already available through an OBD reader. Notes:
https://www.s2ki.com/forums/s2000-ra.../#post24931244 https://www.s2ki.com/forums/s2000-ra.../#post24931898 Ultimately you can do something like this. Speed=yellow, throttle pink, brake green, steering angle blue: https://cimg4.ibsrv.net/gimg/www.s2k...615c2f31fe.jpg Got an upshift, some heel-toe, trail braking, catch a little slide... Not sure how much I'll use the steering trace, but having brake pressure to go along with throttle is really nice to analyze what you're doing (and what you're doing wrong!) Original post ---- Recently RaceChrono Pro has added an option to add an OBDLink MX or MX+ bluetooth OBD2 reader as a CAN bus reader, and theoretically to read custom data from the CAN bus this way. I'm thinking this could be a poor man's way to add data like steering angle and brake pressure without adding any additional hardware beyond bluetooth GPS and OBD2 reader. However, I'm completely new to trying to understand the CAN bus, so haven't gotten very far! I found some posts here and elsewhere from @Gernby that listed the data available via several PIDs (below), but first I need to get it to actually receive data. I'm using the android app 'serial bluetooth terminal' to try and test; am able to connect to the OBDlink MX there; I can send ATZ (reset), ATSPx (set protocol to x, ie 1-9), and ATMA (monitor all). Now, from what I've read, the AP2 CAN bus protocol is ISO 15765-4 CAN (29 bit ID, 500kbaud), which I believe should be ATSP7. However, when I set ATSP7 and then ATMA I don't get any output. I do get output with ATSP6, but it's full of data error messages along with the data. 6 is the same as 7 except for being 11 bit instead of 29 bit, so I think maybe the extra bits are causing the data errors, but then I'm not sure why I don't get anything from ATMA when choosing protocol 7. Also if I try ATSP0 (automatic protocol) and then ATMA it just gets stuck on 'Searching" for the protocol, seemingly forever. I wonder if I need to change my buffer settings in some way, or if there's an initialization command I need to send, but I'm pretty over my head at this point. FWIW I also tried skipping the terminal and just interrogating the PIDs that are supposed to contain info using racechrono, but likewise there I wasn't able to get any live data out of it. Maybe someone who has a clue here can point me in the right direction, or if you have an OBDlink MX, give it a try yourself? Sure would be cool to get this working, if it's indeed possible!
Originally Posted by Gernby
(Post 23684976)
Most of the traffic on the CAN Bus seems encrypted, but not all of it. I spent a TON of time trying to figure out what the non-encrypted data was, which required some custom software. It's been a while since I looked at it, so I'm not sure if the spreadsheet I'm looking at is the latest / most accurate, but here is a summary:
PID Data Byte 106 D4= Misfire? D5 = Starter D7 = Brake Pressure 166 D1 = Fuel Status? D8 = Bitwise Data 170 D1 = Throttle pedal 198 D1 & D2 = Steering Wheel D3 = Lateral Accellerometer 300 D1 = ECT D2 = Ambient Temp or IAT D5 & D6 = RPM D7 = Bitwise stats D8 = Fuel Trims? 448 D1 & D2 = Speed D3 & D4 = Speed 2 D5 & D6 = Speed 3 D7 & D8 = Speed 4 |
I might be able to help. My S2000 didn't have originally Can-Bus, but now it has thanks to standalone ecu. I have general knowledge about obd2 and Can-Bus. I have also used Racechrono long time.
Can you provide some links where did you find information about S2000 Can-bus protocol and where did you find the commands that you are using to communicate with OBDLink mx using the serial bluetooth terminal? I'm afraid that you are confusing Can-Bus and OBD2. They are not the same thing. What you are trying to do is read Hondas own Can-Bus messages, not the OBD2 messages. To receive messages you need to get bus speed and the ID bit length right. Here is some good information about the subject: https://racechrono.com/forum/discuss...s-data-logging |
Originally Posted by _valtsu_
(Post 24930776)
I might be able to help. My S2000 didn't have originally Can-Bus, but now it has thanks to standalone ecu. I have general knowledge about obd2 and Can-Bus. I have also used Racechrono long time.
Can you provide some links where did you find information about S2000 Can-bus protocol and where did you find the commands that you are using to communicate with OBDLink mx using the serial bluetooth terminal? I'm afraid that you are confusing Can-Bus and OBD2. They are not the same thing. What you are trying to do is read Hondas own Can-Bus messages, not the OBD2 messages. To receive messages you need to get bus speed and the ID bit length right. Here is some good information about the subject: https://racechrono.com/forum/discuss...s-data-logging The commands I'm using are just standard ELM327 commands, eg from here: https://www.sparkfun.com/datasheets/...T_Commands.pdf I gathered data from a number of different sources. Gernby posted in a few different threads, like this one: https://www.s2ki.com/forums/s2000-ta.../#post23684976 There's also this thread that discusses reading steering angle etc. https://direct.forum.autosportlabs.c...ic.php?p=28602 So that's where the PIDs are from. As far as the protocol, I can't find the original source that told me it was 29-bit, 500 kbaud, but here's one from imstimpy that also has some stuff to say about headers and targets: https://forum.autosportlabs.com/viewtopic.php?t=4671 I don't have a full enough understanding yet to understand what he's saying there though. I'm not able to get anything just setting the protocol to 7 (which is 29-bit, 500kbaud) and monitoring all data. I do get data setting the protocol to 6 (11-bit), but I don't know that it's CAN data. |
RaceChrono allows you to specify the protocol, the default header to use, and any initialization commands to be sent. You can then define PIDs to read from, and an equation to apply to them (to perform bitmasking, scaling, etc.) That second part should be easy enough once I can get it to actually read live data, but just setting it to protocol 7 isn't doing anything, so I assume either the default header is wrong or other initialization commands are needed.
|
Ok. So the ATSP7 command 7 is not right. That is an OBD2 protocol. On Racechrono I found the protocol setting from the OBD2 settings.
Basically OBD communication works like this: The obd reader sends a message thru Can-Bus "I wan't to know what is TPS%" and then the ECU send the message to tell what is TPS%. All the OBD communication works like this. Now you just wan't to read Can-Bus message stream. You don't want to send anything to the bus. So I'm pretty sure you don't need to setup any protocol. Those are only for OBD. You need to setup on Racechrono the OBDLink as Can-Bus reader and then setup specific channels and pids. |
Originally Posted by _valtsu_
(Post 24930963)
Ok. So the ATSP7 command 7 is not right. That is an OBD2 protocol. On Racechrono I found the protocol setting from the OBD2 settings.
Basically OBD communication works like this: The obd reader sends a message thru Can-Bus "I wan't to know what is TPS%" and then the ECU send the message to tell what is TPS%. All the OBD communication works like this. Now you just wan't to read Can-Bus message stream. You don't want to send anything to the bus. So I'm pretty sure you don't need to setup any protocol. Those are only for OBD. You need to setup on Racechrono the OBDLink as Can-Bus reader and then setup specific channels and pids. |
Originally Posted by Nate Tempest
(Post 24931027)
Take a look at the CAN bus options in Racechrono. You'll need to add a CAN reader first (can use an OBDLink if you have one), and then go into the vehicle settings. You do need to specify a protocol there. (Or use the default to auto-detect.) I've tried auto-detecting, as well as setting it to 7, but am not getting any live data in testing with RC. (It also gives the option to change the default message header, and to send initialization commands.) That's why I took a step back to try to see what I could get by directly using a serial reader. There, I don't get any data stream by setting the protocol to 7, and if I set it to 0/auto it just hangs on 'Searching'. If I set it to 6, I do get a stream of data, but I can't pick out any of the IDs that have been identified for things like steering angle or brake pressure, so I'm not sure it's the right data stream.
Settings -> Add other device -> OBDLink LX/MX/MX+ Bluetooth (CAN-Bus) or Wifi device Then go into vehicle settings: Under CAN-Bus channels: Add channel When I do that same using DIY device I don't have to specify any protocol. |
Originally Posted by _valtsu_
(Post 24931163)
I did take a look, but I don't have OBDLink, so I can't test that. Just to be sure did you do it like this? :
Settings -> Add other device -> OBDLink LX/MX/MX+ Bluetooth (CAN-Bus) or Wifi device Then go into vehicle settings: Under CAN-Bus channels: Add channel When I do that same using DIY device I don't have to specify any protocol. You're right that the protocol settings are under the obd2 section, not the canbus section, but my understanding was that they affect both. (Those settings are there even if I don't have an obd2 reader configured, just the obdlink as a canbus reader.) |
Got it figured out! I thought I'd tried this before, but ultimately I just needed to set the protocol in RaceChrono to 6 (11-bit). Once I did that, I was able to get live data. So far I've configured and tested steering angle and brake pressure. (I'm not sure of the scaling on the brake pressure, so I just set it to brake percentage, and scaled it from 0 to as hard as I'd ever reasonably press the pedal.)
Going to see what else I can add now, then will share the config. |
Alright, so I've got the following channels configured:
Accelerator position: PID: 170 Equation: A*100/255 Byte 0, scaled to 100% Brake position: PID: 106 Equation: max((bytestouint(raw,5,2) - 57448), 0)/4.0 Bytes 5-6. Scaled this one experimentally. At zero brake pressure it reads 57448, so subtracting that amount brings it to 0. Pressing the pedal harder than I ever would on track brings it up to about 400 from there, so I'm just dividing by 4 to get a 0-100% scale. (Using 4.0 causes it to return a float, so we get a resolution of 0.25%.) Engine RPM PID: 300 Equation: bytestouint(raw,4,2) Bytes 4-5 give the RPM directly. Steering angle PID: 198 Equation: bytestoint(raw,0,2) / 10.0 Bytes 0-1, divided by 10 gives the steering angle in degrees. (Using 10.0 instead of 10 causes the result to be a float rather than an int, for more precision). Now, these ones I know I've got the right PIDs, but I'm less sure about the definitions and scaling: Coolant temperature PID: 300 The raw value in byte 0, given by 'A' I think is the temperature in °F For degrees C, Equation: (A-32)*5.0/9 See below Intake air temperature PID: 300 Byte 1. The raw data appears to be in degrees F. See below Lateral acceleration PID: 198 Equation: bytestoint(raw,2,1)/10 Fairly sure those are the right bytes, but I'm not sure about the scaling here. 10 appears reasonable, but once I get some actual data traces I need to compare it to my phone data to check. Could be in m/s² (9.8066) or ft/s² (32.174). Edit: the live data seems to be extremely noisy. Unless I've got something wrong beyond just the scaling, I can't see it being useful for analysis. Speed PID: 448 Equation: PID 448 has four speed representations at various resolutions, in bytes 0-1, 2-3, 4-5, and 6-7. Still need to test this one as well. Edit: see below Thoughts So, this is pretty cool! Even just having the steering angle and brake pressure in addition to existing data will be a huge help when analyzing laps. Definitely worth setting up for anyone who already has an OBDLink MX. Depending on how the lateral accelerometer data from the car looks, that might eliminate the value of a separate precision accelerometer too. So it looks like this is a pretty decent option for a budget data logging setup. If you don't have any equipment yet, you'd need the OBDLinx MX+ ($140; the non-plus version isn't sold anymore), a bluetooth GPS - probably the Qstarz BL-818GT ($160), and RaceChrono Pro ($25). For not a whole lot more though, you could also look at a Racecapture Track for $450, plus CircuitStorm (or SoloStorm if you're doing autocross). Both options would allow for future expansion analog inputs. With the racecapture it would mean adding one of their AnalogX modules ($150). With the RaceChrono setup, you could look at a RaceDAC (190 Euros). |
Glad you found the solution and thanks for sharing.
About the protocol settings: Did have to specify the bus speed or does the software recognize it automatically? |
Originally Posted by _valtsu_
(Post 24931500)
Glad you found the solution and thanks for sharing.
About the protocol settings: Did have to specify the bus speed or does the software recognize it automatically? |
the two other things i tried to find were AFR and Knock count since the hondata flashpro app can pull those. i had no luck trying to figure those out.
|
Updates:
Speed Speed PID: 448 Equation: bytestouint(raw,0,2)/65535.0*200*0.44704 imstimpy's description was close, but not quite right. The four two-byte pairs do each represent the speed, but they roll over at 200mph, 100mph, 50mph, and 25mph. (Or possibly 320kph, 160kph, 80kph, 40kph, which is almost the same thing - the scaling factor is slightly above 1.6. I think mph is more likely since it's round numbers though, and it's closer to the speed given by the speedometer.) Edit: that's closer, but not quite right either. Per the post below, each couple of bytes is a speed at a different wheel, but they're each 15 bits instead of 16, so each one gets offset if you just take the bytes. The equation above does work fine for the LF wheel speed though. It converts to m/s, which RC will covert back to mph or km/h based on your units. Lateral acceleration I'm still not sure the scaling of this one, but I found the data traces extremely noisy in testing, so I don't expect it'll be useful. Coolant temperature PID: 300 Equation: A-40 (°C) or A*1.8-40 (°F) So the first byte in PID 300 represents the temperature in °C, offset by 40°. That means when the register is 0, the temperature reading is -40, which was likely chosen because that's the crossover point of the F and C scales, so it makes conversions simple. Intake temperature PID: 300 Equation: B-40 (°C) or B*1.8-40 (°F) Same as the coolant temp. |
https://cimg7.ibsrv.net/gimg/www.s2k...7b5e0006b.jpeg
This is the format for the individual wheel speeds coming from the 06+ abs unit. |
Originally Posted by 10ks2kftw
(Post 24941307)
https://cimg7.ibsrv.net/gimg/www.s2k...7b5e0006b.jpeg
This is the format for the individual wheel speeds coming from the 06+ abs unit. |
And it looks like you can track individual wheel speeds in RC, so these should be the equations unless I've made a mistake (haven't had a chance to test yet)
Wheel speeds PID: 448 Equations: LF: bitstouint(raw,0,15)/32767.0*200*0.44704 RF: bitstouint(raw,15,15)/32767.0*200*0.44704 LR: bitstouint(raw,30,15)/32767.0*200*0.44704 RR: bitstouint(raw,45,15)/32767.0*200*0.44704 To enter them, you pick Wheel Speed (kph) or (mph) (depending on your units setting) for channel, and then tap "Show More", and choose the specific wheel under Channel postfix. |
thats great that the software lets you specify exactly which bits to use in a simple format. Most things use a bit mask which can get quite complicated.
|
Just confirmed the above works. And it's pretty cool looking at the different wheel speeds! You can watch one side going faster than the other on corners, see where you're starting to spin the rears, and, most interestingly, see whether the front or rears are starting to lock (antilock) first under braking.
|
Whats the resolution you're seeing? Is it 0.1kmh or 1kmh?
|
Originally Posted by 10ks2kftw
(Post 24960305)
Whats the resolution you're seeing? Is it 0.1kmh or 1kmh?
|
Ok, thats what I was seeing.. just needed a sanity check. Setting up a system I've never used and the bit masking makes my head hurt
|
All times are GMT -8. The time now is 07:39 PM. |
© 2024 MH Sub I, LLC dba Internet Brands