SAE J1939 Software
J1939 CANOPEN ISO 15765 ADAPTERS HOME ABOUT TESTIMONIALS EXPERIENCE PRODUCTS CONTACT
SAE J1939 Protocol Stack
SAE J1939 Protocol Stack
     
 

Experience Summary

  • 1000 Global Customers
  • 500 Protocol Stacks
  • 300 CAN Device Drivers
  • 75 Flash Bootloaders
  • 60 Microcontrollers & DSPs
  • 7 Real-Time Operating Systems
  • 1 United States Patent

J1939

 

Our SAE J1939 protocol stack was designed by Simma Software, a nationally recognized CAN bus expert, to meet the demanding needs of the high speed Controller Area Network (CAN). Our source code uses a high performance modular design and has a simple API. Benchmarks have shown the stack to be 800% more efficient than other commercially available J1939 software solutions. The software protocol stack is well documented and has been used in more than a quarter of a milliion embedded systems.

CPU Cycles per Msg
(apprx. for HCS12 CPU)

SAE J1939 Software Execution Timing
Code Size Comparison
(apprx. for HCS12 CPU)

SAE J1939 Source Code Size

There are two J1939 software packages available: ssJ1939-Full and ssJ1939-Light. ssJ1939-Full handles reception and transmission of standard single frame and multi-frame (i.e. Transport Protocol) J1939 messages. Also, ssJ1939-Full handles address claim arbitration specified by the network management layer. ssJ1939-Light is identical to ssJ1939-Full without support for the transport protocol which is used for multi-frame messages. If you have questions about our software, please see our J1939 Protocol Stack FAQ for possible answers.

ssJ1939 Protocol Stack Details:

 

SAE J1939 Introduction

 

This article is intended to give engineers a brief overview of the SAE J1939 protocol. For details on the specification itself, please visit the Society of Automotive Engineers. Here is a printable version of this J1939 introduction and Bosch CAN specification.

SAE J1939 is a replacement for the SAE J1587/J1708 network which has been used for medium and heavy duty commercial vehicles for the past 20 years. Today SAE J1939 is used as the standard communications bus for commercial vehicle's diagnostic and control applications. Due to its popularity and success, it has been adopted by the agricultural (ISO 11789) and marine industries (NMEA 2000).

J1939 Overview

SAE J1939 is a high level communications protocol, which operates on a Controller Area Network (CAN) bus. SAE J1939 specifies exactly how information (e.g. engine RPM) is exchanged between electronic control units (ECUs) on a vehicle.

It defines the data's priority, size, scaling, and offset. For example, J1939 specifies engine RPM to have a default priority of 3, to have a size of 16-bits, a resolution of 0.125 rpm/bit, and an offset of 0.

The standard goes on to define many other aspects, including message timeouts, how large messages are fragmented and reassembled, the network speed, the physical layer, and how applications acquire network addresses.

CA

In J1939, the acronym CA stands for Controller Application and represents the software, not hardware, entity associated with a particular J1939 address. An electronic control unit, which is a single piece of hardware, may contain multiple controller applications.

For example, a centrally located ECU could contain the "Engine Controller", the "Turbocharger Controller", and "Cruise Control Controller". In that case, there would be 3 CAs inside of a single piece of hardware or physical network node. Physically they are one node, but logically they are three nodes. All three CAs have to maintain their own source address and NAME field.

Datalink

SAE J1939 uses a simple datalink layer to communicate information. Altogether there are six subfields which are encoded into the 29-bit CAN identifier, they are shown below and are: Priority, Extended Data Page, Data Page, Protocol Format, Protocol Specific, and Source Address.

P EDP DP PF PS SA
3 bits 1 bit 1 bit 8 bits 8 bits 8 bits

P is the priority of the message, EDP and DP make up 4 different pages with one page being reserved for ISO 15765-3. PF and PS define the parameter group number and destination address, and SA is the source address of the controller application. For details about this encoding, refer to SAE J1939-21.

Messages

At the heart of J1939 is the Parameter Group Number (PGN), which is a unique number assigned to every J1939 message. The PGN serves to identify the message and its data. Although sometimes a message will contain a single parameter (e.g. VIN), typically the PGN will contain a group of parameters. In the standard there is a total of 8,672 PGNs.

For an example message, take PGN 61,444. It identifies the "Electronic Engine Controller 1" message. Per the specification, "EEC1" has seven different parameters embedded in the data field of the message. Engine RPM is one of those seven parameters.

Message Sizes

J1939 has three different allowed message sizes, they are: 3 bytes, 8 bytes, and variable length. There is only one message which is three bytes in length, and that is the request message (PGN 59,904).

The majority of messages in J1939 are 8 bytes in length. This allows for a more efficient use of the network bandwidth by maximizing the amount of data on the network by reducing the number of messages.

Variable length messages are messages with a length from 9 to 1,785 bytes. These messages are too large to fit in a single CAN data frame and must be fragmented by the transmitter and reassembled by the receiver. This process is defined by J1939's transport protocol which is specified by J1939-21.

The transport protocol layer defines two different types of message fragmentation: BAM and CM. There are several differences between those two types, the main difference being the destination address. A BAM uses a global destination address and is therefore sent to all CAs, while a CM is destination specific. Due to the addressing scheme, only a single BAM can be transmitted simultaneously, while multiple CMs using different destination addresses may be simultaneously transmitted.

Another difference between BAMs and CMs is the time is takes to send a messages. With a BAM, data packets must be spaced at least 50 ms apart and no more than 200 ms. With a CM, data frames may be sent as quickly as possible.

BAM

The acronym BAM stands for Broadcast Announce Message and is a type of communication used by the Transport Protocol layer. BAM messages are used to send information which is larger than 8 bytes in size to all J1939 CAs and does not require handshaking.

The first message in a BAM indicates the number of bytes which are about to follow, the total number of data packets which are about to follow, and the PGN for the corresponding data. All of this header information is sent in a Transport Protocol Connection Management(TP.CM) frame, with the data contained in a Transport Protocol Data Transfer(TP.DT) frame.

SPN

In SAE J1939, the acronym SPN stands for Suspect Parameter Number and represents the identity of a J1939 parameter. Every J1939 parameter has a unique SPN, which is 19-bits wide, assigned to it by the SAE committee when the parameter is defined.

The main purpose of the suspect parameter number is to identify a parameter when a failure has occurred. Every failure is identified by its SPN and FMI fields.

PGN 65134    High Resolution Wheel Speed

Transmission Repetition: 20ms
Data Length: 8
Default Priority: 2
Parameter Group Number: 65134

Start Position Length Parameter Name SPN
1-2 2 bytes Front Axle, Left Wheel Speed 1592
3-4 2 bytes Front Axle, Right Wheel Speed 1593
5-6 2 bytes Rear Axle, Left Wheel Speed 1594
7-8 2 bytes Rear Axle, Right Wheel Speed 1595

DTC

In SAE J1939, the acronym DTC stands for Diagnostic Trouble Code, also known as a fault code, and serves to identify the failed parameter. A DTC contains the Suspect Parameter Number (SPN) for the failed parameter, how many times failure has occured (OC), and how it has failed (FMI).

Active DTCs are transmitted by the DM1 message while non-active DTCs (i.e. historic) are transmitted by the DM2 message. The DM1 and DM2 messages may contain multiple DTCs which mean the message may be transmitted using the Transport Protocol (TP). Both the DM1 and DM2 messages are defined by the J1939-73 specification.

DTC Definition:
Suspect Parameter Number (SPN)19 bits
Failure Mode Identifier (FMI)5 bits
Occurrence Count (OC)7 bits
SPN Conversion Method (CM)1 bit

Physical Layers

Currently there are two 250 Kbps physical layers defined, J1939-11 and J1939-15, with a 500 Kbps layer, J1939-14, under development.

J1939-11 specifies a shielded twisted pair of wires with a maximum backbone length of 40 meters and maximum stub length of 1 meter. It uses a three pin connector and allows for up to 30 nodes.

J1939-15 specifies an unshielded twisted pair of wires with a maximum backbone length of 40 meters and maximum stub length of 3 meters. It uses a two pin connector and allows for up to 10 nodes.

CAN Parameters

SAE J1939-11 and -15 specify a network data rate of 250 Kbps with a minimum period of 3.998 us and a maximum period of 4.002 us. CAN networks also allow and require for custom sample point settings. For J1939, the sample point setting has a maximum value of 87.5%. Nodes should be set as close as possible but not exceed 87.5%. CAN peripherals also allow for synchronous jump width (SJW) settings of 1 to 3. The SJW value dictates how much time can be added or subtracted to the node's CAN clock for syncronization purposes. J1939 allows only for a single SJW.

Shield Termination

For networks with a shield, in one spot with least electrical noise and close to the middle, the shield should be connected directly to ground.

Nodes will connect to the shield via a resistor and capacitor in series. The resistor should have a value of 1 ohm and the capacitor should have a value of 0.68 uF.

Clock Tolerance

J1939, which is based on a CAN bus, has a much tighter clock tolerance than what is stated in the CAN ISO 11898 documents. CAN specifics a tolerance of 1.58% while J1939-11 and J1939-15 specify a clock tolerance of 0.05%. Because of these tight tolerances, CAN peripherals often may not be driven by PLL (Phase Lock Loop) and FLL (Frequency Locked Loop) multipliers.

PLLs and FLLs, which are used to multiply frequencies introduce clock jitter. Clock jitter is variation from period to period in a clock signal. Crystals have very low jitter as compared to PLL/FLL circuits. Due to this, jitter can introduction errors into the CAN bus. Consult the microcontroller datasheet for PLL/FLL jitter amounts.

Network Termination

All SAE J1939 networks utilize, and require, two resistors at each end of the backbone. These resistors are balanced with the impedance of the network cable and prevent electrical reflections. Reflections are much like audiable echos, and without dampening, can prevent high-speed operation.

SAE J1939-11 and J1939-15 both specify terminating resistors should not be contained inside of electronic control units. If resistors are placed inside of an ECU, if that ECU is removed from the network then the network will fail to operate. This also allows for backbones to be extended as needed. Instead, terminating resistors should be placed into cable plugs which serve to seal and cap the end of networks. Terminating resistors have a minimum resistance of 110 ohms, typical of 120 ohms, and maximum of 130 ohms.

Protocol Stack

What is a J1939 protocol stack? A J1939 protocol stack is a software library that handles the appropriate layers of the OSI 7 layer model. J1939 specifies layer 1 (physical), layer 2 (data link), layer 3 (network), and layer 4 (transport), and layer 7 (application).

In simple terms, a J1939 protocol stack, for inbound data, will convert and reassemble received raw CAN frames and present complete and valid J1939 messages to the user's application. For outbound data, a J1939 protocol stack will accept complete messages from the user's application then convert, fragment, and transmit raw CAN frames onto the J1939 network.

NAME Field

Every ECU, or CA (controller application) on a J1939 network has a unique NAME. The NAME field is used for two purposes: to identify a J1939 controller application and also acquire a source address. The NAME is 64 bits wide and is made up of the following fields: Arbitrary Address Capable, Industry Group, Vehicle System Instance, Vehicle System, Reserved Bit, Function, Function instance, ECU Instance, Manufacturer Code, and Identity Number. The NAME field gives each CA a unique identity. Nodes on the network use the NAME field to distinguish between each other. The NAME field is also essential to Network Management as it establishes node priority. The NAME translates to a number; the lowest numeric values have the highest priority when claiming addresses.

An ECU may contain multiple CAs and NAME fields. THe NAME field is transmitted inside of PGN 60,928. All controller applications on a network, and all sub-networks, must have a unique NAME field.

Address Claiming

In J1939 CAs, or electronic control units, on the vehicle network bus must claim a unique source address to enable communication. Addresses 0 to 128 are pre-assigned and CAs which use these addresses are allowed to communicate immediately after power up. In anticipation of future devices and functions, however, J1939 includes a method for dynamically assigning addresses. New devices must announce an address for themselves by transmitting an address claim message.

Sending an Address Claim message the new (non-addressed) device sends out an Address Claim PGN indicating the address it is assuming. All devices on the network compare this newly claimed address with their internal address tables. If the address is already in use by a device with a higher priority (determined by the NAME), the higher priority device indicates the conflict by sending out a Address Claim message. The lower priority device immediately stops using the address and must claim a new one.

About the SAE

SAE, Society of Automotive Engineers, is an organization of engineers and technical experts in the aerospace, automotive and commercial-vehicle industries. Their primary goal is to develop technical standards, for example: SAE J2497, SAE J1939, SAE J1850, SAE J1587, and SAE J1708. The SAE provides a venue for government and businesses to agree on technical standards for the worldwide vehicle mobility industry. In general these standards are only recommended practices, which means there is no legal mandate for business to adhere to them. However sometimes goverments madate adoption (e.g. OBD2 and SAE J1979).

To purchase SAE J1939 documents, we recommend buying digital content (PDFs) from SAE's online store. PDFs are very useful when you need to search for specific keywords.

J1939 Specifications

J1939 Protocol Dictionary

    PGN SA DA
    PDU1 PDU2
 

ssJ1939 Software Benchmarks

 

Simma Software provides high-performance deterministic real-time software for the embedded systems industry. For reference and comparitive purposes for our customers, we are providing the below performance analysis metrics. These J1939 software benchmarks are for the combined packages of ssJ1939-Full and ssCAN. They were measured with a 100% utilized 250 Kbps SAE J1939 network. CAN identifiers were randomized and acceptance masks disabled. All builds were compiled with full optimizations enabled and code execution from internal flash memory.

J1939 Protocol Stack Benchmark
 
 

SAE J1939 Ports

 

Our real-time SAE J1939 protocol stack is completely platform independent and written in the ANSI C programming language. It is the CAN device driver, ssCAN, that is target specific and incorporates the details for a given microcontroller.

Together ssJ1939 and ssCAN form a complete ported system allowing customers to be up and running almost immediately. Our ssCAN device driver has been ported to over 40 different microcontrollers. Below is the list of available ports. Please contact us if you are interested in a port or device driver for a hardware platform that is not listed.

  • Linux
  • Windows XP/7/Embedded
  • Texas Instruments RM4x (DCAN)
  • Texas Instruments LM3Sx
  • Texas Instruments TMS470x
  • Texas Instruments TMS470Mx
  • Texas Instruments TMS570x
  • Texas Instruments Tiva TM4C
  • Texas Instruments F28M35xx
  • Texas Instruments TMS320F280x
  • Texas Instruments TMS320F281x
  • Texas Instruments TMS320F282x
  • Texas Instruments TMS320F283x
  • Texas Instruments AM3x - Sitara
  • Texas Instruments DM8x - DaVinci
  • Atmel SAM7
  • Atmel AT90
  • Freescale KS22
  • Freescale HCS08
  • Freescale HCS12
  • Freescale HCS12X
  • Freescale MC68xxx
  • Freescale MCF5xxx
  • Freescale MPC5xxx
  • Freescale 56F83xxx
  • Freescale Kinetis Kxx
  • Infineon C16x
  • Infineon TriCore
  • Intel 82527
  • Microchip PIC18
  • Microchip PIC24
  • Microchip PIC32
  • Microchip dsPIC30
  • Microchip dsPIC33F
  • Microchip dsPIC33E
  • Microchip dsPIC33CK
  • Microchip MCP2515
  • NXP S32
  • NXP LPC11xx
  • NXP LPC17xx
  • NXP LPC21xx
  • NXP LPC23xx
  • NXP SJA1000
  • Silicon Labs C8051
  • STMicro ST7
  • STMicro ST10
  • STMicro STR7
  • STMicro STM8
  • STMicro SPC56
  • STMicro STM32L4x
  • STMicro STM32F0x
  • STMicro STM32F1x
  • STMicro STM32F2x
  • STMicro STM32F3x
  • STMicro STM32F4x
  • STMicro STM32F7x
  • Xilinx LogiCORE AXI (axi_can)
 
   
 
 
 
Call Toll Free:  888-256-3828
SAE J1939 Introduction | J1939 Software | J1939 Source Code | J1939 Protocol Stack