So a year or two ago I bought myself an ElmScan tool from scantool.net to be able to get a Miles Per Gallon (MPG) reading out of the ECU of my car and onto my PDA. Well today I buckled down to learn the standard a bit. It’s not as difficult as I thought. Writing code for Pocket PC 2002 is, but I’ll get into that later. So I’ve gained the following knowledge today: All transmissions over RS232 are done using ASCII characters, not actual hex bytes as I originally thought. (You know, to be more efficient with the bandwidth? Well whatever.) Next, I learned the coolness of AT signals. You know, those that your modem makes, or more correctly, outputs to the console (ATZ comes to mind). So starting off, I used 9600baud for transmission speed, because I was sure that communication worked well at that rate. Later I will be moving to 38.4Kbaud. So to set up a connection, all you need is to send the following signals and do the following actions:
1) Send “ATZr” and wait about 1 second. (This resets the ElmScan tool)
2) Send “ATE0r” and wait 200 msec. (This turns off echo)
3) Send “ATL0r” and wait 200 msec. (This makes it so that only a CR (‘/r’) is sent instead of CRLF (“/r/n”))
4) Send “0100r” and wait 1 second. (This initializes the communication between the ElmTool and the CAN bus and returns a bit encoded set of supported PIDs.)
5) Clear the receive buffer of the RS232. (Unless you really care about the initialization information)
That’s about it. Note the use of the ‘r’ byte, this signifies to the ELM tool that it should execute the command you just issued. The scan tool responds in the following ways (*.* means version number, and XX is some value specific to your car model):
1) “ATZrrELM Scan v*.*r>”
4) “41 00 BE XX XX XXrr>”
One thing I have still to figure out is how exactly the supported PIDs are bit encoded. Also I have this issue with Visual Studio not cooperating with my wishes to compile .NET CF v1.* code. I think twisting Sir.Gates’ arm should be a good remedy. Reading this document, I found out that all you need to calculate MPG is Speed * 7.718 / MAF. The Speed PID is 0D, and the MAF PID is 10. To query those, you just send the ASCII string “010Dr” and “0110r” respectively. A typical response is “410D00” if you’re stationary. I don’t seem to have a Mass Air Flow sensor in my Honda so I get a “NO DATA” as a text string back for the MAF. I’ll have to find another way to calculate MPG. I recommend reading that PDF as it seems to summarize the operation of the ElmScan rather well. For more technical information, don’t forget to hit up the official site.
Well, that’s it for now, I’ll keep you posted on my progress.