To follow along with actual data as I go through this blog, you will need to have a .dbc file available to load into CanKing, or you will need to create one. Creating a .dbc file for just a few CAN messages and signals is not that difficult with the Kvaser Database Editor 3, available free at https://www.kvaser.com/download/. Creating a .dbc file will not be covered in this blog.
Start by opening Kvaser CanKing using the 2 CAN channels template, as in the first blog of this series, then go to View and add the History List window and Times Transmission window to your desktop as before. Creating the CAN message is where most of the complexity will be, so we’ll start with the message I copied from a recent article on J1939 tools. Here is a raw message that I am going to use:
This is a message as received in CanKing, and is called the Electronic Engine Controller 1 message, identified as PGN 61444. The signal we will manipulate within this message is Engine Speed, identified as SPN 190. To do this we first need to break the message down into the Identifier and the data segments.
To show how to construct the identifier from the J1939 data above, here is a cut from the CAN Protocol Tutorial, Higher Layer Protocols, found here: https://www.kvaser.com/about-can/higher-layer-protocols/j1939-introduction/.
This is a 29-bit extended identifier, so we know the following from the information in the frame, as displayed in CanKing:
Priority = 3
Reserved Bit and Data Page = 0
PGN = 0x0F004
Source Address = 0
Combining all this information into a 29-bit identifier and displaying it in hexadecimal format gives us 0CF00400, so plug this into the CAN Identifier box in the message window, putting the small “x” at the end to indicate Extended identifier format. See the next figure below.
If you are having difficulty understanding how I came up with this hexadecimal number from the bits as displayed in CanKing, start from Source Address on the right, and work right to left. Remember that the identifier must be 29 bits, or seven nibbles plus one extra bit on the left. The Priority is what makes it difficult, because it straddles nibbles 7 and 8. A frame with a priority of 3, like this one, always starts with an 0C and has the form 0Cxxxxxx, while a frame with priority 6 has the form 18xxxxxx, and priority 7 would be 1Cxxxxxx.
Next, we know the Data Length Code (DLC) is 8, so enter this in the DLC box.
The eight data bytes are as listed in the CanKing frame above, 60 7D 84 50 14 00 F0 84, so enter these as Byte 0 through Byte 7, reading from left to right. The end-result is the CAN message window as shown below, with the identifier and the data entered, ready to be sent: