In robotic development and research projects, how to quickly and reliably control high-performance brushless joint motors is a key challenge for developers.
This tutorial will guide you through how to use an Arduino development board together with an MCP2515 CAN module to achieve precise joystick-based control of the CubeMars AK45-36 KV80 robotic joint motor.
Through this tutorial, you will learn the fundamentals of hardware wiring, MIT control mode configuration, and control logic implementation, enabling you to easily integrate CubeMars motors into your robotics projects.
Before starting, please make sure you have the following hardware and software ready:
Hardware:
Arduino development board (such as Arduino Uno)
MCP2515 CAN module
Dual-axis joystick module
DC power supply and jumper wires
Software:
Arduino IDE
mcp_can library (installed in advance)
Correct wiring is the foundation of stable communication. You only need to focus on the following three key connections:
MCP2515 and Arduino (SPI Communication): Connect the MCP2515 module to the Arduino through the standard SPI interface pins (CS, SO, SI, SCK, etc.).
CAN Bus Connection (to Motor): Connect the CAN_H and CAN_L pins on the MCP2515 module to the corresponding CAN_H and CAN_L lines of the AK45-36 motor.
Joystick and Power Supply:Connect the joystick X-axis signal pin to an Arduino analog input pin (such as A0).
Finally, connect the motor to a suitable DC power supply.(Note: Do not reverse the motor power connection and CAN signal wiring).
For dynamic control applications such as joystick tracking, we strongly recommend using MIT control mode.
This mode allows position, velocity, and torque commands to be transmitted simultaneously within a single CAN message, providing extremely fast response.
Configuration Steps:
Use the official CubeMars USB-to-CAN module to connect the motor to a computer and open the upper computer software.
Set the motor CAN ID (for example, 0x01) and baud rate (must match the Arduino code, usually 1 Mbps).
Click "Enter MIT Mode".
At this point, manually rotating the motor shaft should produce noticeable resistance, indicating that the configuration has been completed successfully.
In the Arduino environment, implementing joystick-based motor control is straightforward and mainly consists of three steps:
Read Input: Use an Arduino analog input pin (such as A0) to read joystick values in real time.The typical range is 0–1023.
Map Data: Use a mapping function (such as map) to linearly convert the joystick input values into the target position or velocity range supported by the AK45-36 motor.
Send CAN Messages: Use the CAN communication library to package the converted target data into a standard MIT mode CAN frame and send it to the corresponding motor CAN ID.
Tip: To obtain the complete Arduino example code, data conversion functions, and communication protocol documentation, please visit our official download center.
After completing the configuration, power on both the motor and Arduino. Move the joystick, and you should see the motor shaft smoothly rotate forward and backward following the joystick movement.
Watch the video below for a complete hands-on demonstration and detailed explanation.
Q1: The motor does not respond after power-on. It does not rotate when moving the joystick?
A: Please check whether the motor has successfully received the Enable command. In MIT mode, the motor is disabled by default. You must first send a specific CAN message to enable the motor before it can respond to control commands.
Q2: The motor shakes or responds slowly during joystick control?
A: This is usually related to CAN bus communication quality. Please ensure that CAN signal wires are not bundled parallel with the motor power cables. If the communication distance is long, enable the 120Ω termination resistor by switching the DIP switch on the MCP2515 module.
The AK45-36 is just one member of the CubeMars high-performance motor family. Whether you are developing a quadruped robot, humanoid robot, robotic arm, or other robotic platforms, CubeMars provides compact and high-performance actuator solutions tailored to your needs.
[Learn more about CubeMars AK45-36 specifications and dimensions]