Getting started with CAN bus

From openinverter.org wiki
Revision as of 04:32, 20 February 2023 by PrecisionAnalytic (talk | contribs) (Added LIN Category)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.


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