Setting up CAN bus with Arduino shield

Hi guys,
I’m using the Odrive pro to control a 3000 W motor. Hence, there’s a lot of EMI. I’ll purchase a ferrite ring to help my case. However, I also want to implement CAN communication between my Arduino and the Odrive using a CAN shell to have a more reliable connection. However, I’ve read the doc and other threads, but I can’t find anything to help me on the “CMD ID”. I understand the process for the can_id process with the bitshifting and everything.
But for the command ID, I can’t figure how to write it, here’s an example :


To set the input_pos, I simply use the cmd ID to 0x00C, I don’t need the fourth or fifth column of the table above ?
Because in the example below it says that we need to create an 8-byte array. Does that array contains 8 different positions or only one position described by 8 bytes ?

If anyone can help, it’s be very appreciated as I’m stuck and can’t understand how to send a command.

Thanks in advance !

One position described by 4 bytes (32 bits), starting at byte 0. Here’s an example of how to do this in Arduino for AxisID 1. Will add to that section of the docs, thanks for pointing it out!

byte axisId = 0x01 << 5U; // Result: 0x020
byte cmdId = 0x00C;
byte msgId = axisId | cmdId; // Result:  0x02C
byte data[8] = {0};

float input_pos = 1.234f; // Commanding a position of 1.234 turns
memcpy(&data[0], &input_pos, 8); // Directly copy the byte representation of the float into data

// Copy this data buffer into your CAN stack for sending, however that's done on your system
1 Like