PC
PC
-
-
Based Vehicle OBD Tester
Based Vehicle OBD Tester
Presented by: Peter Dzhelekarski, M. Sc.
Presented by: Peter Dzhelekarski, M. Sc.
Ph. D. Student at the Technical University of SofiaE-mail: [email protected]
Research director: Dimiter Alexiev, Assoc. Prof. Dr.
Sofia 2005
Contents
Contents
1.
OBD (On-Board Diagnostics) System Overview
2.
Project Objective & Tasks
3.
Implementation
4.
Verification
1. OBD System Overview
1. OBD System Overview
1.1 Purpose of OBD (On
1.1 Purpose of OBD (On
-Board Diagnostics)
-
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
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
1.3 Characteristics of OBD
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
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
DTC Example:
1.3 Characteristics of OBD
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
1.4 Characteristics of K
1.4 Characteristics of K-
-line Interface
line 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:
Interface Adapter Vehicle OBDII System K L PC (Software) RS 232
PC-Based Diagnostic Tester
D L C
1.5 K
1.5 K-
-line Interface Initialization
line Interface Initialization
5 Baud Initialization (ISO 9141-2 & ISO 14230)
Fast Initialization (ISO 14230 only)
StartCommunication Message request StartCommunication Message response TWuP (50 ms) TiniL (25 ms) P2 P3 Address (K&L) Sync. pattern KW 1 KW 2 KW 2 Address Bus idle W1 W2 W3 W4 W4 5-baud 10400 baud (standard) Data direction:
From tester to vehicle: From vehicle to tester:
time
P3 W0/W5
Wake-up Pattern (K&L) Bus
1.6 Communication Timing of K
1.6 Communication Timing of K-
-line Interface
line Interface
Architecture of communication system
Communication timing (specified in ISO 9141-2 & ISO 14230-1)
ECU1 ECU2 Diagnostic
Tester (client) OBD System (Server) K L Tester request 1 ECU 1 response ECU 2 response Tester request 2 P2 time P4 (5…20 ms) P2 (25…50 ms) P1 (0…20 ms) P3 (55…5000 ms) P3
1.7 Message Structure of ISO 9141
1.7 Message Structure of ISO 9141-
-2 & ISO 14230
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
1.8 Diagnostic Services (Test Modes)
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)
Diagnostic service bytes (Data bytes) SID PID (TID)* Data A* Data B* … ….
1.9 Legislated Diagnostic Services
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)
2. Project Objective & Tasks
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)
3. Implementation
3. Implementation
3.1 Hardware Implementation
3.1 Hardware Implementation
Interface adapter
Electrical converter between RS 232 and K-line interface Structural diagram: CTS GND RTS RxD TxD RS 232 DB9 K-line interface DLC (16 pin) GND +UB (12V) L K To PC To Vehicle power
3.2 Software Implementation
3.2 Software Implementation
Programming Language: C++
3.2.1 Physical Layer
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.)
3.2.1 Physical Layer
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 Tbit (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
3.2.1 Physical Layer
3.2.1 Physical Layer
Program Structure
(Software library RS232_WIN.lib)
class Rs232 class Rs232Private
class Rs232Iso uses inherits Source Files: - Rs232_Win32.cpp - Rs232_Win32.h initSlow(), initFast() transfer() open(), close(), setup(), etc.
3.2.2 Data Link Layer
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
3.2.2 Data Link Layer
3.2.2 Data Link Layer
DiagMessage classes hierarchy
abstract class DiagMessage class DiagMessageKwp (ISO 14230-2) abstract class DiagMessageL (ISO 15031-5) class DiagMessageKwpL (ISO 14230-4) class DiagMessageIso (ISO 9141-2) virtual virtual Source Files: DiagMessage.cpp DiagMessage.h inherits class DiagMessageCan (ISO 15765) class DiagMessageVpw, class DiagMessagePwm (SAE J1850)
3.2.3 Application Layer
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:
3.2.3 Application Layer
3.2.3 Application Layer
DiagService classes hierarchy
abstract class DiagService
abstract class DiagServiceL
(ISO 15031-5)
abstract class DiagServiceU
(ISO 14229 & ISO 14230-3)
class Svc01h class Svc02h class Svc09h class startCommunication class stopCommunication class testerPresent Source Files: DiagService.cpp DiagService.h inherits
3.2.3 Application Layer
3.2.3 Application Layer
Data storage classes:
Source Files: DtVehicleObd.cpp; .h DtSession.cpp; .h DiagIsoDefs.h
Data storage objects:
class DtPidData class DtEcu class DtVehicle class DtSession class DtFreezeFrame inherits Diagn. Session Vehicle Data ECU List:
ECU1, ECU2, …
3.2.4 Connection to Physical Layer
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
3.2.4 Connection to Physical Layer
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
class DtTransfer
Data transfer thread Calls transfer()
class DtStart
Initializing thread
Calls initFast() or initSlow()
starts notifies
3.2.5 GUI (Graphical User Interface)
3.2.5 GUI (Graphical User Interface)
The diagnostic data is from an ECU from Rover 25-LHD, Model Year 2003.
4. Verification
4. Verification
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
Tested vehicles:
Diagnostic message results for Rover 25:
Request for engine RPM
Header Data Bytes
(Diagnostic Service)
CS
Fmt Tgt Src SID PID Data
Request 68 6A F1 01 0C - D0 Response 48 6B 13 41 4C 00 00 13
5. Conclusion
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:
Future work:
Fast initialization verification
KWP 2000 verification
Improving GUI
Adding manufacturer specific data interpretation
Adding CAN diagnostic interface