SHOP News & Articles Contact Impressum

CAN communication with CubeMars motor


I am planning to use the CubeMars AK series motors for a robot project. I have the motors and the accompanying R-Link to set up the motors, I have tested the motors with the R-link so I know they work, but now I want to do more control using CAN Bus.

My problem is that when I try to send or receive CAN messages to and from the actuator nothing happens.

I have set up two Arduinos with CAN bus shields to test that the messages are being sent and that they can be received. So I know that the CAN bus is sending the “correct” signal through the CAN bus to the other Arduino since I can read the signal.

From the documentation (page 48 in the manual) it says that to enter the “MIT mode” one needs to send a command and then send the position command, but it is not working for me.

Can someone help me with this?

Motor: AK70-10 V1.1

SparkFun Arduino CAN shield

Arduino CAN-Bus shield: Arduino CAN Bus Shield | MYBOTSHOP.DE, 19,95 €

CubeMars manual:

Arduino code

// demo: CAN-BUS Shield, send data

#include <mcp_can.h>
#include <SPI.h>
// #include <CAN.h>
/* core
 *  Test script for motor testing

    #define SERIAL SerialUSB
    //#define SERIAL Serial

// Define joystick connection pins
#define UP      A1
#define DOWN    A3
#define LEFT    A2
#define RIGHT   A5
#define CLICK   A4

// Define LED pins
#define LED2 8
#define LED3 7

//const int SPI_CS_PIN = 10;
MCP_CAN CAN0(10);     // Set CS to pin 10

void setup()

     /*while (CAN_OK != CAN0.begin(CAN_1000KBPS))
        Serial.println("CAN BUS Shield init fail");
        Serial.println("Iit CAN Bus Shield againg");

    // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
    if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK) Serial.println("MCP2515 Initialized Successfully!");
    else Serial.println("Error Initializing MCP2515...");

    CAN0.setMode(MCP_NORMAL);   // Change to normal mode to allow messages to be transmitted
    Serial.println("CAN BUS enter normal mode");
    // Setup CAN ID
    unsigned char len = 0;
    unsigned char canId = 1;
    Serial.print("Can ID:");
    Serial.println(canId, HEX);
    //initialize pins
    pinMode(UP, INPUT);
    pinMode(DOWN, INPUT);
    pinMode(LED2, INPUT);
    pinMode(LED3, INPUT);

    // Pull analoge pins hig to eable reading of joystic movment
    digitalWrite(UP, HIGH);
    digitalWrite(DOWN, HIGH);
    // Write LED pins
    digitalWrite(LED2, LOW);
    digitalWrite(LED3, HIGH);

    //Set to MIT mode
    unsigned char MIT[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,0XFC};
    CAN0.sendMsgBuf(0x01, 0, 8, MIT);
    Serial.print("MIT mode command sent:");
    Serial.print(MIT[8], HEX); Serial.print(MIT[1], HEX); Serial.print(MIT[2], HEX); Serial.print(MIT[3], HEX);    Serial.print(MIT[4], HEX);      Serial.print(MIT[5], HEX);     Serial.print(MIT[6], HEX);     Serial.print(MIT[7], HEX); 

unsigned char   stmp[8] = {0, 0, 0, 0, 0, 0, 0, 0};
void loop()
    long unsigned int rxId;
    unsigned char len = 0;
    unsigned char buf[8];
    unsigned char canId = 0; //CAN0.getCanId();
    //send data

    stmp[0] = 0xFF;
    stmp[1] = 0x01;
    stmp[2] = 0x00;
    stmp[3] = 0x24;
    stmp[4] = 0x00;
    stmp[5] = 0x80;
    stmp[6] = 0;

    if (digitalRead(UP) == LOW)
        stmp[7] = stmp[7] + 1;
        Serial.println("Input: UP");
        if (stmp[7] == 255) {
            stmp[7] = 254;
            // stmp[6] = 0;

    if (digitalRead(DOWN) == LOW)
        stmp[7] = stmp[7] - 1;
        Serial.println("Input: DOWN");
        if (stmp[7] == 0) {
            stmp[7] = 1;
            // stmp[6] = 160;

    CAN0.sendMsgBuf(0x01, 0, 8, stmp);

    if(CAN_MSGAVAIL == CAN0.checkReceive())  // check incoming data
        CAN0.readMsgBuf(&rxId, &len, buf); // read data
       // unsigned char canId = 0; //CAN0.getCanId();

        Serial.print("get data from ID: 0x");
        Serial.println(canId, HEX);

        for(int i = 0; i<len; i++)  //print the data
            Serial.print(buf[i], HEX);


Fixed the problem, was wrong code and a reversed connection.

Hi Jorgensao,

I’m currently having the same problem with the AK70-10 motors. I was able to configure the motor using the upper computer program. But now when I try to send the motor commands via CAN nothing happens. I have also checked that my CAN module is working by doing a similar tutorial. I’m using a Teensy 4.0 with a MCP2515 CAN module to communicate with the motors. Can you explain what you did to get yours working?


I made sure the CAN cables were connected correctly, I used two 120 ohm resistors for the bus as I intend to add more motors later. If I understand correctly you nothing is happening then the motor has not received the “enterMotorMode” command which is detailed in the manual. When you send the command it should make a faint sound indicating that it is on.

I would get another microcontroller to read the signal you send from your Teensy 4.0 and see if it is sending the correct input to the motor, as well as check that the MCP2515 CAN module is set to correct rate (1MHz for AK70-10 from the manual).

If the CAN message sent from the Teensy that the other microcontroller is reading is correct according to the manual, the connections are correct according to the manual and the update rate is sett correct, the problem may be the wrong CAN id.


Thanks for the advice, my motors are working now. The clock rate of the MCP2515 CAN module was the problem!

I am using an AK70-10 but something went wrong here. I cannot even connect the motor with the upper software. The driver is ok, the upper sw connects, but the motor led is still blue, it is not connecting properly with the r-link. Do you have any idea what can I do? Thanks, Paulo

Also, can you please share the arduino code that you said is working now? Thanks

Footer With Address And Phones