CAN BUS Shield for Raspberry CanBerryDual V2.1

CanBerryDual Pi V 2.1 is a CAN BUS Shield for RaspBerry Pi. It is an Open Hardware Design. It has two functionalities: a can bus module and an onboard Real Time clock powered by a 12 mm battery CR1216 (Battery is not included). The CanBus is based on a couple of MCP2515 SPI controllers and MCP2551 tranceivers. All functionalities are full integrated in standard linux kernel, so, they can be avaible on fly, or at last recompiling linux kernel to add canbus functionalities. The real time clock is based on DS3231 with internal oscillator I2C controller. It is full compatible with linux too. Using I2C Kernel module, and standard kernel functions, date and hour can be set/get by simple commands. On the bottom side is located an on board battery to guarantee a data autonomy. In chapter hardware there are all informations on principal components, schematics to rebuild and modify RaspBerry PI board. The new board is desaigned with the Raspberry Hat specification. There are four fixing holes and the hardware identification EEPROM (Blank Memory not mounted).

Raspberry Boards Compatibility

Canberry_Dual_Yellow

CanberryDual V2.1 with Two channels.

CanberryDual Single Channel Top Bottom

CanberryDual V2.1 with One channel.

If you have a RPI A or B see the Canberry V1.1 web page.

CAN BUS CanBerryDual V2.1 on Raspberry Pi 4

Dual_Can_2_1_on_PI_B2

CanBerryDual V2.1 on Raspberry Pi 2.

Dual_On_P3

CanBerryDual V2.1 on Raspberry Pi3.

CanberryDual_bottom

The RPI connector exposes two SPI slave select pins, SPI CE0 on pin 24 and SPI CE1 on pin 26. The first is used for MCP2515 channel 1 and the second for MCP2515 channel 2. The same situation is present for the interrupt pins, the first is connected on GPIO22 (pin 15) and the second on GPIO25 (pin 22).

Channel 1 schematich

Channel 2 schematich

CanBerryDual V 2.1 is composed by three blocks: a CanBus Module Normal, a CanBus transceiver Isolated and a Real Time Clock. The SMD Jumper JP2 must be used to connect the RTC Int pin to Raspberry GPIO7. MCP2515 is a stand alone SPI canbus controller full integrated in linux kernel. At the start, the driver was implemented as a block device. Recently it is assumed to be a network module into the kernel. It is supplied by 3.3V from raspberry connector. MCP2551 is supplied by 5V from Raspberry connector insted. So, to match voltage physical level between the two chips, a voltage matching made by R3 and R4 has been used. There are two SMD Jumpers, JP3 for CAN Bus Channel 1 and JP5 for CAN Bus Channel 2, these jumpers provide the 120 ohm termination for the first and the last device.

It’s possible to insert the Raspberry with our Canberry into a Phoenix din enclosure (RPI-BC 107,6 DEV-KIT KMGY – 2202874).

Industrial enclosure canberry

It’s possible to order this board on Industrialberry contact form or our shop.

Industrialberry needs of a global distributor, if interested use the contact form (Commercial).

CanBerryDual V2.1 EagleCad file

CanBerryDual V 2.1.2 Datasheet

CanBerry with Codesys

How to prepare a SD Card with CAN kernel modules (only for expert Linux users). Procedure tested on Raspberry B Rev 1, B Rev 2 and B+ Rev1.

DualCanShell

Download ready to use ISOs (kernel 4.1.7+ for Rpi B2 and B+)

Edit /boot/config.txt modify the following row

dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=22
dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=25

Run the following command:

pi@raspberrypi ~ $ dmesg | grep -i can

This is the output:

[ 13.197388] CAN device driver interface
[ 15.375846] mcp251x spi0.0 can1: bit-timing not yet defined
[ 15.382408] mcp251x spi0.1 can0: bit-timing not yet defined

spi_con

From the output it is possible to observe that can0 is associated to spi0.1 and can1 to spi0.0.

Respect the board shown in figure 1 the interface can0 is located in SPI0.1(X2 connector) and can1 in SPI0.0(X1 connector).

After your raspberry has been booted, go to home directory:

cd /home/pi/
nano can-start.sh

add these lines to the script

#!/bin/sh
#Can
ip link set can0 up type can bitrate 1000000
ip link set can1 up type can bitrate 1000000

Run the script:

sudo sh can-start.sh

So the system is ready, then you can use standard canbus command to use the peripheral:

candump can0 -> to monitoring can bus traffic

cansend can0 7DF#0201050000000000 -> to send canbus commands

candump can1 -> to monitoring can bus traffic

can1_dump

cansend can1 7DF#0201050000000000 -> to send canbus commands

To use both interface simultaneously open 2 different telnet sessions.

IMG_3606

Or read the following guide

For skilled linux users it’s possible to read this guide ( http://skpang.co.uk/blog/archives/1165 ) to prepare the ISO by yourself.

How to use RTC DS1307Z (DS3231)

Certification Disclaimer

13 comments

  1. Can you double check schematic RXCAN1/RXCAN2 is connected to GROUND via an 18K resistor and RX of the CAN transeivers (RXD1/RXD2) is not connected ( on the schematic show above)

    Regards

    1. Dear NV,
      All the nets are connected, consider that ther are over one thousand of cranberry in the World. The 18k is a voltage divider with the resistor network. Rxd1 and Rxd2 are connected to a resistor network.

      Best regards
      Pier

  2. Hi, I’m trying to run the CanberryDual V2.1 Single Channel on a Pi 3 B+ on Raspbian Stretch.
    The problem I have is that candump can0 shows no incoming data.

    I have added the following line to the /boot/config.txt
    dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=22

    The dmesg reports:
    [boottime] CAN device driver interface
    [boottime] mcp251x spi0.0 can0: MCP2515 successfully initialized
    [iptime] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
    [candumptime] can: controller area network cor (rev 20170425 abi 9)
    [candumptime] can: raw protocol (rev 20170425)

    I have bridged the J3. SPI is enabled, so is i2c. Bitrate is set to 500

    The only thing which i find confusing in your docs is statement, that can0 is spi0.1 and can1 is spi0.0. With me it initializes MCP2515 as spi0.0 and creates a can0 device. If I add the can1 line it finds no hardware (as I have a single channel card). Should I have configured it differently or do you have any other recommendation to what should i do to get it running?

    Thank you in advance.

    1. Dear Bostjan,
      Your overlay seems correct, the i2c is independent from Can Bus.
      If you have a canberry one there is only CAN0, the 120 ohm termination is present on the attached device?
      The CANH and CANL are connected with the correct polarity?

      Best regards
      Pierpaolo

  3. I would like to change LED2 to another pin, because I need GPIO 4 (pin 7) for 1-wire. Do I have to recompile the Kernel?
    Do I need the EEPROM to use the CAN functionality?
    Are there any restrictions regarding Speed and Timing when using 4 Can Interfaces simultaneously?

    Best regards
    Frederic

    1. Dear Frederic,
      It is possible to connect a led to another pin without re compilation.
      The 4 can bus interface are connected at two different spi interfaces, the maximum speed of two can is 2 Mbit/s less than spi. It is important to manage the mask and filter for every can peripheral, if you want to build a can data logger, it is better to use an FPGA board.

      Best regards
      Pierpaolo

  4. Hi, I am trying to setup a CanBerryDual V2.1 One Channel on a RPi 4 but when I try the command “dmesg | grep -i can” the output comes empty.
    Any clues of what can be wrong?
    Now my hardware is connected and I had edited the config.txt in this way
    dtparam=i2c_arm=on
    dtparam=i2s=on
    dtparam=spi=on
    dtoverlay=mcp2515-can0-overlay,oscillator=16000000,interrupt=22

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.