According to the layered structure of the SAEJ1939 protocol, taking the control and communication protocols of trucks and buses as examples, the principle content and fault diagnosis methods of several layers are briefly introduced.
- Physical layer
The physical layer of SAEJ1939 describes the mechanical, electrical and electrical signal characteristics and functions of the network transmission physical medium and interface hardware. The definition and function of the physical layer are usually implemented by CAN hardware.
The SAEJl939 physical layer specifies the following main contents.
(1) The maximum number of ECUs on a specific network segment is 30.
(2) The transmission rate is 250kb/s.
(3) The maximum transmission line length of the network bus layout is 40m.
(4) The network adopts shielded twisted pair, the impedance is 120Ω, and the current is driven symmetrically.
(5) Both the left and right bus terminal resistances are 120Ω.
(6) The bus voltage and differential voltage, resistance, capacitance and other parameters.
(7) The bit time, internal delay time and timing request of the bus.
(8) The connection mode of the bus and the parameters of the connector.
1) Wiring layout of the bus
The wiring layout of the SAEJ1939 network should be as close to the linear structure as possible to avoid cable radiation, and two left and right terminal resistors should be used to avoid signal reflection, as shown in Figure 1. Typically, ECU nodes are connected to the backbone cable using short cables. To minimize standing waves, nodes on the network should not be equally spaced and connecting cables should not be exactly the same length. The network size and termination resistance requirements are shown in Table 1.
2) The bus transmits the physical medium
The physical medium generally used in the SAEJ1939 network is a shielded twisted pair, and the communication connection consists of a CANH and a CANL. CANH should be yellow and CAN_L green. The network has special provisions on the characteristics of twisted pair, and its parameters are shown in Table 2.
3) CAN communication reference circuit
The SAEJ1939 provides a recommended reference circuit for Class 3 compliance (Figure 2). Among them, the most commonly used solutions using SMD components and integrated chips are shown in Figure 2.
U1 is an integrated chip, and capacitor C1 is the power supply decoupling capacitor of U1, usually 0.01~0.1μF. Resistor R1 determines the slope of the transmitted signal. U1’s 5-pin VREF output voltage is about VCC/2. L1 is connected to the bus to reduce high frequency switching noise. The device can reduce the radiation interference in the range of 10kHz~200MHz, especially the radiation in the range below 30MHz. However, this component is not required by the SAEJ1939-11 document and may not be used in the application.
- Data link layer
The SAEJ1939 data link layer is to provide stable and reliable data transmission services on the physical layer . The data link layer of SAEJ1939 is based on CAN2.0B. It further defines the grouping of the 29-bit identifier of the CAN extended frame in detail, and uses the original CAN media access sublayer and physical layer protocol for data communication. The data link layer of SAE J1939 mainly describes the data structure, encoding rules, transmission methods and other contents of the information frame. The data flow control in SAE J1939 communication is implemented in a unified message frame format.
The SAEJ1939 protocol runs on the CAN network, and its message format needs to adapt to the requirements of the CAN network. The message format is basically the same as the CAN specification (V2.0B), but there are differences. It should be pointed out that when there is a difference between the CAN specification (V2.0) and SAEJ1939, refer to SAEJ1939 for implementation.
The CAN documentation specifies that node addresses are not used in message routing. The node address is specified in the SAEJ1939 network definition, and is used to prevent multiple nodes from using the same CAN network identifier field through node address management.
In addition, many of the new provisions of the SAEJ1939 protocol are not stipulated in the CAN network.
SAEJ1939 only selects the extended frame format to fully define the standardized communication rules. Therefore, SAEJ1939 devices must use the extended frame format. Standard frame format messages can exist in the network, but only in a defined manner.
It should be noted that the standard frame device does not respond to network management messages and does not support SAEJ1939 standardized communications.
1) SAEJ1939 message frame format (CAN specification (V2.0B) extended frame format) As mentioned above, the SAEJ1939 protocol runs on the CAN network, and the CAN data frame format is shown in Figure 3.
The numbers and function definitions in the arbitration field and control field of CAN standard frame and extended frame are different.
The SAEJ1939 protocol uses protocol data units (PDUs) to define specific messages. A PDU usually contains 7 predefined fields, including priority, reserved bits, data page, PDU format, specific PDU, source address, and data fields, as shown in Figure 4. The specific definition of each field is shown in the following section.
The PDU of SAEJ1939 will be packetized and encapsulated in CAN data frames during communication, and transmitted to other network nodes through the physical medium. It should be noted that when the node based on the SAEJ1939 protocol is applied, the user only needs to define the 29-bit identifier, while the SOF bit filling is implemented by hardware, and the SRR and IDE bit filling is implemented by the user program. In the CAN network, usually a message is only contained in a data frame, and a CAN extension frame can also contain a single PDU. However, some parameter groups (PG) definitions in SAEJ1939 require the use of more than one CAN data frame to send information. At this point, one PDU may require multiple CAN data frames for packet encapsulation.
2) Protocol data unit
The SAEJ1939 protocol data unit consists of 7 parts, namely priority, reserved bits, data page, PDU format, special PDU (can be used as destination address, group extension or dedicated), source address and data field, see Figure 4. PDUs will be grouped and encapsulated in one or more CAN data frames and transmitted to other network devices through the physical medium.
Some fields of CAN data frames are not defined in the PDU, because they are completely determined by the CAN specification (V2.0) and are not visible to layers above the OSI data link layer. PDU includes SOF, SRR, IDE, RTR and control field part, CRC field, ACK field and EOF field. These fields are defined by the CAN protocol and cannot be modified by SAEJ1939.
(1) Priority (P). The 3-bit priority is used to adjust the message transmission delay. This part has nothing to do with the data content and can be ignored by the receiving device. The priority of messages can be set from a maximum of 0 (000b) to a minimum of 7
(11lb) of any of the 8 classes. Usually all control messages have a default priority of 3 (011b), and other messages such as private, request and reply messages have a default priority of 6 (110b). The specific priority can be raised or lowered again when a new parameter group number is defined or the traffic on the bus changes. When messages are added to the application layer, a recommended priority will be given. Consider the original equipment manufacturer (OEM)
The network should be able to be adjusted accordingly, and the priority fields should be reprogrammable.
(2) Reserved bit (R). SAE reserves this bit for future development. This bit should not be confused with the CAN reserved bit. All messages shall have the SAE reserved bit 0 in transmission, which is the content of the parameter group numbers (PGN). New definitions in the future may extend the PDU format field, define new PDU formats, extend the priority segment or increase the address space. At present, some applications have defined it as an extended page position.
(3) Data Page (DP). The data page bit is used to indicate the page number of the PGN, and this bit is the content of the PGN. When this bit is 0, it means that the corresponding PGN is allocated to page 0. When this bit is 1, it is allocated to page 1. Generally, PGN is allocated to page 0 first.
(4) PDU format (PF). The PDU format is used to determine the format of a PDU, with a total of 8 bits, and is also a field for determining the parameter group number corresponding to the data field. The SAEJ1939 protocol specifies two types of PDU formats, one is the PDU1 format used for specific destination address communication, and the other is the PDU2 format used for broadcast communication. The identification rules of the two formats are: PF<240 is PDU1 format, PF=240~255 is PDU2 format.
(5) Specific PDU (PS). PS is also an 8-bit field, and its definition depends on the PDU format. When the PDU1 format is PF~240, the content of the PS is the target address; when the PDU2 format is PF=240~255, the content of the PS is the group extension value.
The destination address defines the address of the specific destination that this message needs to be sent to. It is usually used for addressing in point-to-point communication mode. Special attention is that 255 is defined as the global destination address. The global destination address (255) requires all devices Listen and respond as a message responder. As part of the PGN, the group extension (GE) value is usually used for the identifier of broadcast packets. The use of the group extension value can greatly increase the parameter group number.
(6) Source address (SA). The source address field is an 8-bit field. A source address in the network can match only one device. Therefore, the source address field can ensure the uniqueness of CAN identifiers. Address management and assignment are detailed in SAEJ1939-81. The processing is defined in SAEJ1939-81 to prevent duplication of source addresses.
In SAEJ1939, source addresses can be assigned by sequentially numbering, regardless of message priority, update speed, or importance, but the number of unassigned addresses is limited, so new addresses must be assigned efficiently. In the entire system, the maximum number of addresses that can be allocated cannot exceed 256. Therefore, the new address definition must be limited to the important functions in the vehicle, such as the engine, transmission system, braking system, fuel system and other important functions for which addresses are currently defined. Other functions that require address assignment in the standard should have a scope similar to the functions currently defined for addresses, and they should be useful to most users of SAEJ1939.
Some devices may use the dynamic addressing scheme that is already in use. In this case, the dynamic address can be set by the service tool and/or can be assigned when the network is powered up. In particular, it is important to pre-empt the fact that not all network devices support this mode of operation when using a dynamic addressing scheme.
(7) Data field. When representing a given parameter group with no more than 8 bytes of data, all 8 bytes of the CAN data frame can be used. In general, it is recommended that 8 bytes be allocated or reserved for possible future expansion of parameter group number allocations. When a specific parameter group is represented by data with a length from 9 to 1785 bytes, data communication is achieved through multiple CAN data frames. If a particular parameter group transfers 9 or more bytes, the “Transport Protocol Function” will be used. Communication of sets of parameters is established and stopped through the connection management capability of the transport protocol function.
In CAN-based systems, the shortest messages also require the full use of the data field (all 8 bytes). Unless it is in the case of a very urgent message to transmit time, generally, the relevant parameters should be combined to occupy a data field of 8 bytes. Following this principle, parameter group numbers can be saved for later assignment. Unless there is a special need, it is generally not allowed to define parameter groups that do not fully utilize the length of the data field.
3) Parameter group number and protocol data unit format
(1) Parameter group number. The SAEJ1939 protocol classifies the parameters involved in traditional automobiles and assigns them to 8-bit data fields in different frames. Then, for different frames, the SAEJ1939 protocol uses parameter group numbers to identify these allocated data frames, and different parameter group numbers correspond to different vehicle parameters.
The parameter group number is a 24-bit value formed by numbering the parameter group represented by the data in the frame data field. The default value of the first 6 bits of PGN is 0, and the following bits include reserved bits (1 bit), data Page bit (1 bit), PDU format field bit (8 bits), PDU specific field bit (8 bits).
The value of PGN is related to the PDU format. When the value of the PF field is less than 240, the PF field in the PDU encoding adopts the PDU1 format, and the PS is the destination address. In the PGN encoding, the PF field adopts the PDU1 format, and the PS field is assigned a value of 0; when the value of the PF field is greater than 240, the PF field in the PDU encoding is used. The field adopts PDU2 format, PS is group extension, PF field in PGN coding adopts PDU1 format, and PS is also group extension.
In SAEJ1939, the specification document for the application layer, SAEJ1939-71, describes in detail the assigned parameter group numbers and the data meanings of the corresponding data fields. The meaning represented by the data of the corresponding data bit can be found according to the parameter group number in the identifier. For example, if the identifier is 0x0CF00400, and the PGN parameter group number is 61444 (00F00416), by querying PGN in SAEJ1939-71, the meaning of the corresponding 8-bit data can be queried.
(2) PDU format. The SAEJ1939 protocol defines two PDU formats: PDU1 format (PS is the destination address) and PDU2 format (PS is the group extension). The PDU1 format allows data to be directed to a specific destination address (device):
The PDU2 format is only used for the transmission of CAN data frames without a specific destination address (device). ①PDU1 format. The PDU1 format allows applicable parameter groups to be sent to a specific address or to a global address. The specific PDU (PS) field contains the destination address (DA). Messages in PDU1 format can be requested, or sent on an unsolicited basis. Messages in PDU1 format are determined by the PDU Format (PF) segment. When the value of the PDU Format Field (PF) is between 0 and 239, the message is in PDU1 format. ②PDU2 format. The PDU2 format can only be used in parameter group communication as a global message. Messages in PDU2 format can be requested or sent unsolicited. Choosing the PDU2 format (while assigning the PGN) avoids the PGN being directed to a specific destination. Certain PDUs contain Group Extensions (GE). A message in PDU2 format refers to a message with a PDU Format (PF) value between 240 and 255.
Two different PDU formats are defined in order to provide more combinations of parameter group numbers (PGNs) in communication to meet different communication needs of many parameter groups. Since the PF field that determines the PDU format is a part of the parameter group number PGN, the process of assigning the PGN to the parameter group is also the process of selecting the PDU format. That is to say, once the PDU format is selected for the parameter group, it means that it can only be allocated to the corresponding PGN.
Parameter sets are allocated exclusively using the PDU1 or PDU2 format. Once a parameter group is assigned one of the formats, the other format cannot be assigned to that parameter group. When a parameter group needs to be sent to a specified destination address, the PDU1 format must be used. Otherwise, the parameter group number should be chosen without the destination address so that any device can get the parameters in the message. The following characteristics should be included when assigning a parameter group: priority, update rate, importance of the packet to other network devices, and length of data associated with the parameter group. To assist in this assignment process, the protocol provides a template for assigning parameter group numbers, as shown in Table 3, where the Priority 1 column sets the default value for the priority level of each PGN. If necessary, OEMs can design different priorities for each PGN value to accomplish network tuning. Although any PGN can be requested, the author strongly discourages PGN allocation requests for messages that have been defined for periodic broadcast. At the same time, the definition for the dedicated parameter group has been given (PF=239 or 255), so that both PDU formats can be used in dedicated communication. To prevent identifier collisions, SAE has established standardized methods in dedicated communications.
The PGN allocation rules for PDU1 are as follows: the parameter group that needs to specify the destination and the minimum delay (PDU1) PF starts to increase from 0 to x (or x1), see Table 3; the parameter group that needs to specify the destination but does not emphasize the delay is from PF to 238 starts decrementing towards x (or x1), see Table 3. A PF of 239 (reserved bits 0, data pages 0) is reserved for private use. In this case, the specific PDU (PS) is the target address. The PGN value of dedicated A is 61184 or 00EF0OH.
It should be noted that the value of PS in the PGN in the PDU1 format is set to 0, so the number of PGNs in the PDU1 format is only 2×240-480.
The PGN allocation rules for PDU2 are as follows: the parameter group number of messages transmitted at high speed (usually less than 100ms) is incremented from PF 240 to y (or y1); only when requested, when there is a change, or at a low update frequency ( The parameter group number of messages transmitted with an interval greater than 100ms usually starts with a PF value of 254 and decreases to y (or y1), see Table 3. A PF of 255 (reserved bits 0, data pages 0) is reserved for private use. In this case, specific PDU segments are left for manufacturer-defined use. The PGN value of dedicated B is 65280~65535, that is, 00FF00~00FFFF.
Since the PS value can be set from 0 to 255, the number of PGNs in the PDU2 format is 2×16×256-8192. Therefore, the number of PGNs in the two formats of PDU1 and PDU2 available in the parameter group is 480+8192-8672. According to the criteria required by the parameter group number request form, the parameter group numbers are sequentially assigned to each area in Table 3 (it should be noted that when the repetition rate is greater than or equal to 10 times/s, multiple groups of messages are not allowed), while The number of parameter sets available that have not been assigned in SAEJ1939 is also rather limited compared to the large number of parameter sets required for highway trucks and other applications. The components that make up SAEJ1939 do not require extensive parameter sets. There are three main communication methods in SAEJ1939. Appropriate use of various types of communication methods can effectively use the existing parameter group numbers. The three communication methods are as follows: ① PDU1 format (PS = destination address that allows specifying destination communication) standard communication; ② PDU2 format communication (PS = group extension) standard communication: ③ dedicated communication using two predefined dedicated parameter group numbers .
When preparing the parameter set, the use of the dedicated communication method and the PDU2 format should be considered in turn. If the communication of private information is to be performed, the private communication method should be used. If the message has broad impact and there is no need to designate the message to be sent to a specific node, then allocation in PDU2 format should be considered. Finally, if the message has broad impact, but needs to be specified to be sent to one of many devices, then the parameter group needs to be assigned with a specified destination address and PDU1 format.
4) Message Type
The SAEJ1939 protocol currently supports five types of messages, namely command, request, broadcast/response, confirmation and group extension. A message type is identified by its assigned parameter group number. It is important to note that the request message defined here is different from the remote request frame defined in CAN, and the RTR bit (defined in the CAN protocol remote frame) is not available in the recessive state (logic 1). Therefore, remote transfer requests (RTR=1) are not applicable in SAEJ1939.
For multi-byte parameters appearing in the data field of the CAN data frame, they should be stored in the lowest byte first. Special instructions (such as ASCII data) are given for special cases. Therefore, if a 2-byte parameter is to be stored in bytes 7 and 8 of the CAN data frame, the LSB should be placed in byte 7 and the MSB in byte 8.
(1) Command. This message type includes parameter groups that command a specific destination or a global destination from a source address, and the destination should take a specific action after receiving a message of the command type. Both PDU1 format (PS is the destination address) and PDU2 format (PS is the group extension) can be used as commands. Command type messages may include drive control, address request, torque/speed control, etc.
(2) REQUEST. The request message type specifies the capability to request information from a global scope or from a specific destination. A request for a destination address is called a destination specification request. The following is an example of a request message whose function definition is to request a PGN to a specific destination. This information is in the same format as the parameter group specified in SAEJ1939/71.
An example of a request message is as follows.
Parameter group name: request PGN
Definition: Request a parameter group from a network device
Repeat transmission rate: user-defined, recommended no more than 2 or 3 requests per second
Data length: 3 bytes
Data pages: 0
PDU format: 234
Specific PDU Segment: Destination Address
Default priority: 6
Parameter group number: 59904 (00EA0016)
Byte: 1~3 Requested parameter group number
(3) Broadcast/Response. This message type may be a message broadcast unsolicited by a device, or it may be a response to a command or request.
(4) Confirmation. There are only two possible forms of confirmation. The first is specified by the CAN protocol and consists of an “in-frame” acknowledgment that a message has been received by at least one node. In addition, if there is no CAN error frame, the message will be further acknowledged, and no error frame means that all other devices that are turned on and connected to the bus have received the message correctly. The second form of acknowledgment is specified by the application layer and is a “normal broadcast” “ACK” or “NACK” response to a specific command, request.
An example of a confirmation message is as follows.
Parameter group number: Confirm
Definition: used to provide a handshake mechanism between sender and receiver
Repeat transmission rate: when receiving a PGN that requires this type of acknowledgment
Data length: 8 bytes
Data pages: 0
PDU format: 232
Specific PDU: Destination Address = Global(255)
Default priority: 6
Parameter group number: 59392 (00E80016)
Byte 1: Control byte
Byte 2: Group function value (if applicable)
Bytes 3~5: reserved for SAE allocation, set each byte to “FF16”
Bytes 6~8: parameter group number of the requested message
The data range of the parameters used by this message type is as follows.
The value of the control byte: 0~2 see the following definitions, 3~255 are reserved for SAE allocation.
Positive acknowledgment: control byte = 0, positive acknowledgment (ACK).
Negative acknowledgment: control byte = 1, negative acknowledgment (NACK).
Access Denied: Control byte = 2, access denied (PGN supported but denied).
Group function value: 0~250 can be used to make a specific definition for each PGN; 251~255 follow SAEJ1939-71
(5) Group function. This message type is used for a group of special functions (eg dedicated functions, network management functions, multi-group transport functions, etc.), and each group function is identified by its PGN. The function itself is defined in the data structure (usually in the first byte of the data field).
An example of a group function message for a dedicated function is as follows:
Parameter group name: Private B
Definition: Private PGs use PDU2 format messages to allow manufacturers to define PS (GE) segment content on demand. However, it should be used within the constraints of avoiding making private information more than 2% of the total network information. The use of message data fields and PS (GE) is determined by the manufacturer. The message data length is defined by the manufacturer. Therefore, for transmission, two manufacturers may use the same GE value with different data length codes. The information responder has to distinguish between the two.
Repeat transmission rate: user defined
Data length: 0~1785 bytes (support multiple groups)
Data pages: 0
PDU format: 255
Specific PDU: Group Extension (manufacturer assigned)
Default priority: 6
Parameter group number: 65280~65535 (00FF0016~00FFFF16)
Bytes: 1~8 (manufacturer specific)
- Network layer
The main function of the network layer is to transmit messages from one network segment to another, and this function is mainly implemented by the network interconnection electronic control unit. The network layer of SAEJ1939 specifies the functions of interconnecting electronic devices between different network segments on the vehicle, and defines various types of network interconnection electronic control units and their functions.
1) Function definition of network layer (network interconnection electronic control unit)
From a communication perspective alone, the main functions of the network layer include message forwarding, message filtering, address translation, and message re-encapsulation. The functionality of the network layer should be completely transparent to other units on the vehicle when the system works.
Message forwarding refers to the service that the network interconnection electronic control unit transmits independent message frames between two or more ports (each port corresponds to a network segment). The order in which message frames are received by one port and transmitted to another port is determined by their current priority. The network interconnection ECU shall forward any higher priority messages in the queue before lower priority messages. This rule does not allow queues to exist in a simple first-in-first-out (FIFO) manner.
There are two main filter service modes for message filtering: blocking mode and delivery mode. By default, in blocking filtering mode (mode 0), the network interconnection ECU forwards all messages. If necessary, the identifier record (PGN value) of the message that should not be forwarded (the message should be blocked) can be added to the filtering database in the network interconnection electronic control unit. This mode can be used to reduce bus traffic in the current network segment and is the recommended mode of use for SAEJ1939 bridges. The records in the filter database should be entered at the time of initial vehicle build/configuration and kept in persistent memory. By default, in the pass-through filtering mode (mode 1), the network interconnection ECU does not forward any messages. The identifier of each forwarded message must match the specific identifier (PGN value) currently recorded in the database. This filtering mode is best applied between network segments that implement special functions (such as braking, suspension, etc.) on the network interconnection ECU. The address translation function can provide address translation services for special messages. This feature allows the use of an address to represent a specific vehicle system (such as a trailer or unit) without knowing the detailed address of a particular function of the vehicle system (such as lights).
The service needs to have a database where the source or destination address can be determined by querying the data table.
The message re-encapsulation function, that is, in the process of transmitting a message from one network segment to another network segment, can provide a message re-encapsulation service. This function can realize the conversion between different network protocols.
2) Network interconnection electronic control unit and function definition
Network interconnection electronic control units can be divided into four types according to their functions: repeaters, bridges, routers and gateways.
(1) Repeater: The main function is to forward messages between two bus segments with the same transmission rate, and all messages will be forwarded. Repeaters can play a role in enhancing data signals and making data transmission longer distances. Different propagation media can be used between network segments connected by repeaters.
(2) Bridge; its main function is to forward and filter messages between network segments. Filtering is accomplished by storing, filtering, and then forwarding messages at the data link layer of the network. Through the filtering function, the bridge can effectively reduce the current bus traffic of each network segment. Network segments interconnected by bridges can use different data bit rates and media.
(3) Router: In addition to all the functions that a bridge can achieve, it can also provide the function of re-addressing (message routing). This feature allows other parts of the vehicle network to use an address to represent the current subnet. Routers allow separate address spaces between interconnected network segments.
(4) Gateway: In addition to realizing all the functions that routers can achieve, it can also realize the conversion between different protocol data through data re-encapsulation.