J1939 DBC file discussion
The CAN Basics Training Course provides a practical approach to understanding how CAN works. By giving real world examples, common practices, and an in-depth look at DBC files, Bryan Hennessy gives a real-world walkthrough of CAN.
Presentation by Bryan Hennessy. Recorded as part of a โliveโ training session in January 2019.
Video Transcript:
Bryan Hennessy: [00:00:05] Itโs an example, an arbitrary example, I think originally pulled from the Internet somewhere, of transport protocol. In the case of automotive work, you sometimes want to be able to send the Vehicle Identification Number on the CAN bus. Vehicle Identification Number is more than eight bytes, so how are we going to send that? CAN frame will only send eight bytes of data. Well, weโre going to send it in four different bytes. Iโm going to give a real world example of this that I had actually pulled off of a truck, but this will go through some of the concepts here. So, thereโs a lot of overhead associated with transport protocol. Overhead is 11 bytes in order to send 21 bytes of data. So thereโs 11 bytes at overhead. Thatโs a lot of overhead. So you lose some efficiency in transport protocol. In this diagram, I have the 11 bytes of overhead, highlighted in red. So those are just overhead. The data, in this case, [00:01:05] just 1, 2, 3, up to hexadecimal number 11, I have just used a counter here. So weโre sending this four different CAN frames.
So, at least in J1939 transport protocol, priority for every one of these frames is seven. Itโs the lowest priority, and thatโs just part of the definition, and itโs a disadvantage of transport protocol in J1939, because if you got a high priority message thatโs over 8 bytes, you donโt have any options, you just send it as priority seven. NMEA 2000 fixed that. You can prioritize within the transport layer.
Total of four frames in order to transmit, again, 21 bytes of data, thatโs a lot of overhead. This particular example is the Vehicle Identification Number PGN 65260. [00:02:05] This is a hex conversion of the PGN, the PGN number in transport protocol is actually varied within the first byte of that transport protocol, so the PGN is right here, FEEC. Remember, you got to reverse some, the INTA [sic], motor, all the thing? Yes, itโs going to haunt us.
Iโll go through all of this, but your VIN ends with an asterisk, so you know it ended, and thatโs just transferred into an ASCII number.
Yes, the PGN identifier is buried within the data. This is a PGN number. By J1939 standard, this is actually a PGN. Defined it as a PGN.
So the PGN 60160 is actually the data to transfer and it contains [00:03:05] the actual data payload, so the data payload is just another way of saying the data. So the transport protocol on J1939 only uses two different PGN numbers. Two different PGNs. The first one is the control PGN, that says hey, I got a transport protocol message, Iโm going to send it. It consists of this number of bytes of data, Iโm going to send it in this many frames. This is the PGN thatโs going to be buried within it. Here it comes.
The spec also says that you got to send them 50 milliseconds apart, minimum. Because the theory is that devices receiving it have to crunch it and process it, so you canโt be sending them back to back, because there maybe eight bit processors trying to receive it and they canโt move that fast. So the spec says yes, you got to wait 50 milliseconds between each frame transmission.
So these are the basics of J1939 transport protocol there.
Letโs look a real world example. I donโt want to spend too much time on a fictitious example. [00:04:05] Hereโs a real world example, so I cut this out of a data series. I eliminated all of the data in between, because if you look at this, thereโs a lot of time in there, from a computer standpoint. Thereโs a heck of a lot of time in there. Thereโs actually 70 milliseconds between that message and that one, so if this is running at 250K, there could be 140 messages in between. So I cut them out. I got them out. Iโm only showing whatโs relevant to my transport protocol. But itโs important to realize that these messages are pulled out of a very large dataset that was collected.
This is a request message. I told you this, that most of the J1939 PGNs are eight data bytes. Well, this is the request message that I set I was going to show you, thatโs actually three data bytes. So itโs only three data bytes long. In the advanced course that I showed, that specific that I called J1939 Fundamentals, [00:05:05] we can go on and take every single bit apart and show you what everything means here. Iโm not going to do it in this course because itโs a little bit too lengthy a time, but I will say that itโs only three data bytes. This is the 29-bit header. 1, 2, 3, 4, 5, 6, 7, 8 x 4, thatโs for per character, itโs 32, but remember, I said this one can only be 1 or 0. Youโll never see that on the left, so thatโs 29-bit header, and three data bytes here, and down here, eight data bytes. So how do we take this apart? So this particular device tells you how many bytes are in your frame, so thereโs 7 and then thereโs 12, and each one of these. Iโve highlighted all of the overhead and Iโve left the actual VIN as white here.
This particular tool reassembles this PGN, FEEC PGN, [00:06:05] which is a transport PGN. It reassembles it. It says this is a J1939 PGN that I have reassembled at this time, which happens to exactly matched the time it received the last frame. It couldnโt reassemble it before it received that frame, because it didnโt have all the information. So Iโve reassembled this VIN based on these frames, at this time, and itโs now 22 characters long, and here it is, and this is an actual VIN of a truck I worked on at PACCAR. If you take these as ASCII numbers โ and we know ASCII but ASCII is a standard that allows you to send characters via hex data โ if you take these numbers, I think thatโs an A, I think, and 41 is an A; I canโt remember what 31 is. I think itโs the number one. Each one of these represents a character, and if you decipher that, [00:07:05] you have the VIN. When you look at under the windshield, it better match the VIN thatโs on the truck, because thatโs the purpose. So thatโs transport protocol in a nutshell. Itโs a perfect example of why you need it and how you do it.
Again, itโs not going to be used. I had a dotted line in that one drawing. Itโs not going to be used if youโre just transmitting eight-byte PGNs. But in this case, weโre transmitting a 21-byte PGN.
Question?
Unidentified Man: Can you have [inaudible 00:07:33] in the DBC file?
Bryan Hennessy: Well, I havenโt done that. I havenโt set up an example. Iโd have to look at our DBC file editor and see if it supports transport protocol. I donโt think it does. I donโt think ours does, but in a DBC file in generalโฆ
Unidentified Man: So you canโt go and have 64 bits and signal that?
Bryan Hennessy: Itโs a good question. [00:08:05] How do you do that? I need to look at that. Itโs a good question.
Unidentified Man: Itโs what the J1939 is going to do. Youโre taking your free messages and youโre piecing it together to 22 bytes.
Unidentified Man: How does DBC file know that?
Bryan Hennessy: Well, the J1939-73 specification defines what we called diagnostic messages, and the -71 defines all PGNs, but it doesnโt define them as a byte PGNs. It defines them as whatever they need to be, and it relies on the transport layer to take them apart. But itโs a great question, as to how thatโs represented in the DBC file, because I donโt know that. Iโll check that out. We might be able to pull up a DBC file editor and just take a look at that. Iโd like to have that answer. Thanks for asking.