My normal approach when prototyping stuff is to dive into the schematic editor and cobble together functional blocks from past projects with stuff i found on the interwebs or from the "typical application circuit" section from a data sheet. You've probably been there. I don't really expect stuff to work on the first attempt, but I'm pretty satisfied if I can weed out all brainfarts on the second iteration.
The Dynamixel servos I use (AX-12, MX-12, XL-320) are all half duplex serial devices. There are no dedicated TX/RX lines.
Yesterday I started testing the half duplex UART circuit on the board. I am using uart0 together with a GPIO pin for controlling TX/RX. The GPIO pin and the RX/TX pins on the uart are routed through a level shifter and then to a NC7WZ241. This circuit is more or less equivalent to the Robotis U2D2 communication converter.
For testing i wrote a small program in Go that manually constructs a ping packet and waits for a response. The default response timeout for the servos are typically 500 microseconds.
Dynamixel protocol 1 is pretty straight forward. The PING packet looks like this:
b[0] = 0xFF // Header
b[1] = 0xFF // Header
b[2] = byte(id) // target ID
b[3] = 0x02 // length
b[4] = 0x01 // ping instruction
b[5] = ^(b[2] + b[3] + b[4]) //ChecksumI tried three different serial libraries before I was able to reliably open up and use the serial port. github.com/tarm/serial turned out to be the winner.
The program was cross compiled from my PC and SCP'ed over to the pi.
And...


We got a ping response from servo id 1. Yaaay! :)
It almost looks like this thing actuall works.
PS. I noticed that the Xiaomi CyberGear motors currently are borderline unobtainium (black market pricing on the few that are listed on ebay). I don't know if these motors are discontinued by Xiaomi or not. I did contact a seller in Shenzen via Alibaba. He claimed that Xiaomi are still producing these, so we'll just have to wait and see. Please drop me a comment if anyone has any info on this.
The CAN section on this board is not Cybergear specific, so it is not a big deal, but I really like these motors, since they are relatively cheap and also easy to control.
Hans Jørgen Grimstad
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.