CAN Bus controllers usually come with an internal message buffer, but it is nevertheless highly recommended to create an appropriately sized buffer in your embedded application. Note: Most of today's CAN Bus controllers can theoretically handle a constant busload of 100%. The CAN-Bus Shield provides your Arduino or Redboard with CAN-Bus capabilities and allows you to hack your vehicle! CAN-Bus Shield connected to a RedBoard. This shield allows you to poll the ECU for information including coolant temperature, throttle position, vehicle speed, and engine rpms.
Hello Arduinos!
This Instructable is trying to summarize what I ended up with after a long time of search, tutorials, trials and datasheets to build a functional CAN BUS node. I will try to keep it as easy and concise as possible to get you straight to a properly working setup, saving your time for further developments afterwards.
The first 3 steps are the basic ones that will initiate a CAN BUS at your home, the rest of the steps are a little bit advanced and real-life CAN situations.
CAN BUS is a two-wire, half-duplex communication protocol that is widely used in Automotive industry. One of its greatest advantages is that it connects any number of ECUs (or microcontrollers) in your car through the two-wire bus, CAN High and CAN Low, reducing the weight of wires that could be gained by using point-to-point communication between ECUs.
Enough talking and let's grease our hands!
You can continue reading about CAN from wiki as it really gives a very good and sufficient introduction to the topic. Introduction
The CAN-Bus Shield provides your Arduino or Redboard with CAN-Bus capabilities and allows you to hack your vehicle!
CAN-Bus Shield connected to a RedBoard.
This shield allows you to poll the ECU for information including coolant temperature, throttle position, vehicle speed, and engine rpms. You can also store this data or output it to a screen to make an in-dash project.
Materials Required
You will need the CAN-Bus Shield in order to follow along with this hookup guide.
CAN-BUS ShieldDEV-13262
FavoritedFavorite23
We also recommend you have access to the following materials.
Suggested Reading
If you aren't familiar with the following concepts, you may want to review these tutorials before attempting to work with the CAN-Bus Shield.
How to Solder: Through-Hole Soldering
This tutorial covers everything you need to know about through-hole soldering.
Installing an Arduino Library
How do I install a custom Arduino library? It's easy! This tutorial will go over how to install an Arduino library using the Arduino Library Manager. For libraries not linked with the Arduino IDE, we will also go over manually installing an Arduino library.
GPS Shield Hookup Guide
This tutorial shows how to get started with the SparkFun GPS Shield and read and parse NMEA data with a common GPS receiver.
Arduino Shields
All things Arduino Shields. What they are and how to assemble them.
MicroSD Shield and SD Breakout Hookup Guide
Adding external storage in the form of an SD or microSD card can be a great addition to any project. Learn how in this hookup guide for the microSD shield and SD breakout boards.
Getting Started with OBD-II
A general guide to the OBD-II protocols used for communication in automotive and industrial applications.
Hardware Overview
There are several features to be aware of on the CAN-Bus Shield.
CAN-Bus Shield with features labeled.
1. DB9 Connector
The primary hardware feature on this shield is the DB9 connector. This allows you to interface to OBD-II ports with a DB9 to OBD-II cable.
2. GPS Connector
The GPS connector on-board is a 6-pin, JST SH compatible connector. The board is designed to interface with either the EM-506 GPS Receiver, or the GP-735 GPS Receiver. The
GND jumper allows the user to modify the GPS connector for units that do not have a GND connection on pin 5 of the connector.
3. LCD Connector
The LCD footprint on the shield is compatible with a male 3-pin JST connector and can interface with any of our serial LCD screens. The connection is designed for 5V LCDs, so don't accidentally plug in a 3.3V option! The pin order is 5V, GND, and RX/D6 when looking at the shield straight on.
4. JoyStick
The joystick included on the shield provides a basic user interface for controlling screen displays or selecting CAN scan settings. The connector gives 5 basic user options:
5. microSD Slot
This slot provides the user with the option of storing collected data onto a microSD card. Data collected can include user input on the joystick, CAN-Bus information collected, LCD outputs, or general I/O data.
6. Jumpers
There are six jumpers present on the CAN-Bus Shield.
Note: Though the pin configuration is labeled as OBD-II, this is still a *CAN-specific* device. The jumpers are simply for configuring the shield to work with other OBD-II/CAN-Bus **cables** if necessary.
For reference, here are the configuration options showing which pins are selected on the DB9 connector for each setting.
Jumper Configurations for DB9 Pins
7. CAN Pins
4 CAN lines are broken out to allow you direct access to the raw CAN data coming off of the DB9 connector. These pins are:
Again, this data is raw coming off of the CAN-Bus. It has not been filtered through the MCP2515 or the MCP2551 ICs.
Communication Methods
Because of all of the different hardware features on the shield, there are a couple different communication methods used.
Hardware HookupSolder Connectors
To get your CAN-Bus shield hooked up, solder on the Arduino Stackable Headers.
You can use the RedBoard to hold the headers in place while soldering them to the shield.
Once those are soldered, consider how you want to connect your LCD screen. You can use either male or female headers with 0.1' spacing, or the JST connector. Solder your interface choice onto the shield at this time as well.
Make sure you solder the connector onto the top of the shield, so you can access it while the shield is inserted in the RedBoard.
Connect the Brain!
In our case, the brain will be the RedBoard. Insert your shield into the RedBoard. Take your time and go slowly to prevent bending the header pins.
Connect the Extras
We recommend plugging in the GPS unit, LCD screen, and microSD card now. If you don't plan to use any of these features, you can skip this step.
If you're planning on putting your CAN-Bus/RedBoard combination into an enclosure, you may want to consider using an extension cable for the GPS unit. Enclosures can block the satellites from view and lead to spotty GPS functionality, so placing the GPS unit outside of any enclosures should alleviate those issues.
Note: If you are not using the EM-506, verify the pinout of your GPS unit and make sure the GND jumper is in the proper configuration for your unit.
We also recommend connecting your LCD screen at this time. Your method of connecting the LCD screen will depend on what connector you soldered onto the shield previously. Looking the shield straight on, the connections are 5V, GND, and TX, if you are not using the JST connector.
Make sure you use a formatted microSD card. Once all the extras are connected, your circuit should look like the following:
Connect to your CAN-enabled device
This can be a simulator or a vehicle. Plug the DB9 connector into the shield, and plug the DLC connector into the device to which you plan on talking. If your shield+Arduino turns on now, that's ok. The vehicle/simulator can power the board over the cable.
Final Circuit
Once everything is inserted, your circuit should look similar to the following:
In this case, we show the circuit connected to a CAN simulator. However, you could instead have your circuit connected to a DLC in a CAN-enabled vehicle.
Here we see the circuit connected to Pete Dokter's VW.
Arduino Library Installation
Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.
There's a really great library available for working with the CAN-Bus shield. You will need to download this and install it in your Arduino IDE. You can either search for it in the Arduino Library Manager or download the most recent version from the GitHub repository by downloading the library from the button below.
Example Code
Heads up! The following examples are a demonstration of the CAN-Bus shield's capabilities to get started. Depending on your particular vehicle's parameter identification (PID), the code may need to be adjusted accordingly (i.e. check the Canbus.h file). Additionally, make sure that CAN-bus shield is compatible with the communication protocol of your particular car's model.
There are several different example sketches included in the library, each with different functionality.
Note: Examples 7 and 8 are courtesy of Stephen McCoy- a SparkFun customer. You can find Stephen's original tutorial on Instructables:
For our example, we are going to run through the ECU_Demo sketch, but feel free to use or modify the other sketches. If you decided to not plug in the microSD card, GPS unit and LCD screen, you should instead run the CAN_Demo.
ECU_Demo
This sketch shows off the basic functionality of each part of the shield. Once you've installed the library, open up Arduino and upload this code to your RedBoard.
Check through the comments in the code for details of what each section does, but the general flow of the sketch is as follows:
If you've uncommented the lines for serial debugging, you should see something like this:
Engine RPM readings from CAN-Bus shield hooked up to a simulator.
Once you have collected some readings, you can pull your uSD card out and take a look at the data recorded. There should be a file on your uSD card called 'DATA.TXT', and it should include information like the following:
Note: If you're only recording blank readings for your GPS, as shown above, make sure you have your GPS unit in an area with a good satellite view.
Once you've verified data is being stored to the uSD card, you're good to go! You've successfully interfaced with your vehicle's CAN-Bus and can now start digging into diagnostic codes and building projects around your engine's data.
Resources and Going Further
Once you've gotten the basic functionality of the CAN-Bus shield working, you can start hacking your car and interfacing your own electronics to your vehicle. Try checking out different PIDs on the CAN-Bus with your vehicle, or see if you can interface the CAN-Bus to control LEDs, speakers, and more!
For more information, check out the resources below:
Or check out these videos from According to Pete's explanation of CAN BUS and OBD-II:
Need some inspiration for your next project? Check out some of these related tutorials:
OBD II UART Hookup Guide
How to start working with the OBD-II Uart board.
Getting Started with OBD-II
A general guide to the OBD-II protocols used for communication in automotive and industrial applications.
AST-CAN485 Hookup Guide
The AST CAN485 is a miniature Arduino in the compact form factor of the ProMini. In addition to all the usual features it has on-board CAN and RS485 ports enabling quick and easy interfacing to a multitude of industrial devices.
If you have any feedback, please visit the comments or contact our technical support team at [email protected].
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |