Problem with CAN bus communication between two Arduino Uno

Hi,

I'm trying to get two Arduino Uno to communicate with each other via CAN bus, one is the sender and the other one is the receiver. The initialization goes fine, but when they try communicating the receiver doesn't get any messages at all.

I'm using two CAN bus shields from SparkFun and the library provided for them. I've connected them with a DB9 cable.

To get more information about what's wrong, I tried looking at different registers of the MCP2515 after trying to send a message. They said that the message lost arbitration and there was some kind of receive error. I read that "lost arbitration" means that the message stopped sending because it had lower priority than another message. But how can it loose arbitration if there is only one sender?

The test ID in the library was pretty high (0x7DF) så I tried changing it to a lower ID like 0x1 and 0xF, to get higher priority, but then I just got transmit error instead. I also tried another library, and the same thing happened, no messages received. And when I used the checkError fuction it returned CAN_CTRLERROR.

I'm pretty new to this, and don't really know how to continue troubleshooting this problem. So any help is appreciated.

My code for the sender (the code for the receiver is identical except for the message_tx function):

#include <Canbus.h>

void setup()
{
  Serial.begin(9600);
  Serial.println("CAN-Bus Sender");

  if(Canbus.init(CANSPEED_500))  /* Initialise MCP2515 CAN controller at the specified speed */
  {
    Serial.println("CAN Init okn");
  } else
  {
    Serial.println("Can't init CAN");
  }
}

void loop()
{
  while(Serial.available()){
    char UserInput = Serial.read();
    
    Canbus.message_tx();
  }
}

I'm attaching my print out of the registers, and here is the datasheet for the MCP2515.

registers high ID.txt (359 Bytes)

registers low ID.txt (358 Bytes)

First of all, the problem wasn't the lost arbitration error. The registers clearly said that it lost arbitration, but it also said that there was a bus error. In my confusion I must have thought that the lost arbitration caused the bus error or something, but it's obviously the other way around.

In the end someone else solved the problem for me, and the solution was terminal resistors, which I had thought where included in the shield.

Hi,
I am facing exactly the same issue with high priority messages over CAN using the MCP2515.
Did you add only one additional 120OHM resistor to the Bus or two? Did you have to do any other tweaks to get it resolved, or did the resistor solely do the trick?

Thanks!