Hi,
I just started building communication between an arduino and ODrive using CAN interface. However, I don’t see any response for my CAN message for velocity control at ODrive.
Can someone please help me with this matter ?
Device : Arduino + MCP2515 CAN Bus Module
To set the velocity set point to 2 turns/s
Axis ID = 0x01
Command ID = 0x00D
Arduino Code:
#include <SPI.h>
#include <mcp_can.h>
const int spiCSPin = 53;
int ledHIGH = 1;
int ledLOW = 0;
MCP_CAN CAN(spiCSPin);
void setup()
{
Serial.begin(115200);
while (CAN_OK != CAN.begin(CAN_1000KBPS))
{
Serial.println("CAN BUS init Failed");
delay(100);
}
Serial.println("CAN BUS Shield Init OK!");
}
// ID for ODrive
int canID = (0x001 << 5) + 0x00D;
// velocity set point
int setV = 2;
// CAN message
unsigned char stmp[6] = {setV ,(setV>>8), (setV>>16), (setV>>24), 0, 0};
void loop()
{
CAN.sendMsgBuf(canID, 0, 6, stmp);
unsigned char len = 0;
unsigned char buf[8];
if(CAN_MSGAVAIL == CAN.checkReceive())
{
CAN.readMsgBuf(&len, buf);
unsigned long canId = CAN.getCanId();
Serial.println("-----------------------------");
Serial.print("Data from ID: 0x");
Serial.println(canId, HEX);
for(int i = 0; i<len; i++)
{
// print the data
Serial.print(buf[i]); Serial.print("\t");
}
Serial.println();
}
delay(5000);
}
Do I also need to add another termination resistor (120 ohms) to CAN_H CAN_L line ?
Thank you.