CANKing, Database Editor, advantages and limitations, software that does more from Partner companies

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:00] So weโ€™ve talked a little bit about CANKing. Iโ€™ve mentioned the Database Editor. I want to mention advantages and limitations of the Kvaser software. Kvaser is in the business of selling hardware. Our software supports are hardware. The software that we provide is software thatโ€™s pretty much necessary to play in the industry and sell hardware. You got to have drivers or the hardware doesnโ€™t work. You got to have some basic applications and things to show the hardware works. We sell Memorators, data loggers. We got to be able to configure those. We got to be able to set those up. But the real brunt of the software thatโ€™s specific for a given industry or thatโ€™s detailed for a given application, the really good software comes from our partners. Weโ€™re not in the software business. Weโ€™re supplying software that allows our partners to be in the software business and sell our hardware. Thatโ€™s the basic business model. [00:01:01] I call it software that does more from the partner companies.

So weโ€™ve talked a little about our software. We show some examples of our software here. So this is a cutout of my homemade hacked DBC file displayed via Kvaserโ€™s DBC file editor. So you have a couple of things here. Iโ€™m not going to get into every detail of it. It does a lot. But Iโ€™ll just, again, give you the gist of it. So we would define some messages out here, or some complete messages. One of my messages here is the heading message. The other message is the rate-of-turn message.

Well, weโ€™ve seen both of those frames. Weโ€™ve seen those CAN frames in real life earlier, those two CAN frames. If I had all of my goodies and I didnโ€™t have to bring my ski boots, Iโ€™d be able to show you some other stuff like system time and position rapid update messages coming out of my GPS which I left home. [00:02:00] Speed coming out of my little water sensor that can flip a little paddle wheel and you can see my water speed. A different message. Signed data, which actually comes out of a Memorator which is a t-program that I wrote to generate a message. Iโ€™ve actually got a t-program I can demonstrate you that does an ECU simulation with t-programming and generates messages that I invented. I just said, โ€œWell, Iโ€™m going to write a t-program to demonstrate that a Memorator can be used for an ECU simulator.โ€ What kind of data I want to send, well, I just pulled something out of the air and said, โ€œIโ€™ll just make a sine wave and Iโ€™ll just make a 100 sine wave and send that data via floating-point signal.โ€ So I got a package thatโ€™s floating-point signal in a CAN frame. How do I do that? Well, I just do a DBC file and package it with a DBC file. So I did that. So that would be. But again I could do that because I do have a Memorator. So I can show you that one if you want.

So down here in this block, Iโ€™ve highlighted heading here. [00:03:00] Down here this tells me, well, what signals are in the heading message. Well, the heading message, first of all DBC file editor has this little pretty window over here that just lights up what signals youโ€™ve described. Iโ€™ve put the heading message in these two bytes. Actually, I didnโ€™t. NMEA 2000 spec did. So, headingโ€™s going to be in these two bytes. Thereโ€™s something else up here in this byte, I donโ€™t know what it is. Thereโ€™s a lot more things down here in these bytes, I donโ€™t know what they are either. I donโ€™t really care because for my demonstration purposes Iโ€™m going to teach you about heading. So thereโ€™s a lot of information here but weโ€™re only going to worry about heading today.

So when you highlight heading, it tells you each signal that happens to be in heading. In the heading message it lights up down here. Inside of my heading message, I have a signal called Heading Magnetic because thatโ€™s what this is putting out, what the data is putting out, is the magnetic heading. [00:04:00] What is that signal? Well, itโ€™s an unsigned integer. This is all stuff you can figure within your DBC file to describe your message. Itโ€™s in the Intel format. But you got to go back to digital computer invention history to really get a good feel for that.

Intel and Motorola decided theyโ€™re going to transmit data differently many, many years ago, and one of them said, โ€œWeโ€™re going to send the least significant byte first.โ€ The other then said, โ€œWeโ€™re going to be different. Weโ€™re going to send the most significant byte first if itโ€™s a multi-byte message and a multi-byte value.โ€ Just randomly we use Intel format that was decided by J1939 committees years ago. Theyโ€™re using the Intel format, which is weโ€™re going to send the least significant byte first. So Iโ€™ll show you why thatโ€™s important. We canโ€™t figure out what the data is unless we know what format itโ€™s in.

This is a signal. Itโ€™s going to start at bit position eight and itโ€™s 16 bits long. That identifies where it is [00:05:00] in the frame. We already start with zero when weโ€™re counting digital stuff. So zero through seven is the bit positions. Then eight starts here. So we know where it starts and we know itโ€™s 16 bits long. So we know where our signal is now and we know which byte is most significant and which byte is least significant. So weโ€™ve just defined where our signal is within that data frame with a couple simple values. What do we have over here? What do we have left? We have a factor and an offset.

In this case, offset is zero. If offset was other than zero, we would apply an offset to that value. But itโ€™s zero in this case weโ€™re having. We have a factor. Weโ€™re going to apply that factor and figure out what our heading is.

Factor is just what it sounds like, itโ€™s just scales, that value. So when I say a DBC file, the main purpose of it is to define the messages and then to scale [00:06:00] and offset the data. Iโ€™ve just shown you exactly what I mean by those three statements.

This is an important slide. Iโ€™ll spend a little bit of time on this slide. So before I do that though, let me show you one other thing here. Iโ€™m going to actually minimize this so itโ€™s not in the background.

So we got our data clipping along here. The data is being displayed in standard text format. If you look at this box right here, this tells me how Iโ€™m going to display my data. I have a bunch of different options, Iโ€™m not going to get into them but will look at some examples and show you. I have a format that I can display my data and itโ€™s called a DBC formatter. My DBC formatter CANKing actually will read your DBC file and will format your data according to your DBC file. So Iโ€™ve created this funny DBC file and Iโ€™m going to click that little box, [00:07:00] and whatโ€™s going to happen up here, look at my screen, is now you see my data in two different formats because I have two different formatter boxes clicked.

Now you see my data in raw data format up here. You see my identifier, my flags, and my DLC, and then my data which is changing and my timestamp. But because Iโ€™ve got the DBC formatter box clicked, you also see it formatted according to my DBC file. This is the name of my DBC file right here. Itโ€™s a long name. I should have shortened it. It would be more understandable. But this is just a file with a dot DBC extension thatโ€™s on my PC. This is what I edited in my DBC file editor I showed you earlier.

Heading Magnetic is the name of the signal Iโ€™m looking at. So my DBC file dot heading, which is โ€œHeadingโ€ is the message, โ€œHeading Magneticโ€ is the signal, and [00:08:00] thereโ€™s the value. So my DBC file is taking this text data and itโ€™s converting it into this value. This message down here is my sign turn rate. Iโ€™m not going to get into that other than to show you that. When I turn the compass in the clockwise direction, my heading changes and my sign turn rate goes up positively. If I turn the compass in the counterclockwise direction, I get a negative turn rate, and you can always see my heading change out here as I turn it. Right now, Iโ€™m pointing it at about north. Letโ€™s go to exactly north. We go this way. So thereโ€™s perfectly north right there. So this is a compass. Use to steer on autopilot and hundreds of vessels that have installed these on.

While Iโ€™m doing that, the main bytes that are changing are here. We know those two bytes. We know how theyโ€™re scaled and we know how theyโ€™re offset. Somehow, [00:09:00] all of that information from the DBC is going to be used to calculate this value. Well, why donโ€™t we see exactly how? Letโ€™s use to calculate that value because itโ€™s not very complicated.

So Iโ€™ve grabbed here three different CAN frames and formatted them to be understandable. We have the raw data that I just showed you and then we have the interpreted data based on the DBC file. The first two CAN frames here were being put out by my simulator that I told you about, I created in a t-program. Iโ€™m not going to get into them other than to say my simulator was counting. Each time you just send for CAN frame, I incrementally counter. Then I was putting out a signed value here in a floating-point format.

You had a question?

Unidentified Man: Do you always have access to the DBC file? You mentioned the embedded processors and things.

Bryan Hennessy: [00:10:00] No, you donโ€™t. Iโ€™m sure that many companies that make an embedded processor they donโ€™t even use a DBC file, they use the concept in some other format in an embedded processor. I mean letโ€™s face it, there are smart sensors out there that use 8-bit processors, theyโ€™re certainly not going to use the DBC file, especially in a format thatโ€™s readable by an IBM compatible computer. Now theyโ€™d use it in some other format. So no, you wouldnโ€™t.

In the case of J1939, the J1939 standards committee makes a standard. Itโ€™s a very complicated standard .The J1939 committee does not make a DBC file. The industry makes a DBC file. So you go to one of our partners, you go to any other company, you can buy a DBC file. Thatโ€™s intellectual property by that company. Most manufacturers, I can speak for PACCAR since I worked for them, we have a standard DBC file [00:11:00] thatโ€™s a J1939 that we bought from somebody. We have additional DBC files that have secret information in them for messages that we donโ€™t want people to interpret. I mean a CAN bus is so dynamic that โ€“ I made this point yesterday practicing on this presentation โ€“ thereโ€™s so much information on a CAN bus in a vehicle, for example, that you might be interested in 2% of that CAN bus and never know whatโ€™s going on on the other 98% of the messages on there, and you may not have the keys to unlock whatโ€™s going on on the other messages on there. Itโ€™s just gobbledygook. Itโ€™s just hex data going by. Thatโ€™s one of the beauties of the CAN bus, is you can be an expert on your segment and look at the other stuff all day long every day and never know what it means, because you donโ€™t have the key, the DBC file. Here we have the key. We reverse engineer [00:12:00] that actually, because I didnโ€™t have an official NMEA 200. So I just reverse engineered this, I hacked it basically. This one I invented so I didnโ€™t have to hack. These datas I invented.

So what I did here, for those of you who are interested, itโ€™s a little more complicated, is I just calculated a signed value based on the number and I just set up a counter and I counted it from 1 to 100 and I just broke up a sine wave into 100 different increments and I encoded that with a floating point number. Iโ€™m not going to explain floating point today. Iโ€™d have to go back and research, I donโ€™t remember. But floating point is a way of representing a positive and a negative value and scaling it the way you want it. I just created that.

But this is the frame weโ€™re going to talk about mostly. These are just example frames. You can see Iโ€™m counting. Iโ€™m off, so you can see Iโ€™m counting in hex because I went from 1.9 to 1A and the decimal equivalent of that, which my signal sample interprets this from 2.5 to 2.6, [00:13:00] pretty simple if you know hex data.

This is the frame Iโ€™m most interested in. This is the frame put out by that compass. Thereโ€™s the date coming out in the raw CAN frame. Thereโ€™s the heading value that is interpreted, that the compass is transmitting at that time. This is a little snip from my DBC file editor that I showed you earlier. This is just describing heading magnetic signal. Youโ€™ve seen this before, I walked you through this.

So how do we get from here to here using this information? Itโ€™s pretty easy. We know itโ€™s Intel format, so we know itโ€™s least significant byte first, most significant byte second. So this is read as 849C. 849C. Well, if any of you want to pull up your calculator on your PC, [00:14:00] I can do it, and go to programmer mode and type in a hex number of 849C, youโ€™ll quickly understand that that converts to 33,948 decimal. Itโ€™s a simple hexadecimal conversion. So if we take that number, we know we donโ€™t have any offset because itโ€™s zero, but we have a factor. So we take that number and we multiply it by our factor. What do we get? We get that, donโ€™t we? This is just a display that rounds it off. Itโ€™s that easy.

We can now go from the voltages on a CAN bus all the way to meaningful data with what weโ€™ve learned here. That means something. That means where Iโ€™m heading as I turn my compass. It could be oil temperature, itโ€™s the same concept. It could be boost pressure in a heavy-duty truck. [00:15:00] It could be tire pressure. It could be anything. It could be any signal we want to define with a DBC file just like I defined a floating point sine wave signal here in something I invented.

Unidentified Man: Who define the factor?

Bryan Hennessy: Here?

Unidentified Man: Yes.

Bryan Hennessy: I just calculated it. Yes. If I bought an official DBC file for NMEA 2000 from Warwick or somebody who sells it, I wouldnโ€™t had to. But I didnโ€™t want to buy it so I just calculated it and figured it out. It was a learning curve for me. I actually didnโ€™t have a full understanding of what a DBC file does and did. I kind of did but I wanted to understand it deeper, so I figured Iโ€™ll just hack my own and then Iโ€™ll really understand it. So I hacked it. Iโ€™ll give you all the stuff if you want it. I mean this just free stuff. This is just play stuff for me.

So weโ€™ve got through the physical layer. Weโ€™ve got through the data link layer. Weโ€™ve taken the data apart. We know what the data does, [00:16:00] at least in J1939. Now I canโ€™t stress enough if weโ€™re in CANopen, or weโ€™re in DeviceNet, or something other high-level protocol. The identifier phase may be broken up differently, the data is going to be broken up differently, itโ€™s going to mean different things, but weโ€™ve seen an example, a real world example coming out of a real device thatโ€™s on the market that gives us data. So we understand the data. We pretty much understand what an application layer is, how it separates between everything else.

What I havenโ€™t gone into is transport protocol. So weโ€™ll do that. But whatโ€™s the question?

Unidentified Man: One more question. So, if you have various devices in the CAN bus, so we have various DBC files, correct?

Bryan Hennessy: DBC file can explain every device on the network or any number of devices on the network. Most of the applications will allow you to load more than one DBC file in to describe.

Unidentified Man: So, that comes back to the question, if you go to the CANKing, how do you [00:17:00] assign one DBC file to one of the datasets?

Bryan Hennessy: Well, the way a DBC file does is you load more than one of them and hopefully thereโ€™s no duplicates in there. But if there are, most of the applications will tell you if thereโ€™s a duplicate definition of a particular CAN frame. Then weโ€™re going to use the last one we get. Weโ€™re going to overwrite the first. Or they might say weโ€™re going to ignore the last. I donโ€™t even know. But thatโ€™s which way it is. But applications will usually, if theyโ€™re proper applications with proper documentation, specify which frame identifier theyโ€™re going to use in the case of duplication.

Thereโ€™s other questions? No.

So weโ€™ve covered everything. Weโ€™ve covered everything except [00:18:00] for transport protocol. Weโ€™ve talked about physical network sending 1โ€™s and 0โ€™s. Weโ€™re really clear on bit-wise arbitration. Weโ€™ve talked about data link layer defining the different pieces of the CAN frame. Weโ€™ve taken them apart. We know what they mean. Weโ€™ve talked very extensively now about the applications layer, in this case J1939, and how to translate data via DBC file into real meaningful values.

One thing we havenโ€™t talked about is this little blue box here, the transport protocol. So weโ€™ll go into transport protocol now. Again, transfer protocol is different depending on what protocol are you talking about. Transport layer, I should say, is different depending on what protocol youโ€™re talking about. Transport layer, the one Iโ€™ll talk about, is again the transport layer in J1939 or what they call it transport protocol.

Unidentified Woman: But this DBC file, is that the key that you were talking about?

Bryan Hennessy: [00:19:00] Thatโ€™s the key.

Unidentified Woman: If you have a DBC file, weโ€™ll understand the data. So thatโ€™s the key?

Bryan Hennessy: Yes, and thatโ€™s how the computer understands the data, is by looking at the DBC file. Yes.

Back to: CAN Basics Training: A Practical Introduction to the CAN bus > DBCs and Beyond