Skip to content

CANBED V1

Introduction


Docs in PDF

CANBed V1 is a CAN Bus dev board with Atmega32U4 microcontroller inside, which has 32KB of Flash and 2.5KB of RAM. The operating frequency is 16MHz, which can meet most embedded applications. There's Arduino Leonardo bootloader inside the Atmega32U4. If you have used the Arduino IDE, programming will not be a problem for you. You can also use AVR Studio for development, we provide ICSP interface.

CANBed V1 uses MCP2515 as CAN controller and MCP2551 as CAN receiver, chich are high-performance CAN Bus chip, work at CAN 2.0 protocols. There is a Micro USB connector on the board, through which you can program the board or supply power to the board.There are one I2C, one UART, one SPI interface, 3 analog input interfaces and 8 digital IO on the board.

We use a flexible way for CAN interface. You can use 4PIN Terminal or DB9 connector. DB9 connector uses OBD-II mode by default. You can also configure CAN Open mode on the hardware. The voltage input range of the CAN interface is 9-28V, which can provide a stable 5V/1A output.

If you want to use this board to develop OBD related applications, click to get a DB9 to OBD-II cable.

Note

For transportation considerations, the plug-in components of the kit are not soldered by default. After you receive the kit, you need to do some soldering work. If necessary, you can also contact info@longan-labs.cc after purchasing the board, then we can send it to you after the board is soldered well.

Version Track

V1.0: Initial version

V1.1:

  • Change package of Atmega32U4 from MU to AU
  • Change package of the 16M crystal SMD5032 to DIP

V1.2:

  • Change package of Atmega32U4 from AU to MU
  • Change package of the 16M crystal from DIP to SMD3215

V1.2c:

  • There are two packages for Atmega32U4 on the PCB, AU and MU packages, chich is selectively used during production. You may receive AU or MU version. The difference is only the packages of Atmega32U4, functions and performance are exactly the same. Please don't worry about it.

Application Ideas

With CANBed FD, you can,

  1. To learn CAN Bus communication
  2. To build product prototypes. After you complete the product prototype, we can help you integrate it into a product and assist you in production
  3. To read the data from the car
  4. As a part of your product, you don't need to design the MCU and CAN Bus separately, only need to complete other hardware design

CANBed Family

Currently we have 4 CANBeds, you can choose the right one according to your needs.

VRESION CANBed V1 CANBed FD CANBed M0 CANBed M4
PICTURES
MCU Atmega32U4 Atmega32U4 ATSAMD21G18 ATSAME51G19A
CORE AVR 8 bit AVR 8 bit ARM Cortex M0+ 32bit ARM Cortex M4 32bit
PROTOCOL CAN2.0 CANFD & CAN2.0 CAN2.0 CANFD & CAN2.0
CLOCK 16MHz 16MHz 48MHz 120MHz
FLASH 32KB 32KB 256KB 512KB
RAM 2.5KB 2.5KB 32KB 192KB
PRICE $24.9 $19.9 $24.9 $19.9
LINK GET ONE NOW GET ONE NOW GET ONE NOW GET ONE NOW

CAN BUS PRODUCTS LIST OF LONGAN LABS


Logan-Labs have manufactured many different Can-Bus products. You can get more information through the following list, and choose a suitable product.

PRODUCT NAME LINK PRICE MCU CHIP PROTOCOL
Serial CAN Bus Module LINK $19.9 ATMEGA168PA MCP2515 CAN2.0
I2C CAN Bus Module LINK $19.9 ATMEGA168PA MCP2515 CAN2.0
OBD-II Serial CAN Bus Dev Kit LINK $20.9 ATMEGA168PA MCP2515 CAN2.0
OBD-II CAN Bus GPS Dev Kit LINK $29.9 ATMEGA32U4 MCP2515 CAN2.0
OBD-II CAN Bus Basic Dev Kit LINK $24.9 ATMEGA32U4 MCP2515 CAN2.0
CAN-FD Shield LINK $12.9 NO MCU MCP2517FD CAN-FD
CAN Bus Shield LINK $5.9 NO MCU MCP2515 CAN2.0
CANBed LINK $24.9 ATMEGA32U4 MCP2515 CAN2.0
CANBed-FD LINK $19.9 ATMEGA32U4 MCP2517FD CAN-FD
CANBed M0 LINK $24.9 ATSAMD21 MCP2515 CAN2.0
CANBed M4 LINK $19.9 ATSAME51 - CAN-FD
OBD-II RF Dev Kit LINK $19.9 ATmega168PA MCP2515 CAN2.0

Features


  • Implements CAN V2.0B at up to 1 Mb/s
  • Industrial standard 9 pin sub-D connector or 4PIN Terminal.
  • OBD-II and CAN standard pinout selectable at sub-D connector
  • 2x4Pin Connector compatable with Grove system from Seeedstudio
  • SPI Interface up to 10 MHz
  • Standard (11 bit) and extended (29 bit) data and remote frames
  • Power input from 9-28V

Specifications


Parameter Value
MCU Atmega32U4
(with Arduino Leonardo bootloader)
Clock Speed 16MHz
Flash Memory 32KB
SRAM 2.5KB
EERROM 1KB
Operate Voltage 9-28V
Output Current @ 5V 1A
Input Interface sub-D

Hardware Overview


Part List

Note

For transportation considerations, the plug-in components of the kit are not soldered by default. After you receive the kit, you need to do some soldering work. If necessary, you can also contact info@longan-labs.cc after purchasing the board, then we can send it to you after the board is soldered well.

  • CANBed PCBA
  • sub-D connector
  • 4PIN Terminal
  • 4PIN HY2.0 Connector x 2
  • 9x2 2.54 Header x 1
  • 3x3 2.54 Header x 1
  • Switch for 120Ω terminal resistor

Pin out

Note

Click to get larger image.

1. GPIO - 9x2 I/O Pin OUT:

The I/O of Atmega32U4 is list out here, which is consist of,

  • 1 x UART (Serial1)
  • 1 x I2C
  • 4 x Analog Input(can be used us Digital IO)
  • 8 x Digital I/O

2. Micro USB connector for programming

If you use Arduino IDE program the board, you need a micro USB cable to connect the board to PC.

3. SPI - ICSP connector

If you use AVR Studio to program the board, you can use this ICSP connector, and it can be used as SPI interface.

4. CAN RX/TX Indicator

When CAN Bus is transmitting data, these two leds blink.

5. DB9 connector or Terminal for CAN Bus

6. Switch for the 120Ω terminal resistor for CAN Bus

If you use this board on the end of the CAN bus, please put this switch to 120Ω. For more detail about the CAN bus protocol, please refer to the NI CAN Physical Layer and Termination Guide

7. Grove connector for UART

Use Serial1 in the code

8.Grove connector for I2C

9. Reset

Click to reset the board.

DB9 connector

The DB9 interface of CAN Bus has two different protocols, OBD and CAN Open. Their definition is as follows,

pin# OBD(default) CAN OPEN
1 GND N.C
2 GND CAN_L
3 CANH GND
4 N.C N.C
5 CANL GND
6 N.C N.C
7 N.C CAN_H
8 N.C N.C
9 CAN_V+ CAN_V+

If you want to use the OBD protocol, you don't need to make any changes to the hardware.

If you need to use the CAN Open protocol, first we look at the back side of the PCB board, you can see the Pads below,

Note

The picture shows another board, but it doesn't matter, the operation method is the same.

These pads are connected to the OBD side by default. We have to prepare a knife to disconnect the OBD side, and then use an electric soldering iron to solder the CAN Open side of the pads.

Getting Started


Here we use the Arduino IDE as a demonstration, through this chapter you can learn how to get started with CANBed. You need a micro USB cable to connect the CANBed FD Dev board to the computer.

IDE and Driver

There's Arduino leonardo bootloader in the board.

Click to get the latest Arduino IDE.

There's Arduino Leonardo driver in the folder: Arduino/drivers.

Download the install the library

Click to get the Arduino Library for CANBed FD Dev board.

In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library to install the Library.

Open the code and upload it to the board

Open the Arduino IDE, here we open the send example. This example can continuously send data to the CAN Bus.

#include <mcp_can.h>
#include <SPI.h>

const int SPI_CS_PIN = 17;              // CANBed V1
// const int SPI_CS_PIN = 3;            // CANBed M0
// const int SPI_CS_PIN = 9;            // CAN Bus Shield

MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin

void setup()
{
    Serial.begin(115200);
    while(!Serial);

    // below code need for OBD-II GPS Dev Kit
    // pinMode(A3, OUTPUT);
    // digitalWrite(A3, HIGH);

    while (CAN_OK != CAN.begin(CAN_500KBPS))    // init can bus : baudrate = 500k
    {
        Serial.println("CAN BUS FAIL!");
        delay(100);
    }
    Serial.println("CAN BUS OK!");
}

unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
void loop()
{
    CAN.sendMsgBuf(0x00, 0, 8, stmp);
    delay(100);                       // send data per 100ms
}

// END FILE

You need to select Arduino Leonardo on the Arduino IDE boards and select the correct COM port. Then you can upload the program to the CANBed FD Dev board by pressing the Upolading button on Arduino IDE.

Arduino Code


We provide an Arduino library for CANBed.

Note

Please change the SPI_CS_PIN to 17 for CANBed V1

There're many examples for the library, which is consist of,

  • OBDII-PIDs - Get data from OBD-II interface
  • send - Send a frame to CAN Bus
  • recv - Receive a frame from CAN Bus
  • set_mask_filter_recv - Receive a frame from CAN Bus with mask and filter setting

APIs


1. Set the Baud rate

This function is used to initialize the baud rate of the CAN Bus system.

The available baud rates are listed as follows:

#define CAN_5KBPS    1
#define CAN_10KBPS   2
#define CAN_20KBPS   3
#define CAN_25KBPS   4
#define CAN_31K25BPS 5
#define CAN_33KBPS   6
#define CAN_40KBPS   7
#define CAN_50KBPS   8
#define CAN_80KBPS   9
#define CAN_83K3BPS  10
#define CAN_95KBPS   11
#define CAN_100KBPS  12
#define CAN_125KBPS  13
#define CAN_200KBPS  14
#define CAN_250KBPS  15
#define CAN_500KBPS  16
#define CAN_666kbps  17
#define CAN_1000KBPS 18

2. Set Receive Mask and Filter

There are 2 receive mask registers and 5 filter registers on the controller chip that guarantee you getting data from the target device. They are useful especially in a large network consisting of numerous nodes.

We provide two functions for you to utilize these mask and filter registers. They are:

Mask:

init_Mask(unsigned char num, unsigned char ext, unsigned char ulData);

Filter:

init_Filt(unsigned char num, unsigned char ext, unsigned char ulData);
  • num represents which register to use. You can fill 0 or 1 for mask and 0 to 5 for filter.
  • ext represents the status of the frame. 0 means it's a mask or filter for a standard frame. 1 means it's for a extended frame.
  • ulData represents the content of the mask of filter.

3. Check Receive

The MCP2515 can operate in either a polled mode, where the software checks for a received frame, or using additional pins to signal that a frame has been received or transmit completed.

Use the following function to poll for received frames.

INT8U MCP_CAN::checkReceive(void);

The function will return 1 if a frame arrives, and 0 if nothing arrives.

4. Get CAN ID

When some data arrive, you can use the following function to get the CAN ID of the "send" node.

INT32U MCP_CAN::getCanId(void)

5. Send a frame

CAN.sendMsgBuf(INT8U id, INT8U ext, INT8U len, data_buf);

It is a function to send data onto the bus. In which:

  • id ID of can frame.
  • ext represents the status of the frame. '0' means standard frame. '1' means extended frame.
  • len represents the length of this frame.
  • data_buf is the content of this message.

For example, In the 'send' example, we have:

unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
CAN.sendMsgBuf(0x00, 0, 8, stmp); //send out the message 'stmp' to the bus and tell other devices this is a standard frame from 0x00.

6. Receive a frame

The following function is used to receive data on the 'receive' node:

CAN.readMsgBuf(unsigned char len, unsigned char buf);

In conditions that masks and filters have been set. This function can only get frames that meet the requirements of masks and filters.

  • len represents the data length.
  • buf is where you store the data.

FAQ


I can't upload code to CANBed

  • When the board is connected to the computer via the Micro USB cable, a new COM device will appear on the computer. If the new device does not appear on your computer, you can try a different USB cable or try another computer.
  • If your PC recognize the COM port, please try pressing the reset button, then click on the Upload button in Arduino IDE, when the IDE shows compile done, release the reset button immediately.*

The RX/TX led light up and never turn off

  • Check if the baudrate of CAN Bus is setting correct
  • Try turning on/off the switch for the 120Ω terminal resistor
  • Check if CANH and CANL is well connected, H to H and L to L

How to find the tech support

Please contact support@longan-labs.cc for technical support. Our technical support engineer will usually reply you within 24 hours on working days. In order to get faster support, we hope that when you send us an email, you need to include at least the following content,

  • When and how to buy the product
  • Product version information
  • Take a high-definition picture of the product you use, including the connection
  • Describe in detail the problem you encountered and what kind of help you would like to get

Schematic Online Viewer


V1.0

V1.1

V1.2

V1.2c

Reference