A practical desktop control tool and Python driver for DaMiao brushless motors. Connect an adapter, discover the motor, watch it live, edit registers, and control position or velocity from one clean interface.
It works on Windows with DaMiao's DM-USB2FDCAN adapter and retains the original Linux SocketCAN library and CLI support. The aim is simple: make bringing up a motor feel quick and understandable.
- Automatic motor discovery with a safe Disable handshake
- Live position, velocity, torque, temperature, and status plots
- Clear one-click motor enable/disable control
- Responsive position and velocity sliders
- MIT, position/velocity, velocity, and force-position modes
- Motor register editor and raw CAN traffic log
- Native Windows DM-USB2FDCAN support through DaMiao's official SDK
- Python API and
damiaocommand-line tools
- Windows 10 or 11, 64-bit
- Python 3.10 or newer
- Node.js and npm
- DaMiao DM-USB2FDCAN adapter
- DaMiao's official
libdm_device.dllandlibusb-1.0.dllruntime files
Clone and install this repository:
git clone https://github.com/Joeclinton1/python-damiao-driver.git
cd python-damiao-driver
py -m pip install -e .
cd damiao_motor\gui\webapp
npm install
npm run build
cd ..\..\..
damiao gui --port 5001Open http://127.0.0.1:5001.
The driver automatically looks for the official SDK here:
%USERPROFILE%\damiao-motor-sdk\Python例程\u2canfd\dlls
You can use a different location by setting an environment variable:
$env:DAMIAO_DM_DEVICE_DIR = "C:\path\to\u2canfd\dlls"
damiao gui --port 5001No Gitee account is required to install or run the tool.
- Connect motor power, CANH, CANL, and signal ground.
- Select the detected
DM-USB2FDCANadapter and press Connect. - Select the discovered motor in the left sidebar.
- Confirm the motor type so position, velocity, and torque use the correct scale.
- Enable control and use the live sliders.
The tested setup is a DM4310 at command ID 1, feedback ID 0, using classic CAN at 1 Mbit/s.
| Mode | Use it for |
|---|---|
| MIT position | Position control with adjustable stiffness, damping, and torque |
| Position + velocity limit | Moving to a position at a limited speed |
| Velocity | Continuous rotation at a requested speed |
| Force position | Position control with velocity and torque limits |
To spin the motor continuously, keep it disabled, choose Velocity, enable it, then move the velocity slider away from zero. Return the slider to zero or disable the motor to stop.
Mode changes update motor register 10 at runtime. They are not automatically written to flash.
Motor type selects the position, velocity, and torque ranges used to encode commands and decode feedback. It does not change the physical motor or its firmware. Selecting the wrong type produces incorrectly scaled commands and readings, so match the model printed on the motor.
Install the published base package:
pip install damiao-motorConfigure a classic CAN interface at 1 Mbit/s:
sudo ip link set can0 down
sudo ip link set can0 type can bitrate 1000000
sudo ip link set can0 upThe original SocketCAN controller API remains available in this fork.
from damiao_motor import DaMiaoController
controller = DaMiaoController(channel="can0", bustype="socketcan")
motor = controller.add_motor(
motor_id=1,
feedback_id=0,
motor_type="4310",
)
motor.ensure_control_mode("MIT")
motor.enable()
motor.send_cmd_mit(
target_position=1.0,
target_velocity=0.0,
stiffness=10.0,
damping=0.2,
feedforward_torque=0.0,
)
print(motor.get_states())
motor.disable()
controller.shutdown()Hardware can move as soon as it is enabled. Secure the motor and keep clear of the mechanism before running control code.
damiao scan --motor-type 4310
damiao send-cmd-mit --motor-type 4310 --id 1
damiao send-cmd-vel --motor-type 4310 --id 1
damiao set-zero-position --motor-type 4310 --id 1
damiao gui
Run damiao --help or damiao <command> --help for all options.
3507, 4310, 4310P, 4340, 4340P, 6006, 8006, 8009, 10010, 10010L, H3510, G6215, H6220, JH11, and 6248P.
This fork adds native Windows USB2CANFD communication, a compact tabbed GUI, and reliable live motor control. The underlying driver is based on jia-xie/python-damiao-driver.
MIT. See LICENSE.