Hi all,
I have been trying to use an UNO and the CAN Bus shield V2.0 form Seedstudio to send frames to a custom stepper motor driver PCB.
When I send the frame, both the Rx and Tx LEDs turn red and the constant red light stays on. To clear, I have to give the arduino a power cycle.
From another forum, I see that if the shield is receiving info, the Rx LED should blink red, and when sending info (not sure if this is sending a CAN frame or sending data over SPI back to the arduino?), the Tx LED should blink red (hopefully I understand this correctly?)
I cannot find any information as to why both LEDs turn red and stay red?
The INT LED never lights up and the PWR LED is a constant green.
I have attached the schematic with the only LED info I can find (not sure where the source of this schematic is), and my code is below. When I open the serial port I get the message "CAN BUS Shield init ok!" I am satisfied that the extended CAN frames are okay except for the node address, which I believe to be 6.
Any help is greatly appreciated! Even if there are any recommended scripts to run as a test I would like to hear your thoughts.
Thank you
#include <mcp_can.h>
#include <SPI.h>
/*SAMD core*/
#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
#define SERIAL SerialUSB
#else
#define SERIAL Serial
#endif
const int SPI_CS_PIN = 10;
MCP_CAN CAN(SPI_CS_PIN); // Set CS pin
char data;
void setup() {
Serial.begin(115200);
while (CAN_OK != CAN.begin(CAN_500KBPS)) { // init can bus : baudrate = 500k
SERIAL.println("CAN BUS Shield init fail");
SERIAL.println(" Init CAN BUS Shield again");
delay(100);
}
SERIAL.println("CAN BUS Shield init ok!");
}
void loop() {
// m = Stepper Motor Move
// CAN.sendMsgBuf(id = 0x1000627F, extended frame = 1, data len = 3, {data in a buffer})
if(Serial.available() > 0) {
data = Serial.read();
if(data == 'm'){
byte msgBuffer[3] = {0x06, 0x02, 0x01};
CAN.sendMsgBuf(0x1000627F, 1, 3, msgBuffer);
delay(100);
Serial.println("Stepper Motor Move");
}
}
}