
ELM329
50 of 83
ELM329DSC
Elm Electronics – Circuits for the Hobbyist
www.elmelectronics.com
Using J1939
This section provides a few examples which show
how to monitor an SAE J1939 data bus, and how to
make requests of devices that are connected to it.
To begin, you will need to configure the ELM329
for J1939 operation, at the correct baud rate. Protocol
A is predefined for J1939 at 250 kbps, which is what
most applications require. To use protocol A, send:
>AT SP A
Protocols B to F may also be used with J1939, if
you wish to experiment with other baud rates. To use
them for J1939, the CAN options (PP 2C, 2E, etc.)
must be set to 42, and the baud rate divisor (PP 2D,
2F, etc.) must be set to the appropriate value. Perhaps
the simplest way to provide an alternate rate is to use
the AT PB command, as it allows you to set both the
options byte (which is always 42), and the baud rate
divisor (which is 500k ÷ the desired baud rate) at the
same time. For example, to set protocol B for J1939
operation at 500 kbps, simply send:
>AT PB 42 01
then send:
>AT SP B
to select it. Note that this setting will not be maintained
if the IC is reset, so if you want a more permanent
setting, you should store the values in PP 2C and 2D.
Once the protocol is set, then you are ready to go.
There is no need to adjust anything else (timing, etc.)
as that is all done for you.
If you do wish to adjust the timing, you should be
aware that the ELM329 provides the ability to extend
the AT ST time by switching a x5 timer multiplier on
and off (see the JTM5 command). This may be useful
when requesting data that will have a multiline
response while similar data is already flowing. Since
there can be only one message like this at a time on
the bus, the response to your request would have to
wait while the initial response completes (and this
could take more than the normal ST time since
broadcast responses must be spaced at least 50 msec
apart). If you know that a reply should be coming, and
you are seeing ‘NO DATA’ responses, then send
AT JTM5 and try it again, as that may be the problem.
Restore the timer multiplier to normal with AT JTM1.
Once the J1939 protocol is selected, the ELM329
is ready for a command. The first one that we will use
is called a DM1 or ‘diagnostic message 1’, which
provides the currently active diagnostic trouble codes.
DM1 is one of more than 50 predefined diagnostic
messages, and is special in that it is the only one that
is broadcast continually over the bus at regular
intervals. The ELM329 has an AT command that can
be used to obtain the DM1 trouble codes:
>AT DM1
If you are connected to a vehicle, you should now
see messages printed at one second intervals. If you
are only connected to a single device (for example,
with a simulator on the bench, or to a device with a
single CAN data port), you may see data with
<RX ERROR printed beside it. This is because the
receipt of the data is not being acknowledged by any
device on the bus (certainly not the ELM329, as it is by
default a completely silent monitor). See our ‘AN05 -
Bench Testing OBD Interfaces' application note for
more information on this, and some advice on what to
do. If you are not connected to a vehicle, and are
having trouble receiving data, try sending:
>AT CSM 0
and there should be no more RX ERRORs. Once you
have this sorted out, repeat the request. If all goes
well, you should see several replies, similar to this:
00 FF 00 00 00 00 FF FF
00 FF 00 00 00 00 FF FF
You will likely need to stop the flow of data by
pressing any key on the keyboard. This is because the
DM1 command is actually a special form of a
monitoring command, and all monitoring needs to be
stopped by the user. The response means that there
are currently no active trouble codes, by the way.
To see the exact same response, you can also
Monitor for PGN 00FECA (which is the code for DM1):
>AT MP 00FECA
Note that the ELM329 requires that you send hex
digits for all data, as shown above (and as used by all
other protocols). Many of the PGN numbers are listed
in the J1939 standard as both a decimal and a hex
number, so be careful to choose the hex version.
You will likely find in your testing that the PGNs
you encounter often begin with a 00 byte as above. To
simplify matters for you, the ELM329 has a special