I’m looking to talk to and control multiple ODrives over CANbus with an Arduino Due. I got a basic script going that just reads the heartbeat that the ODrive periodically sends, but now that I"ve confirmed the CAN communication is working, I want to disable the heartbeat. I read on a previous post that setting odrv0.axis0.config.can_heartbeat_rate_ms = 0
would disable the heartbeat, but I still get a heartbeat after setting that parameter and saving the config. The message I get for the heartbeat is:
ID: 0x21 Len: 8 Data: 0x0 0 0 0 1 0 0 0
This message is a bit confusing to me since I expected ID to be either 0x700 for the CMD ID as listed in the protocol docs or 0x01 for the CAN node ID I set for the ODrive (1). Could someone explain what exactly I’m looking at with this message?
My Arduino test code is below:
/**
* Experimentation script using https://github.com/collin80/due_can/blob/master/examples/CAN_AutoBaud/CAN_AutoBaud.ino
* as guidance.
*
* ============= SEQUENCE THAT NEEDS TO BE IMPLEMENTED IN CAN PROTOCOL
* 1) odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE (startup)
* 2) odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL (startup)
* 3) odrv0.axis0.controller.input_pos = <float> (repeat)
*
* documentation of ODrive CAN protocol -> https://docs.odriverobotics.com/can-protocol
* example of data frame for pos control -> https://discourse.odriverobotics.com/t/can-interface-available-for-testing/1448/8?u=andrew_103
*
*/
#include <due_can.h>
// #include <DueTimer.h>
void setup() {
Serial.begin(115200);
Can0.begin(CAN_BPS_250K);
for (int filter = 0; filter < 3; filter++) {
Can0.setRXFilter(filter, 0, 0, true);
}
for (int filter = 3; filter < 15; filter++) {
Can0.setRXFilter(filter, 0, 0, false);
}
}
void print_frame(CAN_FRAME &frame) {
Serial.print("ID: 0x");
Serial.print(frame.id, HEX);
Serial.print(" Len: ");
Serial.print(frame.length);
Serial.print(" Data: 0x");
for (int count = 0; count < frame.length; count++) {
Serial.print(frame.data.bytes[count], HEX);
Serial.print(" ");
}
Serial.print("\r\n");
}
void loop() {
if (Can0.available() > 0) {
CAN_FRAME incoming;
Can0.read(incoming);
print_frame(incoming);
}
}