PC-Based Vehicle OBD Tester Presented by: Peter Dzhelekarski, M. Sc. Ph. D. Student at the Technical University of Sofia E-mail: pid@tu-sofia.bg Research director: Dimiter Alexiev, Assoc. Prof. Dr. Sofia 2005 Sofia, 10. 2005-1-
Contents 1. OBD (On-Board Diagnostics) System Overview 2. Project Objective & Tasks 3. Implementation 4. Verification 5. Conclusion Sofia, 10. 2005-2-
1. OBD System Overview 1.1 Purpose of OBD (On-Board Diagnostics) To ensure correct operation of vehicle emissions-related control system by monitoring components To warn the driver when fault is detected To provide diagnostic interface for external test equipment 1.2 Brief History of OBD OBD I: USA, California, 1991 Manufacturer specific OBD II: USA, 1996 EOBD (= OBD II): Europe, 2001 (gasoline), 2003 (diesel) The system is standardized Monitors all emission related components Sofia, 10. 2005-3-
1.3 Characteristics of OBD Mandatory for new vehicles Monitors components/systems for malfunction/deterioration When a fault is detected illuminates MIL (malfunction indicator lamp); stores DTC (diagnostic trouble code) & freeze frame DTC Example: P0128 Coolant Thermostat Malfunction Provides diagnostic interface for tester / scan tool There are 3 Physical Diagnostic Interfaces: SAE J1850 (PWM & VPW variants) - USA ISO 9141-2 & ISO 14230 (K-Line interface) - Europe ISO 15765 (CAN Controller Area Network) 2008, all vehicles Sofia, 10. 2005-4-
1.3 Characteristics of OBD OBD monitors the following components / systems: Oxygen sensors Fuel system Catalytic converter Exhaust gas recirculation (EGR) system Evaporative purge system Misfire monitoring, etc. External test equipment variants: Generic OBD scan tool PDA-based OBD tester PC-based OBD tester Sofia, 10. 2005-5-
1.4 Characteristics of K-line K Interface Physical layer is specified in ISO 9141-2 & ISO 14230-1,2 Compatible with UART/SCI Baud rate up to 10400 baud, format 8N1 Communication bus contains K-line (bidirectional) and L-line (optional, unidirectional) Diagnostic System Configuration: Vehicle OBDII System D L C K L Interface Adapter RS 232 PC (Software) PC-Based Diagnostic Tester Sofia, 10. 2005-6-
1.5 K-line K Interface Initialization 5 Baud Initialization (ISO 9141-2 & ISO 14230) time Bus idle W0/W5 Address (K&L) 5-baud W1 Sync. W2 W3 W4 W4 pattern Fast Initialization (ISO 14230 only) KW 1 KW 2 KW 2 Address 10400 baud (standard) P3 Data direction: From tester to vehicle: From vehicle to tester: Wake-up Pattern (K&L) Bus idle T inil (25 ms) T WuP (50 ms) StartCommunication Message request P2 P3 StartCommunication Message response Sofia, 10. 2005-7-
1.6 Communication Timing of K-line K Interface Architecture of communication system OBD System ECU1 ECU2 (Server) Diagnostic K Tester (client) L Communication timing (specified in ISO 9141-2 & ISO 14230-1) Tester request 1 ECU 1 response ECU 2 response Tester request 2 P3 P4 (5 20 ms) P2 (25 50 ms) P1 (0 20 ms) P2 P3 (55 5000 ms) time Sofia, 10. 2005-8-
1.7 Message Structure of ISO 9141-2 2 & ISO 14230 Specified in ISO 9141-2 & ISO 14230-2 (Keyword protocol 2000) (Data link layer) Header Data Bytes Checksum Fmt Tgt* Src* Len* Data CS 1 4 bytes 1 255 bytes 1 byte * Optional bytes, depending on Fmt Fmt Format byte Tgt Target address Src Source address Len Data length Sofia, 10. 2005-9-
1.8 Diagnostic Services (Test Modes) Information exchange initiated by the tester (server) Application layer of diagnostic communication General format specified in ISO 14229 (Unified diagnostic services) Contained in data bytes Referenced by SID (service identification) SID PID (TID)* Diagnostic service bytes (Data bytes) Data A* Data B* * Optional bytes depending on SID. Sofia, 10. 2005-10-
1.9 Legislated Diagnostic Services Specified in ISO 15031-5 (Emission-related services) The application layer of OBD communications Describe the diagnostic data which can be obtained: Service $01: Real-time data values (PIDs) Oxygen sensor(s) voltage; engine RPM; ignition timing advance, etc. Service $02: Freeze frame data values (PIDs) Service $03: DTCs Service $04: Clear diagnostic information Service $05: Oxygen sensor test results (TIDs) Service $06: Monitoring test results (MIDs) Service $07: Pending DTCs Service $08: Control of component/system Service $09: Vehicle information (InfoTypes) (VIN, CVN, etc.) Sofia, 10. 2005-11-
2. Project Objective & Tasks Objective Implementation of PC-Based OBD Tester utilizing K-line interface (ISO 9141-2 & KWP 2000 protocols) according to requirements in ISO 15031-4 (=SAE J1978) Tasks: 1) Hardware implementation interface adapter 2) Software implementation a) Physical layer serial port access, initialization, message timing (data transfer) b) Data link layer message structure, error handling c) Application layer diagnostic services (data interpretation & storage) d) GUI (graphical user interface) Sofia, 10. 2005-12-
3. Implementation 3.1 Hardware Implementation Interface adapter Electrical converter between RS 232 and K-line interface Structural diagram: RS 232 power K-line interface CTS +U B (12V) To PC TxD RxD RTS GND K L GND To Vehicle DB9 DLC (16 pin) Sofia, 10. 2005-13-
3.2 Software Implementation Programming Language: C++ 3.2.1 Physical Layer Tasks 1) Serial port access 2) Initialization (5 baud & fast) 3) Message timing (data transfer: send/receive) Implementation Platform: Microsoft Windows (98- and NT- family) Compiler: free command-line Borland C++ 5.5 Compiler As software library: RS232_WIN.lib 1) Serial port access Non-overlapped access using Win32 base API services (CreateFile, ReadFile, WriteFile, etc.) Sofia, 10. 2005-14-
3.2.1 Physical Layer 2) Initialization 5 Baud Initialization 2 methods for generation of 5-baud address: Configuring port to 5 baud; sending byte Using system timer for T bit (200 ms) Set/clear BREAK (K-line) & RTS (L-line) Fast Initialization Wake-up pattern generation using system timer (25 ms low, 25 ms high bus level using set/clear BREAK & RTS) 3) Message timing Using SetCommTimeouts() & system timer Sofia, 10. 2005-15-
3.2.1 Physical Layer Program Structure (Software library RS232_WIN.lib) class Rs232 uses class Rs232Private inherits class Rs232Iso open(), close(), setup(), etc. Source Files: initslow(), initfast() transfer() - Rs232_Win32.cpp - Rs232_Win32.h Sofia, 10. 2005-16-
3.2.2 Data Link Layer Specified in 2 similar protocols: ISO 9141-2 ISO 14230-2,3 (KWP 2000) Tasks: Message structure handling Error handling Implementation Using Qt 3.0 C++ software development kit from Trolltech Advantages of Qt: Platform independent (Windows, Linux/Unix, MacOS) Fully object-oriented Signals and slots object model State-of-the-art GUI Implemented as DiagMessage hierarchy of classes Sofia, 10. 2005-17-
3.2.2 Data Link Layer DiagMessage classes hierarchy abstract class DiagMessage Source Files: DiagMessage.cpp DiagMessage.h virtual class DiagMessageKwp (ISO 14230-2) class DiagMessageKwpL (ISO 14230-4) virtual abstract class DiagMessageL (ISO 15031-5) class DiagMessageIso (ISO 9141-2) class DiagMessageCan (ISO 15765) class DiagMessageVpw, class DiagMessagePwm (SAE J1850) inherits Sofia, 10. 2005-18-
3.2.3 Application Layer Protocol ISO 15031-5 (Emission related diagnostic services) Tasks: 1) Diagnostic services handling/ data interpretation 2) Data storage Implementation Using Qt toolkit 1) Diagnostic services: DiagService classes hierarchy 2) Data storage: Classes: DtPidData, DtEcu, DtVehicle, DtSession Sofia, 10. 2005-19-
3.2.3 Application Layer DiagService classes hierarchy abstract class DiagService Source Files: DiagService.cpp DiagService.h abstract class DiagServiceL (ISO 15031-5) abstract class DiagServiceU (ISO 14229 & ISO 14230-3) class Svc01h class Svc02h class startcommunication class stopcommunication class Svc09h class testerpresent inherits Sofia, 10. 2005-20-
3.2.3 Application Layer Data storage classes: class DtPidData inherits Source Files: DtVehicleObd.cpp;.h DtSession.cpp;.h DiagIsoDefs.h class DtEcu class DtVehicle class DtFreezeFrame Data storage objects: Vehicle Data ECU List: ECU1, ECU2, Freeze Frame class DtSession Diagn. Session Sofia, 10. 2005-21-
3.2.4 Connection to Physical Layer Uses physical layer library RS232_WIN.lib Tasks: 1) Establishes diagnostic connection 2) Maintains the connection 3) Provides high-level interface for data transfer Implementation Using Qt toolkit Multiple program threads 1) Establishment of connection Performs initialization in a new thread (class DtStart). 2) Maintaining of connection Sends periodically messages (approx. every 4 s) using timer (QTimer) Sofia, 10. 2005-22-
3.2.4 Connection to Physical Layer 3) Data transfer Sending request message to OBD system, receiving response(s). Placing the messages into data communication package. Multithreaded data transfer: class DtConnection Main thread starts notifies class DtStart starts notifies class DtTransfer Data transfer thread Calls transfer() Initializing thread Calls initfast() or initslow() Sofia, 10. 2005-23-
3.2.5 GUI (Graphical User Interface) The diagnostic data is from an ECU from Rover 25-LHD, Model Year 2003. Sofia, 10. 2005-24-
4. Verification Tested vehicles: Manufacturer Model Year Interface PID Count Rover 25-LHD 2003 ISO 9141-2 17 Audi A6 Quattro 2,5 TDI 1999 ISO 9141-2 6 Diagnostic message results for Rover 25: Request for engine RPM Header Data Bytes (Diagnostic Service) Fmt Tgt Src SID PID Data Request 68 6A F1 01 0C - D0 Response 48 6B 13 41 4C 00 00 13 CS Sofia, 10. 2005-25-
5. Conclusion PC-Based OBD Tester is implemented Supports only K-line interface (ISO 9141-2 & KWP 2000) Successfully tested on ISO 9141-2 protocol (5 baud initialization) Future work: Fast initialization verification KWP 2000 verification Improving GUI Adding manufacturer specific data interpretation Adding CAN diagnostic interface Sofia, 10. 2005-26-