PDA

View Full Version : Arduino Mega 2560 and AX12A servos



DVS
07-08-2013, 02:33 PM
Hi everyone,
I am new to the whole world of robotics and have decided I would like to build a quadruped robot.
The parts I have chosen are the Arduino Mega 2560 R3 and dynamixel AX12A servos. Various other sensors will be incorporated later.
The problem I seem to be having at the moment is that I am not able to write angles to my servo. When I call .attached() I get a true.
At the moment I have the arduino board powered through usb and the servo is powered with a 11.1V external power source with its ground connected to the arduinos with a connection between pins 23 (digital pin 10) and the info line of the servos


This is the code I have been trying to run

#include <Servo.h>

Servo myservo;


void setup()
{
Serial.begin(9600);
myservo.attach(23);
// delay(500);
myservo.write(45);
// delay(1000);
Serial.println(myservo.read());
}


void loop()
{
}

As far as I understand the servo library allows direct angle writing like this to servos using TTL half duplex com protocol.

Perhaps it is in how I am supplying power to the servo but I dont see why It would be a problem doing it this way.
Thanks alot

jwatte
07-08-2013, 04:09 PM
Dynamixel servos do not use hobby-style PWM pulses for communicating positions or feedback. Instead, they use a single-duplex serial bus, similar to the serial port on the Arduino.

The easiest thing to do is to hook the TXD of a serial port to the Dynamixel signal wire with a 68 Ohm resistor, then back to the RXD port with another 68 Ohm resistor. Then configure that serial port for the speed you have set your Dynamixels to (default 57600 bps I think, can go up to 1000000 bps.) Write correctly formatted packets to the TXD, and you will receive them back on the RXD; then wait for a response from the servo. If you're running at 1000000 bps, you want to keep interrupts off and poll the receiver for bytes, rather than rely on the built-in Serial port, as that speed is faster than the Arduino can keep up with using interrupt-based receiving.

The actual protocol is documented on the Robotis support site:

http://support.robotis.com/en/product/dynamixel/dxl_communication.htm

(http://support.robotis.com/en/product/dynamixel/dxl_communication.htm)