CANSEND? CANDO! Controlling gripper motor via handtyping CAN protocol messages (Linux / Steadywin)

I got a gripper from some very nice SteadyWin folks at the boston robotics expo (part of boston robotics week / boston tech week) and finally got it working last week!!

 

After chatting with the steadywin folks on wechat, I got a link to their wiki.

The relevant pages are

How motor talk = registers

The way these quasi direct-drive (QDD — has small planetary gearbox, not direct drive) brushless DC (BLDC) motors with integrated controllers (driver is built into the housing) work: you write to a register to control the motor and read from the register to get statuses.

On to the practical part:

Hardware setup

The XT30(2+2) consists of the fat motor power wires and two small signal wires. [6]

Plug in the cable, then connect to 1) the power supply and 2) the USBCAN device.

** Connect USB CAN to laptop. **

** Turn on power to motor **

A bit messy, but this is what it looked like.

 

Software setup 

I got this working in Linux with the Steadywin motors.

In a nutshell:

$ uv venv
$ uv pip install python-can

$ sudo slcand -o -c -s8 /dev/ttyACM2  # [1]
$ sudo ip link set can0 up txqueuelen 1000 # [2]

# In a new terminal:
$ candump can0 # Listen to all the CAN messages back and forth

CANSEND? CANDO!

Sending CAN commands by hand

The overall flow

Check the motor is talks back and where it thinks it is using #280204 (should get a response from the motor), #21000103FFFFFF (set to position control), #34000101FFFFFF (set position to zero so we don’t get unexpected big movement — this needs to happen while torque is off, and we should get 01 in response, not 00), #00020101FFFFFF (torque on), #14020400040000 (command a position), #00020100FFFFFF (torque off).

The commands I used


cansend can0 001#01                  # ping — confirm it answers
cansend can0 001#02                  # status
cansend can0 001#280204              # read position
cansend can0 001#21000103FFFFFF      # mode = position (0x03, FFFFFF is for padding)
cansend can0 001#280204              # read position
cansend can0 001#34000101FFFFFF      # [3] set position to zero -- should get 01 as response, not 00 ! 
cansend can0 001#280204              # read position
cansend can0 001#00020101FFFFFF      # torque on (0x01)
cansend can0 001#14020400040000      # goal +1024
cansend can0 001#280204              # read position
cansend can0 001#00020100FFFFFF      # torque off (0x00)
cansend can0 001#02                  # check motor still alive. I use this because it's easy to remember

 

SUCCESS!!!!!!!111111!!!

The first high was when the motor actually talked back, the second was when it finally moved !!!!!!!!!!!!111111111!!!!!!!!!!!!!1

Parenthetical Notes

[1] Use sudo dmesg | tail to find the port, you’ll see something like […] ttyACM2: USB ACM device. (See later section on udev for how to fix it so the address doesn’t change each time you plugin the device).

[2] The TX Queue length increases the buffer so that while the motor is still processing a command, incoming commands may not get dropped. AFAIK.

[3] Reading candump. The successful reply looks like the following, where (can0 = the interface, 001 = motor CAN id, [1] for length of message, 01 for message — aka success)

can0  001   [1]  01

[6]  Iif you’re fancy you can terminate the XT30(2+2) data wire in wire ferrules with a crimper, then they fit nicely into the usb can headers)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.