DIY OBD II Interface
My goal is to read some basic OBD II information. I am using a PIC 18F2585 c/w CAN module, connected to MCP 2551, then attached to the CAN HI/LO pins on the OBD II connector on Toyota Sienna 2005.
When I connect my circuit, I see (lots of) messages, so I'm reasonably comfortable that I am receiving CAN messages. So, next I try to transmit a request for OBD II info, as follows:
// ECAN port vars
unsigned long id = 0;
BYTE txlen = 0;
id = 0x7DF; // Functional address
txdata = 0x02; // PCI ProtoCol Information; two data (within 8 byte CAN/OBD payload)
txdata = 0x01; // OBD mode 01 == get PID
txdata = 0x00; // PID 00 == bit map of supported PIDs from 0 thru 20
txdata = 0x55; // avoid 0's to minimize bit stuffing
txdata = 0x55;
txdata = 0x55;
txdata = 0x55;
txdata = 0x55;
txlen = 0x08;
vs = ECANSendMessage(id, txdata, txlen, (ECAN_TX_STD_FRAME | ECAN_TX_PRIORITY_0));
The ECANSendMessage function returns SUCCESS. I expected to receive some messages from devices in address range 0x07** but I don't get anything other than this (over and over):
CAN RX ID: 0020 Flags: 00 Data: 00 00 07
CAN RX ID: 0025 Flags: 00 Data: 0F 91 0F 8D 75 75 75 C8
CAN RX ID: 0023 Flags: 00 Data: 02 00 01 FD 00 00 2A
and a few recurring messages like this:
CAN RX ID: 04C6 Flags: 00 Data: 07 00 01 00 00 00 00 00
CAN RX ID: 0423 Flags: 00 Data: 00
CAN RX ID: 04C3 Flags: 00 Data: 03 00 01 00 00 00 00 00
CAN RX ID: 04C7 Flags: 00 Data: 08 00 01 00 00 00 00 00
So, here are a few questions:
Is there anything in CAN that is equivalent to a PING? i.e. a query that 'should' be answered?
What are the usual debugging techniques when trying establish communications to a device?
Thread moved to OBDII forum for increased visibility.
Does your Sienna have pins 7 (and maybe 15) populated?
I tried laying on the floor under the steering column; but my eyes won't focus at that short distance, so I can't tell for sure what pins are there. I also tried taking a picture with the wife's digital camera, but even on 'macro' the distance is so short that the flash overpowers the image.
Meanwhile, I know for certain that pins 6 and 14 are live - because I am receiving CAN messages.
Also, based on info on other web sites, I suspect that pin 7 is connected. Are you suggesting that I switch from CAN to ISO 9141?
Edit: I attached a cable with pigtails, connected to the OBD-II plug, and measured voltage on both pins 7 & 15; so the answer is yes.
You're asking it, mode 1, pid 0 is mandatory. It think that the point of the question above is that just because the vehicle has a CAN bus doesn't mean that it supports OBD-II over it. That was not a regulatory requirement in the US until basically '08.
Originally Posted by eejake52
Pin 7, mentioned above, is the K line, used in the common ISO 9141/KWP2000 protocols, common in EU and Japanese vehicles. However, just because it is there doesn't automatically mean that CAN is not OBD-II supported.
Sometimes the older protocol lines are left in place for dealer diagnostic tools. For example, my daughter's '06 Saturn supports OBD-II over CAN, but also has J1850 lines, which only respond to GMLAN commands.
Something you could try is connecting a scan tool (some auto places will do it for free) and seeing what protocol is reported. The vehicle will generally only support one.
On the CAN side, you are asking for a mandatory PID, but you are generally supposed to ask for it four different ways. 250Kbit std (11 bit addressing), 250Kbit ext. (29 bit addressing), 500Kbit std, 500 Kbit ext.
It *looks* like you are seeing legitimate vehicle traffic, but it can be deceiving. That is, just because you are seeing 11 bit addressing on broadcast messages doesn't mean that 29 bit addressing is not used for OBD-II (though it isn't very common). Both can exist on the same bus, but a vehicle is, by regulation, only supposed to respond to OBD-II one way or the other.
What Joe said. :)
I would either buy or "rent" an OBD interface, and find out for sure which protocol the car is using. Since you're doing embedded development, I'm sure your time is far from free.
The good news is, the ISO protocols are very simple. You can bitbang the pins, or use a 2nd UART if you want to cut down on your programming workload. The bad news is, ISO is at least ten times slower than CAN.