odbii

Upload: mathhoang

Post on 06-Jul-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/17/2019 ODBII

    1/30

    Arduino-based OBD-II

    Interface and Data LoggerCS 497 Independent Study

    Ryan Miller

    Advisor: Prof. Douglas Comer

    April 26, 2011

  • 8/17/2019 ODBII

    2/30

    Arduino

    •  Italy 2005

    •  ATmega328 microcontroller•  14 digital I/O pins• 

    16 MHz clock speed•  32 KB memory•  About $30 online

    Arduino

    Hardware

    Automotive OBD

    ISO Interface

    Software

    Data

    Conclusions

  • 8/17/2019 ODBII

    3/30

    Arduino•  Program “sketches” inMulti-platform Java-based IDE

     

    Code in C/C++•  Serial Communication(currently USB)

  • 8/17/2019 ODBII

    4/30

    Hardware

    •  Goals of this project:

    •  Communicate with an automotiveengine control unit (ECU) via theArduino

    •  Gather and record instantaneousdata that is reported by the vehicle

    Arduino

    Hardware

    Automotive OBD

    ISO Interface

    Software

    Data

    Conclusions

    ?

  • 8/17/2019 ODBII

    5/30

    Hardware•  Vehicles produced inthe U.S. after 1996 arerequired to have an

    OBD-II (on-boarddiagnostic) connector

  • 8/17/2019 ODBII

    6/30

    Hardware•  OBD-II Interface

    •  Very simple connectionfor most applications

    • 

    Most important pins•  K-Line

    •  Ground

    •  +12V

  • 8/17/2019 ODBII

    7/30

    Hardware•  Open-source projectcalled “OBDuino”offered the interface

    schematic(which is fortunate,because I am not anEE major)

  • 8/17/2019 ODBII

    8/30

    Hardware•  Open-source projectcalled “OBDuino”offered the interface

    schematic(which is fortunate,because I am not anEE major)

  • 8/17/2019 ODBII

    9/30

    Hardware•  Freescale MC33290 handles the tricky parts

    •  K-Line, Ground, and +12V go in

    •  Serial Tx/Rx come out

  • 8/17/2019 ODBII

    10/30

    Hardware

    OBD-II

  • 8/17/2019 ODBII

    11/30

    Software

    •  A few functions to perform:

    •  Initialize ISO connection

    •  Request data from vehicle’s ECU

    • 

    Display the result on the LCD andrecord the value to retrieve later

    Arduino

    Hardware

    Automotive OBD

    ISO Interface

    Software

    Data

    Conclusions

  • 8/17/2019 ODBII

    12/30

    Software•  Initialization:

    •  Starts by “bit-banging” 0x33 at 5 baud

    •  i.e.

    0 0 1 1 0 0 1 1 

    200ms pause = 1.6 seconds

  • 8/17/2019 ODBII

    13/30

    Software•  Initialization:

    •  Starts by “bit-banging” 0x33 at 5 baud

    •  Code:

    !"#$ " # $%&&'

    ()* +!"#$ ,-./ # $%$0' ,-./' ,-./ 11# 023

    4( +" 5 ,-./2 66 78)).9 "4: 

    ;4*4:9+?@ABCD EFGE2' 66 H9I; 0 

    9=.9

    ;4*4:9+?@ABCD JA>2' 66 H9I; $ 

    ;9=-K+L$$2'

    M

  • 8/17/2019 ODBII

    14/30

    Software•  Then you can start 10.4 kbps communication andperform these steps to finish initialization:

  • 8/17/2019 ODBII

    15/30

    Software•  Parameter IDs (PIDs)

    •  SAE J1979 standard

    •  Examples:

    PID Bytes Description Formula

    0x0C 2 Engine RPM ((A*256)+B)/4

    0x0D 1 Vehicle Speed (km/h) A

    0x11 1 Throttle Position (%) A*100/255

    0x3F 2 Catalyst Temp (B2, S2) ((A*256)+B)/10 - 40

  • 8/17/2019 ODBII

    16/30

    Software•  Steps:

    1.  Request PID with hex value

    2.  Continuously read data from ISO until successfulchecksum or timeout

    3.  Convert returned value with formula

    4.  Display / record value and repeat

  • 8/17/2019 ODBII

    17/30

    Software

    1. Request PID with hex value

    Index Value Description

    0 0x68 SAE J1979 standard

    1 0x6A OBD-II request

    2 0xF1 Off-board tool

    3 0x01 Mode 1 PIDs

    4 pid Hex value for PID requested

    5 Checksum Computed from message

    !"#$ ,9..-

  • 8/17/2019 ODBII

    18/30

    Software

    2. Continuously read data from ISO until successfulchecksum or timeout

    Byte(s) Description

    0 Message Header 1

    1 Message Header 2

    2 Source Address

    3 – 9 Data (up to 7 bytes)Final byte Checksum

    !"#$ "S(N00P'

  • 8/17/2019 ODBII

    19/30

    Software

    3. Convert returned value with formula

    ie.:

    PID Bytes Description Formula

    0x0C 2 Engine RPM ((A*256)+B)/4

    '()!*$ *T,'

    *T, # ++'()!*$2"S(N$P U LVO2 Q +'()!*$2"S(N0P2 6 WX$'

  • 8/17/2019 ODBII

    20/30

    Software

    4. Record/display value and repeat

    •  Displaying on an LCD screen:

    +%,)%'-."/#0* =Y;'

    =Y;XT*4I:+*T,2'

  • 8/17/2019 ODBII

    21/30

    Software

    4. Record/display value and repeat

    •  Writing to an SD card:

    1%*$ =)

  • 8/17/2019 ODBII

    22/30

    Software

    •  One last note on PIDs…

    •  This gives you the rate of air in grams / second

    PID Bytes Description Formula

    0x10 2 Mass Air Flow Rate ((A*256)+B)/100

  • 8/17/2019 ODBII

    23/30

    Software

    •  You can convert into

    •  And then use vehicle speed to convert to

    or MPG

    g air 

    s

    gal  gasoline

    h

    miles

    gal gasoline

  • 8/17/2019 ODBII

    24/30

    Data

    • Scanned four PIDs over a20-minute interval every1-2 seconds

    • Vehicle Speed

    • Engine RPM

    • 

    Engine Coolant• Calculated MPG

    Arduino

    Hardware

    Automotive OBD

    ISO Interface

    Software

    Data

    Conclusions

  • 8/17/2019 ODBII

    25/30

    Data

    mph

  • 8/17/2019 ODBII

    26/30

    Data

    mph rpm

  • 8/17/2019 ODBII

    27/30

    Data

    °C

  • 8/17/2019 ODBII

    28/30

    Data

    mph°C

  • 8/17/2019 ODBII

    29/30

    Conclusions

    • Embedded computing isubiquitous

     

    Massive amounts of datagenerated by everydaymachines

    • 

    Elec. Engineering and CScan come together to makesome pretty cool things

    Arduino

    Hardware

    Automotive OBD

    ISO Interface

    Software

    Data

    Conclusions

  • 8/17/2019 ODBII

    30/30

    Questions?