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)