Understanding J1939 SAE Protocol: The Complete Guide to Communication in Commercial Vehicles. Part-3
Published: 2023-12-12 15:28:33

Hello Readers, 👋😃
My name is Aravind B. N., and I work at Luxoft India as a junior software developer. Luxoft has given me several opportunities to work on various projects, which has inspired me to discuss the important processes involved in learning the SAE J1939 communication protocol Part 3.

**Structure**
The J1939 21 document outlines the way in which the 29 bit CAN identifier should be understood. Just like how a CAN messages 8 byte data field has start bits and lengths to define signals the CAN identifier is divided into segments, for a parameter group. This means that only A part of the identifier represents the PGN itself while the rest is used to determine source address, destination address, priority and data page. The diagram titled "From the 29 bit CAN Identifier to the Parameter Group" illustrates how a J1939 CAN identifier is structured.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dmn07blm0b3yyf1nmair.png)


**PGN Format**
The diagram illustrates that the PDU Specific section can be interpreted in ways. This section serves two purposes; it extends the PDU Format section. Defines a PGN while also specifying a destination address. The rules, for this are as follows;

If the value in the PDU Format section is than 240 then the content of PDU Specific is treated as the destination address. This is referred to as a PGN in PDU Format 1 or a specific PGN. A PGN in PDU Format 1 can be sent directly to a destination address using point, to point communication. It can also be sent globally using the global address (255). In this way a specific PGN can be transmitted globally to all network nodes.

If the value of the PDU Format segment is equal, to or greater than 240 it indicates that the PDU Specific segment functions as a group extension. In this scenario there is no destination address. The message will be transmitted to all network nodes. The PDU Format and PDU Specific together form a 16 bit value that corresponds to the Parameter Group Number (PGN). In the case mentioned, where the PDU Format is 2 it is referred to as a PGN.

How certain PGNs are depicted in the absence of address data required? According to the specification in cases '00' replaces the address information in order to extend the PGN. Therefore;

If the portion in PDU format includes '0xEE' then the corresponding PGN would be '0xEE00'.

This approach defines a range, for PGNs as depicted in the "PGN Value Range" graphic.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g4xdnbv80x8aqefsq08r.png)

The PGN includes two bits called "Data Page" and "Extended Data Page," which can be moreover counted because the essential info. Consequently, the sort of numbers is divided into four PGN pages. Only 3 of them are applied in J1939.

The general number of PGNs may be decided as follows: (240 (+ (16x 256)) x 3).

Here are the available definitions, for each data page;

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hjdyp96khc0c7c2k5u23.png)


**Here's an example of a Group of Global Parameters**
Below is a PGN that represents parameter groups in the J1939 standard, commonly used in the industry.

Global PGN;

PGN 65262 | Engine Temperature | ET1

Transmission Rate; 1 second
Data Length; 8 bytes
Data Page; 0
Extended Data Page; 0
PDU Format; 254
PDU Specific; 238
PGN Supporting Information; Optional (if 
Default Priority; Priority level 6
Parameter Group Number; 65262 ( representation. 0x00FEEE)
Start Position  Length  Parameter Name   SPN
1        1 byte  Engine Coolant Temperature  SPN 110
2        1 byte  Engine Fuel Temperature 1 , SPN 174
3 4       2 bytes  Engine Oil Temperature   SPN 175 
5 6       2 bytes  Engine Turbocharger Oil Temperature  SPN 176 
7        1 byte  Engine Intercooler Temperature    SPN 52
Please observe that every one the parameter businesses mentioned in the J1939 71 document were consolidated right into a table called J1939 DA.

Lets check an instance collection of parameters;

PGN 54528 also called Time/Date Adjust or TDA follows the representation of parameter organizations mentioned within the J1939 popular.

Here are the details of this PGN;

Transmission Rate; As wanted

Date Length; 8

Data Page; 0

Extended Data Page; 0

PDU Format; 213

PDU Specific; DA

PGN Supporting Information; Please talk to Appendix D, PGN 65254.

Default Priority; 6

Parameter Group Number; 54528 (0x00D500)

Lets spotlight some parameters regarding time and date adjustment;

- Adjust seconds; Utilize this parameter to exchange the seconds value.
- Adjust mins; Modify the mins price using this parameter.
- Adjust hours; This parameter allows you to make changes, to the hours.
- Adjust month; Use this parameter to exchange the month.
- Adjust day; Modify the day cost the use of this parameter.
- Adjust close by minute offset; Utilize this parameter to alter the minute offset.You can alter the hour offset through using this parameter. 

Below are some key Parameter Groups (PGNs) and their descriptions as said in record J1939 80-one.

1. Address Claimed (PGN 0x00EE00); This is used to pick out an ECU and come across cope with conflicts.
2. Commanded Address (PGN 0x00FED8); This network service assigns tool addresses, to ECUs.
3. Name Management (PGN 0x009300); This network provider is used to assign and modify the device call (NAME) of an ECU.

Please observe that Remote Frames aren't supported in J1939. The Request PGN refers to a CAN statistics body.
Under the J1939 21 standard there are Manufacturer definable PGNs, such, as Proprietary A with identifier 0x00EF00 and Proprietary A1 with identifier 0x01EF00. Additionally there is a PGN range of 256 PGNs defined as Proprietary B with identifiers ranging from 0x00FF00 to 0x00FFFF.

**Data Content**
In the context of J1939 not are the PGNs defined but their contents. These message contents are commonly referred to as signals, in languages. According to the J1939 specification the term used for describing the contents of a PGN is Suspect Parameter Number (SPN). An SPN essentially represents a signal ID. Can represent values, statuses or commands. SPNs are also defined for protocol information. The J1939 DA currently lists all specified SPNs in table form. An SPN is a number provided by the SAE. The position of the SPN, within a PGN is specified in the PGN description (refer to chapter (A Global Parameter Group example). When interpreting the SPN we start from the right (LSB). Move towards the left (MSB) except for data. It is possible for an SPN to be present in PGNs.

Each SPN has a format and includes the following attributes;

 **SPN**; **Suspect Parameter** **Number and Name**
 Description; Provides an explanation of an SPNs function
 Data Length; Indicates the length of data in bits or bytes
 Resolution; Describes how to convert raw values into physical values
 Data Range; Specifies valid physical value ranges
 Type; Identifies signal types, such as measured, status or application dependent signals
 PGN Reference; Refers to the PGN(s) where the specific SPN occurs

This is identified by the J1939 standard's SLOT 3 specification (The scaling, Limitation, offset, & Transfer Functions) presentation as the description, for each presented SPN.

**Value Range**
Typically when defining a SLOT (Scaling, Limit, Offset and Transfer Function) we don't use the range of values, for an SPN, as the payload. For instance lets consider an 8 bit value (28 = 256) that represents a range of 0...255 values. However Only the range 0....250 is allowed and considered data. The remaining values, in the range from 251 to 255 indicate attributes or conditions of the SPN.

To illustrate this further lets take the example of a limit switch used to represent the status of a door (OPEN/CLOSE). In this case one bit is required to convey the information. The following values have been defined:

00. OPEN
01. CLOSE
10. ERROR
11. SNA (Signal Not Available)

This technique permits us to discover sensor malfunctions or cable breaks and decrease the risk of misinterpretation. The SNA signal status is utilized when an equivalent variation of the device does not support a signal. Refer to Table 1 for a representation of Table 2 shows the ASCII values. for measured discrete values and Table 3 for discrete commands.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jtzgn5bbdjgwu39oz4cf.png)

As a rule if every bit in an SPN is configured to '1' it signifies an SNA status.

In the article we will continue exploring this [topic](https://dev.to/arvind_b_n_luxoft/understanding-j1939-sae-protocol-the-complete-guide-to-communication-in-commercial-vehicles-part-4-4mi) with examples.

Thank you for taking the time to read this.