ArduinoGeneral

CAN BUS Shield PROBLEM

userHead Account cancelled 2018-04-13 19:19:46 2746 Views1 Replies
Hello,

I bought recently the DFrobot CAN BUS Shield V2.0
I attached it to my arduino uno and loaded up the send data demo program.

The port monitor shows only "DFROBOT's CAN BUS Shield init ok!" and no CAN message afterwards just blank. What could be the problem? Broken shield ?

my setup is simple arduino uno, can bus shield, arduino connected via usb cable. Tried connecting it via the dc connector, nothing worked.

Please Help.

The code that i used \/

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

const int SPI_CS_PIN = 10;

MCPCAN CAN(SPI_CS_PIN); // Set CS pin

void setup()
{
Serial.begin(115200);
int count = 50; // the max numbers of initializint the CAN-BUS, if initialize failed first!.
do {
CAN.init(); //must initialize the Can interface here!
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("DFROBOT's CAN BUS Shield init ok!");
break;
}
else
{
Serial.println("DFROBOT's CAN BUS Shield init fail");
Serial.println("Please Init CAN BUS Shield again");

delay(100);
if (count <= 1)
Serial.println("Please give up trying!, trying is useless!");
}

}while(count--);

}

unsigned char data[8] = {'D', 'F', 'R', 'O', 'B', 'O', 'T', '!'};
void loop()
{
// send data: id = 0x06, standrad flame, data len = 8, data: data buf
CAN.sendMsgBuf(0x06, 0, 8, data);
delay(100); // send data per 100ms
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------
2018-04-20 21:18:45 Your monitor is connected to your serial port I assume... since "Serial.println("DFROBOT's CAN BUS Shield init ok!")" is printed on the screen. However, CAN.sendMsgBuf(0x06, 0, 8, data); is not a serial port command, so I'm not sure you should be expecting to see anything on your terminal window. userHeadPic BMagnan