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.