Mega ADK Board with CAN-BUS Shield

I'm totally new to this Adruino program and was wondering if i could get some help with getting my MEGA ADK board to communicate with a neo VI FIRE. I wrote the following code to send out information and i keep receiving CAN inti failed on my serial monitor. Can someone help me not get that failure:

// demo: CAN-BUS Shield, send data
#include <mcp_can.h>
#include <mcp_can_dfs.h>
#include <SPI.h>

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

void setup()
{
Serial.begin(115200);
// init can bus, baudrate: 500k
if(CAN0.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()
{
// send data: id = 0x00, standrad flame, data len = 8, stmp: data buf
CAN0.sendMsgBuf(0x00, 0, 8, stmp);
delay(100); // send data per 100ms
}

Also i have a CAN-BUS Shield connected with my MEGA ADK board properly.

I downloaded the zip from the link: GitHub - coryjfowler/MCP_CAN_lib: MCP_CAN Library and then used the examples send Adruino sketch that is provided in the zip folder i downloaded:

"// demo: CAN-BUS Shield, send data
#include <mcp_can.h>
#include <SPI.h>

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

void setup()
{
Serial.begin(115200);
// init can bus, baudrate: 500k
if(CAN0.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()
{
// send data: id = 0x00, standrad flame, data len = 8, stmp: data buf
CAN0.sendMsgBuf(0x00, 0, 8, stmp);
delay(100); // send data per 100ms
}

/*********************************************************************************************************
END FILE
*********************************************************************************************************/"

I also attached the file of this sketch. As you can see i changed line 4 "MCP_CAN CAN0(10);" to "MCP_CAN CAN0(9);" because I'm using a later version of Adruino and it's my understanding that i must do that because i have a later version of adruino and a MEGA 2560 board attached to a CAN-BUS Shield (properly). The problem I'm having is that the sketch compiles and downloads to the bopard successfully but when i pull up the serial monitor i seem to always be getting "Can init fail!!\r\n". Are there any strategies to fixing this problem. PLEASE HELP.

send.ino (807 Bytes)

Can you provide a link to the CAN-BUS shield that you are using ?

What have you got connected to pin 10 ?

http://www.ebay.com/itm/like/271804482183?lpid=82&chn=ps
here's a link to the CAN BUS Shield I'm using

Also i have nothing connected to pin 10 (i think you might mean 9 because the code is linked to pin 9 not 10) I do have the CAN BUS Shield hooked up to a NEO VI FIRE via CANH and CANL pins. (not sure if that matters but ultimately my goal is to get a mega 2560 board with a CAN BUS Shield to communicate with the NEO VI FIRE) I'm very new to this stuff so any kind of information what-so-ever would be greatly appreciated.

You are right, I did mean pin 9. The link to the board you gave is very short of details. How did you know to use pin 9 instead of pin 10 ?

I read that online "CAN BUS shield (SKU:SLD01105P) – Feedback & Ideas for seeed" here and I've tried the code with the pin set at 10 neither of them worked.

The first piece of advice on the page you linked to is

Using CAN-BUS Shield with Arduino Mega
Arduino Mega 2560 has its own SPI port located on pins 50, 51, 52 and 53 instead of 10, 11, 12, 13 on Arduino. The CAN shield has them on pins 10, 11, 12, 13,so you need some jumper wires. For details, please refer to its wiki page here.

Have you taken this into account ?

Yes, I looked into it and it's only for version 1.0 of Adruino. The later versions fixed the bug. I tried i different library with a different looking Adruino sketch to send a signal. The sketch is attached and below i pasted the results i get on my serial monitor for this new sketch and library:

Enter setting mode fall
Can init fail!!
cantxValue: 118
cantxValue: 110
cantxValue: 106
cantxValue: 104
cantxValue: 102
cantxValue: 102
cantxValue: 101
cantxValue: 101
cantxValue: 100
cantxValue: 100
cantxValue: 100
cantxValue: 100
cantxValue: 100
cantxValue: 100
cantxValue: 100
cantxValue: 100
cantxValue: 100
cantxValue: 100
cantxValue: 100
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 99
cantxValue: 100
cantxValue: 100
cantxValue: 100

And it continues to go on forever like this. Does this mean its working? or does this mean nothing at all?

Sorry forgot to attach the Adruino sketch.

sketch_may06a.ino (1.1 KB)

I'm brand new to Adruino and need help getting my CAN-BUS Shield to send a signal out. I downloaded a zip library online that had a pre-made sketch example to upload to my board to send a signal out. However when I upload the sketch and click on the serial monitor it always shows the same "Can init fail!!" any bit of information would help at this point I'm very confused as to why its not working.

The library I'm using is attached to this and the sketch I'm using is:

// demo: CAN-BUS Shield, send data
#include <mcp_can.h>
#include <SPI.h>

void setup()
{
Serial.begin(115200);
// init can bus, baudrate: 500k
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()
{
// send data: id = 0x00, standrad flame, data len = 8, stmp: data buf
CAN.sendMsgBuf(0x00, 0, 8, stmp);
delay(100); // send data per 100ms
}

/*************************************************************
END FILE
*************************************************************/

Do not cross-post. Threads merged.