Jimu: Hacking the Communication Protocol (2)

In the previous post I started to show you the details of the communication protocol between the Jimu controller and servos. We’ll be dealing with some more details in the next posts (like “read” packages, or packages that interact with sensors).

Before we go there I thought it would be interesting to share with you the experience of hooking the Jimu servos to a Robotis Dynamixel controller and to a laptop where I can run simple code to send commands to the servos. This way we can remove some of the constraints that I have seen in the tablet app like and covert the platform from a toy to something more serious.

To connect to the servo with the computer I am using an USB2Dynamixel device. This sets up a USB port that is accessible in programming and provides all the logic changes for the semi-duplex TTL communication. Since the Jimu bus is slightly different (as mentioned in this post) I have put together a small board that:

  • has a 2.5mm power connector for powering the servo (the USB2Dynamixel does not provide power)
  • provides the adapting between the MOLEX SPOX connector in the USB2Dynamixel (used with the AX/MX/RX range of Dynamixel motors) and the MOLEX Micro Blade that is used in Jimu servos
  • swaps the GND and DATA pins between the two connectors
  • provides a voltage reduction from the 5V logic in the USB2Dynamixel and the 3.3V used by Jimu; this is done simply with a resistor divisor – not a long term solution but good enough for the tests
  • adds three pins for connecting the logic analyser

Here is the board:

fullsizeoutput_7e9
USB2Dynamixel adapter board

I have hooked up everything like this:

IMG_2066
Jimu servo hooked up to the USB2Dynamixel

I’m using a bench power supply and provide 7.5V to the servo. The rest is connected using normal cables from Robotis.

On my laptop I have put together the following Python script (I run it in Jupyter Notebooks – I love that!). Since I did not want to spend too much time writing code at this moment the commands are all hard-coded and pre-calculated. Later we will deal with this using a proper library to interact with the servos and sensors.

from serial import Serial
bus = Serial('/dev/tty.usbserial-AL01QHDB', 115200)

This opens the port with the USB2Dynamixel (the ugly name is what happens on MacOS when these FTDI chips are connected) and we have to use 115,200bps communication speed. We might investigate later if there is any way to change the communication speed for the Jimu servos as it is possible for the Robotis ones.

Then I define the instructions to send to the servos. They are simple goto positions (0, 45 and 90 degrees) for the Servo ID 5:

go0 = bytearray.fromhex("FAAF05017814000193ED")
go45 = bytearray.fromhex("FAAF0501A5140001C0ED")
go90 = bytearray.fromhex("FAAF0501D2140001EDED")

I can then send these commands to the servo (in Jupiter they are on separate cells and I can run them one by one – you will see me doing that in the movie later):

print(bus.write(go45))
print(bus.write(go0))
print(bus.write(go90))

And here is what the servo does:

Now we have a hole world of possibilities. I will be able to see over the next days how efficient the control can be made (for instance how much information can we read from the servo and how many instructions can we send per second – this would be an important factor for determining how well these servos might perform in a proper robot).

Go to Jimu posts index