The duration of this delay is defined by INTERSYMBOL_WAIT. In the first phase, the bytes necessary for the request are written on the Tx line, according to the specification there should be a 5 millisecond delay between each symbol.
Requesting the value of a PID consists of two phases, the first is the request phase the second the response. To understand how a request works, lets consider the case the 0x0D PID is requested, this represents the vehicle's speed.
Several parameters related to timing are given by the specification, some others are beyond our influence.
For more information on how to use the library, refer to to the header files. The reader_softserial example shows how to use it with the AltSoftSerial library. The reader and simulator examples are to be used with a hardware serial port. Three examples are given in the example folder. All timing parameters can be tweaked from the header file, by tuning these parameters, performance of up to 20 requests per second has been achieved (on the same car, 6 readings per second was the maximum with the Bluetooth dongle). In the logic folder are some recordings made with a Saleae logic analyzer, these show the state of the K-line pin using either a Bluetooth OBD-II reader or this library, these might be useful when developing your own hardware. The EN pin can either be connected to a pin on the microcontroller or just pulled high in order to always enable the chip. The KWP functionality of this library was verified to work on a Teensy 3.5.Ī minimal example of how to use the SN65HVDA195 chip mentioned is given by the following schematic: The example reader_softserial was tested with an Arduino UNO. For use with Arduino the AltSoftSerial library is used by default. The OBD9141 class itself has been tested on one Kia car build in 2004.įor the Teensy 3.x or LC versions it is recommended to use one of the HardwareSerial ports. All three transceiver IC's worked without problems when the typical application circuit from the datasheet was used.
The code has been developed using Teensy 3, the K-line transceiver IC's used were during the development were the MC33290, SN65HVDA100 and SN65HVDA195. Additionally a second class has been created which can simulate responses for testing purposes. The goal of the library is to provide a simple class which handles the communication with the port. This makes it hard to extract the communication parts for use in another project.
However, I found that most of these projects either use an ELM327 chip or the communication code is interwoven with the rest of the program. There are numerous projects which read data from the diagnostic port and display or record this. This is a library to read data from the OBD-II port through the K-line pin using either ISO 9141-2 or ISO 14230-2 (KWP).