Site Information

 Loading... Please wait...

Controller Area Network (CAN Bus) Prototyping With the Arduino Uno

 

Controller Area Network (CAN Bus) Prototyping With the Arduino UnoController Area Network Prototyping with Arduino

by Wilfried Voss 
Copyright © by Copperhill Technologies Corporation

While the Arduino is not widely considered an industrial-strength solution, it provides, due to its low price and ease of programming, the perfect prototyping platform for all kinds of Controller Area Network (CAN Bus) applications.

This online book guides the reader through the process of acquiring all necessary hardware and software components, the implementation of the CAN Bus driver, and the implementation of programs (Arduino Sketches) to read, send, process, and display data from and to a CAN network.The collection of programming examples cumulates into a full-fledged USB-to-CAN Gateway communicating with a Windows/Linux PC. 

This online book will enable you to achieve CAN Bus functionality literally within only a few hours, but it assumes some knowledge of the Arduino hardware and its programming. There are myriads of books on Arduino, Arduino Sketches, and Arduino Shields available in the market, and I won’t waste your time. However, references to Arduino basics may appear but only in passing.

I also assume some basic knowledge of Controller Area Network (CAN Bus). I will refer briefly to some aspects of the CAN Bus, but these are the mere basics of the actual protocol, just enough to understand the concept. In all truth, there is no need to understand all details of the protocol, since 100% of the protocol is implemented on a chip, the CAN controller. All we need to do in this book is to receive, transmit, and process data. The rest is up to your fantasy.

Nevertheless, the CAN protocol utilizes some ingenious features, and if you are interested in learning more, please refer to my book A Comprehensible Guide to Controller Area Network.


Note by the author:

I have chosen to give this book away as a free download and to post it on this website in its entirety. There were two reasons to do so: First of all, it is difficult to update such a book when the introduced hardware changes over the years - nevertheless, the information herein, specifically the Arduino sketches, are still valid. Secondly, we got majorly screwed by the publisher of our electronics documents, Lulu.com. Their "improved" website design included the loss of half of our publications. The beneficiary of this situation is you, the reader.

Download the PDF file here free-of-charge and feel free to distribute any which way you like:
Controller Area Network (CAN) Prototyping with Arduino (PDF)...


Table of Content

1. Introduction to Controller Area Network
2. Prototyping Hardware
3. Arduino CAN Shields

3.1 Microchip MCP25215 CAN Bus Controller (included in chapter 3.)
3.2 Arduino CAN Bus Shield by Sparkfun (included in chapter 3.)
3.3 CAN Bus Shield by Seeed Studio (included in chapter 3.)

4. Arduino CAN Bus Sketches

4.1 The MCP2515 Library

4.1.1 Function Calls (included in chapter 4.1)
4.1.2 Implementation (included in chapter 4.1)

4.2 CAN Bus Programming (See below chapters)

4.2.1 Simple CAN Bus Shield Test
4.2.2 Extended CAN Bus Shield Test
4.2.3 A Simple CAN Bus Network Monitoring And Diagnostics Program

4.3 CAN Bus Network Monitoring Under Windows

Arduino/Visual Studio Project Samples Download

The following programming samples (accessible as .zip files) are free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The samples are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. With downloading these programs, you confirm that these code samples and projects were created for demonstration and educational purpose only.

Disclaimer: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties or merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss or profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.

Recommended Literature

There is more than plenty and valuable literature available on the Arduino, but, being an experienced programmer, the two and only works I read was:

Programming Arduino
Getting Started with Sketches
By Simon Monk

Programming Arduino Next Steps
Going Further with Sketches
by Simon Monk

Also recommended for providing more background information:

A Comprehensible Guide to Controller Area Network
By Wilfried Voss

A Comprehensible Guide to J1939
By Wilfried Voss