Problem with CAN bus shield

Hi everybody,

I have a problem with Arduino Uno R3 and the Sparkfun Canbus-Shield

I am using the library

http://www.seeedstudio.com/wiki/images/0/0c/CAN_BUS_Shield_Code.zip

So far, I have successfully uploaded the following sketch, which does nothing but send the same message on the bus repeatedly:

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

void setup()
{
  Serial.begin(115200);
  if(CAN.begin(CAN_500KBPS) ==CAN_OK) Serial.print("can init ok!!\r\n");
  else Serial.print("Can init fail!!\r\n");
}

unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
void loop()
{
  if(CAN.sendMsgBuf(0x00, 0, 8, stmp)==CAN_OK) 
  {
    Serial.println("OK.");
    Serial.println(CAN.sendMsgBuf(0x00, 0, 8, stmp));
  }
  else
  {
    Serial.println("ERROR.");
    Serial.println(CAN.sendMsgBuf(0x00, 0, 8, stmp));
  }
  delay(1000);
}

Uploading works without problems, but the serial output looks like this:

Enter setting mode success
set rate success!!
Enter Normal Mode Success!!
can init ok!!
OK.
0
OK.
6
ERROR.
6
ERROR.
6
ERROR.
6
ERROR.
6
ERROR.
6
ERROR.
6
ERROR.
6
ERROR.
6
...

So after the message is sent two times, the buffer is full and no more messages can be sent - at least that is my guess.

Does anybody have experience with the CAN bus shield and can tell me what the problem is? I also tried other libraries, but this problem always remained the same.

Thank you so much,

papillon

So after the message is sent two times, the buffer is full and no more messages can be sent - at least that is my guess.

Perhaps if you told us what the messages are going to, you wouldn't have to guess.

If your guess is correct, then it implies that the other device is failing to remove the message from the queue. So, you need to have a stern talking to with it.

Ok, problem solved: My device (PCAN-USB CAN analyzer) had a different D-9 pin layout, so the CAN Hi and CAN lo pins from the shield went nowhere...

In case anybody has similar problems:

Shield Pin 3 (CAN Low) <--> PCAN Pin 2 (CAN Low)
Shield Pin 5 (CAN High)<--> PCAN Pin 7 (CAN High)

Thanks anyway!!!

Thanks anyway!!!

You're welcome. I like problems like this, where you are going to go do all the work.

Hi, I have same problem with you
but I am not clear about your solution
Shield Pin 3 (CAN Low) <--> PCAN Pin 2 (CAN Low)
Shield Pin 5 (CAN High)<--> PCAN Pin 7 (CAN High)

what is it mean?
thank you

I am having same problem please respond. what is wrong with it??
what does it mean?
Shield Pin 3 (CAN Low) <--> PCAN Pin 2 (CAN Low)
Shield Pin 5 (CAN High)<--> PCAN Pin 7 (CAN High)

it looks like he is showing you that pins 3 and 5 of D9 sparkfun shield connector should be connected to respective pins 2 and 7 of PCAN' D9 connector