Even when I just try to initialize the bus I get the status byte 1 (Error-> cant initialize). I do not have anything connected (except the 100Ohm termination resistor) on the CANH, CANL side.
#include <Arduino.h>
#include <mcp_can.h>
#include <SPI.h> //SPI is used to talk to the CAN Controller
MCP_CAN CAN(10); //set SPI Chip Select to pin 10
void setup()
{
Serial.begin(9600); //to communicate with Serial monitor
Serial.println("---Setup---");
//tries to initialize, if failed --> it will loop here for ever
START_INIT:
if(CAN_OK == CAN.begin(CAN_500KBPS)) //setting CAN baud rate to 500Kbps
{
Serial.println("CAN BUS Shield init ok!");
}
else
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
delay(2000);
goto START_INIT;
}
}
loop {
delay(1000);
}
As you probably know CAN is a multi-master serial bus standard for connecting Electronic Control Units [ECUs] (Engine Control Units) also known as nodes. TWO or more nodes are required on the CAN network to communicate. ... All nodes are connected to each other through a two wire bus. Note it is best to also connect the grounds, I have never had much luck unless there are connected. The wires are a twisted pair with a 120 Ω (nominal) characteristic impedance. You need to put termination resistors 120 Ohm at the physically end of the buss only, no more. For can to operate it needs an acknowledge from one or more units. I would recommend you get a logic analyzer it will help a lot, many have a CAN analyzer as part of there software. You can get some cheap ones on eBay for a few dollars.
Good Luck & Have Fun!
Gil