Site Information

 Loading... Please wait...

Blog

SAE J1939 Programming with Arduino - Receiving and Responding to J1939 Request Frames

Posted by Wilfried Voss on

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino.

SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino

In this following project, we will discover yet another SAE J1939 protocol feature, namely the Request Message (as defined in the SAE J1939/21 standard). As with the previous project, we will need two J1939 nodes, and therefore will need two projects, one to receive the request and response, the second to send the request and receive the response.

But first, let’s have a look at the Request Message: This message type, which is represented by a dedicated PGN, provides the means to request information globally (broadcast) or from a specific node address (peer-to-peer).

  • PGN 59904 – Request for Address Claimed Message.
    • Parameter Group Number: 0xEAxx (where xx represents the destination address, either the global address 255 for broadcasting, or the specific node address)
    • Data Length: 3 bytes
    • Data: Bytes 1, 2, 3 = PGN being requested (LSB first, MSB last)
    • Default Priority: 6

Note: The transmission/reception of a 3-byte PGN according to the SAE J1939 standard always confuses programmers that are new to J1939, specifically the sending of LSB first and MSB last, which defies common programmer’s thinking. To make things worse, there is only one small sentence within the massive 1600-page SAE J1939 Standards Collection that refers to that little, nevertheless important detail.

A node receiving the Request Message will respond with the requested PGN and its data.

For our current project we will create the following scenario: Node 0x20 (32) sends out a request for PGN 65262 (0xFFFE – Engine Temperature) to node 0x30 (48). Node 0x30 will receive the request and responds by sending the PGN.

Note: The node numbers and the requested PGN have been randomly chosen and serve only as demonstration examples. In all consequence, the method of requesting messages as shown here is not 100% J1939 compliant. One of the following projects, the J1939 Network Scanner, is a better example for the use of the Request Message.

To re-iterate the tasks at hand:

  1. Node 0x30 receives the request message and responds by sending the PGN
  2. Node 0x20 sends the request message and receives the response

To simplify the project management, I have combined the two tasks into one project and loaded it onto two separate Arduino systems. In this case both system simulate both node addresses.

The following code, an excerpt from the loop() function, explains the function of this project:

  1. As soon as we receive a J1939 message frame we display it on the serial monitor (code has been blended out).
  2. We analyze the received PGN.
  3. If the PGN is the Request Message PGN, we check the attached data for the requested PGN.
  4. If the requested PGN is for Engine Temperature we transmit the corresponding PGN.
  5. If the user sends any data through the serial monitor, we send out a request for Engine Temperature.

Note: This Arduino project is available through the download page at ARD1939 - SAE J1939 Protocol Stack for Aduino.

The following image shows the Arduino’s serial monitor after the user has sent a request message. The other Arduino node answered the request.

Note that the destination address is shown as 0xFF (255), which is the global address. As I mentioned previously, this example is not quite J1939 compatible. The destination address must be the global address, because the PGN 65262 (0xFEEE) cannot be transmitted from peer-to-peer but only as a broadcast message.

The following screen shot taken through the ADFweb CAN Bus analyzer shows the data traffic on the J1939 vehicle bus, and it confirms the functionality of the project.

Line 1

  • 0x18 indicates a message priority of 6.
  • 0xEA30 indicates a request message sent to node address 0x30.
  • 0x20 represents the address of the requesting node (source address).

Line 2:

  • 0x18 represents a message priority of 6.
  • 0xFEEE is the PGN for Engine Temperature (as requested).
  • 0x30 represents the address of the transmitting node.

A Comprehensible Guide to J1939

SAE J1939 has become the accepted industry standard and the vehicle network technology of choice for off-highway machines in applications such as construction, material handling, and forestry machines. J1939 is a higher-layer protocol based on Controller Area Network (CAN). It provides serial data communications between microprocessor systems (also called Electronic Control Units - ECU) in any kind of heavy duty vehicles. The messages exchanged between these units can be data such as vehicle road speed, torque control message from the transmission to the engine, oil temperature, and many more.

A Comprehensible Guide to J1939 is the first work on J1939 besides the SAE J1939 standards collection. It provides profound information on the J1939 message format and network management combined with a high level of readability.

Read more...