J1939 decoder
by Ben Martins

Thanks to the software team at Pico, the improvements to PicoScope 7 Automotive continue. I want to share a new feature that was included in build 7.0.73.8350, a serial decoder made specifically for the CAN protocol J1939.

 As PicoScope 7 Automotive's other serial decoding tools, the CAN J1939 serial decoder converts CAN bus voltages to a readable form (typically hexadecimal, but binary, decimal, or ASCII formats are also possible). The J1939 decoder is, however, built for decoding J1939 CAN protocol messages and specifically the ID.

 What makes J1939 deserve its own decoder comes down to how the ID is formed and the amount of information included in it. To begin with, we need to understand how the message ID of a J1939 message is made up. The message header, ID, contains 29 bits, which when translated into hex gives us 4 bytes. These 4 bytes hold key information about the data contained within the CAN message payload. This ID can be broken down into three sections, Priority, Parameter Group Number (PGN), and the source address.

 The PGN gives you a reference to the SAE J1939 standard’s Suspect Parameter Numbers (SPNs), where you can look up how to locate and scale/offset the data in the message payload. This is particularly useful if you need to check whether the data is valid but have no other way to access it. The important part, though, is to find the PGN in the header. You do this by taking the two middle bytes in the ID as decoded from Pico, for example – 0C F0 04 00. The two middle ones, F0 04, are the important ones here. Next, you convert F004 into a decimal. By using a programmer calculator in Windows, we get the number 61444. A quick search through the SAE standards for PGN 61444 confirms that this is for the Electronic Engine Controller 1. Therefore, we can be confident that 0C F0 04 00 represented the Engine ECU or EEC1.

Diagnostically speaking, the Source Address can be even more useful. By using the global Source Address ID list in the SAE J1939-DA document, it is possible to create a data-to-text description file and then selecting it in the decoder. The decoding table can display the descriptions of all the CAN controllers communicating on a network. This can tell you exactly which controllers are online, offline, or might be causing network issues.

In addition to the CAN message parts that can be returned by a CAN serial decoder, the CAN J1939 serial decoder fully decodes the message identifier (ID) and splits it into the three constituent parts: the Priority, Parameter Group Number (PGN) and Source Address. When a suitable data-to-text file (relating the ID values to their descriptions) is supplied and selected, full-text descriptions of the PGN and Source Address will be displayed in the decoding table.
 

In the image above, you can see the clear difference between the conventional CAN decoder (1) and the J1939 decoder (2).
 
As I mentioned above, we can use the Data to Text or Link file function within the decoder to convert the decoded values into a readable format. To create a Link file, we must first create a template. On the decode table, click Data to Text and select Create template. You will then be asked to save a file to a location on the computer. My advice is to pick somewhere you can easily find. Once saved, locate this file and open it with software that can open CSV files, for example, Excel.
 

This CSV file functions as a lookup table. Each column in the decode table now has another column labelled with a description. I’ve highlighted the boxes of interest for visibility.
 
Here we can take the values we see in the J1939 decoded table and give them a description. If you search on the internet, there are free resources that contain PGN’s and source address IDs. We have written more in-depth about PGNs and Source address in this forum post. If you want the full PGN list, you need to purchase it from the SAE.
 
I’ll demonstrate a common ID: Engine Controller 1. We have already learned that Engine Controller 1 has the PGN 61444, which converted to hex results in F004. Our decoder splits the values into hex bytes, which means that F004 becomes F0 04. We can now insert our first ID into the Link file under the headings ID2 PGN and ID2 PGN Description.
 

For the source address description, all the IDs can be found on the ISOBUS Data dictionary website. This site does refer to the source address in decimal format. For the lookup table to work, you will need to convert the decimal back into hex. Windows calculator has a handy programmer option that can handle this easily. One thing to bear in mind is that the source address ID can change depending on the industry type. This could be industrial, on and off-highway, marine, etc. The nice thing about the Link files is that you can create separate ones for each industry you are interested in.
 
There are some common source addresses between all the different sectors and an easy example is ‘0’ for Engine #1. As with the PGN, this is in a decimal form which when converted to hex will appear as ‘00’ on the J1939 decode table in PicoScope 7. Excel doesn’t like leading zeros, which means that for any single-numbered source address ID, we have to convert them to text. This is easily done in Excel by highlighting the cell, or cells, right-click on the mouse and select format cells.
 

In the Format Cells dialogue box, click Custom and select ‘0’ from the list. In the marked box, type in another ‘0’ so the sample shows ‘00’ to add a leading zero. Click OK and then the cell or cells should now include a leading 0 which will match the decode table. Once completed the example Link file now appears like this.

Save this file and then close Excel. The link file feature with PicoScope will not function if the file is being used by another program.
 
Back in PicoScope 7 Automotive, with the decode table still active, click Data to text and then click Open. Use the file explorer to navigate to where the link file is saved and then select Open. PicoScope 7 Automotive will then apply the link file to the decode table. You can now see the data in a readable format for us.
 

GIF showing the steps to open the edited CSV file in PicoScope 7 Automotive so that you can see the data in a format you can read.

The link file would not be this easily made had it not been for the PicoScope 7 software team spending time creating the J1939 decoder. Much thanks to them as I feel this will help when dealing with J1939 issues where the scan tool has to go through a gateway if there is an issue, such as bus overload.

Comments

Add comment

Neil Davy
August 17 2021 - 8:03:27

Awesome work!

Your email address will not be published. Required fields are marked *