AVR J1850 VPW Interface Documentation
AVR J1850 VPW Interface Documentation
AVR J1850 VPW Interface Documentation
Issue: F
Author:Michael Wolf
Printed: 22/10/2005
Overview
AVR J1850 VPW interface to connect a Chrysler or GM car bus to a PC for On Board
Diagnostic (OBD) monitoring. My interface is build around Atmel AVR mega8 controller, my
favourite workhorse. The controller is available also in DIP package for all who not want to
built with SMD components. With 8k flash memory we have plenty of space for all kind of
features. The basic source code which supports all functions uses 3k code space.
Some features:
The source code for this interface is released under GNU GENERAL PUBLIC LICENSE.
See license.txt for details.
Hardware description
K3 In-Circuit-Programming connector
Compatible pin-out for Atmel STK500 development board
Pin 1 = MISO
Pin 2 = 5V supply
Pin 3 = SCK
Pin 4 = MOSI
Pin 5 = Reset
Pin 6 = Ground
D1 Power on indication
D3, D4, T3, T4 VPW output buffer, signal inverter and voltage converter
Note:
Firmware version 1.04 and higher requires a crystal with 7.3728MHz for proper function.
Important note:
The voltage regulation circuit R8/D4 is designed for at least 315 Ohm bus load!
Do not keep the J1850 line in high level without load resistor connected to K1-7 and
K1-1 otherwise D4 will be destroyed immediately.
Programming the AVR
The circuit provides an ISP connector to program the firmware. Use your favourite
programming hardware to flash the AVR.
After flashing the firmware you must change the fuse settings on new devices. Remember
that a clean ATmega8 is delivered with internal RC oscillator enabled, running at 1MHz.
Program (checked) the fuses in the following order:
In AVR-Studio:
Boot flash section size=128 words Boot start address=$0F80; BOOTSZ=11
Brown-out detection level at VCC=4.0V; BODLEVEL=0
Brown-out detection enabled; BODEN=0
CKOPT fuse; CKOPT=0
Ext. Crystal/resonator High Freq.; Start-up time: 1k CK + 0ms; CKSEL=1110 SUT=10
In PonyProg:
Checked fuses:
SUT1, CKSEL0
Unchecked Fuses:
BOOTSZ1, BOOTSZ0
All responses from the interface are terminated with a single carriage return character and,
by default, a line feed character as well.
After correct connection and power up, the interface will display the initial message:
>
Showing code description and version, date and time when the code was compiled and the
command prompt character >.
The interface is now ready and can receiver user commands. All commands used to control
the interface are separated from vehicle commands with the command tag AT. Vehicle
commands can contain only with ASCII characters for hexadecimal digits (0-9 and A-F).
All commands send to the interface, internal AT or hex string for VPW, must be terminated
with a single carriage return character (0x0D) before they will be accepted, they are not case
sensitive.
A single ? will indicate that the message was misunderstood by the interface (syntax error).
This includes wrong or incomplete AT commands and wrong hex strings. This is not a sign
for invalid VPW message because the interface not validates VPW message.
AT command description
An interface control command must begin with the AT command tag followed by a
command code and, if required, one or more parameters.
Set the receive address is equal to the third header byte for physical addressing or
second header byte +1 for functional addressing.
The receive address changes whenever the header bytes changes.
Set desired Baud rate. The interface will change the Baud rate immediately after executing
the command. Status message is returned with new Baud rate set.
Possible values for xx: 0 = 9600 Baud 1 = 14400 Baud
2 = 19200 Baud 3 = 28800 Baud
4 = 38400 Baud 5 = 57600 Baud
Any other value = 115200 Baud
With echo on all characters received via RS232 are echoed back to user terminal.
All responses are returned as standard ASCII characters readable on any terminal program.
Hex values are returned as 2 byte ASCII values, separated by space and terminated by
carriage return and optional line feed.
Controls whether or not the header and CRC bytes are shown for received VPW messages.
I [Ident]
Controls whether or not a line feed character is returned with each carriage return character.
MA [Monitor All]
Set the interface in monitor mode. All message received via VPW bus are returned, optional
with header and CRC.
Any serial input will stop this mode and the interface returns to idle state waiting for user
inputs.
Note:
You will see garbage output if MA mode is enabled, Header output is disabled and VPW
frames are transmitted with one byte header only. Use command AT O1 first to enable one
byte header modus for correct output!
MI xx [Monitor ID]
Set the interface in monitor mode for a specific frame ID provided as command parameter.
The frame ID is the first byte in J1850 messages in single byte header format, i.e. used in
Chrysler vehicles.
All message received via VPW bus matching the given frame ID are returned, optional with
header and CRC.
Any serial input will stop this mode and the interface returns to idle state waiting for user
inputs.
See SAE J2178-Part 3 for details of frame ID and single byte header format.
MR xx [Monitor Receiver]
Set the interface in monitor mode for a specific receiver address provided as command
parameter. All message received via VPW bus matching the given receiver address are
returned, optional with header and CRC.
Any serial input will stop this mode and the interface returns to idle state waiting for user
inputs.
MT xx [Monitor Transmitter]
Set the interface in monitor mode for a specific transmitter address provided as command
parameter. All message received via VPW bus matching the given transmitter address are
returned, optional with header and CRC.
Any serial input will stop this mode and the interface returns to idle state waiting for user
inputs.
Use this command to enable or disable transmitting and monitoring of one byte header
messages. With this option enabled the interface will send only one byte as header instead
of three bytes. The header byte must be set using command AT SH xxyyzz, where xx is the
header byte which is will be used. Byte 2 and 3 will be ignored, but must be send to make a
valid AT SH command.
In MA mode this command ensures the correct data output if headers are disabled.
All messages received via VPW bus are returned as hex string starting with a single length
byte followed by complete message content, without terminating character (carriage return or
line feed).
The length byte will indicate only the number of data bytes following, excluding itself.
If a message error was detected (CRC error) the MSB bit 7 of the length byte is set to
indicate and error.
If no data was received within the time out a single length byte with value 0 is returned.
With responses turned off, the interface will not wait for any response from the vehicle. All
given VPW messages are passed to the bus and the interface returns immediately to idle
state, waiting for user inputs.
With responses turned on, the interface will wait at least 100ms for node response and an
additional timeout which is set via ST command.
SH xx yy zz [Set Header]
This command set the three byte header which is send before all user VPW commands.
For details of header bytes see standard SAE J2178 part 1 and SAE J1979.
Default header is 0x68 0x6A 0xF1 for external diagnostic equipment.
Users can set a specific receive address to which the interface will respond. This command
will turn off AR mode and the interface will accept only responses from address xx.
This command set the additional timeout before the interface returns an NO DATA.
Default value is 50 which give an additional timeout of 4ms x 25 = 100ms.
The command parameter must be send as hex value range 0x00 to 0xFF. Values less than
0x08 will be forced to 0x08 to set a minimum timeout of 32ms.
This timeout recommended to the 100ms minimum node response timeout specified in SAE
J1850.
Z [Reset]
The interface will perform a complete reset, all values will set to default.
Note:
For commands with 0/1 disable/enable option, only a 0 will disable the function, other values
than 0 will enable the function!
ODB or VPW commands
I will not descript VPW or ODB commands here, because you can find a lot of ODB
information using you favourite internet search engine and its not the purpose of this
document.
Just a few words how to send VPW messages using the interface:
All VPW messages must be send as hex string given with 2 byte ASCII values. String length
must be an even number of ASCII bytes with a maximum number of 8 VPW data bytes. No
header byte (set via SH command) and NO CRC.
CRC will be calculated independent for each given hex string will be included automatically
to the message send to the bus.
So the maximum message length send to the VPW bus is 12 byte as specified in SAE
J1850.
The interface will calculate a CRC for all messages received via VPW bus. This CRC will be
compared with the received CRC. In case of CRC error, the interface will mark this message
faulty.
Error messages
The interface will return various error messages; here is a description of each message:
BUSBUSY
The interface tried to send a message but bus was busy.
BUSERROR
The interface has detected a bus error. It was not possible to change bus levels, or an bit
level collision was detected.
<DATAERROR
Calculated and received CRC byte not equal, message faulty.
NO DATA
No data received within timeout.
?
Given command wrong or incomplete or hex string wrong or incomplete.
OK
Not an error message, but indicates execution of given command successful.
You will find the interface schematic, PCB layout, part placement layout and bill of material in
the appendix of this document.
PCB layout file is available on request. Format will be Target 3001 v11.
(http://www.ibfriedrich.de/)
Disclaimer:
By using this circuit or description or other material presented, then you (meaning the reader
of this material being yourself, or any other person that you may subsequently pass any
material to) explicitly accept the following.
I will accept no liability for loss or damages that may be imposed upon you by any Court of
Law, statutory or other body. It is entirely the reader's responsibility to determine the
suitability of any design for the intended purpose. The project is presented "as is" and are
believed to be without error, however this cannot be guaranteed, and it is reasonable to
assume that mistakes or other errors will occur from time to time. If errors are found, please
contact me, Michael and describe the error (and its consequences) so that corrections may
be made.
License for firmware source code
AVR J1850 VPW Interface, this firmware and hardware will realize an
interface between a cars J1850 VPW bus and RS232.
Copyright (C) 2004 Michael Wolf
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
AVR J1850 VPW Interface, diese Firmware und Hardware realisiert ein
Interface zwischen einem J1850 VPW Fahrzeug Bus und RS232.
Copyright (C) 2004 Michael Wolf
Dieses Programm ist freie Software. Sie knnen es unter den Bedingungen der
GNU General Public License, wie von der Free Software Foundation
verffentlicht, weitergeben und/oder modifizieren, entweder gem
Version 2 der Lizenz oder jeder spteren Version.
Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
K1
1
2
3
4
5 +12V +5V
6 IC1 78L05
7
R1
8
IN OUT3
GND
9 1 1 2
+
2 1
C1 C2 220 1
LED Green
Sub-D-9M 100 1 2 2 0,1 D1
2
+5V
+12V
1 LED Yellow 3
T3 T4
D2 2
2 1N4148 BC548A 3 BC548A
1
2
2
R3 2 1
2 1
15K D4
1 D3
3
1 ZPD8V2 2
T1 R10
2
BC548A 1K
1 +5V 1
2
R4
2,2K
1 2 2
R5
R6
47K
1 1 47K
3
T2
2 +5V
BC548A
1
2
R7 16
1
10K C10
1 IC3 2 0,1
15
+5V
Sub-D-9F