Skip to content

MassiveButDynamic/CANduino-v4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

CANduino v4

Here you can find a quick tutorial on how to get started with your CANduino v4.

Please make sure that you are really using the v4, because on the v3 the CAN chip select pin was different (CS pin 8).

If you don't have a CANduino yet, you can get one here: https://canduino.de Or here with international shipping: https://www.tindie.com/products/21492

On the CANduino v4, the CAN controller and CAN transceiver are integrated in a single chip: the MCP25625.
This chip combines the functionality of the MCP2515 CAN controller and the MCP2551 CAN transceiver.


Getting started

Before uploading your first sketch, please check the following points:

CAN_CS jumper

Make sure that the jumper CAN_CS (on top, next to the USB-C port) is connected to a solder pad.
Only then can the CAN controller be addressed via SPI.

CAN bus termination

If your CANduino v4 is located at the end of the CAN bus, the CAN_T jumper (next to the CAN connector) must be connected.

Without proper termination, CAN communication may not work reliably.

Install the CANduino library

To use the CAN functionality, install the CANduino library.

Recommended: Install it directly via the Arduino Library Manager.

Alternatively: You can install it manually from GitHub:
https://github.com/MassiveButDynamic/CANduino

Download the repository and place it in your Arduino libraries folder:

Documents/Arduino/libraries/CANduino

Important parameters

The CANduino library is already configured for the CANduino v4 hardware.

This means:

  • CS pin = D10
  • INT pin = D2
  • MCP clock = 8 MHz

So instead of manually creating and configuring an MCP2515 object, you can simply write:

CAN.begin(500000);

For example:

#include <CANduino.h>

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

  if (!CAN.begin(500000)) {
    Serial.print("CAN init failed, error ");
    Serial.println(CAN.getLastError());
    while (1) {}
  }
}

void loop() {
}

Please note that the CAN controller uses the following pins:

  • D2
  • D10
  • D11
  • D12
  • D13

These pins should therefore not be used freely, or only with great care, while CAN is active.


Example code

In the examples folder of the CANduino library, you will find example sketches for:

  • sending CAN messages
  • receiving CAN messages
  • loopback testing
  • interrupt-based receive handling
  • sleep and wake-up handling

Typical usage looks like this:

CAN.send(0x123, data, 2);

or:

CANFrame frame;

if (CAN.receive(frame)) {
  Serial.println(frame.id, HEX);
}

Troubleshooting

The board is not recognized over USB

If the CANduino v4 is not detected by your computer, please install the driver for the CP2102 USB-to-UART converter:

https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers?tab=downloads

CAN communication does not work

Please check the following:

  • is the correct CAN bitrate selected?
  • is the CAN_CS jumper connected?
  • is the CAN_T jumper connected if the board is at the end of the bus?
  • are CANH and CANL wired correctly?
  • is the bus terminated correctly?
  • are you using the correct controller mode?

Initialization fails

If CAN.begin(...) fails, print the error code via:

Serial.println(CAN.getLastError());

This helps to determine whether the problem is caused by:

  • controller not found
  • unsupported bitrate
  • failed mode switch
  • other initialization problems

Dimensions and pinout

Here you can find the dimensions and pinout of the CANduino v4:

Pinout

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors