MCP2515 & MCP2551 trouble

Hi,

I've been having some bad luck when it comes to these CAN devices.

I tried seeed studio's CANbus shield v1.0, and tried my own boards.

The trouble I'm having is Error sending message on my own boards, and Error entering configuration mode on the seeed shield.

Does anyone have any pointers on rookie mistakes? :slight_smile:

Serial monitor my board:
Entering Configuration Mode Successful!
Setting Baudrate Successful!
MCP2515 Initialized Successfully!
Error Sending Message...

Serial monitor SeeedStudio's CANshield:
Entering Configuration Mode Failure...
Error Initializing MCP2515...
Message Sent Successfully!

// CAN Send Example
//

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

MCP_CAN CAN0(10);     // Set CS to pin 10

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

  // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
  if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK) Serial.println("MCP2515 Initialized Successfully!");
  else Serial.println("Error Initializing MCP2515...");

  CAN0.setMode(MCP_NORMAL);   // Change to normal mode to allow messages to be transmitted
}

byte data[8] = {0x05, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

void loop()
{
  // send data:  ID = 0x100, Standard CAN Frame, Data length = 8 bytes, 'data' = array of data bytes to send
  byte sndStat = CAN0.sendMsgBuf(0x100, 0, 8, data);
  if(sndStat == CAN_OK){
    Serial.println("Message Sent Successfully!");
  } else {
    Serial.println("Error Sending Message...");
  }
  delay(100);   // send data per 100ms
}

what are the canbus 9pin D-type connections on your boards ?

  1. the canbus shield V1.2 CANH is pin 3 CANL is pin 5
    Canbus shield v1.2 schematic
  2. on Canbus systems I have CANH is pin 7 and CANL is pin 2
    CANBUS interface description

I had to build a 9 pin D-type back to back conector to connect the shield v1.2 to my Canbus systems

I find it is a good idea to have a USB-CAN dongle for a PC when dubugging Canbus

I'm using the screw terminals on the side.

I use the Saleae Logic Analyzer to debug my CANbus. Only thing putting out data right now though is my ECU on the bench :frowning:

the SPI_CS_PIN on some Canbus shields is pin 9 ?
is the bus correctly terminated?