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.
Before uploading your first sketch, please check the following points:
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.
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.
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
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:
D2D10D11D12D13
These pins should therefore not be used freely, or only with great care, while CAN is active.
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);
}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
Please check the following:
- is the correct CAN bitrate selected?
- is the
CAN_CSjumper connected? - is the
CAN_Tjumper connected if the board is at the end of the bus? - are
CANHandCANLwired correctly? - is the bus terminated correctly?
- are you using the correct controller mode?
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
Here you can find the dimensions and pinout of the CANduino v4:
