Skip to content

CANBED DUAL

Introduction


CANBed Dual is a CAN Bus development board with 2 independent CAN Bus interface based on RP2040, there are two independent CAN interfaces on the circuit board, one is CAN2.0 and the other is CAN FD. RP2040 has 2MB of Flash and 264KB of RAM. The operating frequency is up to 133MHz, which is suitable for most embedded applications.

CANBed Dual uses MCP2515 as CAN 2.0 controller and MCP2517FD as CAN FD controller, chich are high-performance CAN Bus chip. 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.

There's a 6PIN Terminal for connecting CAN Bus interface. The voltage input range of the CAN interface is 9-28V, which can provide a stable 5V/1A output.

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.

Application Ideas

With CANBed Dual, 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 6 CANBeds, you can choose the right one according to your needs.

VRESION CANBed V1 CANBed FD CANBed M0 CANBed M4 CANBed RP2040 CANBed Dual
MCU Atmega32U4 Atmega32U4 ATSAMD21G18 ATSAME51G19A RP2040 RP2040
CORE AVR 8 bit AVR 8 bit ARM Cortex M0+ 32bit ARM Cortex M4 32bit Dual ARM Cortex-M0+ Dual ARM Cortex-M0+
PROTOCOL CAN2.0 CANFD & CAN2.0 CAN2.0 CANFD & CAN2.0 CAN2.0 CANFD & CAN2.0
CLOCK 16MHz 16MHz 48MHz 133MHz 133MHz 133MHz
FLASH 32KB 32KB 256KB 2MKB 2MKB 2MKB
RAM 2.5KB 2.5KB 32KB 192KB 264KB 264KB
PRICE $24.9 $24.9 $24.9 $24.9 $15.9 $24.9
LINK GET ONE GET ONE GET ONE GET ONE GET ONE GET ONE

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 $24.9 ATMEGA32U4 MCP2517FD CAN-FD
CANBed M0 LINK $24.9 ATSAMD21 MCP2515 CAN2.0
CANBed M4 LINK $24.9 ATSAME51 - CAN-FD
CANBed RP2040 LINK $15.9 RP2040 MCP2515 CAN2.0
CANBed Dual LINK $24.9 RP2040 / CANFD&2.0
OBD-II RF Dev Kit LINK $19.9 ATmega168PA MCP2515 CAN2.0

Features


  • Powerful RP2040 processor
  • 2 Independent CAN Interface, CAN2.0 and CAN FD
  • 2x3 Pin SPI Interface
  • 2x9 Pin IOs pinout
  • CAN2.0 with MCP2515 CAN controller
  • CANFD with MCP2517FD CAN controller
  • Power input from 9-28V

Specifications


Parameter Value
MCU RP2040
Clock Speed flexible clock running up to 133 MHz
Flash Memory 2MB
RAM 264KB
Operate Voltage 9-28V
Output Current @ 3.3V 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.

  1. CANBed Dual PCBA x 1
  2. 6 Pin Terminal connector x 1
  3. 6 Pin Switch x 2
  4. 9x2 2.54 Header x 1
  5. 3x2 2.54 Header x 1

Pin out

Note

Click to get larger image.

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

The I/Os of RP2040 list out here, which is consist of,

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

2. Micro USB connector for programming

3. SPI Interface

4. CAN20 (CANFD) Indicator

LED blinks when there's data communication.

5. CAN20 (CANFD) 120Ω Switch

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

6. 6Pin Terminal for CAN Interface

7. BOOT

8. RST

Click to reset the board.

Getting Started with Arduino IDE


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

In this demo, CAN FD will send a frame to CAN 2.0 every 100ms.

Arduino IDE Steup

First download the Arduino IDE from https://www.arduino.cc/en/Main/Software. Arduino IDE can be installed and run on Windows, Linux, and Mac OS X operating systems. Download the installer or zip file (Windows only) and install (if you have the zip file, extract it to your Windows computer’s hard drive) it on your operating system.

Once finished, start the Arduino IDE.

Copy and paste the link below into the Additional Boards Manager URLs option in the Arduino IDE preferences (File > Preferences).

https://raw.githubusercontent.com/Longan-Labs/Longan-RP2040/main/package_rp2040_index.json

Once done, click OK button to save the new preference settings.

Now open the Boards Manager by navigating to the Tools -> Board menu.

Select All from the Type drop-down menu. Then type longan in the top search bar. While typing, you will see the Longan RP2040 Boards package.

Click on the Longan RP2040 Boards by Longan Labs and then click on Install button.

Once installed, close the Boards Manager window.

Download the install the library

As there's CAN2.0 as well as CAN FD in the board, we need 2 library here.

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

Hardware Connection

Please conect CANFD-H to CAN20-H, CANFD-L to CAN20-L.

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.

// Demo for CANBed Dual

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

// pins for CANBed FD
const int CS_CANFD = 12;
const int CAN_INT_PIN = 13;

mcp2518fd CANFD(CS_CANFD); // Set CS pin

const int CS_CAN20 = 9;  

MCP_CAN CAN20(CS_CAN20);                                    // Set CS pin

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

    while (CAN_OK != CANFD.begin(CANFD_500KBPS)) {             // init can bus : baudrate = 500k
        Serial.println("CAN FD init fail, retry...");
        delay(100);
    }
    Serial.println("CAN FD init ok!");

    while (CAN_OK != CAN20.begin(CAN_500KBPS))    // init can bus : baudrate = 500k
    {
        Serial.println("CAN 2.0 init fail, retry...");
        delay(100);
    }
    Serial.println("CAN 2.0 init ok!");
}

unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
unsigned char len = 0;
unsigned char buf[8];

void loop() {

    CANFD.sendMsgBuf(0x01, 0, 8, stmp);                 // can fd send a frame

    if(CAN_MSGAVAIL == CAN20.checkReceive())            // check if data coming from can 2.0
    {
        CAN20.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf

        unsigned long canId = CAN20.getCanId();

        Serial.println("-----------------------------");
        Serial.print("Get data from ID: ");
        Serial.println(canId, HEX);

        for(int i = 0; i<len; i++)    // print the data
        {
            Serial.print(buf[i], HEX);
            Serial.print("\t");
        }
        Serial.println();
    }

    delay(100);
}

// END FILE

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

After the uploading is done, open the Serial monitor, you will see data printed to the monitor.

Arduino Code


We provide Arduino libraries for CANBed Dual, one for CAN 2.0 and the other for CAN FD.

For CAN2.0, 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

For CANFD, below examples are available,

  • CAN20_RECV_CHECK - Receive a CAN2.0 frame with check mode
  • CAN20_RECV_INT - Receive a CAN2.0 frame with interrupt mode
  • CAN20_RECV_MASK_FILT - Receive a CAN2.0 frame with mask/filter setting
  • CAN20_SEND - Send a frame to CAN Bus at CAN 2.0
  • CANFD_RECV_CHECK - Receive a CAN FD frame with check mode
  • CANFD_RECV_INT - Receive a CAN FD frame with interrupt mode
  • CANFD_RECV_MASK_FILT - Receive a CAN FD framw with mask/filter setting
  • CANFD_SEND - Send a CAN FD frame
  • OBDII_PIDs - Get data from a vehicle

Getting Started with MicroPython

What is MicroPython

MicroPython is a Python interpreter (with partial native code compilation feature). It provides a subset of Python 3.5 features, implemented for embedded processors and constrained systems. Read more about the differences to CPython here.

How to Use

As the CANBed Dual uses the same chip as the Raspberry Pi Pico (RP2040), please to to Getting Started with Pico for details.

FAQ


I can't upload code to CANBed Dual

  • 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.

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


Reference