Dynamixel Servo Library(Position command)

Hi guys, I'm using a servo Dynamixel MX-64T and I'm having a problem in feedback position command or reading position and temperature.
I'm using the library Dynamixel_Serial - V2.0 at Google Code Archive - Long-term storage for Google Code Project Hosting.

I use Arduino 1.0.4 environment with Pololu Orangutan B-328 robot controller with connection to TX and RX.I have connected RX and TX together because MX-64T uses half duplex serial.
The VIN is 12 VDC regulated. Attached picture is the wiring. Using the example code that comes with the library :


#include <Dynamixel_Serial.h> // Library needed to control Dynamixal servo

#define SERVO_ID 0x01 // ID of which we will set Dynamixel too
#define SERVO_ControlPin 0x10 // Control pin of buffer chip, NOTE: this does not matter becasue we are not using a half to full contorl buffer.
#define SERVO_SET_Baudrate 57600 // Baud rate speed which the Dynamixel will be set too (57600)
#define LED13 0x0D // Pin of Visual indication for runing "heart beat" using onboard LED
#define TX_DEALY 2000 // in uSec
#define CW_LIMIT_ANGLE 0x001 // lowest clockwise angle is 1, as when set to 0 it set servo to wheel mode
#define CCW_LIMIT_ANGLE 0xFFF // Highest anit-clockwise angle is 0XFFF, as when set to 0 it set servo to wheel mode

void setup(){
delay(1000); // Give time for Dynamixel to start on power-up

Dynamixel.begin(SERVO_SET_Baudrate, SERVO_ControlPin, TX_DEALY); // We now need to set Ardiuno to the new Baudrate speed
Dynamixel.setMode(SERVO_ID, SERVO, CW_LIMIT_ANGLE, CCW_LIMIT_ANGLE); // set mode to SERVO and set angle limits

}

void loop(){
Dynamixel.servo(SERVO_ID,0x001,0x100); // Move servo to angle 1(0.088 degree) at speed 100
delay(4000);

Dynamixel.servo(SERVO_ID,0xFFF,0x3FF); // Move servo to max angle at max speed
delay(4000);

}


This works fine.The servo moves to the specified position every 4s.

The problem is when I tried to receive feedback from the servo. Based on this thread
http://arduino.cc/forum/index.php/topic,116011.0.html
I tried using the Dynamixel.readPosition(SERVO_ID);


#include <Dynamixel_Serial.h> // Library needed to control Dynamixal servo
#include <SoftwareSerial.h>

SoftwareSerial mySerial(4 , 7); // RX, TX

int Position;
#define SERVO_ID 0x01 // ID of which we will set Dynamixel too
#define SERVO_ControlPin 0x10 // Control pin of buffer chip, NOTE: this does not matter becasue we are not using a half to full contorl buffer.
#define SERVO_SET_Baudrate 57600 // Baud rate speed which the Dynamixel will be set too (57600)
#define LED13 0x0D // Pin of Visual indication for runing "heart beat" using onboard LED
#define TX_DEALY 2000 // in uSec
#define CW_LIMIT_ANGLE 0x001 // lowest clockwise angle is 1, as when set to 0 it set servo to wheel mode
#define CCW_LIMIT_ANGLE 0xFFF // Highest anit-clockwise angle is 0XFFF, as when set to 0 it set servo to wheel mode

void setup(){
mySerial.begin(57600);
delay(1000); // Give time for Dynamixel to start on power-up

Dynamixel.begin(SERVO_SET_Baudrate, SERVO_ControlPin, TX_DEALY); // We now need to set Ardiuno to the new Baudrate speed
Dynamixel.setMode(SERVO_ID, SERVO, CW_LIMIT_ANGLE, CCW_LIMIT_ANGLE); // set mode to SERVO and set angle limits

}

void loop(){
Dynamixel.servo(SERVO_ID,0x001,0x100); // Move servo to angle 1(0.088 degree) at speed 100
delay(3000);

Position = Dynamixel.readPosition(SERVO_ID);
mySerial.print(Position);
delay(1000);

Dynamixel.servo(SERVO_ID,0xFFF,0x3FF); // Move servo to max angle at max speed
delay(3000);

Position = Dynamixel.readPosition(SERVO_ID);
mySerial.print(Position);
delay(1000);

}


I use Arduino 1.0.4 with the serial monitor for the incoming mySerial feedback. I always get value 3968 no matter the position. I have also tried Dynamixel.readTemperature with no correct results. Just to eliminate other potential problems, I have double checked mySerial UART and it works fine for other applications.

I'm not sure if Im getting the correct results.Im also unsure about the wiring and using the read function correctly.I greatly appreciate any help to get me in the right direction.

You don't give us much to go on.
How about a link to the servo, one to the library and a diagram of your wiring and post your code.

Edit the original post has changed a lot since the original post

oh sorry,this is the link

servo is dynamixel mx-64(http://www.robotis.com/xe/dynamixel_en)

library is Dynamixel_Serial - V2.0 (Google Code Archive - Long-term storage for Google Code Project Hosting.)

and the diagram is attached.

Its a simple test of the servo with the code but im just gettting weird answers like the number 3968. Just want to know what is the issue and whether is hardware or software related.Thank you for your help.

Do help me out guys.Thanks.Its been a dead end for me .Thanks :slight_smile:

bump

Still not much to go on. I now see the servo in question but there is absolutely no data on the page that tells me how it communicates.
That diagram is rubbish. It just shows two wires on the arduino being connected together and one wire going on into the servo. Is that really how you have wired it? If so why.

You have not posted any code that you are trying to use with that library.

So far its not working because I'm getting weird answers

What sort of answers?

An answer can only be as good as the question and so far it's not very good.

The below appears to have the dynamixel command set.

http://www.electronickits.com/robot/BioloidAX-12(english).pdf

Apologies for the lack of details on my part.I have edited my original post to include more details on my wiring and coding. Would appreciate your help.Thank you!

That diagram still shows the transmit and recieve pins from the arduino wired together and then on to the controller. If it is wired like this you will never recieve anything back from the controller.

Hi,thanks,can i ask how to wire it since the wiring of mine is wrong.

Thanks

I would have thought that the RX arduino pin has to go to the TX on the servo driver and the TX on the arduino has to go to the RX ont the servo driver. The two wires should not be joined together.

Hi Mike ,

Thanks for the info however what you are mentioning is the traditional sense of seperate Tx and Rx. That is the full duplex UART. However im using half duplex UART. Therefore I have to share the same line for Tx and Rx.It is listed inside the dynamixel MX64 doc which is this link http://www.crustcrawler.com/motors/RX64/docs/DYNAMIXEL%20MX64T.pdf under the protocol section.Do review it.Thanks again Mike.

The servo might have a half duplex connection but your arduino does not. Therefore you have to make one you can not just connect the TX and RX together.
You can make one with a data select multiplexer and an arduino pin that selects if it is in the transmit mode or the recieve mode.

The below has a little more info.

http://www.crustcrawler.com/motors/RX64/docs/RX-64_Manual.pdf

Yes read page 12 that says you need to build a special half duplex controller. You can't just connect it up to an arduino directly. This will be something like I outlined in my last post.

From your linked manual:

Protocol RS485 Asynchronous Serial Communication (8bit,1stop, No Parity)
Link (Physical) RS485 Multi Drop Bus

So you are going to need a RS485 transceiver converter module to convert the arduino serial TTL full-duplex to a RS-485 half duplex wire pair and use an additional arduino digital output pin to control the transmit enable pin on the RS-485 module in your sketch before and after every time you send a message to a servo. Not hard.
Something like this would probably work:
http://www.ebay.com/itm/MAX485-module-RS-485-TTL-to-RS485-MAX485CSA-Converter-Module-For-Arduino-/171013044696?pt=LH_DefaultDomain_0&hash=item27d12bf9d8
Lefty

You don't need the differential pair. In the first post he says he already has it working talking to the servo it is just he can't get anything back from it. This is due to him wiring the arduino's TX and RX together. He just needs a data select for the arduino end.

Thanks to everyone! You all have been most helpful. Perhaps I failed to point out is the MX-64 servos comes in two versions - MX-64R and MX-64T. The R version uses RS-485, while the T version uses TTL. What I have been using is the T version, hence it can talk directly to it using the Baby O without any RS-485 conversion. Thought I point this out because the links so far could be misleading (it talks a lot of TTL <-> RS-485 conversion).

Since the T version uses half duplex, I initially wired the Tx and Rx together on the Baby O side. I got the servo moving just fine, as mentioned in my first post. The problem comes when I try to get a feedback from the servo. The data I always get is 3968 (using the serial monitor). Checking the Dynamixel_Serial 0 V2.0 .cpp library file, I confirmed it is an error packet. I messed around with it by changing the the return error packet line to just return (2). As expected, the data I get is integer 2.

As Mike suggested, I have wired up a tri-state buffer SN74LS241N like in the image attachment. More info is at
http://www.mouser.com/ds/2/405/sdls144c-104486.pdf

The code I use now is :


#include <Dynamixel_Serial.h> // Library needed to control Dynamixal servo
#include <SoftwareSerial.h>

SoftwareSerial mySerial(4 , 7); // RX, TX

int Position;
#define SERVO_ID 0x01 // ID of which we will set Dynamixel too
#define SERVO_ControlPin 2 // Control pin of buffer chip, NOTE: this does not matter becasue we are not using a half to full contorl buffer.
#define SERVO_SET_Baudrate 57600 // Baud rate speed which the Dynamixel will be set too (57600)
#define LED13 0x0D // Pin of Visual indication for runing "heart beat" using onboard LED
#define TX_DEALY 2000 // in uSec
#define CW_LIMIT_ANGLE 0x001 // lowest clockwise angle is 1, as when set to 0 it set servo to wheel mode
#define CCW_LIMIT_ANGLE 0xFFF // Highest anit-clockwise angle is 0XFFF, as when set to 0 it set servo to wheel mode

void setup(){
mySerial.begin(57600);
delay(1000); // Give time for Dynamixel to start on power-up

Dynamixel.begin(SERVO_SET_Baudrate, SERVO_ControlPin, TX_DEALY); // We now need to set Ardiuno to the new Baudrate speed
Dynamixel.setMode(SERVO_ID, SERVO, CW_LIMIT_ANGLE, CCW_LIMIT_ANGLE); // set mode to SERVO and set angle limits

}

void loop(){
Dynamixel.servo(SERVO_ID,0x001,0x100); // Move servo to angle 1(0.088 degree) at speed 100
delay(3000);

Position = Dynamixel.readPosition(SERVO_ID);
mySerial.print(Position);
delay(1000);

Dynamixel.servo(SERVO_ID,0xFFF,0x3FF); // Move servo to max angle at max speed
delay(3000);

Position = Dynamixel.readPosition(SERVO_ID);
mySerial.print(Position);
delay(1000);

}


The control pin is pin 2. I got this wiring schematic for the buffer from one of the older AX-12 Arduino sites. With this wiring, the servo does not work - no moving and and no feedback. I have tried various things like disconnecting the buffer pin 1 or 19. Sometimes the servo would move but the feedback is 0.

Am I wiring the buffer correctly?

Schematic

Original circuit from Slide-33 project is

I HAVE THE SAME PROBLEM with reading data from Dynamixel MX-28T
I even open ISSUE @ Google Code Archive - Long-term storage for Google Code Project Hosting.

But month is pass and no reply from developer.
I spend a lots of time with this library and circuit. Still can't read data! I can only write (move servo).

I guess only what we can do is spam Developer about this issue. And hope he will fix or explain what is the problem.

His web site: http://www.teda.id.au/
Vimeo: Ian Teda
facebook: Ian Teda
twitter: https://twitter.com/IanTeda