Professional Documents
Culture Documents
Joseph Julicher
Microchip Technology Inc.
INTRODUCTION
The Enhanced Universal Synchronous Asynchronous
Receiver Transmitter (EUSART) was developed to
address the demands created by higher clock speeds
and automotive low-speed networks. The EUSART is
found on many PIC microcontrollers. PIC16F688 will
be used for the examples in this application note. This
document demonstrates the EUSART used to
communicate on an SAE J1708 data bus, such as
those found in a modern heavy truck.
FEATURES
The features of the EUSART are as follows:
Further Reading
Additional information can be found in the data sheet
for PIC16F688, the SAE J1708 and the SAE J1587
specification.
Note:
INTRODUCING J-1708
History
The J1708 serial communications link specification
was issued by SAE in 1986. It is intended to describe a
hardware and protocol to standardize the
communications between modules in heavy-duty
vehicle applications. The objectives of the link are:
Minimize hardware costs and overhead
Provide flexibility for expansion and
advancements without impacting existing systems
Utilize standard hardware
Be electromagnetically compatible with the rest of
the vehicle
Provide flexibility for suppliers to customize the
link for proprietary reasons
The J1708 link is a bidirectional communications link
which links electronic modules that contain
microcomputers. The actual J1708 specification
defines hardware and the protocol requirements to
maintain the link. The actual data that is communicated
on the link is defined by a separate J1587 document.
Today, the J1708 data bus is alive and well in heavy
trucks. It is used to communicate general status
information between electronic modules. A federal
requirement for the trailer anti-lock braking system to
light a fault lamp in the tractor has led to the
development of a power line carrier version of the
J1708 data bus. The hardware interface is changed to
allow communications over the 12V DC power bus, but
the protocol and communications timing remain the
same.
J1708 Overview
J1708 is a simple multi-master bus interface built upon
a USART peripheral in a microcontroller. While any
wired-or type physical layer works with J1708, the
specification describes a physical layer based upon an
RS-485 bus (see Figure 1). By using a recessive state
and a dominate state for the bus, multiple masters can
share the transport media without fear of contention.
The J1708 protocol includes methods for claiming the
bus, resolving collisions, and transmitting data. The
data is transmitted at 9600 baud with 1 Start bit, 8 data
bits and 1 Stop bit. The packet length is 2 to 21 bytes
including a checksum for error detection. Parameter
Identification (PID) numbers identify the data on the
bus. Groups of PIDs are reserved for data that are of
DS01230A-page 1
AN1230
different lengths. Module Identifiers (MID) identify
different transmitters on the bus. The MIDs are
numbered to provide an implicit priority scheme. In this
way, engine modules get a higher priority than vehicle
modules or diagnostic tools.
Other Uses
The hardware and software that makes up the basics
of a J1708 data bus can easily be used in other
applications. A robot could use J1708 and custom
messages to share data between multiple CPUs.
J1708 can even be used with optical or RF components
to create a wireless network. Interfacing a J1708 bus to
a PC requires very simple hardware because the PC
serial port can understand the data with an appropriate
physical layer transceiver.
It is inexpensive
It is available
Despite being used in an unusual way, it is
adequate for low-speed work
FIGURE 1:
R3
+ 5V
RX
4.7K
+ 5V
R1
U1
GND
R2
RS-485 Transceiver
47
4.7K
DE
DI
47
R4
A
B
C2
Inverter
RE
8
7
6
2.2 F
VDD
C1
TX
RO
2.2 F
1
2
3
Serial
Data Bus
DS01230A-page 2
AN1230
J1708 NETWORK ACCESS
Devices that require access to the bus must perform a
process called arbitration.
The steps to arbitration are as follows:
1.
2.
FIGURE 2:
BIT TIME
The bit time is the time required to send 1 bit of data.
For the J1708 specification, 1 bit time is 104.16
microseconds. This time corresponds to 9600 baud. All
other times specified by the J1708 specification are
multiples of bit times.
BUS IDLE
Per the J1708 specification, the bus is Idle after 10-bit
times have elapsed from the previous character with no
received Start bits. This is very important and must be
accurately determined because the J1708 specification
defines the end-of-packet condition as the bus going to
Idle. After the 10-bit times have elapsed and the
receiver is not receiving, then we know the bus is Idle
so the previous packet can be validated and any
arbitration can continue.
BUS IDLE
MID
Checksum
Bus Busy
Stop bit of last
character
MESSAGE PRIORITY
All messages on the J1708 bus are assigned a
message priority by the defining application document.
The message priority is converted into a message
priority delay by the following equation:
EQUATION 1:
Pd = Tb*2*P
Pd = Priority Delay in S
Tb = Bit time or 104.16 S
P = Message Priority
DS01230A-page 3
AN1230
TABLE 1:
CLASSES OF MESSAGE
PRIORITIES
TABLE 2:
PSEUDO-RANDOM NUMBERS
1.
2.
3.
MESSAGE CHECKSUM
3.
4.
95
23
45
123
XXX
DATA FORMAT
byte 0
byte 1
byte 2
MID
PID
Data
DS01230A-page 4
byte 3 to N
(N not to exceed 20)
Additional PIDs and
Data
byte N + 1
Checksum
AN1230
For example, J1587 extension on J1708 specifies the
MID for an engine to be 128. An instrument cluster is
assigned MID 140. If both of these devices attempt to
gain access to the bus at the same time, the result of
the MID collision will be the bitwise AND of the two
MIDs (see Table 3).
Notice that the data that ends up on the bus is the same
as MID 128. This means that the only device that will
see a collision is MID 140. MID 140 will begin the
collision retry procedure and will lose because the bus
will remain busy until MID 128 finishes sending its data.
Once the bus is free again, MID 140 will be able to try
again for bus access.
J1587 defines the data format when the MID is > 127.
The J1708 rules still apply, but the data payload is
specified.
TABLE 3:
Bit 1
Bit 2
Bit 3
Bit 4
Bit 5
Bit 6
Bit 7
MID128
MID140
Result
Payload
The payload of a J1708 packet is a block of up to 19
bytes of data. J1708 does not define a data format for
the payload. However, if your MID is 128, then your
payload must conform to the J1587 extension to the
J1708 specification. Of course if you are not going live
on a real J1708/1587 data bus, then your data format
is your own business.
All PIDs, after an extension PID, are taken for the next
page. If a packet has 3 extension PIDs, then the
remaining PIDs will be from page 4.
TABLE 4:
MID
PID
TABLE 5:
MID
PID
DATA
PID
DATA
Checksum
DATA
DATA
Checksum
Library
Advantages
DS01230A-page 5
AN1230
TABLE 6:
Resource
Used
Purpose
USART
TX and RX IRQ
Data I/O
TIMER0
T0 IRQ
GPR
73 bytes
Program Memory
332 Words
FIGURE 3:
FIGURE 4:
J1708 RECEIVE
FLOWCHART
Begin
Begin
Yes
Yes
No
Place data in j1708_tx_buffer.
Only 19 bytes.
Yes
j1708_checksum_error
Clear
j1708_checksum_error
Call j1708_tx_data
No
j1708_active_buffer changed?
j1708_tx_busy==1
Yes
No
j1708_active_buffer is 1
No
End
End
DS01230A-page 6
AN1230
CONCLUSION
The J1708/1587 bus is a simple, robust, low-speed,
multi-master data bus that has been successfully used
in heavy trucking for many years. This bus has many
aspects such as low-cost and multi-master that could
be useful for other applications. The features of the
EUSART and the attached library simplify the task of
using J1708 in an application.
DS01230A-page 7
1
2
3
4
5
6
+5V
R1
PIC16F688
RA5/T1CK1/OSC1
D2
4.7
220
RC
R9
D1
HDR - 1X6
0.1F
VDD
RA/AN/C1+/PD
RA1/AN1/C1-/Vref/PC
RA2/AN2/TCKI/INT/C1
RA3/MCLR/VPP
RA4/AN3/T1G/OSC2
RC1
1
13
12
11
4
3
C6
R8
C4
10 RC
9
RC1
8
RC2
7
RC3
6
5
1F
GND 14
RC/AN4/C2+
RC1/AN5/C2RC2/AN6
RC3/AN7
RC4/C2OUT/TX/CK
RC5/RX/DT
D3
U1
RC2
J3
220
C7
220
+5V
R2
0.1F
R7
CCW
CW
+5V
Ground
4
RC3
1F
DS75176-SO
1 RO VDD 8
7
2
B 6
3 RE
A5
4 DE
DI GND
U2
Input
Ground
2
U3
C3
+5V
10F
+5V
R3
4.7K
+5V
LM294IMP
+
C5
4.7K
R4
3 Output
C1
14V
2.2 F
DS01230A-page 8
5W
47
47
R6
R5
680
C2
+12V
GND
12V
APPENDIX A:
2.2 F
+5V
AN1230
SCHEMATICS
AN1230
APPENDIX B:
0-127
128
Engine #1
129
Turbocharger
130
Transmission
131
Power Takeoff
132
133
Axle, Trailer #1
134
Axle, Trailer #2
135
Axle, Trailer #3
136
137
Brakes, Trailer #1
138
Brakes, Trailer #2
139
Brakes, Trailer #3
140
Instrument Cluster
141
Trip Recorder
142
143
Fuel System
144
Cruise Control
171
172
Off-board Diagnostics #1
173
Engine Retarder
174
Cranking/Starting System
175
Engine #2
176
Transmission, Additional
177
178
179
180
Off-board Diagnostics #2
181
182
183
Engine #3
184
Engine #4
185
Engine #5
186
Engine #6
187
188
189
190
191
145
146
147
148
149
192
150
193
151
Suspension, Trailer #1
194
152
Suspension, Trailer #2
195
Annunciator Unit
153
Suspension, Trailer #3
196
154
197
155
198
156
199
157
200
158
201
159
202
160
203
161
204
162
205
163
Vehicle Security
206
164
Multiplex
207
165
208
Maintenance Printer
166
209
Vehicle Turntable
167
Tires, Trailer #1
210
168
Tires, Trailer #2
211
169
Tires, Trailer #3
212
170
Electrical
213
DS01230A-page 9
AN1230
Appendix B Message ID Assignment
List (Continued)
214
215
Surveillance Microphone
216
217
218
219
220
Tachograph
221
222
Driveline Retarder
223
224
Parking Heater
225
226
227
228
229
230
231
232
233
234
Instrument Cluster #2
235255
Reserved to be assigned
DS01230A-page 10
AN1230
APPENDIX C:
PID
Parameter
63
64
Request Parameter
65
1(1)
66
2(1)
67
3(1)
68
69
Reserved to be assigned
70
(1)
71
(1)
72
73
74
7-30
Reserved to be assigned
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
75
76
77
78
79
80
81
82
83
84
Road Speed
85
86
87
88
89
46
90
47
Retarder Status
91
48
92
49
93
Output Torque
50
94
95
51
Throttle Position
96
Fuel Level
52
97
53
98
54
99
100
55
57
58
59
60
61
101
Crankcase Pressure
102
Boost Pressure
103
Turbo Speed
104
105
106
DS01230A-page 11
AN1230
Appendix C J1587 Parameter ID
Assignment List (Continued)
150
151
107
152
108
Barometric Pressure
153
Crankcase Pressure
109
Coolant Pressure
154
110
155
111
Coolant Level
156
112
157
113
Governor Droop
158
114
159
115
Alternator Current
160
116
161
117
162
118
163
119
164
120
165
Compass Bearing
121
166
122
167
123
Clutch Pressure
168
124
169
125
170
126
171
172
173
174
Fuel Temperature
Component-specific request
175
Reserved - to be assigned
176
177
178
136
179
137
180
Trailer Weight
138
181
Cargo Weight
139
182
Trip Fuel
140
183
Fuel Rate
184
141
142
127
185
186
187
143
188
144
189
190
Engine Speed
145
191
146
147
148
149
(1)
Multisection Parameter
Transmitter System Diagnostic Table
DS01230A-page 12
AN1230
Appendix C J1587 Parameter ID
Assignment List (Continued)
194
Request Parameter
257(1)
195
258(2)
196
259(3)
197
Connection Management
198
199
200-223
Reserved to be assigned
224
225
226
227
228
229
230
231
232
233
234
Software Identification
260377
(4121)
Reserved to be assigned
378(122)
379(123)
380(124)
Articulation Angle
381(125)
382(126)
383(127)
Vehicle Acceleration
Component-specific request
Reserved to be assigned
385-446
(129-190)
447(191)
Passenger Counter
235
236
237
238
Velocity Vector
449(193)
450(194)
451-499
(195-243)
Reserved to be assigned
500(244)
239
Vehicle Position
501(245)
Signage Message
240
502(246)
241
Tire Pressure
503(247)
242
Tire Temperature
504(248)
243
Component Identification
505(249)
244
Trip Distance
245
506(250)
246
507(251)
Driver Identification
247
508(252)
248
509(253)
249
250
510(254)
251
Clock
511(255)
Page 2Extension
252
Date
253
Elapsed Time
254
255
Extension
DS01230A-page 13
AN1230
NOTES:
DS01230A-page 14
Note the following details of the code protection feature on Microchip devices:
Microchip products meet the specification contained in their particular Microchip Data Sheet.
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchips Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as unbreakable.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchips code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro,
PICSTART, rfPIC, SmartShunt and UNI/O are registered
trademarks of Microchip Technology Incorporated in the
U.S.A. and other countries.
FilterLab, Linear Active Thermistor, MXDEV, MXLAB,
SEEVAL, SmartSensor and The Embedded Control Solutions
Company are registered trademarks of Microchip Technology
Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, CodeGuard,
dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN,
ECONOMONITOR, FanSense, In-Circuit Serial
Programming, ICSP, ICEPIC, Mindi, MiWi, MPASM, MPLAB
Certified logo, MPLIB, MPLINK, mTouch, PICkit, PICDEM,
PICDEM.net, PICtail, PIC32 logo, PowerCal, PowerInfo,
PowerMate, PowerTool, REAL ICE, rfLAB, Select Mode, Total
Endurance, WiperLock and ZENA are trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
2008, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
DS01230A-page 15
ASIA/PACIFIC
ASIA/PACIFIC
EUROPE
Corporate Office
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200
Fax: 480-792-7277
Technical Support:
http://support.microchip.com
Web Address:
www.microchip.com
India - Bangalore
Tel: 91-80-4182-8400
Fax: 91-80-4182-8422
India - New Delhi
Tel: 91-11-4160-8631
Fax: 91-11-4160-8632
Austria - Wels
Tel: 43-7242-2244-39
Fax: 43-7242-2244-393
Denmark - Copenhagen
Tel: 45-4450-2828
Fax: 45-4485-2829
India - Pune
Tel: 91-20-2566-1512
Fax: 91-20-2566-1513
France - Paris
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
Japan - Yokohama
Tel: 81-45-471- 6166
Fax: 81-45-471-6122
Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Boston
Westborough, MA
Tel: 774-760-0087
Fax: 774-760-0088
Chicago
Itasca, IL
Tel: 630-285-0071
Fax: 630-285-0075
Dallas
Addison, TX
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Farmington Hills, MI
Tel: 248-538-2250
Fax: 248-538-2260
Kokomo
Kokomo, IN
Tel: 765-864-8360
Fax: 765-864-8387
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
Santa Clara
Santa Clara, CA
Tel: 408-961-6444
Fax: 408-961-6445
Toronto
Mississauga, Ontario,
Canada
Tel: 905-673-0699
Fax: 905-673-6509
Australia - Sydney
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
China - Beijing
Tel: 86-10-8528-2100
Fax: 86-10-8528-2104
China - Chengdu
Tel: 86-28-8665-5511
Fax: 86-28-8665-7889
Korea - Daegu
Tel: 82-53-744-4301
Fax: 82-53-744-4302
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
China - Nanjing
Tel: 86-25-8473-2460
Fax: 86-25-8473-2470
China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205
Malaysia - Penang
Tel: 60-4-227-8870
Fax: 60-4-227-4068
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
Philippines - Manila
Tel: 63-2-634-9065
Fax: 63-2-634-9069
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
China - Shenzhen
Tel: 86-755-8203-2660
Fax: 86-755-8203-1760
China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118
Taiwan - Kaohsiung
Tel: 886-7-536-4818
Fax: 886-7-536-4803
China - Xiamen
Tel: 86-592-2388138
Fax: 86-592-2388130
Taiwan - Taipei
Tel: 886-2-2500-6610
Fax: 886-2-2508-0102
China - Xian
Tel: 86-29-8833-7252
Fax: 86-29-8833-7256
Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
Spain - Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
UK - Wokingham
Tel: 44-118-921-5869
Fax: 44-118-921-5820
China - Zhuhai
Tel: 86-756-3210040
Fax: 86-756-3210049
01/02/08
DS01230A-page 16