Beruflich Dokumente
Kultur Dokumente
Arduino
Italy 2005
Arduino
Hardware
Automotive OBD
ISO Interface
Software
Data
Conclusions
ATmega328 microcontroller
14 digital I/O pins
16 MHz clock speed
32 KB memory
About $30 online
Arduino
Program sketches in
Hardware
Goals of this project:
Arduino
Hardware
Automotive OBD
ISO Interface
Software
Data
Conclusions
Hardware
Vehicles produced in
Hardware
OBD-II Interface
Very simple connection
Hardware
Open-source project
called OBDuino
offered the interface
schematic
(which is fortunate,
because I am not an
EE major)
Hardware
Open-source project
called OBDuino
offered the interface
schematic
(which is fortunate,
because I am not an
EE major)
Hardware
Freescale MC33290 handles the tricky parts
K-Line, Ground, and +12V go in
Serial Tx/Rx come out
Hardware
OBD-II
Software
A few functions to perform:
Arduino
Hardware
Automotive OBD
ISO Interface
Software
Data
Conclusions
Software
Initialization:
Starts by bit-banging 0x33 at 5 baud
i.e.
00110011
200ms pause = 1.6 seconds
Software
Initialization:
Starts by bit-banging 0x33 at 5 baud
Code:
byte
b
=
0x33;
for
(byte
mask
=
0x01;
mask;
mask
<<=
1)
{
if
(b
&
mask)
//
Choose
bit
digitalWrite(K_OUT,
HIGH);
//
Send
1
else
digitalWrite(K_OUT,
LOW);
//
Send
0
delay(200);
}
Software
Then you can start 10.4 kbps communication and
Software
Parameter IDs (PIDs)
SAE J1979 standard
Examples:
PID
Bytes
Description
Formula
0x0C
Engine RPM
((A*256)+B)/4
0x0D
0x11
A*100/255
0x3F
((A*256)+B)/10 - 40
Software
Steps:
1. Request PID with hex value
2. Continuously read data from ISO until successful
checksum or timeout
3. Convert returned value with formula
4. Display / record value and repeat
Software
1. Request PID with hex value
byte
message[6];
Index
Value
Description
0x68
0x6A
OBD-II request
0xF1
Off-board tool
0x01
Mode 1 PIDs
pid
Software
2. Continuously read data from ISO until successful
checksum or timeout
byte
buf[11];
Byte(s)
Description
Message Header 1
Message Header 2
Source Address
39
Final byte
Checksum
Software
3. Convert returned value with formula
ie.:
PID
Bytes
Description
Formula
0x0C
Engine RPM
((A*256)+B)/4
double
rpm;
rpm
=
((double)buf[0]
*
256)
+
(double)buf[1])
/
4.0;
Software
4. Record/display value and repeat
Displaying on an LCD screen:
LiquidCrystal
lcd;
lcd.print(rpm);
Software
4. Record/display value and repeat
Writing to an SD card:
File
log;
log.print(rpm);
Software
One last note on PIDs
PID
Bytes
Description
Formula
0x10
((A*256)+B)/100
Software
You can convert g air into gal gasoline
s
h
And then use vehicle speed to convert to
miles
gal gasoline or MPG
Data
Scanned four PIDs over a
Arduino
Hardware
Automotive OBD
ISO Interface
Software
Data
Conclusions
Data
mph
Data
mph
rpm
Data
Data
mph
Conclusions
Embedded computing is
Arduino
Hardware
Automotive OBD
ISO Interface
Software
Data
Conclusions
ubiquitous
generated by everyday
machines
Questions?