ROM THE BENCH
There’s a lot more moving under the hood of a modern automobile than
gears and liquids. Today's vehicles also move essential system instructions
and on-board diagnostic data between electronics and dedicated computer
applications. This article details the relationship between automotive control
systems (€.g,, engine and transmission) and OBD-II data. You also learn
how to tap into a vehicle’s LAN,
Ienow some readers live in areas where 50”
of snow is the norm, but Connecticut
rarely sees anywhere near as much as it did last
January. I quickly tired of lifting snow shovels
full of the white stuff over my head, At times I
felt like T was in a labyrinth, or, better yet, wan.
dering chroug!
‘a mouse maze looking for some
spicy pepper jack. I felt foolish spending time.
cleaning our my ice-filled gucters only to find
my neighbors going through the same ricual, As
my pastor said one Sunday, “Will whoever is
praying for snow please stap it?
took the chill off by snuggling into my
favorite chair with a mug of hot chocolate and
4 good book or an enginecsing magazine, like
Circuit Cellar. Do you notice that magazines
tend to get delivered in batches? I'l spend the
night going through them, reading the articles,
and ripping out ads that look interesting. 1 like
to hold print issues as their ads tend to rip out
‘more easily than the digital ones. While my
Droid has a Kindle app, it doesn’t feel the same as
when Thold the pages of a real book ar magazine,
To me this is like going from a standard
ssmission to an automatic, For those of you
dard, you don't
know what you're missing, You drive a stan.
dard, An automatic drives you, Both will get
you where you want to go, but there’s a kind of
Zen thing you experience with a standatd that
you can’t get with an automatic. I'm certainly
not against progress. I'm all for the move
who have never driven a st
The CAN Protocol and OBD-II
by Jeff Bachiochi (USA)
toward electrics. It's just a bummer that this
away from that fecling of
cexhilaration—or is that acceleration?
Truth be told, I've become a wimpy driver
‘My wife's Prius has replaced my eluteh popriag
desires with an interest in conservation. Jus
how many miles can be eked out ofa gallon of
gasoline? Lind the performance feedback di
played to be a strong motivator. So much s
that Vd like to have that available in my vehi
cle, The solution is in front of me every time
drive: the on-board diagnosties (ORD)
TREE HUGGING
Allow me to quote Wikipedia: “Smog is ape
of air pollution, the word ‘smog’ is a portman
teau of smoke and fog. Modern smog is type ct
air pollution derived from vehicular emission
from internal combustion engines and industrial
fumes that react in the atmosphere with sum:
light to form secondary pollutants that also con:
bine with the primary emissions to form photo
chemical smog. Smog is also caused by lange
amounts of coal burning in an area caused bya
‘mixture of smoke and sulfur dioxide
With che vast number of automobiles in Cali
fornia, ivs no wonder people became concerted
with what was coming out of their tailpipes.
Progtessive Californians became the list 1
demand attention from Detroit. Slowly, Detwit
began to curb the production of unburned
hydrocarbons and carbon monoxide by adding
theit in
‘with the
that cael
torund
ing. Do.
facility
HC, CO
spending
mobil
ble fora
time for
Youm
tor” ligh
nent ai
Jong uni
nator lig
light, the
the seat
switch
into “Gp
actualy
those wi
tuanslate
‘Natt
opedies
automet
this OBL
tive Eas
all toxe
a lop
set of dis for the
facta
smarts to the fuel delivery and ignition systems on all of
their internal combustion engines. Along
with these improvements came a mandate
that each automobile must prove its right
to run the roads by passing emission test
ing, Do you remember visiting the testing
facility where they
on a dynamometer and check the extent of
4C, CO, and NOX? Failure usually meant
spending up to $1,000 getting your auto:
mobile to comply before it w
uuld put each vehicle
|e
wld be eligi
ble for an exemption—at least until it was,
time for the next test
You might remember when the “alterna
tor’ light was the only indication of immi-
nent failure. Since these new smart emis:
sion systems required a computer, it wasn’t
Tong until manufacturers began using the
computer to handle other tasks. The alter
nator light was replaced by a new idiot
light, the light. If you knew
the secret sequence, the ignition (key
‘check engine
switch would turn the check engine light
ctuall
‘Gotham City’s bat signal” that would
jumber code. Only
blink out a
those with the ring” could
translate this into a real error message
Naturally, as each manufacturer devel
oped a system specific for their line of
automobiles, there were no standards for
this OBD ability. The Society of Aucomo-
tive Engineers (SAE) attempted to pull it
all together by defining OBD-I,
1 16-pin standard connector and a standard
set of diagnostic codes and terminology
(see Figure 1). You'll note that this standard connector ha
‘connections forall of the major systems in use! Some stan
dard, huh? Actually, that’s not fair at all since you can’t
change industry overnight. The OBD-I as it stood
required on all automobiles built after January 1, 1996.
In general, Chrysler, European, and many Asian imports
use what is known as the ISO 9141 standard (OBD-II pins
7 and 15), General Motors uses the SAE J1850 variable
pulse-width (VPW! modulation (OBD-II pins 2 and 10}
Ford uses another version of SAE J1850, pulse-width mod.
ulation (PWM) [also on OBD-II pins 2 and 10). For the
most part, all of these systems communicate at a rate of
approximately 10 Kbys.
In keeping wit
and bandwidth
definition, The ISO 15765 control area network (CAN),
which has been predefined to use pins 6 and 14. Automo.
biles built after January 1, 2008 are required to use this
h the necd for increased standardization
another protocol is included in the OBD-I
You might think that by now we all are pretty much
driving automobiles that use the CAN interface, but
according to the U.S. Department of Transportation, the
average lifespan of a vehicle is 12 years, or about 128,500
miles, So, the average car may not use CAN until after 202U.S. AUTOMAKERS. the CAN protocol, which is already under transition,
| Thanks to the government’ offer to loan monies to the Vd like to start with the ISO 9141-2 protocol as it i, pe
US. automotive industry, we still have viable alternatives to haps, the easiest to understand for those familiar with sen
the import market. But this line is becoming fuzzy as many al communications. It uses an asynchronous seria
foreign companies have assembly lines here in the U.S. running at 10,400 bps. While RS-232 normally ust
think many will agree that it is U.S. jobs that are number shifting IC (such as the MAX232) for a 12 V/-12 V inverte
one, not necessarily that an employer is a U.S. company signal swing, 9141-2 is more like 12 V TTL [if you will
he automotive industry will remain important to our econ: with 12 V being the passive state and 0 V the active stat
omy, even if rocket packs were to become a reality Each byte begins with an active start bit, followed by 8
Let's take a look at the four major protocols of OBD-I that data bits, no parity bits, and a single passive-stop bit. Bid:
he following _rectional communication takes place on the “K” Line (pi
‘each of the big three, as well as 7) of the OBD-II connector. Optionally, the “L" line (pin 1
re in use today. Refer to Figure 2 through
FlashPro430
FlashPro-CC =
FlashPro2000 p
GangPro430 asm
GangPro-CC
Reliable and the fastest programmer on the mar}
Perfect for production usage,
f gridconnect.
www.gridconnect.com
+1 800 975-4743
62may be used as a unidirectional
wake-up” signal to the vehicles’
unit |ECU). Mes
9141-2
differe
and Be
tioned 9141-2 and
These are designated SAE
and SAE 9150 PWM, Variable pulse
idth (VPW) modulation is based on
bit symbols,
2 64-ns width pulse
ind a 128-ns width pulse, The VPW
ignal varies between 0 V (passive
Each packet begins
depending
This protocol
he OBD-II
the active state, A di
state for 64 ps an
protocol also has a 4x mode
he throughput is increased to
bps. In this mode all timing
ased by a factor of fou
n attempt to be more immune
the SAE
10), The B+ line ust
active state of 5 V, while th
Functional target address] uses an active state of O V. Thi
ox6a passive state of B+ is pulled lo
and B-is pulled high
Except for the 4x mode of the
SAE 1850 PWM
In case you ha
a eye working on you!
revs mu d has
Jifficult, I can remember being
able to see the ground when I
‘opened the hood. Today ever
and cranny is filled with components
of our smarter ears. The amount of
eae
ae me atic eof
pin 2 nook
1¢ B- line
DOWNLOAD our free CAD software
DESIGN your two or four layer PC board
SEND us your design with just a click
RECEIVE top quality boards in just days
expresspcb.comProtocol Header
Size Priority Target address Source addross
SAE J1850 PWM (24 bis) 0x61 ox6a oF
SAE J1850 VPW (24 bits) 0x68 A oF
130 9141-2 (24s) ove x6 oF
80 14290.4 (24 bis) oxca 033 ort
150 157054 (29 bits) OKTBDB x33 oF
ISO 18785-4 (11 bats) OxTOF
Table 2—The he 2 provides the information necessary to route the cata
data flowing under the hood has nat
urally increased. Multiple computers
ssaty, each handling
specific tasks. It wasn’t difficult to
foresee the original throughputs as
limiting. In their infinite wisdom the
SAE added the CAN protocol to the
OBD-II specifications. At the time
this was not used by any Am
Bosch
began using the CAN bus in the
ly 90s.)
ISO 15765 CAN
The CAN protocol specified for
use in OBD-Il is capable of using
either 250 or 500 kbps, (You may
read more about CAN and the CAN
open protocol in my Circuit Cel
columns from June and [uly, 2006.)
re allowed in the CAN
protocol, an 11-bit addressing mode
Two formats
and a 29-bit extended addressing
mode. IF you include the dual data
rates, that’s four possible formats for
the CAN protocol
There is no clock transmission
associated with the d
speed synchronous transn
cas in high:
therefore the CAN hardware employs
a mechanism for keeping the receiver
he transmitter. An
lock loop (PLL) syne
on-state transitions, To ensure transi
tions, bit stuffing is used, Bit stuffing
is the procedure of adding an opposi
state bit whenever the data state
remains the same for five consecutiv
bit times, The receiver automatically
tosses out the next bit whenever it
receives five consecutive bits of the
Similar to the SAE 1850 PWM proto
col, che output signal of the ISO 15765
CAN protocol is transmitted differen
tially using two lines, CAN-H (pin 6)
and CAN-L (pin 14), The CAN-H line
while the
CCANGL line uses an active state of 0.
of both the CAN-H
The passive sta
and CAN-L lines is undriven, a
2.5 V. The idle state is considered a
logic “1
4 15 (250 kbps) or 2 ps (500 kbps} ind
cates the SOF. Data bits follow using
the same bit timing,
Therefore a “0” bit of either
DATA FORMAT
‘While different methods of trans.
ing information exist, the data
ogy PIC:
F240 mi
One
value
Na
SOF p
8D.
er1D
oa
farnent menitorng, est resus for al (reusing oy- |
for Cat
Temains consistent throughout the ¢
riginal protocols,
is that of bus arbitration
any bus can always be over
ridden by an active state by any node, This ereates a pri
ority where “0" (active data] wins out over “1” (passive
red to listen to the bus as they send
detects an active state while iti
a passive state, it must quit se
lle. There
ore, smaller
est for water temperature might
Note that all buses are considered to be in their idle
state if there has been no activity for some amount of
end-of-data (EOD). E
top of Figure
ata. The priority byte enables arbitration of the
e The
time, call
SOF pul
Header bytes are used
node and indicate where the response
The data field can include up
A runnin
quality (ensuring that the
The CAN format
tom of Figure 3}
s pretty much the same (see the bot
an use either the s
11-bit or the extended 29-bit format. Eight data bytes are
al sd with the first byte PCI, use
The heade andard
as formatting
he following data bytes. Corruption con
ened with a 15-bit CRC value [sce last
month's column for more on CRCS},
OBD-II DATA
ill consist of a mode byte and a parame-
But how
The OBD-II
we know who's out there for
requires one functional addtess that
responded to, This functional address can be dif
m the protocol. For the most part, these
le 1). Th
are target addres:
for up to eight ECUs,
systems other than th
engine, such as the transmi
TCM] or the anti-lock braking
ABS). All ECUs must respond to a query to the functional
address (this is like notice that if
re is more than one ECU, the re:
to the priority of each ECU. Im.
myself a bit here, but when they re
public shout). You
the
‘out a broadeast to the functional addres
re the header of the m
wn bac
header might be 24 bits, 19 bits, or 29
to Table 2 for the header information nece
data packet ready to send to the functional a
will
Now,
modes defined in the
sted in Table 3]. Not all modes are st
will us
7 We ca
fe us a response from any EC
hat can we ask for! Presently, the
randard that can be requested
(these are I ported
by all manufacturers, Our initial reque mode |
any parameters defined by the se
port
instance, PID 0x00 m
PIDs (PIL
returns 4 bytes (32 bits) one bit f
bit position
of the message packet, the PID byte. For
supported as it requ
which other x0 to
hat associaged
If the first bit, the MSBit {for PID 0x2
reece mead
eens)
CIRCUIT CELLAR”
www -citeviteellar.comPIC-SERVO
MOTION CONTROL
Secu ICL
nica rery
Written by
engineers,
for engineers.
Now reviewing
proposals for
textbooks and
resource guides
Rms
are supported, and so on, See the reference at the end of this column for PIDs 1
PHYSICAL INTERFACING
We're now ready vo communicate with OBD-IL ¥
except for one small
pack
problem, we need 5 to be sent int
the ORDAT connector. The circuitry shown in Fi
cols used in the OBD.IT interface. You can cho
needed for your vehicle. 1 used the same bas
tronicss application note, “ANO2 ~ELM327 Circuit Construction.” Elm Elee- | Cj
ong with this circuitry) creates an OBD-II-to-serial interpreter. Many oft
cease ea OF one ae has yo clo fae our avo Py
me support circuitry to enable
cuit as referenced in Elm E
face that can be driven by either the ELM327 or your own code using a
this all works, 1 may not need the “AT-style” user interface, a8
sr applicat
the microcontroller will enable you to handle those interactions m
tapping into the dat
our application without external interven
in. What do you want to know?
Next month, we'll look at a little cade to make this circuitry sing, or at least
begin to unlock the treasures under the hood, Between now and then you als
might want to look at www-scantool.net. It is an American
only offers OBD-II scan tools and components, including a functional equivalent
of the ELM interpreter and a module complete with interfacing circuitry, it also
Just when you thought working on your car was a thing of the past, the |
nis growing bounty of information by tapping into your
cle’s LAN. For now, this doorway is OBD-II, and although there is already wor
1, with FCC
to happen an
REFERENCES
J. Bachiochi, “Can You Speak CANT (Part 1)," Circuit Cellar 191, 2006.
“Can You Speak CAN? (Part 2," Circuit Cellar 192, 2006.
Elm Electronics, Inc, “ELM327 OBD to RS232 Interpreter,” ELM327DSH,
2010, www.elmelectronics.com/DSheets/ELM327DS pat.
ANO2 ~ ELM327 Cireuit Construction,” ANO2 rev A, www.elm
electronics.com/AppNotes/AppNote02 pdf
ScanToal net, OBD-II Scantools, www.scantool.net/scantool/downloads/
101 /ecusim_2000-ug.paf
SOURCES
ELM327 Interpreter
Elm Electronics, Inc. | www.elmelectronies.com
PICISF2480 Microcontrollers with ECAN technology
Microchip Technology, Ine. | www.microchip.comROM THE BENCH
The firs
t part of this series was a primer on automotive contro
Vehicle Diagnostics (Part 2)
Pre-CAN Protocol Standards
stems
and OBD-II data. This article explores the pre-CAN protocol standards sti
in use. You can use this information
deh
enough to look for your car's on-hoard diagnos
fter reading my introduction last
month, [hope you were curious
tics Il |OBD-II} connector. They were installed
around the driver's seat in all automobiles man
sfactured after January 1, 1996, This single con
nector contains all of the networks in use today
1s well as the control area network (CAN) stan
dord, required for automobiles manufactured
after January 1, 2008, We ean thank the Society
of Automotive Engincers (SAE}—encouraged by
carly EPA emissions standards—for the foresight
of proposing an open-ended standard commun:
cations set for the control and monitoring of
nes and other subsystems. And just as,
n for phasing out the var
1us protocols in use for a single standard.
important was its
We are well past the date requiring new auto
mobiles to use the single CAN standard. But,
of the automobiles on the road today still use
to diagnose trouble codes and more
‘one of the pre-CAN standards, Therefore, itis
possible that your car uses one of the older
standards, The purpose of this series is to
explain each of the standards so you can ma
f the
II networks for some ulterior motive. Thi
use of the inforfnation available on one
might be to mercly diagnose a trouble code, t
indicate where to look for a component prob
Jem, or to provide some additional information
about a vehicle tha
leg, real-time fuel consumption versus distanc
‘or MPC
{As engine compartments become ja
with increasingly complex engine control sys
tems, itis easy to understand that what begat
much more, Today, we have “smart” transmis
sions, brakes, tire pressure monitoring, and vehi
cle suspension, as well
as cabin temperature controls, navigation, and
entertainment, Our automobiles are morphing
ode Operation
sot oes what power formato is avalale othe scan tol
sae Diss ene tame ota
| sas Lists emsionlated ‘corfimest DTCs a our cots
sot Clears emission agnosie rormaton incur caring sored penéngtenimed DTCs ad eee-tame dala
805 Diaye the ongen omgen senso
80 Aeguess on teed montana ests fer a con ye syste
Requests erission relat
ected dung cure ora competed ving cle
8 Enables he ltrs test vice toca he opeatn ofan an-beard esi, test or compo
i | s00 Retievs vice ination
son ‘Stra emission ats ‘pemaneet TCS = a
Table L—Each cornmand begins with a mode byte. These mode im general tasks Ea
ave nim second PID byte further defines func
PACK
that ia
heade
prion
he bus
check
Di
freq
modes
modes
DTCs
code
you ke
DICs
perms
pooleinto mobile homes and offices, Much of that is due to the
PACKET DATA
the basic fi
mat is a packet beginning with a header
a destination, and a source, The
header provides a clue to the importance of the packet
along with the intended receiver and requester. Lower
used in bus arbitration to ensure impor
Priority values indicate mon These values
tant messages have priority to the bus. Since all devices on
the bus have their own address, they can filter the destina
tion of messages and respond to onl
Following th
their own,
packet's header is the request (or response!
followed by a checksum or eyclie redundancy
cheek (CRC). The data is usually limited to 7 bytes. The daa
in a request packet uses a mode and parameter identification
1D} forma byte indicating what type
Table 1 isa list of the 10 standard
turers may request the use of additional
The mode is a sing
of request is being made
modes. Manu
‘modes specific to their system. For instance, one might
equest mode Ox(3 to discover any diagnostic trouble codes
(DTCs). Figure 1 shows the breakdown of the DTCs, (You
can locate specific DTCs at DTCsearch.com.) Perhaps you
might retrieve a DTC of “POO12,” which is a generic trouble
code for “over-etarded timing of Camshaft
you know how to readjust the timing, you might want to
Temove this DTC by issuing a mode Ox(s request. I the
Presuming
problem isn't rectified, it will be reissued again. Any cleared
DTCs (using mode 0x04) still remain in mode Ox0A. This is @
permanent record of the DTC
problem
and remains there until the
Most modes require additional information (hesides the
For example, requests using mode OxOL
require a PID. V
with various modes. Most people know that a vehicle iden.
mode value
Kipedia provides an extensive list of PIDs
tification number |VIN} is the manulacturer’s ID number of
a specific vehicle. It can be found on your vehicle registra
‘don and normally on a tag on the driver-side corner of the
vehicle's windshicld. It can also be requested through mode
Ox09 PID 0x02. Ler’s use this example
various protocols handle requests and replies for the VIN.
ISO 9141-2 & ISO 14230-4
Last month’s introduction hegan with the similar IS
9141-2 and ISO 14230-4 protocols because they closely match
he familiar UART serial
10,400-bps clock for the data transmissions and the EMU.
ansmissions. Both protocols use a
06s into sleep mode when communications cease for 5 s
Communications must therefore begin with a wake up. And
if you wish to keep the lines of communication open, you
must make sure the packets are periodically transmit
within this “stay awake” window. ISO 914]
init,” while ISO 14230-4 has an alternative “fast init
has a speedier wake-up process
which
The “slow init” process requires sending a 0x33 at 5 bps.
Because the one UART on this microcontroller is used for
communication with the user, all non-CAN protocols are
nking
slow init
bit-banged using software routines. Instead of
down the clock on a 10,400-bps routine (for the
requirement), I used a timer to ere
This is (I start bit) 200 ms low, {0x33 data byte) 400
high, 400 ms low, 400 ms high, 400 ms low,
bit) 250 ms high. The EMU then acknowledges this by a
2 similar ourpu
and (1 stop
communication dance at thesnominal
of sending back 3 bytes, acquiring | byte, and sending
hack 1 byte (see Table 2. At this point, the EMU is ready
The x protocol ISO 14230-4] essentially con
sists of a break transmission (a transmission of the active
state for longer than 9 bits (at 10,400 bps, that
865 ys). So a simple active 25-ms low (break), followed by
fast init
it least
25-ms high {pause} is all that’s necessary. Once this open.
ing sequence finishes the command 0x81, 0x66 will
instruct the EMU to open communications until it is told
to close communications (or a timeout occurs with a lack
of communications for more than 5 5}
A bus-eye view of the in
slow and fast initialization is shown i
tialization sequences for both the
oto | and Photo 2
For both of these protocols, you need to set up a timer to
make sure a simple command is periodically sent to keep
the lines of communication open. As this occurs in the
background, you might not be aware that it is happening
SAE J1850 PWM & VPW
Although these protocols don't require any special “wake
up” or “stay-awake” signaling, they don’t use asynchronous
UART timing. PWM uses a fixed frequency PWM pulse for
ceach bit time, with a one-third (active) PWM as a 1” and
ence sequence (lolowing Spsinalzaton)
Fesporse
0155, 0469, BF
oo
woeuie
042508 O55, O08, 108
Table 2—The “scpassive state, With this proto
J packet transmissions
with an active SOF pulse
similar to the PWM
SHOE CURSE
Photo 2
ing bits) begin on a change of state, Each bit time is e
64 or 128 ps. The same timer can be used (32 ps) as int
WM format, Multiple overflows of 2X or 4X are used t0
the state changes after cach bit, it is easy for the receiver
to stay in syne with the transmitter. When producin
active state bits, the logic is opp Wis indicated
by a 64-ns wide state. A“1”" u
ACKs ate used with the VE
s wide state. Ni
Suppose you need to produce a widget that electr
reads the VIN and displays it for DMV confirmation. Th
standalone code written to interface with the OBD-I
would not require any user intervention, There would be
no need for a serial port (unless it is the display interfac
uch as a serial LCD). My point here is th
ar1A Command
CR Pepe th
0.
Deserption
rable, diste oe
le, dade auelemating
cue prctoo| nmbe
bl, disable headers
sl, sale space
Seto prteca x
Without a dedicated task, such as just
displaying the VIN, you must be open
to all kinds of finagling and enable a
user to ask for data
Back in 1977, Hayes C
presented the “AT” ¢
nmand sct to
enable configuration of their 300-bps
Smartmodem. Commands would only
be recognized if they were preceded by
haracters "AT.
he ASCH It's easy
ions for potential o
xt of letter combina.
mmandls in some
all-inclusive standard. So, it’s the ide
of recognizing the difference between
and a command (and not a stan
that enables the
dard list of commands
AT command to live on in more prod:
nets than the modem,
T mentioned ELM Elec
OBD-IL-to-serial
Last month
aser interface chip. I based this series
of columns on emulating this
standard
The scan tools
thas be
for OBD-M i
and applications found for vehicle
\dopted as "the
ertaci
diagnostics speak ELM. For those not
nterested in playing with the low
evel code I'm presenting, you can pur
chase a preprogrammed mictocot
troller from ELM, ELM mierocon
use an ATs
users to change parameters
troller je command set
to enabl
and ask for specific information from
any of the potential interfaces,
those AT.
commands that will get you started
I've started implementin,
Table 3 gives you an idea of what is
available with this project. First and
foremost, you need a way af
specifying the use of a protoco
or enabling the device to search
through the nine available proto-
cols looking for one that will
answer a request. The user inter:
face expects any input to be actu:
al data bytes that are to be
stuffed into a packet jrequest)
n ASCIL
AT.” A carriage return (CR)
unless it begins with
indicates the end of input and
the preceding data should be
acted upon,
ATTPx
a particular protocol, where
An input of
is the command to set
is the protocol of choice (see
Table 4), By appending an “A\
the command “ATTPxA,” the
requested protocol will be used.
But, if there isn’t a good answer, it
will automatically go through the list
until it finds a working protocol or
runs out of protocols.
As input is reecived, itis stacked
into an input buffer. Each alpha chat
acter is converted into uppercase
When a CR c butter is
searched for acceptable commands or
received, t
data [which has been received in pair
of hexadecimal digits)
values are considered
packet of data to be sent via the
requested protocol. Unless this data
forms an actual ODB-II command, it
won't receive a reply. So, the user
One to seven
must know what to send. In the
CAN protocol, the first data byte of
the packet states how many bytes (of
nificant,
number ean be calculated and
the ei
Thi
automatically added or ean come
¢ potential) are s
directly from the input strin
This automatic formatting can be
enabledjdisabled via the |
ATAFx” command [i
The serial port connection for |?
this project provides you with a |g
|
window into the microcontrolle
You will need to open your -
mand |
see what's [6
favorite terminal prog 5
connect to this port
going on. When the circuit is
powered up it will respond with
ELM
which will enable my emulation
the sign-on message,
code to be recognized by third.
party software. You should see
Protocol umber
he VIN, enter “0902
an input string. This requests a mo
PID 0x02 (VIN). If the
To receive
0x08 |inforype
present prot
f you see the phrase NG,
then the present protocol didn’t work
and other protocols were tried until a
response was found
won't know what protocol actually
This can be
queried by entering the following
protocol (DP) command:
At this point you
If chat matrix of digits doesn’t look
much like a VIN, it’s because the VIN
was longer than the number of charac
sers that can be transmitted in a singl
packet, There is also some formatting
here that helps identify how the mul
tiple packets are to be reassembled
The first two digits are a reflection of
he original command sent, which
10902." Bit 6 of the mode byte
Protect,
1850 PH
15081412 (aowinazan)
90 142304 sow ntinzaton
150 142504 intizaton
ps, IT CAN
's0 157 6s, CAN)
180 157644 (250\tps. 1-68 CAN) |
Table 4is the packet number of the response, Here you
received packets one to five, If you toss out the leading
filler bytes 0x00, you have 17 binary values for the VIN.
‘The ASCH values of those bytes indicate a VIN of
GIJC5444R 7252367,
At least that's what I would have seen if my 2000 Caravan
supported the 0902 VIN command, In reality, it is not sup-
ported, How do you know what's supported? The obvious
answer is that only supported requests get a reply. However,
there is a mechanism for determining this. PID 0x00 has the
function of indicating which PIDs are supported for each
‘mode. Requesting a "0900" command returns
Hmm. There are two identical responses. What's with d
Unless we turn on the header display, these look identical
After using the enable headers command “ATHL” the
Tere you see from the he
ing from ECU 4
coming from ECU 40
s that the frst response is com:
header byte 3) and the second response is,
Previously, bytes 4 to 6 contain a com
mand and a packet number, The last byte is a checksum of
he data that spans bytes 7 t0 10 If you expand the data for
these 4 bytes into their binary equivalent, you get
‘These 4 bytes indicate the PID support for PIDI-32
(0x00-0x20). A “1” jin a bit position) indicates support for
hat PID. PID20 is another support PID. Ifthe last bit was
a1," then PID!
PIDs 33
(0x20| would hold the support inform
in see that the VIN,
PID 02, is not supported in this vehicle
tion fo 64, and so on. You
MULTIPLE ECUs
As [noted in the f this series, OBD-I makes
room for up to eight ECUs. Expect to s
st pa
these slots fill up
wo ECUS,
% an engine control module (ECU 10) and a transmission
control module [ECU 18} are being used (circa 2000), Ini
tially, the header default values are set to request informa-
in by using a functional address that all ECUs will
respond
in the future. My elderly Dodge Caravan shows
Note that each of these responds with a physi:
cal adaess, in this ease 10 and 18. 1 can carry on private
conversations with any of the individual ECUs by using
their addresses in the headers, which begin every packet
So, there are a few commands that enable me to set the
header values, The header for the protocols discussed here
requires 3 bytes, following the set he SH" com
‘mand. The three pairs of hexadecimal bytes indicate xx-pr
rity, yy-source, and zz-destination. Higher-priority values
where the
\dress of OXF
ated, the destination can be a
iddress of a specific ECU,
When headers are displayed, you'll note that the last byte
he ISO 9141-2 and ISO
14230-4 protocols use a simple &-bit checksum initialized to
zero, The J1850 protocol uses the “CRC-8-SAE 1850” for cal
‘lating CRC values. 1 included an 8-bit look-up table in the
application t
begin with the CRC in
can obtain a new CRC by first ereating a table pointer. [KOR
mean lower priority, The source quest
comes from, this interface defaults to an
— _—. =
As previously functional
address or the physical
{checksum] is displayed as well
help simplify this function.” To use the table
ialized to OxFE. For each byte, you
the present CRC with the new byte.) Use this pointer to get
new CRC value from the table (of pre-calculated &-bit CRCS)
INTO THE FUTURE
Next time, I'll finish up with
cols, ISO 15765-4 CAN. This is the mandatory future of a
manufactured vehicles, and this future has already begun.
last of the four prota
You might have noticed that last month's schematic used a
xenerie connection for TX and RX, the user serial commu:
nications channel. Next month, I'll also look at alterna:
tives to the standard RS-232 link. Tl
REFERENCES
[1] SAE International,
Product Code J1979,” htep:/standards.sae.org/j1979
E/E Diagnostic Test Modes,
201009, 2010.
[2] J. Bachiochi, “Error Checking,’ C
2011
uit Cellar 250,
RESOURCES
Search Engine for DTCs, 2011, www.dtesearch.com,
SOURCES
PICISF2480 Microcontroller
Microchip Technology, Inc. | www.microchip.com
ELM327 v1.4b OBD-to-RS-232 Interpreter
Elm Electronics | www.elmelectronies.com
STN1110 Maltiprotocol OBD Il-to-UART interpreter
and ECUsim 2000 Multiprotocol OBD II simulator
ScanTooLnet, LLC | www-scantool.net
Sub| ROM THE BENCH
as
=
es Vehicle Dia
Jeff Bachioch
gnostics (Part 3)
ISO 15765-4 (The CAN Protocol)
The first and second parts of this series Introduced you to OBD-II and t
pre-CAN protocol. This final installment focuses on I50 1576!
and wraps up with some speculation about the future of OBD-III
protocol)
wo guys are standing in a driveway in
front of a parked car. One dials up his wife
on his cell phone. She is about to board a plane
and the husband says, “Do it again, Honey
She replies, “Last time.” As the scene flips back
to the driveway, the car doors’ locks are pop.
ping up and down and the horn is beeping. |
can't even tell you what type of car this was a
‘commercial for! And it’s debatable just how
handy this litle trick is, but it tells you a lot
ahout the future of the automobile
IE you have purchased a new car inthe last few
years, your vehicle uses the industry-wide auto-
motive networking standard ISO 15765-4. A cou
ple of months ago, I began this series by explain.
ing the ODBIl protocols developed for this indus
try, At che time, each manufacturer had its own
proprietary network. OBD-II gathered these
together in a single connector and set its sights
on 2008, when all manufacturers would phase
out their old protocol in favor of one standard
Because so many pre-2008 cars are still on the
today, last month I continued by explaining
how you can talk with your car via one of the
protocols in use prior to 2008, General Motors,
4 (the CAN
Chrysler, Ford, and many imports used either
cone of the two SAE J1850 protocols, VPM and
PWM, or ISO 9141.2, a LIN-type UART:-based
protocol (or its offshoot, ISO 14230]
The circuitry presented in the first part of
this series can be used to speak through ¢
OBD-II connector to any of the early dialects. I
1m presenting this series to help you learn
out each protocol so you can write your own
code to interface with your vehicle. I have emu
lated many of the commands handled by the
ELM327 OBD-II microcontroller. This micro:
controller has be
ears and has become a standard on its own.
round for more than 15
This circuitry is compatible with the ELM
Ina standalone application, you may not need
user I/O, but, for experimenting, a user inter
1ce is a necessity. Therefore, [chose to emu:
late the ELM interpreter. You can connect up
your favorite terminal program and begin a con,
CAN
This month I will finish up with the CAN
protocol, While the CAN format can be pro
‘duced like the previous
se | 8 | cama | | 2 | fare pa cor Jes} wl cial hardware, many micro
e nel "| controllers offer a CAN
——— peripheral as part of thei
Figure 1—The CA packet format. Hote thatthe CAN packet frame compl standard lineup. Origina
ated than Just @ header, data, and checksum. The micracontrl feral ing in 1983 by Robert
Boseh, this protocol has
Prat
FigsAN phy er has
been in use for many years, Th
lent itself to a number of application-layer protocols, such
DeviceNet, CANopen, CAN Kingdom, SafetyBUS p
MlLean, and many othe
Ket format for CAN contains three basic parts, a
header, data, and
bit more complicated than that, but the CAN peripheral
with the identifier and the data, Even the CRC chi
is caleulated as necessai
The synchronous bit timing uses non-return-to-
NRZ} coding and decoding with each bit broken di
into multiple segments, syne, propagation delay
butfer 1 and 2. This enabl
adjusted within each bit. Because there is n
transmitted, bit stu
ng ensuwith the transmitter)
we. In the
terest of saving space and time, we
We tend to be conser
fren end up with complications due
to our short sightedness. After the int
tial implementation of CAN the L1-bit
icking. Modi
address was found to be
ow for an
expanded address of an additional 18
bits. So, we end up with two possible
CAN formats. Again, the hardware
takes care of all of that if we tell it
Although CAN
which format to use
can operate up to | mbps, the OBD-IL
specifies either 250 Kbps or 500 Kbps.
This then defines the ODB-II CAN
cifications as either an L1- or 29-bit
ID running at either 250 or $00 Kbps.
The differential 5-V CAN bus driver
nuts undriven. An
active transmitter pulls the CANH
node high and the CANL node low
Receivers determine an active state by
idles with both out
the differential voltage between CANH.
and CANL
other formats discussed, an active state
Therefore, like all the
oie
takes precedence over a passive state
All transmitters must monitor the bus
during their transmission and stop
transmitting if
while transmitting a passive state
Photo 1 shows a CAN receiver (top
trace) and a CAN transmitter (bottom
trace) requesting a Mode 1, PID 0
command, You can sve the transmit:
ter’s request and the three engine con
trol units (ECUs) responding with
data. Note the requestor ACKing each
response, You cannot see the ACK on.