Contents
- What is CANBed?
- CANBed v1 Pinout
- 18-pin Header with GPIO Interfaces
- Micro USB Connector for Programming
- SPI - ICSP Connector
- CAN RX/TX Indicator
- 9-Pin Sub-D Connector (DB9 Connector)
- Switch for the 120Ω terminal resistor for CAN Bus
- Grove connector for UART
- Reset
- Features and Specifications
- Features
- Specifications
- CANBed Application Ideas
- How to Get Started With a CAN Bed?
- Arduino IDE Setup
- Download and Install the Library
- Open the Code and Upload it to the Board
- Arduino Code
- APIs
- CANBed Family Comparison
- Summary
What is CANBed?
CANBed (CAN Bus development board) is an Arduino CAN-Bus development kit containing the following:- Atmega32U4 chip
The Atmega32U4 chip
Source: Wikimedia Commons- MCP2515 CAN Bus controller
- MCP2551 CAN Bus receiver
A CAN Bus topology
Source: Wikimedia CommonsCANBed v1 Pinout
The CANBed v1 has several connector ports split into the following parts.18-pin Header with GPIO Interfaces
These include:- An I2C interface (SCL and SDA) that doubles up as two digital pins
- A UART interface (Rx and Tx) that also doubles up as two digital pins
- Four analog inputs (you can use these for digital I/O)
- Eight digital I/O pins
- Vin (5V)
- GND
Micro USB Connector for Programming
If programming via the Arduino IDE, connect this port to a computer via a micro USB cable.SPI - ICSP Connector
If you prefer to program the CANBed using AVR studio, connect the ICSP connector to the SPI port. It is also the ideal port for uploading the bootloader.CAN RX/TX Indicator
These LEDs blink when the CAN Bus transmits data.9-Pin Sub-D Connector (DB9 Connector)
The sub-D connector is the CAN Bus terminal. This 9-pin CAN standard pinout contains the following.Switch for the 120Ω terminal resistor for CAN Bus
Solder a 120Ω resistor if using the dev kit on the CAN Bus end.Grove connector for UART
Use Serial1 when coding to access this port. There is also a grove connector for I2C.Reset
This port resets the onboard Atmega chip.Special Offer: Get $200 off your order!
Email [email protected] to get started!
Features and Specifications
Features
- Arduino development board and CAN Bus shield in one
- Up to 1Mbps CAN V2.0B implementation
- Adopts the MCP2515 CAN Bus controller with an SPI interface
- 4-pin terminal or 9-pin industrial standard sub-D connector
- 18-pin header with analog & digital pins and UART & I2C interfaces
- CAN and OBD-II standard pinout selectable at the sub-D connector
- Two 4-pin grove system compatible connectors
- Up to 10MHz SPI interface
- 11-bit standard and 29-bit extended data and remote frames
- It does not require any other MCU for control
- Arduino IDE compatible
- 9-28V power input
Specifications
CANBed Application Ideas
- Learning CAN Bus communication
- Building product prototypes
- Read data from cars (car hack and upgrade)
- Build vehicle dynamics control system
- Develop attitude and orbit control system
- CAN Bus and MCU for other products
How to Get Started With a CAN Bed?
We will use Arduino for this demonstration, and here's how you get started with the development board.Arduino IDE Setup
Download and install the latest Arduino IDE version. You'll find the Arduino Leonardo driver in the "Arduino/drivers" folder.Download and Install the Library
After downloading the IDE, download the CAN Bed Arduino library and import it into the IDE.Open the Code and Upload it to the Board
Open the library example named "Send" in the IDE, which should look like the code below. This code sends data continuously to the CAN Bus. But before uploading, select Arduino Leonardo on the IDE boards. After that, pick the correct COM port, then upload the code.Arduino Code
Besides the example above, the library contains Arduino code for receiving a frame (with and without mask & filter settings). There's also a sample code for reading data from a car's OBD-II port. Here is a sample code to get a vehicle's speed and engine revs. You need to have an understanding of a car's OBD technology and the interface. Usually, it has 16 pins, but we only want pins 5, 6, 14, and 16. Connect them as shown below.OBD connector pins. Note the pin numbers
Source: Free SVG Alternatively, you can use a DB9 to OBD-II cable, which is more convenient. After that, open the sample code and upload it to the CANBed.A female OBD-II connector in a vehicle
Source: Wikimedia Commons Please note that you should change the SPI_CS_PIN to 17 in the code for it to work with CAN Bed v1.APIs
There are six APIs you can use to access the CAN Bed. They include the following.Set the Baud Rate
You can set the baud rate to any of the following 18 figures.Receive Mask and Filter Setting
The controller chip contains two receive mask registers and five filter registers for getting data from the device. These come in handy in a broad network containing several nodes, and there are two functions to utilize them. For the mask, use For the filter, use- num shows which register to use (0 or 1 for the mask and 0-5 for the filter).
- ext shows the frame status. 0 implies a standard frame for the mask or filter, while 1 indicates an extended frame.
- ulData represents the content in the mask or filter.
Check Receive
A CAN Bus controller (MCP2515) can operate in a polled mode or by using extra pins to indicate signal reception or transmission completion. The following function polls for received frames and returns 0 if nothing arrives and 1 if a frame arrives.Get CAN ID
The following function gets the CAN ID of the "send" node when data arrives.Send a Frame
Use the function below to send data to the bus.- id is the frame's ID
- ext is the frame's status (0-standard frame, 1-extended frame)
- len shows the frame length
- data_buf is the message content
Receive a Frame
The last API is a function for receiving data on the "receive" node.- len shows the data length
- buf is the data storage location
CANBed Family Comparison
The CANBed we are looking at here is v1. However, there are five other versions with different features, and here's how they stack up against each other.Summary
There you have it! A CANBed is an integral component for project prototyping and development because it packages a microcontroller and a bus controller & receiver in one. If you need the unit or have any questions/comments, contact us for further details.Special Offer: Get $200 off your order!
Email [email protected] to get started!