Getting started with CAN bus
A Controller Area Network (CAN bus) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other's applications without a host computer. It is a message-based protocol, designed originally for multiplex electrical wiring within automobiles to save on copper, but it can also be used in many other contexts. For each device, the data in a frame is transmitted sequentially but in such a way that if more than one device transmits at the same time, the highest priority device can continue while the others back off. Frames are received by all devices, including by the transmitting device.
For more info and history on can see: https://en.wikipedia.org/wiki/CAN_bus
This page will help get you started with CAN bus.
Some people will tell you CAN is hard or complicated. They're wrong. The hardware you need isn't expensive and you don't need to be a programming whiz. Even Damien can do it.
There are a few routes you can take, depending on what you want to do:
I want to receive or send simple CAN bus messages...
If you already know which CAN bus messages you want to send or receive, one of the cheapest ways to do this is with an Arduino Uno and a suitable CAN bus shield.
I want to analyse CAN bus traffic and possibly do some serious hacking...
If you want to analyse CAN bus messages on an existing vehicle, you'll need the help of some software. You can use the free SavvyCAN software together with a suitably configured Arduino Due or Teensy. Alternatively, you can buy a pre-configured Due-based kit from EVTV.
hello folks welcome to another fun packed episode presented by the gomcat and yours truly so before we get into the detail of today's episode as usual just the health warning it would be extremely boring it will not be of any entertaining value so if you're here for entertainment up there search box funny cat video
It's your friend also uh this video will be available free of any and all advertising on vimeo should you find yourself on old youtube so what are we going to talk about today well today we're going to talk about the topic of can logging i'm going to tell you what can logging is hopefully tell you what it is not because there's quite a bit of
Misinformation out there and also we will show you the basics of how to do it for yourself yes that's right okay gomcat just reminded me so reason for making this particular video is that as some of you will know for the past while i've been working on the bmw i3 lim for the purposes of getting ccs fast charging available to the masses
And the way that that has primarily been done the enabling piece of the puzzle has been through the use of can logs now i have been appealing to two people on various platforms to perform some can bus logging for me and it became apparent that i guess not a lot of people really understood what it was that i was asking them to do so hopefully this video uh
Excuse me will help to fill in the uh blanks so i'm not going to get into what a CAN bus is um if you don't know what that is i'd suggest a quick internet search there's a lot of information out there but i guess a one sentence would be that it is a means for the control units in a modern vehicle so all the
Little computers to exchange data because they need to do that uh for exa example the engine control computer would need to be able to speak to the gearbox controller would be able to need to speak to the abs traction control system and so forth and they do that by means of exchanging data via can so it's a little bit like computer networks where we plug ethernet cables
Into our computer so that they can exchange data with other computers either locally or on the internet and can bus is a way for all the little control boxes in your vehicle to exchange data so what is a can bus log a simple analogy for a can bus log is a bit like the old days of tapping a landline phone so let's say that we had four people on a conference call so we would come
Along connect to the phone line without any of the four people knowing that we were there and record their conversation we would then have a log or a recording of the information that those four people exchanged during the course of that conversation that would then allow us to analyze how the words in this case but in the case of can how the data flowed between those four
People that we analogize to four control units in a car and it lets us then speak the same not only the same language but speak the same words in the same way as they were spoken during the original conversation so that we can take a module away from its parent vehicle put it in a different vehicle or in a different application
And basically fool it into thinking that it is still in its parent vehicle and get it to work and perform its originally intended tasks for us so in the case of the lim i have another one of these in my e46 touring that is fairly convinced at the minute that it's still in a nice shiny 2017 i3 but like all things uh nothing is ever as easy as
It sounds and it's learning a language and learning a dialect we make a lot of mistakes and our little control units can be very strict about any of those mistakes and they can say no i don't like what you've just said to me or the speed at which you've just said it or the order in which you have spoken the words
And i'm gonna go away now and cry so the logs are the first step interpreting the logs is the second step and then forming our own communications that we can use with the control units are the final step so the more logs that we have the richer the data set is and the easier it is to learn the language and see the nuances and understand
Better how to talk the language that our control boxes are expecting so that's what can logging is and why we need to do it it is the lifeblood of modern uh vehicle reverse engineering and repurposing of modules from basically crashed or end of cars finally the gomcat is going to explain to us what can logging is not and that's a
Very important area over to you gomcat the camera's on seriously okay i guess i'll be explaining to you today folks what can logging is not so quite simply can logging is not a way for me to steal your personal info or indeed it's not a way for
Anyone to steal your personal info um yes there is vehicle specific in from informa information typically contained within can logs and depending on which can bus that we're communicating with there may be more or less of that vehicle specific information to take the example of the limb it is connected to the powertrain can so examples of messages that would be
Exchanged over powertrain can would be your battery voltage your state of charge the current draw what the charger is doing what the motor and inverter are doing the vehicle speed things like that in terms of vehicle specific personal information about the worst of it that we see on these logs from di3 is the vin and the mileage from the parent vehicle now if we got into other areas of the
Car could we get access to phone records and things like that i guess so but not on powertrain can and powertrain can is the stuff that we're interested in so i have a few can logs from a bmw i3 here and if i were some hacker type person that wanted to follow up one of these people
Or hunt them down or get into their bank accounts or um stalk them or do any of that stuff do we hear about um i would be absolutely wasting my time with those powertrain can logs folks so i just wanted to get that point across uh so that people understand it that it's not any kind of a security risk um or that the kind of people
Like myself that are involved in this have some kind of nefarious intent so now with that out of the way hopefully you'll now understand uh what a can log is why we do it and what it's not so what i'm going to do now is i'm not going to bother asking the gomkat to do to do this part i'm going to show you physically how we would connect to a can bus and i'll show you some of the hardware
That you can buy and some of the excellent free software that you can download for yourself and experiment with that not only lets us see the raw can data but more importantly gives us the tools to reverse engineer it and to interpret it in a much more human readable way so let's get to that and uh hopefully i can get him to do something then because
This was supposed to be a giant production today but look at this okay so let's get straight to it what is a canvas well it's pretty damn complicated here we have a bare circuit board that in this case we'll say that this is some module in your car that is doing something it could be controlling headlights could be
Just i guess anything windows anything physically in your car that needs to be controlled it's connected to a can bus from the can bus is basically two wires that's it in this case the red wire is can high and black wire is called can low and this this is a differential bus so you don't actually need a ground
Or anything else you just need these two wires and through the signals that are transmitted on these we can get a lot of information sharing going on so let's say that we had this boss going to this control ue unit and we were interested in reverse engineering this control unit here and we want to know what can information that it transmits and most importantly what it
Expects to see coming back into it in order for it to believe that it's still in its parent vehicle and will perform the foot the function that we want it to so all throughout the car we're going to have these can bus wires so they will be typically in the loom and they will loop from unit to unit so you will have multiple what are called nodes on
The canvas so this board could be buried somewhere completely inaccessible in our car we don't need to go tearing the car apart all we need to do is to find a convenient location where we can access the same can bus so the two wires that are connected to our module that we're we're interested in
So next thing we need to do is to put something in here that can listen to the the canvas now there are multiple pieces of hardware available for performing this task some of them super cheap some of them super expensive and a lot of them in the middle i'm not going to attempt to cover all of them um or
To try to say well you know this one's better than that one the ones that i use are typically things that i have myself that i've pieced to gather but there is one important thing that we have to specificfy here is that automotive can buses particularly particularly powertrain can buses run with a lot of data on them example the bmw i3
Powertrain can runs at about two and a half thousand frames per second so if you can imagine that's like two and a half thousand wards per second on this particular phone line the tesla model 3 powertrain can pushes that up to depending on what the car is doing between three and a half and four thousand frames per second so a lot of the low-cost
Can bus loggers and things like that that you see will at best lose some of the conversation and most of the time won't even be able to listen to it they'll just sit there looking at you so the ones that i recommend that i've used are based on the Arduino DUE um ATMEL sam 3x80 microcontroller i'll bring you on to the
Computer in a few minutes and i will show you where you can purchase specific piece of hardware for doing just that so these little ones that i have on the bench today are kind of my hacky versions of a much neater piece of hardware that i will be showing to you but the principle remains the same we'll have a module we'll have a usb
Cable that we'll connect to it's just normal usb that we'd have on most computers we'll have two wires coming out of this board strangely enough they'll be can high and can low and we will find a convenient place on our can bus that is connected to the module that we're interested in and we will basically tap into it we will connect our
Module into the can boss so now we've effectively tapped the phone line and we can listen to the conversations on there we will not participate in them we will not put any of our information in here we will just listen and that is what a logging system does now obviously in this case here it's just a
Few wires that i have on the bench that are forming the can bus um and thus there's no problem cutting them and sticking our own connectors in here now quite understandably uh some folks particularly if they've gone out and bought a new car don't like the idea of some weirdo on the internet and his very lazy cat uh connecting into their powertrain can bus or you know having to
Um strip the wire or to connect to it that's perfectly understandable hell i wouldn't let someone i mean you have to cut that part out yeah okay right so there's a few alternatives uh to doing that the first is that most of these buses will connect to places in the car where there will be um multi-pin connectors so elon will you let me
Elon thank you so you'll typically have a connector like this one this is from a tesla model 3. and you see here that there is a yellow and a blue wire that's actually a can bus so if this was in your vehicle plugged in somewhere then one way that we can gain access to the can bus without having to you know cut into the wiring is by a procedure known as
Back probing and if i can see how much preparation i put into my videos the gomcat was supposed to get the back probes out but of course he didn't do that either so what we have is typically a probe like this that's very fine and has a point we simply insert it through the back seal until it makes contact with the pin in the connect connector
Perform the log and remove the probe and there's no damage anywhere um so that's one way that we can circumvent having to cut into the wiring there is an even more better way and thanks to a donation by a member of the open inverter forum i have just such a device here that i can show to you now this little guy is an inventure cl can version 2.2 and what this
Is is it's an inductive can pick up so how does this does this work well it's got four wires we give it 12 volts and ground and it has can it's our yellow and blue wires here now on the back it's got two screws here so if we go on cat could you not have gotten the screwdriver out for me oh my god gonna be one of my worst productions
Ever this now i'm gonna make an absolute idiot out of myself because i never do that on camera really really seriously you couldn't even have got a phillips screwdriver for my god yeah this co-hosting thing is really not going to work out is it seriously we got all flathead screwdrivers if i didn't want a flathead screwdriver okay okay okay they won't get angry
Won't get angry you know they say that these partnerships never work but okay you know i was wrong had to be me to be made to fool of again give me a second folks i'm going to get a phillips screwdriver here all right so we'll just edit out that part there where i look like a complete idiot trying to open phillips screws with a flathead screwdriver
So as i was saying with the correct screwdriver look at that i'll use the screening can from the limb for something practical we simply take these two screws out of the back of it pop the back cover off and inside here so there's two little white lines one of them says can high one of them says can low so if we were to take our CAN bus wires and
Place the can low wire just without cutting it without doing anything in there like that and they can't hide wire just in on top of it there's a little thing on the back here to keep them separated so i think the actual correct way to do this is basically to stick them yeah there it is is basically to
Stick them around yeah there's these little padded things i haven't used this before so of course i'm making an idiot out of myself i should ask the golem cat to um maybe to demonstrate this he's much more ambidextrous than me so we take our wires wrap them through the back cover just screw the back cover back on perform the can log do what we need to
Do we can take the screws out release the wires and that's it we're basically done that's our can log performed so there are many ways to do this in ways that do not risk you know anything being discovered any vehicle warranties being invalidated or anything
Of that nature so that's how we connect to a canvas finally i'm going to go ahead now on the computer here and i will show you how we you know where to get a proper piece of hardware to perform this function and the relevant computer software that you would also need okay folks so this is uh we're on the computer here and what we're looking at is the EVTVDUE
micro controller board and this is what i would uh strongly recommend that you use for canvas logging so i'll put a link in the description to this web address here where you can go to purchase it it has a purchase price of just under 100 us dollars and you can come in here and you can read the instructions for it and a lot more of the data but just want to focus on one thing here
It'll be very simple so we have a usb port and so we connect to our computer we have four screw terminals on this connection block we have a ground and a power in case we want to run it in a car from a 12 volt supply but in the case of can logging we will simply be powering it from
The usb port and then the bottom is can i and can also are to our canvas and that's it that is our connect connection finally we need some software to run on our computer to connect to to this and that software is called savvycan and it's again i'll put a link to this address in the description and it is available here it is completely free and open source
And is basically without a doubt the best piece of software that you can get for can reverse engineering there is a good bit of uh discussion going on over on github here and i believe there is here a link to an older video that uh colin kidder who is the gentleman that designed and maintains this uh did uh so here it is here is a very basic
Video on how to use it and you can grab this for uh mac linux and windows both here and over on github so i'd recommend that you go to the git github to get the latest version so i won't get into any detail on this at the minute and encourage people even have a passing interest grab this and you can download some of
The can logs from my uh github as well and have a look at them and you know get yourself a little bit more familiar with them so that just yeah you just get to see what's going on under the bonnet of your car in a little bit more detail so that's about it there's the hardware that you need and the accompanying
Software now i understand there are other hardware software combos some of them very expensive some of them very cheap i'm not going to get into what's better or best or anything i can simply tell you from my own experiences that this is this and this are the way to go for the modern high-speed can bus networks
All righty folks so i hope that that's how to clear up a little bit about why we need can logs uh what we do with them what we don't do with them and the basics of how we obtain them yeah that was a board yeah anyway um so i'll just make final appeal here that if you do have bmw i3 and you will be willing
To let to either do yourself what i've demonstrated or to let me do it for you then do please leave a comment and get in touch because the more data do we get on the limb uh then the better that we're going to be able to make all of this stuff work so i'll leave it there as usual don't forget to dislike do not share and for pete's sake unsubscribe from this stupid channel i will put links in the description to
The EVTVDUE board and the savvy can software as well as the usual suspects in there for the open inverter forum github paypal and patreon in case you want to buy food for him no i don't want to do that either so until next time from the gom cat and from me happy CAN bus logging
I want to build a CAN bus device...
Once you've got your CAN messages sorted, you can build a dedicated device to send or receive those messages. For example, you could build a custom battery gauge. Or add a touch screen controller. Anything is possible! If you want, you can just use the Arduino hardware described above. Alternatively, something small and reasonably robust like a Teensy 3.x might be a better choice for a permanent solution.
Here's a quick-start guide to getting CAN working on a Teensy 3.6.
Here's a simple CAN bus State of Charge meter using a Teensy 4.0.
Local Interconnect Network
LIN (Local Interconnect Network) is a serial network protocol used for communication between components in vehicles. It is a single wire, serial network protocol that supports communications up to 19.2 Kbit/s at a bus length of 40 meters. The need for a cheap serial network arose as the technologies and the facilities implemented in the car grew, while the CAN bus was too expensive to implement for every component in the car. European car manufacturers started using different serial communication technologies, which led to compatibility problems.
For more info and history on can see: https://en.wikipedia.org/wiki/Local_Interconnect_Network