Biblioteca de Arduino para AX-12

El Dinamyxel AX-12+ es un un servo digital “inteligente”, fabricado por la empresa coreana Robotis e incluido en sus kits robóticos Bioloid (que cuando pueda me voy a comprar uno); es lo que podríamos llamar un “superservo”.

Algunas de sus características, que me vienen a la mente ahora:

  • soporta rotación continua y modo servo standard, este último con un radio de giro de 300 grados
  • velocidad y torque ajustables
  • velocidad máxima: 300 grados/seg. Torque máximo: 16Kg/cm
  • comunicación serial a 1Mb/s, half duplex. Se pueden conectar varios motores en cadena a un mismo bus.
  • usa un microcontrolador ATmega8 (vale decir que adentro de cada motor hay una Arduino de las viejas)
  • 10 bits de resolución en todos los parámetros (0-1023)
  • alimentación de 7-10V (los servos standard funcionan entre 4,5-6V)
  • feedback de todo tipo de información: posición angular, temperatura, voltaje, fuerza, velocidad, sobrecarga, errores, etc.  a través del bus serial, y posee además un led de notificación.
  • y lo que más me gusta: viene con los famosos “brackets” en forma de “U”, de un plástico muy resistente, tornillos, y otras piezas mecánicas de gran interés, por sólo 45 dólares.

Cuando me enteré de la existencia de tan maravilloso actuador, comencé a buscar información sobre su control mediante Arduino. Dado que el propio motor implementa un ATmega8 y que el microcontrolador central de los Bioloid es un ATmega128, pensé que tenía que ser más que posible dicha combinación.

Afortunadamente encontré este proyecto, el ArbotiX RoboController, que es justamente una placa controladora de robots capaz de manejar los AX-12, basada en ATmega644 y de código abierto. La ArbotiX está basada en Sanguino, y no en la Arduino propiamente dicha. La principal diferencia es que estas placas, al igual que la CM-5 del Bioloid, tienen dos puertos USART, mientras que la Arduino “clásica” tiene solamente uno.

Si usamos los AX-12 en un proyecto, siempre nos va a convenir tener un segundo puerto serial, para comunicar con la PC u otro hardware “superior”. En el caso de la Arduino clásica, esto se resuelve usando la biblioteca SoftwareSerial, que fue lo que yo hice en el video de más abajo. Hay que tener en cuenta que la SoftwareSerial está limitada a 9600 baudios, y que consume memoria y tiempo del procesador, pero en muchos casos esto no representa mayor problema.

En resumen, la adaptación de la biblioteca de ArbotiX a una Arduino clásica consistió simplemente en cambiar el nombre de algunos registros. Una vez que probé que esto funcionaba, aproveché para ampliar y mejorar la funcionalidad de la librería, y actualmente estoy trabajando con mi propia versión, que pueden descargar aquí.

En el video de prueba, el setup es el siguiente:

  • los pines 0 y 1 (RX y TX) van unidos entre sí y conectados al pin de datos del AX-12
  • la alimentación del AX-12 se extrae de los mismos 9V que alimentan a la tarjeta
  • los pines 2 y 3 se utilizan con la “software serial”, y van conectados a un convertidor serial-USB (FTDI) el cual a su vez se conecta al PC y es monitoreado con el Putty. No es posible usar para esto el propio convertidor serial-USB incluido en la Arduino, ya que el mismo se encuentra físicamente soldado a los pines 0 y 1.

Bueno, aquí les dejo el video. Saludos!

Imagen de previsualización de YouTube

Be Sociable, Share!

372 Comentarios »

  1. avatar Bernice Franklin Dice:

    This article was very useful for a paper I am writing for my thesis.

    Thanks

    Bernice Franklin

  2. avatar Oskar Mobardov Dice:

    Dear Pablo

    I need very urgent your help!

    Can you give me a hint, how can I run my ax-12 with ardunio?

    Can I you give me a hint, how I must to wire ardunio and ax-12?

    Best regards,
    Oskar

  3. avatar pabloxid Dice:

    Hi Oskar, you have to wire TX and RX together to AX12 data pin, and use this library (go to “descargas” section to download it).

  4. avatar Proyecto Butiá | Palmera blog Dice:

    […] se optó por comenzar el desarrollo usando Arduino, dada la facilidad ofrecida por la biblioteca para controlar motores AX-12+, pero sin descartar una futura implementación usando el hardware […]

  5. avatar Oskar Mobardov Dice:

    Dear Pablo

    Thank you very much for your reply.

    Can you give us your test Arduino Sketchfile (pde) for ax-12?

    I’ve no idee, how can i use ax12.cpp and ax12.h file with arduino editor.

    Thank you.

    Best regards,
    Oskar

  6. avatar pabloxid Dice:

    You have to put these files into a folder under the “libraries” folder of yor Arduino IDE installation. Please note that this folder is not in the same place for Arduino 0018 and previous IDE releases. For 0017 and older, the folder is \hardware\libraries.

    Then, you can load this code in Arduino IDE to test the motors:

    #include < SoftwareSerial.h >
    #include < ax12.h >

    SoftwareSerial swSerial (2, 3);

    void setup() {
    ax12Init (1000000);
    swSerial.begin(9600);

    writeData (14, AX_TORQUE_ENABLE, 1, 1); // “14” is the motor ID

    }

    void loop() {

    int error = ping (14);
    swSerial.print (“ping ID: “); swSerial.print (status_id, DEC);
    swSerial.print (” int.error: “); swSerial.print (error, DEC);
    swSerial.print (” status.error: “); swSerial.println (status_error, DEC);
    swSerial.println (” “);

    error = readData (14, AX_PRESENT_TEMPERATURE, 1);
    swSerial.print (“temperatura: “); swSerial.print (status_data, DEC);
    swSerial.print (” int.error: “); swSerial.print (error, DEC);
    swSerial.print (” status.error: “); swSerial.println (status_error, DEC);
    swSerial.println (” “);

    error = writeData (14, AX_GOAL_POSITION_L, 2, int(random(1024)));
    swSerial.print (“goal position ID: “); swSerial.print (status_id, DEC);
    swSerial.print (” int.error: “); swSerial.print (error, DEC);
    swSerial.print (” status.error: “); swSerial.println (status_error, DEC);
    swSerial.println (” “);

    delay (200);

    error = readData (14, AX_PRESENT_POSITION_L, 2);
    swSerial.print (“posicion: “); swSerial.print (status_data, DEC);
    swSerial.print (” int.error: “); swSerial.print (error, DEC);
    swSerial.print (” status.error: “); swSerial.println (status_error, DEC);
    swSerial.println (” “);

    }

  7. avatar Oskar Mobardov Dice:

    Hi Pablo

    You are my HERO!!!!

    Thank you very very very much!!!

    Can u tell me please, which kind of terminal software you are using?

    Best,
    Oskar

  8. avatar pabloxid Dice:

    PuTTY. Please note that terminal is connected to Arduino via a serial-USB converter on pins 2,3. These pins are used by the SoftwareSerial library.

    In more recent implementation, I just use the FTDI chip included in Arduino, I detach it from pins 0,1 and connect it to pins 2,3. Then, I reconnect it to pins 0,1 when programming the board.

  9. avatar MikeFr Dice:

    Hi Pablo,

    Nice Work ;)

    I just have a little problem with your example… :(

    When i try to compile your example Sketch you gave us just above i have some errors.

    I give you the result of compiling :

    ——————————————-
    C:\arduino-0018\libraries\Bioloid\ax12.cpp: In function ‘void setTX()':

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:44: error: ‘UCSR1B’ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:44: error: ‘RXEN1′ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:45: error: ‘TXEN1′ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:46: error: ‘RXCIE1′ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp: In function ‘void setRX()':

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:59: error: ‘UCSR1B’ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:59: error: ‘TXEN1′ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:60: error: ‘RXEN1′ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:61: error: ‘RXCIE1′ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp: In function ‘void ax12write(unsigned char)':

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:68: error: ‘UCSR1A’ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:68: error: ‘UDRE1′ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:69: error: ‘UDR1′ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp: In function ‘void ax12writeB(unsigned char)':

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:74: error: ‘UCSR1A’ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:74: error: ‘UDRE1′ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:75: error: ‘UDR1′ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp: In function ‘void USART1_RX_vect()':

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:80: error: ‘UDR1′ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp: In function ‘void ax12Init(long int)':

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:123: error: ‘UBRR1H’ was not declared in this scope

    C:\arduino-0018\libraries\Bioloid\ax12.cpp:124: error: ‘UBRR1L’ was not declared in this scope
    ——————————————-

    Can you help please??!!

    Thanks a lot for answers!

    Regards,

    MikeFR

  10. avatar MikeFr Dice:

    Sorry My mistakes!!!!!!

    Before i found your blog i tried with another tutorial on trossen robotics but it was successless!

    and they give me the bioloid librairy and at the compilation Arduino gave me : C:\arduino-0018\libraries\Bioloid\ax12.cpp:124 … error!

    Well that’s done but i have another issue!

    now i have this error message :

    ——————————————-
    30: error: SoftwareSerial.h : No such file or directory In function ‘void setup()':
    In function ‘void loop()':
    ——————————————-

    Do you have an idea ??

    Thanks for help,

    Regards,

    Mike

  11. avatar MikeFr Dice:

    Sorry, it’s me again ^^

    I resolve my problems of compilation.

    I reduce your sample code to that, this is only to make the servo moving without informations.

    ——————————————-
    #include
    #include

    SoftwareSerial swSerial (2, 3);

    void setup() {
    ax12Init (1000000);
    swSerial.begin(9600);

    writeData (14, AX_TORQUE_ENABLE, 1, 1); // “14″ is the motor ID

    }

    void loop() {
    writeData (14, AX_GOAL_POSITION_L, 2, int(random(1024)));
    delay (200);
    }
    ——————————————-
    but the servo won’t move and it’s plug correctly.

    How did you choose your ID 14 ??
    maybe my probleme it’s my serov doesn’t have the same ID ?

    Thanks,

    Mike

  12. avatar pabloxid Dice:

    Hi Mike, thank you for trying the AX-12 library.

    Well, the problems that you have in first post are related to microcontroller/Arduino board model. The original library is for ATmega644 and mine is for ATmega168/328.

    The problems in second post are related to SoftwareSerial or NewSoftwareSerial, a library that I use in example only for PC monitoring. You can download it on Arduino homepage.

    The problems in third post are mostly related to motor ID. I choose 14 because my servo has ID 14, maybe yours have ID 0 or 1.

    I come with an updated library version, that avoid all these problems, beacuse it support all microcontroller models (ATmega8, 128, 168, 328P and 1280) and feature ID auto-detection functionality. Please let me know if you are interested, then I upload it for you.

    Best regards,

    P.G.

  13. avatar MikeFr Dice:

    Hi Pablo,

    Thanks a lot for your answers!! That’s could be useful, I’ll try your advices and tell you what happened. :)

    For the update of your library, I’m interested because my project is going to run on different micro controller, so when it’s available, tell me ;)

    Regards,

    Mike

  14. avatar MikeFr Dice:

    Hi again Pablo,

    A little feedback to say that’s Works!!!! :)

    But new problems : I want to implement 2 servos in my system.

    But when I connect the two servos, they had the same IDs (1).

    I try to change the IDs with the following line code :

    writeData (1, AX_ID, 1, 2); //Change ID 1 to 2

    But now my servo doesn’t work anymore :(
    Did I make something wrong ??

    Thanks!

    Regards,

    Mike

  15. avatar MikeFr Dice:

    Hi Pablo,

    A little question : Do you implement the Sync Write Function ??

    Cause I’m interested :)

    Thanks,

    Best Regards,

    Mike

  16. avatar pabloxid Dice:

    Hi Mike.

    I don’t see anything wrong in that code. I’ve used the same method to change my AX-12’s IDs. Make shure that only one servo is connected when you perform the change, otherwise the two servos will get affected.

    The new library’s auto-ID detection feature can simplify your work. I will upload it as soon as possible. The sync write is not yet implemented, unfortunately.

    Best regards,

    P.G.

  17. avatar pabloxid Dice:

    Hi Mike.

    You can download the new AX-12 library here:

    http://www.pablogindel.com/images/ax12v2.0.rar

    If you use an Arduino Mega, the AX12-bus works on Serial1, so, you can’t use Serial1 in yor project. For using the other serial ports, you have to edit the HardwareSerial.cpp file (in Arduino Cores) and make the following changes, in order to avoid compilation errors:

    // modificación para usar la biblioteca AX12
    /*SIGNAL(SIG_USART1_RECV)
    {
    unsigned char c = UDR1;
    store_char(c, &rx_buffer1);
    }*/

    Sorry but no documentation is available by the moment.

    Regards,

    P.G.

  18. avatar MikeFr Dice:

    Thanks a lot Pablo, You’re a master :)

    Regards,

    Mike

  19. avatar jhonatan garcia Dice:

    hola pablo espero que estes bien quiero hacerte una pregunata acabo de descargara el software de arudunio ahora , como le meto la libreria que desxcargue de tu pagina y otra pregunat se pueden mover 3 servos a la vez? pues con diferente id, me gustaria comentarte lo que quiero para hacer mi tesis te agradezco mucho si me pudieras colaborar

  20. avatar jhonatan garcia Dice:

    otrap pregunta tu como haces para saber la pocicion en la que se encuentra el servo , y como le envias ordenes al servo para que se mueva , hay retroalimentacion de torque? muchas gracias Pablo agradezco tu respueta

  21. avatar pabloxid Dice:

    Hola jhonatan, gracias por visitar el blog.

    No sé qué versión bajaste, si la 1.0 o la 2.0; en cualquier caso, lo que debes hacer es crear una carpeta “AX12″ dentro de la carpeta “Libraries” del software de Arduino, y meter allí los 2 archivos de la biblioteca: ax12.h y ax12.cpp. Luego, si has bajado la 2.0 cargas el archivo .pde de ejemplo, y de lo contrario, utilizas el código que le envié en respuesta al usuario Oskar, en esta misma página.

    En el hardware, lo que tienes que hacer es unir RX y TX y conectarlos ambos al pin de datos del AX-12.

    Se pueden utilizar varios servos simultáneamente, simplemente pones el ID en cada comando, si usas la 1.0, y si usas la 2.0, es más simple aun, sólo defines una instancia de la clase Ax12 para cada motor, y puedes usar la autoDetect para asignarles el ID a cada una.

    Saludos,

    P.G.

  22. avatar pabloxid Dice:

    Hay retroalimentación de torque, de velocidad y de posición. La biblioteca implementa lo necesario para acceder a estos datos. Te recomiendo leer el manual del AX-12 y luego mirar mi código de ejemplo, allí está todo.

    Saludos,

    P.G.

  23. avatar jhonatan garcia Dice:

    otra pregunta , que pena por molestar tanto , pero que clase de circuito esta en el video que muestas en la parte de arriba, se que esta el arduino pero el que muestas en el minuto 1:24 del video que es . yo puedo envierle una clase de instrucciones a lso servos o , osea tengo que enviarle una trama de datos como dice en el manual de los servos. muchas gracias

  24. avatar pabloxid Dice:

    Es un convertidor USBSerial, utilizado para monitorear el programa en un terminal. No es necesario para el funcionamiento de los motores.

    La biblioteca tiene todo para manejar fácilmente los motores, sólo mira los ejemplos.

  25. avatar MikeFr Dice:

    Good Morning Pablo!

    I thought about somethings yesterday,If I’m using an arduino Mega, Can I use the Serial 1 to connect my Servos and the others serial ports (1,2,…) to get back the informations of the servos (like temp, position, etc…) ??

    And another things, How Can i improve the precision of my servos ? I explain,

    I connect a Potentiometer to my arduino and I use it to control the servos on the full range.

    Now I want to use that potentiometer in full range (0-1023) to move my servos on a range of 0-5 degrees.

    I used the map() function to scale the values but my servos move well when I move quickly the potentiometer, but when I’m going slowly the servo don’t move and then “make a jump” to an approximative position.

    Do you have some suggestions about my problem ??

    Thanks a lot for your time ;)

    Regards,

    Mike

  26. avatar MikeFr Dice:

    Hello again! ^^

    (Sorry I’m disturbing you a lot…)

    I try to implement the sync write function in your older version of your library.

    I follow what is write in the data sheet but I don’t see any difference with the writeData function! :(

    What do you think ??

    ——————————————-
    byte SyncWrite (byte regstart, byte reglength, int value) {
    byte data [(reglength+1) 2 + 4]; //According to the Datasheet page 24
    data [0] = regstart; data [1] = reglenght;
    data[2] = 0x01; //First Motor
    data[3] = value&0xFF;
    if (reglength > 1) {data[4] = (value&0xFF00)>>8;}
    data[5] = 0x02; //Second Motor
    data[6] = value&0xFF;
    if (reglength > 1) {data[7] = (value&0xFF00)>>8;}
    ax12SendPacket (0xFE, reglength+1, AX_REG_WRITE, data); //Send the packet with Broadcast ID 0xfe
    return ax12ReadPacket();
    }

    ——————————————-

    This is the first time i’m working directly in a library, so be fair with me, I’m new :)

    Thanks,

    Regards,

    Mike

  27. avatar jhonatan garcia Dice:

    hola pablo acabo de ler lo que me respondiste muchas gracias voy a hacer que me dijiste, cuando hablas de la version 2, es de la bibiotleca edl ax12 cierto , si descargue esa, entocnes voy a ahcer eso , muchas gracias

  28. avatar jhonatan garcia Dice:

    hola pablo tu podrias publicar el codigo que itilizaste en el video, para ver los movimientos y los comandos y obetener ea retroalimentacion

    gracias

  29. avatar pabloxid Dice:

    Hi Mike, about the precision problem:

    yeah, I know exactly the source of that problem. This has to do with the CW_COMPLIANCE_MARGIN, CCW_COMPLIANCE_MARGIN, CW_COMPLIANCE_SLOPE and PUNCH parameters, shown in my version 2.0’s example. Notice AX12 manual, page 16, for explanation about this issue.

    Regards,

    Pablo.

  30. avatar pabloxid Dice:

    Mike, about your Sync Write implementation:

    hmmm, let me consider the matter, and I reply sooner.

  31. avatar pabloxid Dice:

    La versión 2, puedes descargarla aquí, ya viene con un .pde de ejemplo

    http://www.pablogindel.com/images/ax12v2.0.rar

    Saludos,

    P.G.

  32. avatar pabloxid Dice:

    El código está publicado aquí mismo, búscalo en las primeras respuestas a los comentarios. Ese código es para la version 1, la version 2 trae su propio código de ejemplo.

    Saludos,

    P.G.

  33. avatar jhonatan garcia Dice:

    Buenas tardes Pablo
    he seguido todas las instrucciones que me has dado , descargue la segunda version y cree la libreriioa con los arrchivos que estan adentro , luiego le di compilar el ejemplo que se llama ax12test2, pero me arroja el siguiente error y no se que hacer

    C:\DOCUME~1\pc334\CONFIG~1\Temp\build7831609751381171514.tmp\core.a(HardwareS
    erial.cpp.o): In function `__vector_18′:

    C:\Documents and Settings\pc334\Escritorio\arduino\arduino-0018\arduino-0018\hardware\arduino\cores\arduino/HardwareSerial.cpp:95: multiple definition of `__vector_18′

    C:\DOCUME~1\pc334\CONFIG~1\Temp\build7831609751381171514.tmp\ax12\ax12.cpp.o:C
    :\Documents and Settings\pc334\Escritorio\arduino\arduino-0018\arduino-0018\libraries\ax1
    2/ax12.cpp:87: first defined here

    te agradezco si me puedes seguir ayudadno , estoy alimentando el servo con una fuente externa , lo estoy haciendo bien?
    gracias

    jhonatan

  34. avatar pabloxid Dice:

    Debes editar el archivo “HardwareSerial.cpp” que está dentro de la carpeta donde has instalado el IDE de Arduino, y hacer la siguiente modificación:

    // modificación para usar la biblioteca AX12
    /*SIGNAL(SIG_USART1_RECV)
    {
    unsigned char c = UDR1;
    store_char(c, &rx_buffer1);
    }*/

  35. avatar pabloxid Dice:

    El ejemplo es para Arduino Mega, tú qué modelo de Arduino tienes?

  36. avatar jhonatan garcia Dice:

    Buenas trades Pablo
    voy a hacer los cambios que me dices, mi arduino es el duemilanove con este se puede correr el programa de prueba

    muchas gracias

  37. avatar jhonatan garcia Dice:

    otra vez yo que pena pablo si te incomo porfa me lo haces saber, es lo que menos quiero hacer muchas gracias por tu ayuda pero hice elcambio que me dijiste y ahora me arroja el siguiente erro lo unico que cambia con el error anterior es el numero largo que sale

    C:\DOCUME~1\pc334\CONFIG~1\Temp\build8277698458456560908.tmp\core.a(HardwareS
    erial.cpp.o): In function `__vector_18′:

    C:\Documents and Settings\pc334\Escritorio\arduino\arduino-0018\arduino-0018\hardware\arduino\cores\arduino/HardwareSerial.cpp:95: multiple definition of `__vector_18′

    C:\DOCUME~1\pc334\CONFIG~1\Temp\build8277698458456560908.tmp\ax12\ax12.cpp.o:
    C:\Documents and Settings\pc334\Escritorio\arduino\arduino-0018\arduino-0018\libraries\
    ax12/ax12.cpp:87: first defined here

    muchas gracias

  38. avatar pabloxid Dice:

    Johnatan:

    Si tienes una Duemilanove, debes eliminar del programa de ejemplo todas las líneas que empiezan por “Serial.”

    La razón es que el ejemplo está hecho para Arduino Mega, que tiene 4 puertos seriales, pero la Duemilanove tiene únicamente 1 puerto serial, y es el que se utiliza para los motores AX12, de modo que no puedes usar el mismo puerto serial como feedback hacia la PC. La opción en ese caso es habilitar las íneas que dicen:

    #include
    y
    SoftwareSerial swSerial (2, 3);

    Luego sustituyes en el código todas las ocurrencias de “Serial” por “swSerial”, y conectas un convertidoy USB<>Serial en los pines 2 y 3 de la Arduino, como hice yo en el video.

    De lo contrario, simplemente elimina todas las líneas que hablen de Serial, y así podrás manejar los motores, pero no tener Feedback.

    Un abrazo,

    Pablo.

  39. avatar MikeFr Dice:

    Hi Pablo,

    I want to know, when i try your example, when the motors finish to initialize one of my two servos can’t stop, is moving around the command.

    That’s can be due that I plugged the motors in “Daisy Chain” ??

    And did you take a look to the Sync Write I wrote a few days ago ???

    Thanks,

    Regards,

    Mike

  40. avatar jhonatan garcia Dice:

    Buenos dias Pablo
    mira quisiera pedirte un consejo especial, hable con mi companera de tesis y pues queremos comprar el arduino que mejor se adapte a lo que necesitamos , el consejo es comprar el arduino mega o cual hay alguno ultima version que podamos tener retroalimentacion de torque y de posicion
    espero tu respuesta y hare lo que me dices gracias

  41. avatar jhonatan garcia Dice:

    Pablo, hice algunas pruebas como me dices pero ya me conpila pero no me funciona , es decir no se mueven los servos , del codigo quite lo que empieza por serial y ya me compila, en el hardware cortocircuito los pines tx y rx y ese corto es el de datos del servo y no me sale nada.
    si utilizo el duemilaneve y no quiero que haya comunicacion con el pc sino por software controlar algunas pociciones podria hacerlo con este arduino? los servos me envian algun dato al arduino osea retroalimentacion de la pocision y torque pero no al pc sino al arduino y digamo yo preguntar si la posicion es esta comparela con alguna almacenada y que me encienda un led o deje de moverse esto seria posible muchas gracias

  42. avatar pabloxid Dice:

    Mike:

    Each command returns two error codes, one from the motor itself and the other from the library. They can help you determine the source of the fault.
    In my experience, most failures that I’ve found are due to low voltage supply, especially if it’s the 2nd servo in the chain.

    Regarding the sync write, no, I could not even look at it :(

  43. avatar pabloxid Dice:

    Hola Jonathan.

    Retroalimentación desde el motor hacia la tarjeta tienes en todos los casos, pero si quieres a su vez trasmitir esos datos via Serial al PC, entonces necesitas una Arduino Mega. Si lo que quieres es usar esa información en tu programa dentro de la Arduino, entonces puedes usar una Duemilanove.

    Saludos,

    P.G.

  44. avatar pabloxid Dice:

    Hola Jonathan.

    mmm.., el ejemplo es para 2 servos, veré de hacerte un ejemplo más sencillo para poder determinar la causa del error.

    Respecto a tu segunda pregunta, sí, todo eso es posible con la Arduino Duemilanove. No necesitas una Mega si no piensas interactuar con la PC.

    Saludos,

    P.G.

  45. avatar jhonatan garcia Dice:

    Hola Pablo yo tengo 3 servos , hice la prueba con dos no mas y tampoco se mueven , estoy haciedno lo siguiente
    los pines 0 y 1 los cortocircuito y de esa union lo envio al pin de datos del servo uno , uego con el otro es una comunicacion en serie.
    cuando compilo no arroja error pero cuando le doy quemar o subir(upload)progrma me arroja el sigueiente error

    avrdude: stk500_getsync(): not in sync: resp=0x30

    avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

    estoy haciedno algo mal
    disculpa la molestia causada

  46. avatar pabloxid Dice:

    Sí, mientras subes el programa, debes mantener desconectados los AX12, y sobre todo, sin cortocircuitar RX y TX, ya que es el mismo puerto que se usa para subir el programa.

    Saludos,

    P.G.

  47. avatar jhonatan garcia Dice:

    hola pablo no se que estoy haciedno mal la verdad por que no he logrado mover los servos ,me di cuenta de algo no se si sea la razon el arduino que yo tengo es este
    http://www.sigmaelectronica.net/sigduino-2009-p-1143.html
    sera qeu influye o me puedes ayudar a hacer un programa simple que la rueda gire te lo agradezco
    que pena con tigo sera que tienes un correo donde te puede explicar lo que quiero hacer para que me des una guia te lo agradeceria

  48. avatar pabloxid Dice:

    Hola Jhonatan, mi correo es palmer@pablogindel.com.

    A priori esa tarjeta debería funcionar perfectamente, no veo razón para que no funcione con los AX-12.

    Las causas del problema podrían ser varias, habría que probar independientemente cada parte, los motores, la arduino, la fuente de alimentación, el pinout, los cables, los IDs, etc., etc.

  49. avatar Aeropónica | Palmera blog Dice:

    […] básicamente posible, porque es precisamente lo que hicimos en el Proyecto Butiá con los motores AX-12. No había tiempo para hacer más pruebas, de modo que la solución adoptada fue usar 2 Arduinos […]

  50. avatar jhonatan garcia Dice:

    hola Pablo donde podrias descargar la version uno del ax-12 si quisiera compilar el primer programa que tienes en la parte de arriba me arroja el sienguiente error

    In function ‘void setup()':
    error: ‘ax12Init’ was not declared in this scope In function ‘void loop()':

    y si elimmino esa linea me arroja
    In function ‘void setup()':
    error: ‘AX_TORQUE_ENABLE’ was not declared in this scope In function ‘void loop()':

    lo que creo es que no me reconoce la libreria #include o pues yo descargue la version 2

    muchas gracias

  51. avatar pabloxid Dice:

    La versión 1 la obtienes en la sección “descargas” de este mismo sitio.

    Saludos,

    P.G.

  52. avatar jhonatan garcia Dice:

    Buenos dias pablo espero que estes bien mira con mi compañera decidimos comprar el arduino mega ya lo tenemos ahora quisiera hacerte una pregunta para saber bien los comandos que necesito prara programas los servos sabes de alguna guia guia o algo asi donde pueda leer , te lo agradezco tu ayuda ha sido fundamental para mi trabajo gracias, voy a probrar el programa que tienes gracias

  53. avatar jhonatan garcia Dice:

    Buenas tarde Pablo
    el programa de test compila pero me arroja el siguiente error

    internal error 7
    AX12 error -1

    hice lo siguiente para tratar de mover los servos . cortocircuite los pines tx y rx y los uni al pin de datos del servo , el arduino esta alimentado con la misma fuente por ende , poseen la misma tierra y el boudrate del servo tiene el mismo del programa ,muchas gracias

  54. avatar Pabloxid Dice:

    Hola Jonathan, qué tal?

    La decodificación de los errores es la siguiente:

    error interno:
    Bit 0 = Error de Cabecera
    Bit 1 = Error de Coherencia
    Bit 2 = Error de Checksum

    error del AX12:
    Bit 6 = Instruction Error
    Bit 5 = Overload Error
    Bit 4 = Checksum Error
    Bit 3 = Range Error
    Bit 2 = Overheating Error
    Bit 1 = Angle Limit Error
    Bit 0 = Input Voltage Error

    Por lo que veo, te está dando error interno 7, es decir que los 3 bits están activados, significa que no está recibiendo absolutamente nada ni parecido a un mensaje AX12. El otro error te da -1, porque no hay ningún byte de error para decodificar.

    Te comento que si usas Arduino MEGA, los pines que debes conectar al motor son los RX y TX correspondientes al Serial1, no los que dicen RX y TX a secas.

    Respecto a la fuente del motor, la misma debe ser de 10V y ambas tierras deben estar conectadas.

    Asegúrate de que el motor esté configurado para enviar mensajes, de esta manera sabremos si el error 7 se debe a que hay una fallo importante en la comunicación, o a que el motor no envia respuestas, en cuyo caso habría que buscar por otro lado la causa de que no se mueva.

    Todo parece indicar que hay un gran problema en la comunicación.

  55. avatar Ricardo Dice:

    Hi,

    Did you connect the AX-12+ data pin to the arduino UART directly, without any IC?

  56. avatar pabloxid Dice:

    Yes, this is correct.

    Actually, I connect it to both RX and TX simultaneusly.

  57. avatar Tom Dice:

    Hello Pablo!
    Your library of AX12 code looks very impressive. I intend to build a juggling robot using the AX12 and driven – in the prototype phase – by an Arduino. Actually, it’s an iDuino clone.

    I have downloaded your version 2 lib and the example.

    I commented out all the serial stuff in order to get the example to compile. Shouldn’t the serial calls invoke the created object “swSerial”?

    Thanks for the good work.

    Tom

  58. avatar pabloxid Dice:

    Hi Tom, welcome!

    The example was not really made thinking in order to distribute the library, it is a mixture of code I used in the video with the Butia robot’s code, that uses 2 AX12-motors. I made it quickly, but I don’t remember to test what.

    Version 1 only worked with ATmega168 and 328, so used “swSerial” to have a second serial port. Version 2 supports all Arduino models, and the example is made for Arduino Mega, so the “swSerial” was replaced by “serial.”

    But, in order to compile it, you have to modify the “HardwareSerial.cpp” arduino file, the way that I have posted in another comment. The reason for this is that the library uses its own code to operate the UART, which is incompatible with the Arduino implementation, but is perfectly functional and lets you use the other ports normally.

    Regards,

    Pablo.

  59. avatar Savage Dice:

    Hola, espero puedas ayudarme ya que acabo de adquirir un arduino “Uno” este también tiene un ATMEGA328 pero ya he intentado con las librerías y no he podido hacer que el servo hago algo, podrías ayudarme con un pequeño programa que lo único que haga sea mover el servo para darme un ejemplo y de ahí poder continuar

  60. avatar pabloxid Dice:

    Hola, Savage. Qué versión de la biblioteca estás usando, con qué programa de ejemplo y qué error te arroja? Estás seguro de haber conectado bien las cosas a nivel del hardware?
    Los motores están bien alimentados?

  61. avatar Savage Dice:

    Hola, Estoy utilizando la primera versión de la biblioteca, no arroja ningún error solo que el servo no hace nada. He conectado el RX Y TX del arduino hacia el pin de data del servo y la alimentación del servo, Hay alguna forma de saber si realmente esta enviando algo el arduino???. Grax :P

  62. avatar pabloxid Dice:

    Si usas la primera versión, debes tener cuidado de poner correctamente la ID de tu motor en el código. Si es un motor comprado de fábrica, habitualmente tiene la ID 1.

    Hay forma de saber lo que llega al motor utilizando el puerto serial por software, tal como hace en el ejemplo.

  63. avatar Savage Dice:

    Si he comprobado desde la ID 0 hasta 253, e incluso la 254, y no puedo comprobarlo como en ejemplo ya que no cuento con un FTDI.
    Si no mal entendi el codigo, podria mandarle las instrucciones con writeB() ( writeB(0xFF); writeB(0xFF); writeB(0x01);… length.. instrucciones y checksum )pero parece no importar, el servo no se mueve. ya no se que pueda estar fallando. Gracias de todas formas :P

  64. avatar pabloxid Dice:

    te recomiendo que uses writeData(), por ejemplo así:

    writeData (14, AX_GOAL_POSITION_L, 2, 768);

    donde 14 es el ID del motor, y 768 la posición a la que lo quieres llevar.

    es importante que primero que nada hagas un:

    writeData(14, AX_TORQUE_ENABLE, 1, 1);

    para habilitar el torque, de lo contrario el motor no se moverá.

    Saludos,

    P.G.

  65. avatar Savage Dice:

    He hecho esto pero aun así no se mueve solo prende el led del servo y de ahí no pasa más.

    ******************************************************************
    #include

    void setup() {
    ax12Init(1000000);
    writeData(1,AX_TORQUE_ENABLE,1,1);
    }
    void loop() {
    writeData(1,AX_GOAL_POSITION_L,2,768);
    delay(1000);
    }
    ******************************************************************
    El Voltaje que le llega al servo es de 8v, será suficiente?

  66. avatar pabloxid Dice:

    El voltaje es suficiente sí. Ahí lo que puede estar pasando es que el ID no sea 1 o que el motor no esté seteado a 1Mb/s.

    Si usaras la versión 2 de la biblioteca y con una Arduino Mega sería muy simple de diagnosticar.

    Si tienes el controlador de Bioloid, te recomiendo que resetees el motor a su estado de fábrica y vuelvas a intentar.

    El led se debe prender al principio y luego apagarse. Si el led permanece prendido significa que hay errores, casi siempre problemas de alimentación.

    Saludos,

    P.G.

  67. avatar Savage Dice:

    Hola, creo saber que es lo que pasa, he puesto a prueba todas las velocidades de transmision que se pueden configurar para el servo y visto que cuando envio datos seriales desde 500000 bits/s en el arduino prende el led de TX y cuando lo coloco a 1Mb/s no prende este led como hago que envie a 1Mb/s Es una ( arduino uno ) es capaz de enviar datos a ese velocidad ?? que estara fallando por que no querra enviar los datos a 1Mb/s :P Grax

  68. avatar pabloxid Dice:

    La velocidad de comunicación con los motores se establece en esta línea:

    ax12Init(1000000);

    Ahí estaría seteado a 1Mb/s, por ejemplo. Yo nunca he probado esto con una Arduino Uno, pero en teoría debería funcionar.

    Nótese que en la Arduino Duemilanove los pins TX y RX estaban conectados al chip FTDI, pero esto no parecía estorbar a los AX-12. Por las dudas sugiero mantener el USB desconectado y alimentar la placa con una fuente externa.

    En la Arduino Uno, el FTDI ha sido sustituido por otro chip, y talvez allí radique el problema, por eso en este caso sugiero más aún mantener el USB desconectado.

    Saludos,

    P.G.

  69. avatar Savage Dice:

    Ya he probado con alimentación externa y no hay cambios, el arduino uno tiene un micro Atmega328P-PU cual tiene el arduino Duemilanove?? quiza cambien los registros del micro. :P

  70. avatar Ryansway Dice:

    I’ve tried ver 2 of your library using different boards and this error keeps occurring?

    ax12Init’ was not declared in this scope

    The .rar file on your downloads page is empty (its size is 4kb and there is nothing inside the folder and no .pde), so I have used files you posted in this comments section.

  71. avatar pabloxid Dice:

    .rar file is not empty, there is a .pde inside it, along with the .cpp and .h library files.

    Please try again with this link:

    http://www.pablogindel.com/images/ax12v2.0.rar

    Thank you.

  72. avatar Ryansway Dice:

    Halo,

    I downloaded ax12v2.0.rar and still there is no pde file.

    I moved ax12.cpp and ax12.h to the folder and deleted the o file.

    Here is the report Arduino creates when it begins with the new library:

    hardware/tools/avr/bin/avr-g++: line 2: readlink: command not found
    ax12.cpp:190:1: warning: “/*” within comment
    ax12.cpp: In member function ‘unsigned char AX12::action()':
    ax12.cpp:264: warning: ‘data’ is used uninitialized in this function
    ax12.cpp: In member function ‘unsigned char AX12::reset()':
    ax12.cpp:257: warning: ‘data’ is used uninitialized in this function
    ax12.cpp: In member function ‘unsigned char AX12::ping()':
    ax12.cpp:250: warning: ‘data’ is used uninitialized in this function
    ax12.cpp: In static member function ‘static void AX12::autoDetect(int*, unsigned char)':
    ax12.cpp:129: warning: ‘data’ may be used uninitialized in this function

    I restarted the Arduin IDE and no errors.

    I have this code which is still generating the error error: ‘ax12Init’ was not declared in this scope In function ‘void loop()':

    Here is the pde code I am using.

    #include
    #include

    SoftwareSerial swSerial (2, 3);

    void setup() {
    swSerial.begin(9600);
    ax12Init (1000000);
    writeData (14, AX_TORQUE_ENABLE, 1, 1); // 14 is the motor ID
    }

    void loop() {

    int error = ping (14);
    swSerial.print (“ping ID: “); swSerial.print (status_id, DEC);
    swSerial.print (” int.error: “); swSerial.print (error, DEC);
    swSerial.print (” status.error: “); swSerial.println (status_error, DEC);
    swSerial.println (” “);

    error = readData (14, AX_PRESENT_TEMPERATURE, 1);
    swSerial.print (“temperatura: “); swSerial.print (status_data, DEC);
    swSerial.print (” int.error: “); swSerial.print (error, DEC);
    swSerial.print (” status.error: “); swSerial.println (status_error, DEC);
    swSerial.println (” “);

    error = writeData (14, AX_GOAL_POSITION_L, 2, int(random(1024)));
    swSerial.print (“goal position ID: “); swSerial.print (status_id, DEC);
    swSerial.print (” int.error: “); swSerial.print (error, DEC);
    swSerial.print (” status.error: “); swSerial.println (status_error, DEC);
    swSerial.println (” “);

    delay (200);

    error = readData (14, AX_PRESENT_POSITION_L, 2);
    swSerial.print (“posicion: “); swSerial.print (status_data, DEC);
    swSerial.print (” int.error: “); swSerial.print (error, DEC);
    swSerial.print (” status.error: “); swSerial.println (status_error, DEC);
    swSerial.println (” “);

    }

  73. avatar Ryansway Dice:

    There may be a problem with some of the Spanish characters in the comments of the .cpp and .h which I have translated to English which has fixed this error:-

    ax12.cpp:190:1: warning: “/*” within comment

    Unfortunately this error still persists:-

    ‘ax12init’ was not declared in this scope In function ‘void loop()’:

    The init function is not even inside the void loop so the error is difficult to understand.

  74. avatar pabloxid Dice:

    the code you are using is not for that library version. On the other hand, seems that you have uncommented some parts of the code.

    Please look deep inside the ax12v2.0.rar and use the .pde file that should be there.

  75. avatar Ryansway Dice:

    I located ax12test2.pde inside the .rar after using an online .rar extractor.

    I used all the files from the rar, deleted the o file, and recompiled.

    Here is the compiler report for ax12test2.pde – I noticed the include SoftwareSerial.h is commented out, is that correct?

    hardware/tools/avr/bin/avr-g++: line 2: readlink: command not found

    hardware/tools/avr/bin/avr-gcc: line 2: readlink: command not found

    /tmp/build36018.tmp/core.a(HardwareSerial.cpp.o): In function `__vector_18′:

    /hardware/cores/arduino/HardwareSerial.cpp:95: multiple definition of `__vector_18′

    /hardware/libraries/ax12/ax12.o:/hardware/libraries/ax12/ax12.cpp:87: first defined here

    Couldn’t determine program size: hardware/tools/avr/bin/avr-size: ‘/tmp/build36018.tmp/AX12.hex': No such file

  76. avatar pabloxid Dice:

    Yes, that’s a known problem, the solution is in another comment.

    You should edit the file “HardwareSerial.cpp” (in Arduino cores) and make the following changes::

    // modificación para usar la biblioteca AX12
    /*SIGNAL(SIG_USART1_RECV)
    {
    unsigned char c = UDR1;
    store_char(c, &rx_buffer1);
    }*/

    Try this.

  77. avatar Ryansway Dice:

    Success! Thank you = )

    I installed a fresh version of Arduino 17. Installed the libraries. Commented out the core code you mentioned in the above post and it compiles perfectly.

    BUT!

    For anyone else reading this, the code will only compile for the Arduino MEGA!!!!!!

    I don’t have a Mega but I’m ordering one now.

    Thanks again Pablo, I might create an English translated version of the library when I have some spare time so I’ll send you a copy when its done.

  78. avatar pabloxid Dice:

    I’m creating a new version 2.2 of the library, with several new features and the much needed documentation. Sync_write support, broadcast messages, different status return levels, and many new things. Will be ready in a few days, as soon as possible.

    On the other hand, the current version 2.0, was tested with Arduino IDE 0018, and several board models, from the NG with Atmega8 to the Mega with ATmega1280.

    Maybe you can help me to translate the documentation, we can send this library to be included in Arduino’s official release.

    I’m currently working on a robot with 18 AX12 motors, controlled with an Arduino Mega.

  79. avatar Ryansway Dice:

    I would be happy to help with the translation, it will be an excellent addition to the Arduino family!

  80. avatar pabloxid Dice:

    By the way, the reason why the code does not compile is:

    The Hardware.cpp modification is to allow using serial ports on the Arduino Mega, but with any other “single serial” board, this cannot be done at all. So if you have an Arduino One, you have to remove any “Serial” reference in the code, maybe replacing it by “SwSerial”.

  81. avatar Ryansway Dice:

    It’s possible using 2 Atmega 168’s connected over i2c and using the serial from one to control the Ax-12, while using the serial from the other to communicate with external devices.

    The 168’s connected on A4+A5 with a pulldown resistor and common ground, and 2 168’s are a lot cheaper than 1 Mega, yes? Two 168’s cost less than US 8 dollars, so very cheap solution.

    Lookup the dualCoreDuino at Arduino, I invented it, and I still have many pcb’s.

    So we need to allow this to compile for the 168, yes?

  82. avatar prax Dice:

    Hi there!
    Pablo, Im very exited about your library. Im trying to use it for a project.
    I did everything Ryansway was summarizing..

    #Arduino 0017
    #placed ax12-labrary in folder
    #using your pde from rar file
    #edited the HardwareSerial.cpp like you explained
    #using Arduino Mega

    but got this ERROR:

    …/ax12/ax12test2/applet/core.a(HardwareSerial.cpp.o): In function `__vector_36′:

    /Applications/arduino-0017/Arduino.app/Contents/Resources/Java/hardware/cores/arduino/originale HardwareSerial/HardwareSerial.cpp:72: multiple definition of `__vector_36′

    …/ax12/ax12test2/applet/ax12/ax12.cpp.o:/Applications/arduino-0017/Arduino.app/Contents/Resources/Java/hardware/libraries/ax12/ax12.cpp:91: first defined here

    What am I missing?

  83. avatar pabloxid Dice:

    You are missing the following:

    1) Arduino 0018 or later is recommended.

    2) the change in HardwareSerial.cpp (it is in several comments above), or otherwise, do not use Serial.

    Take this opportunity to comment that version 2.2 is almost ready, completely re-written, much easier to use, with more features, I just need to complete some documentation details and upload it.

  84. avatar prax Dice:

    your right it compilles with 0018!

    Im really looking forward to see the 2.2 version!

    keep up the work! it is so helpful.
    Thank you!

  85. avatar prax Dice:

    sorry to keeping you away from finishing the 2.2 version =) but i have got a final question.

    Im sure i red it some where but Im not able to find it again:
    How do I have to wire the ax12 to the arduino?
    Just D- in serial send and D+ in serial read?

    What wiring is needed to get the control information back to the Computer?

  86. avatar prax Dice:

    update: im sitting infront of an RX10 servo, which has got 4 pins.

    can i use this one with your library anyway?

  87. avatar pabloxid Dice:

    Apparently, both servos use the same software protocol, but problems can arise in hardware communication layer. AX12 library cannot read and write data simultaneously, for example.

    2.2 version is done. At this point I’m making examples for each of its functions.

  88. avatar prax Dice:

    wouw, you are fast!!!

    i will order some ax12 to get started as soon as you are uploading…

  89. avatar Ryansway Dice:

    If you can post a link of 2.2 and I’ll test and begin the English translation.

  90. avatar Ryansway Dice:

    One more thought also.

    It might be nice to provide detailed instructions about the need to create AX-12 ID’s “before” a main sketch is run.

    So perhaps a separation of both tasks using 2 separate Arduino sketches.

    The first sketch to program the ID of an individual AX-12.

    The second a sketch for using AX-12’s “after” the ID’s have been programmed.

    I think there may be some confusion for new people using AX-12’s and maybe such a separation might assist their understanding.

  91. avatar pabloxid Dice:

    Well, yes, indeed it is advisable before using the library to read the AX12 manual itself and to know how the AX12 motor works.

  92. avatar Ryansway Dice:

    They don’t come with a manual when you buy them and finding literature on the web depends on who the seller happens to be.

    The manual only states “it is imperative that no Dynamixel units share the same ID in a network node”. It is not a very helpful statement for people from the Arduino community who are sometimes only amateur level users looking for fast and easy to understand solutions.

    There is also no mention in the manual about running a small Arduino sketch to change the default ID to a unique number between 1 and 254, so highlighting that point might be useful to help new (Arduino) people save time, and perhaps ask fewer questions = )

  93. avatar pabloxid Dice:

    Ryansway:

    Yes, you’re right.

    I send you a preliminary 2.2 version, with spanish manual and without examples.

    It has several differences with the previous version, for example:

    1) many new features such as syncWrite, multiPos, setPosVel, multiPosVel, etc.

    2) status_id, status_error and status_data variables are over. Now all the functions return an error code and the data when necessary, through a structure.

    3) the error code is one and only, no more “internal error” and “ax12 error”.

    4) Now the library supports the different AX12 status return levels.

    5) provides register-oriented methods (the “smart”) and data-oriented methods. The latter, unlike before, can write and read any number of memory locations simultaneously.

    6) the auto_detect method returns the number of detected motors, and has error checking.

    Here’s the link:

    http://www.pablogindel.com/images/ax12v2.2.rar

    While you translate it, I’m thinking about a solution that makes it easy for the beginner to deal with AX12 IDs.

    Greetings.

  94. avatar Ryansway Dice:

    Excellent work, you are very talented! I will report back my findings once I have explored the new code.

    Best!

  95. avatar Ryansway Dice:

    The example sketch no longer compiles.

    If you can provide a new example sketch so we can begin this from scratch rather than trying to debug old code.

    Thanks.

  96. avatar pabloxid Dice:

    Of course it don’t compiles. I’m currently working on new examples.

    It is assumed that the library is now easy to use, by reading the manual. Try to create your own examples, I’m interested to verify that indeed this is true.

    For now, here’s a sample code that I’m using to set up 18 motors.

    #include

    AX12 * motor;
    AX12 broadcast = AX12();

    void setup() {
    motor = (AX12*) malloc (18*sizeof(AX12)); // array de 18 motores;
    for (byte f=0; f<18; f++) {
    motor [f] = AX12();
    }
    Serial.begin (115200); // inicializa el Serial a 115,2 Kb/s
    AX12::init (1000000); // inicializa los AX12 a 1 Mb/s
    byte detect[18]; // array para detectar automáticamente las ID de 18 motores

    byte num = AX12::autoDetect (detect, 18); // detección de IDs

    Serial.print (" deteccion: ");
    Serial.println (num, DEC);

    for (byte i=0; i<num; i++) {
    motor[i].id = detect[i]; // asigna las ID detectadas a los motores definidos previamente
    motor[i].SRL = 2;
    //motor[i].changeID (int(i/3)*4+(i%3));
    //motor_init (i);
    Serial.print ("motor ");
    Serial.print (i, DEC);
    Serial.print (" ID detectado: ");
    Serial.println (detect[i], DEC);
    Serial.print (" delay: ");
    AX12info test = motor[i].readInfo (RETURN_DELAY_TIME);
    Serial.println (test.value, DEC);
    Serial.print (" error lectura: ");
    Serial.println (test.error, DEC);
    }
    }

    void loop() { }

    The line containing "changeID" has been commented out. This is a new method I wrote to make ID handling easier.

  97. avatar Ryansway Dice:

    Should the following be commented out of HardwareSerial.cpp to compile on 328 and 168?

    //#else

    //#if defined(__AVR_ATmega8__)
    //SIGNAL(SIG_UART_RECV)
    //#else
    //SIGNAL(USART_RX_vect)
    //#endif

  98. avatar pabloxid Dice:

    HardwareSerial.cpp modification is intended for using Serial with AX12 in Arduino Mega. In other Arduino boards you cannot use Serial with AX12 in any way, because they have only 1 port.

    It’s explained in the manual “Hardware Notes” section.

  99. avatar Ryansway Dice:

    I don’t have copious amounts of free time to indulge hobbies and read manuals right now, but I will get around to it once I do.

    Like most people, I download a library, use the example provided, then apply that example for whatever application I have in mind. If that application works, then I make more time to familiarize myself with any manuals using free time that I’ve convinced my wife is worthwhile spending instead of helping with house chores and other mundane tasks.

    One day in the very distant future I’ll be nice and retired and have all day long to play with my hobbies. But until then, its very much spontaneous when the opportunity arises and sometimes I ask dumb questions because life, is a rush : )

  100. avatar pabloxid Dice:

    Ryansway:

    yes, the official distro will have examples, I’m working on this issue now. I either don’t have so much free time as I wish.

  101. avatar prax Dice:

    Hey!

    Nice work pablo! But my spanish is not good enough to work with your manual.
    Your english seems to be very good, have you created a english manual?

    Without an example and a manual its very hard to try your library, and i was so excited about it…

  102. avatar pabloxid Dice:

    I mainly use the google translator to post here, but it’s not enough to translate all manual.

    Regarding the examples, I had to leave work, but will resume as soon as possible.

  103. avatar prax Dice:

    Ok i see, thats bad.

    can you just give an example how to move two servos from angle 0 to 180 in various speeds?

    and

    how to connect them to an Arduino Mega?

    That would be so great!

    with understanding this basics, i could work with you spanish manual and try to get more advanced.

    greetings

  104. avatar prax Dice:

    hey, me again.
    i tried to use your 18 motor example.

    # I wired one ax12+ to 9V
    # the dataPin to Tx & RX of an Arduino Mega
    # changed the hardwareSerial.cpp like you said
    # using Arduino Software 0018
    # compiling your example and run in

    I just get “detection: 0″ when i run it

    any hints, whats wrong?

  105. avatar pabloxid Dice:

    Hi prax.

    Do you wire TX1 and RX1 to AX12 data pin?

    Please verify that.

  106. avatar prax Dice:

    two notes:

    the servo blinks red for a short time, when i plug in the 9V power supply.

    and

    i wired the ground from the servo to the arduino ground

    any hint – whats wrong?

  107. avatar prax Dice:

    no that was the mistake!!!
    I used
    “RX0″ and the “TX1″

    sorry.

    so is it possible to get a short example just to move two servos in various speed from angle 0 to 180?

    thanks so much. You are the only one in the web i found, who is working on a library like yours.

  108. avatar prax Dice:

    If I connect a secound servo i get the “deteccion: 0″ again.

    both of them give me “motor 0 ID detectado: 1
    ” if i plug them in allone

    do they have the same id? and dont work together until I change one servos id?

  109. avatar pabloxid Dice:

    >> do they have the same id? and dont work together until I change one servos id?

    Exactly. To change ID, connect the servo ALONE and use this command:

    motor[0].writeInfo (ID, 35);

    Execute the program one time and then be carefully to remove the line and program the board again, to prevent accidentaly servo reprogramation.

  110. avatar prax Dice:

    it worked! great!

    what is the command to move the servo?
    motor[i].endlessTurn (-500); delay (500);
    or
    void movimiento (byte direccion, int velocidad) {
    motor[0].endlessTurn (-velocidad*bin2sign(direccion&1));
    motor[1].endlessTurn (-velocidad*bin2sign(direccion>>1));
    }

    is there a command just to say “go there” and use “that speed” ?

  111. avatar pabloxid Dice:

    yes, the commad is:

    motor[0].setPosVel (pos, vel);

    where pos and vel are integers in the range 0-1023.

    :)

  112. avatar prax Dice:

    so if I place

    motor[0].setPosVel (20, 1000);
    delay(500);

    in the draw loop it makes the servo move to position “20” with speed “1000” ?

    so this line of code actually move the servo or do i need to call another function?

  113. avatar pabloxid Dice:

    Once the servo is initialized, these simple line of code actually does the job.

    Servo initialization, in this case, consist to enable torque, just one time at the begining, for example in “setup” section:

    motor[0].torqueOn;

    In summary, here is the full code that you have requested:

    #include

    AX12 motor[2] = {AX12(), AX12()};

    void setup() {

    Serial.begin (115200);
    AX12::init (1000000);
    byte detect[2];

    byte num = AX12::autoDetect (detect, 2);

    Serial.print (” deteccion: “);
    Serial.println (num, DEC);

    for (byte i=0; i<num; i++) {
    motor[i].id = detect[i];
    motor[i].SRL = 2;
    motor[i].torqueOn;
    Serial.print ("motor ");
    Serial.print (i, DEC);
    Serial.print (" ID detectado: ");
    Serial.println (detect[i], DEC);
    }
    }

    void loop() {

    motor[0].setPosVel (20, 1000);
    delay(500);
    // etc, etc

    }

  114. avatar prax Dice:

    ok so far so good. thanks allot!!!

    but, if i use
    motor[0].setPosVel (20, 1000);
    delay(500);

    the servo just keeps moving, it doesnt go to a fix position it just moves on until i call

    motor[0].setPosVel (0, 1000);

    but i need to move it in 180 degres in fix positions, like 170 or 30

    is that possible?
    or does the library just use the servos like stepper motors?

  115. avatar pabloxid Dice:

    try to put this line in setup:

    motor[i].setEndlessTurnMode (false);

    just before the torque enabling.

  116. avatar prax Dice:

    ok that works.

    but from 0 to 1023 it just turns 90degres.

    how can i get 180degres or 360?

  117. avatar prax Dice:

    problem solved – sorry

    the 500 milliseconds delay where not enough to make more than 90 degrees.

    but even with 2000 milliseconds it turns just about 270 degrees from 0 to 1023

  118. avatar pabloxid Dice:

    That’s very strange. The motor should move in a 300 degrees range, in wich 512 is the center.

    Maybe it has some erroneous settings.

    Do you get this response with the two servos?

  119. avatar pabloxid Dice:

    Ok, excellent. Ignore my last post then.

  120. avatar prax Dice:

    ok so
    integer 0 to 1023
    is
    0 to 300 degrees?

  121. avatar pabloxid Dice:

    yes.

    0 = -150 degrees
    512 = 0 degrees
    1023 = +150 degrees

  122. avatar prax Dice:

    first: your so helpful, its unbelievable! Thank you for your time!
    Again i have a question about you library, mybe you find a minute to think about it:

    I want to receive some data from processing while controlling the ax12 with your library.

    does the change in the HardwareSerial.ccp has any effect on that? Can I still receive serial data from Processing like normal?

  123. avatar pabloxid Dice:

    Prax: you can usually send and receive data via all Serial ports, except port1, using the AX12 library (on a Mega board). The change in “HardwareSerial.cpp” only affects the serial port 1, which is being used for the AX12 motors.

    You can receive serial data from Processing like normal, in fact, you were getting data from the board through the Arduino terminal, try to send data from there as well.

    Regards,

    Pabloxid

  124. avatar prax Dice:
  125. avatar prax Dice:

    Hey, its me again.
    It seems that the servos always run one after another…
    How can I start two at the same time?
    I am using his code right now.

    motor[0].setPosVel (var[0], var[1]);

    motor[1].setPosVel (var[2], var[3]);

  126. avatar prax Dice:

    problem solved, it was the serail communication, sorry!!!

  127. avatar prax Dice:

    just to confirm:

    its not possible do control any Servo with 4 pins with your library, right? (like DX10)

  128. avatar pabloxid Dice:

    I’m working on that issue right now.

    Apparently the library serves, what needs to change is motor connection, which must be done through an integrated circuit MAX485.

  129. avatar prax Dice:

    oh that sounds great.
    I will need stronger servos than the ax12. As soon you upload news I will try it out!

  130. avatar prax Dice:

    Hey,
    I just realized i will need better servos than the ax12.
    Have you got any plans, when you might will succeed to controlling the dx10?

  131. avatar pabloxid Dice:

    Soon I will receive an RX-24F with a MAX485 integrated circuit for testing. Where available, I do not take long to develop the communication system.

  132. avatar prax Dice:

    hey,
    have you got any results testing the RX-24F?

  133. avatar pabloxid Dice:

    I haven’t received it yet. Things are just a little bit slow here in Uruguay :(

  134. avatar prax Dice:

    ah nice. I tought you are from spain.
    Uruguay, I have never been to south america.

    What part of Uruguay are you from?

  135. avatar pabloxid Dice:
  136. avatar Elabinna Dice:

    Hi,
    I plan use your library V2.2 for my project based on Arduino Mega (1280), It’s possible change hw serial port used for ax12?

    Thank you

  137. avatar pabloxid Dice:

    It is possible, but involves changing several ATmega’s register names in the library itself.

    Maybe in a future version this can be done from the code.

  138. avatar Anton Zalutsky Dice:

    Hello,
    I’m a senior at WPI. My team is working on a pretty intense project and we were just working with ax-12 servos and needed a cheap way to test them… I had an arduino but wasn’t sure if it was capable to perform the tests. My team was fortunate to stumble upon your site and find the library.

    Though there was a lot of confusion I’d love to resolve some of this for any american speaking people that have an issue:

    We had an Arduino Mega (Necessary because of the Rx/Tx connections)
    We used the AX-12’s.

    The connections can be found on http://www.trossenrobotics.com/images/productdownloads/AX-12(English).pdf , page 6 of the pdf.

    You will be connecting to the port on the left side of the axle (the bottom port on the picture with pin assignment )
    The data will connect to both RX1 and TX1 (pins 15/16 or something)… NOT RX0, TX0! That was our biggest misunderstanding.

    I downloaded http://www.pablogindel.com/images/ax12v2.0.rar
    and put it in the arduino/libaries/ folder
    It is to my understand that the 2.2 version works just as well but I haven’t tested it yet.

    Be sure to go into the hardware/arduino/cores/HardwareSerial.cpp and make the following changes::

    // modificación para usar la biblioteca AX12

    /*SIGNAL(SIG_USART1_RECV)
    {
    unsigned char c = UDR1;
    store_char(c, &rx_buffer1);
    }*/

    ^^ COMMENT THIS OUT!

    After that, load up the test pde and load it.
    Be sure to ground and power your servo!
    It needs 7-10 volts.

    Good luck!

  139. avatar pabloxid Dice:

    Thanks Anton for your clear explanation.

    Version 2.2 introduces many improvements and comes with a manual (in Spanish) but brings no such .pde example, however.

    Greetings,

    P.G.

  140. avatar Savage Dice:

    Hola, estoy haciendo un pequeño programa para controlar estos servos, ya los puedo mover a la posicion y velocidad que yo quiera, pero no logro leer los datos de status que regresa el servomotor, estoy utilizando el puesto uart del arduino uno tx y rx conectados al pin de datos del servo. sabes cuanto tarda en llegar los datos de status o por que otra razon no puedo leer los datos que deberia regresar?. Grax

  141. avatar pabloxid Dice:

    ¿Estás usando la biblioteca? ¿Qué versión?

    La versión 2.2 tiene un sistema mucho más claro para leer e interpretar lo que viene del motor, y además te permite cambiar el SRL, status return level, el seteo que hace que el motor conteste o no y a qué mensajes.

    Básicamente los AX12 tienen 3 maneras de operar, o respondiendo a todos los mensajes, respondiendo sólo a los de lectura, o no respondiendo a ninguno. Nótese que, sin embargo, los mensajes de broadcast y los sync write no generan respuesta, independientemente de cuál sea el SRL.

    Nótese también que si estás dentro de una ISR podrás mandar mensajes pero no recibir. Esto se debe a que la recepción serial utiliza interrupciones; lo mismo ocurre con la biblioteca Serial estándar de Arduino.

    Saludos.

  142. avatar Pabloxid Dice:

    Próximamente un instructivo para manejar motores Dynamixel de las series RX, DX y EX con Arduino.

    http://www.youtube.com/watch?v=3kMAj-sadNo

  143. avatar SOSO Dice:

    Hi

    this is my first time to use arduino to control ax-12(never use ax-12 before too)
    first i try to use your code
    so i coppy it to arduino-18 and try to complie it

    #include
    #include

    SoftwareSerial swSerial (2, 3);

    void setup() {
    ax12Init (1000000);
    swSerial.begin(9600);

    writeData (14, AX_TORQUE_ENABLE, 1, 1); // “14″ is the motor ID

    }

    void loop() {

    int error = ping (14);
    swSerial.print (“ping ID: “); swSerial.print (status_id, DEC);
    swSerial.print (” int.error: “); swSerial.print (error, DEC);
    swSerial.print (” status.error: “); swSerial.println (status_error, DEC);
    swSerial.println (” “);

    error = readData (14, AX_PRESENT_TEMPERATURE, 1);
    swSerial.print (“temperatura: “); swSerial.print (status_data, DEC);
    swSerial.print (” int.error: “); swSerial.print (error, DEC);
    swSerial.print (” status.error: “); swSerial.println (status_error, DEC);
    swSerial.println (” “);

    error = writeData (14, AX_GOAL_POSITION_L, 2, int(random(1024)));
    swSerial.print (“goal position ID: “); swSerial.print (status_id, DEC);
    swSerial.print (” int.error: “); swSerial.print (error, DEC);
    swSerial.print (” status.error: “); swSerial.println (status_error, DEC);
    swSerial.println (” “);

    delay (200);

    error = readData (14, AX_PRESENT_POSITION_L, 2);
    swSerial.print (“posicion: “); swSerial.print (status_data, DEC);
    swSerial.print (” int.error: “); swSerial.print (error, DEC);
    swSerial.print (” status.error: “); swSerial.println (status_error, DEC);
    swSerial.println (” “);

    }

    and i got the problem this

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp: In function ‘void setTX()':

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:44: error: ‘UCSR1B’ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:44: error: ‘RXEN1′ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:45: error: ‘TXEN1′ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:46: error: ‘RXCIE1′ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp: In function ‘void setRX()':

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:59: error: ‘UCSR1B’ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:59: error: ‘TXEN1′ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:60: error: ‘RXEN1′ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:61: error: ‘RXCIE1′ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp: In function ‘void ax12write(unsigned char)':

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:68: error: ‘UCSR1A’ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:68: error: ‘UDRE1′ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:69: error: ‘UDR1′ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp: In function ‘void ax12writeB(unsigned char)':

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:74: error: ‘UCSR1A’ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:74: error: ‘UDRE1′ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:75: error: ‘UDR1′ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp: In function ‘void USART1_RX_vect()':

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:80: error: ‘UDR1′ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp: In function ‘void ax12Init(long int)':

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:123: error: ‘UBRR1H’ was not declared in this scope

    D:ProjectSenioe\arduino-0018\libraries\Bioloid\ax12.cpp:124: error: ‘UBRR1L’ was not declared in this scope

    how can i solve this problem
    please help me
    my board is freeduino V1.16
    and chip is ATMEGA328P-PU

    please you will help me a lot

  144. avatar Ax-12 Dice:

    Hello Pabloxid!

    I am trying to incorporate my Arduino Duemilanove with AX-12 and is stuck with basic things.

    First, how do I connect the Rx and Tx Pin with the Data Pin on the Ax-12? (I am using two Arduino jumper wires and attempting to squeeze it through the wire connector for Ax-12)

    And I think you mention that those two pins must be short-circuited, but how do I do that?

    Thanks.

  145. avatar Pabloxid Dice:

    SOSO: it seems that you have selected the wrong board model in IDE configuration. Please select “Arduino diecimilla or duemilanove with atmega 328″. Also, try to get latest library and IDE versions.

    Ax-12: put 2 headers on the TX and RX pins. Solder a wire from one to another header and solder another wire from either of them to AX12’s data pin.

  146. avatar Ax-12 Dice:

    Pabloxid,

    thank you for the prompt response.
    So let’s say that I use pin 7 and 8 for tx and rx.
    Then I would put one header(stackable 6 pin header) in pin 7 and another in pin 8.

    Then I connect one end of wire A from header in pin 7 to header in pin 8. Then I connect one end of wire B from any header to the data pin of AX-12.

    Is this correct?

    And also, what power source is needed for AX-12? From my understanding, Arduino uses 5V but AX-12 needs 9V for maximum torque.

    I have tried connecting 9V (from a wall wart) and common ground to the AX-12 and then the LED on Ax-12 blinked for about a second and then turned off. Am I doing something wrong?

    Thanks.

  147. avatar pabloxid Dice:

    You cannot use pins 7 and 8 for RX/TX, you must use pins 0 and 1, that are hardwired to microcontroller USART interface.

    The led on Ax12 blink for about a second, then turns off, this is the normal behavior, this means that everything is OK.

  148. avatar Ax-12 Dice:

    Hey pabloxid,

    I have read the past posts (you helped quite a lot of people!) and realized that there is a clear distinction between the Duelimanove and Mega.

    It seems like the difference is the difference in number of serial ports: what difference does the difference in number of serial ports create problem for the Duelimanove?

    Also, in terms of the communication, is the Arduino going to communicate at 1Mbps? As far as I know (my short span of knowledge,) Arduino is not capable of receiving and transmitting at full 1Mbps. Correct me if I am wrong.

    Thanks!!

  149. avatar pabloxid Dice:

    The problem with Duemilanove is that, having a single serial port, it cannot communicate with the AX12s and with the PC (or another Arduino) simultaneously; this is why we use newSoftserial.h in example. But in that case, the software-emulated serial port is used for PC communication, while for AX12 we must necessarily use microcontroller USART.

    Regarding the second question, Arduino cannot communicate at full 1Mb/s, but Atmel microcontroller can, which is why we use AX12 library and do not use Arduino Serial library to control AX12 motors.

    The problem arises on the Mega, when trying to use the other Serial ports in the normal way, which forces us to modify the HardwareSerial.cpp core file.

  150. avatar Ax-12 Dice:

    Hi!

    I currently have Duemilanove and am considering buying the Mega (because I need to control 14 servos at once.) Do you think it’s worth buying Mega 2560?

    And what do you mean by software-emulated serial port? Are you saying that digital pin 7,8 can be used as serial port to communicate with the computer while AX-12 is connected to pin 0 and 1? (Do you have an example that has the software-emulated serial port?)

    Or couldn’t you just connect Arduino to the computer on pin 0 and 1 while uploading the sketch and then connect the AX-12 only to see if it works (the downside would be that I cannot monitor any sort of feedback from the Ax-12)

    And could you help me understand the difference between UART and USART, touching the basics of serial communication?

    So because Arduino cannot communicate at 1Mbps, we are simply using the pins and the microcontroller on the Arduino. Correct me if I am wrong.

    Thanks

  151. avatar pabloxid Dice:

    You can control 14 AX12s with any Arduino. If your code requires communication with the PC (not when loading but when running), you can use the newSoftwareSerial library, which work just fine.

    If in addition to communicate with the PC, you are planning a large project, then you should use an Arduino Mega. My new hexapod uses 18 of these servos with a Mega 1280.

    Arduino is based on an Atmel AVR microcontroller (ATMega8, ATMega168, ATMega328, ATMega1280 or ATMega2560, depending on model). This microcontroller has a serial interface, called USART or UART (virtually the same). This interface can operate at any speed, limited by the clock frequency (which in the Arduino is 16MHz), but another thing is that the software can actually handle the data at that speed.

    Arduino Serial library cannot receive information at 1Mb/s, but our AX12 library can.

  152. avatar Ax-12 Dice:

    Hi!

    Okay, now I can see how your library works. How did you manage to make the AX-12 library so that it can receive information at 1 Mbps? (I just wish to understand this part a bit better althought the explanation might be complicated)

    And how does clock frequency affect the speed of the communication?

    I do wish to monitor the feedback through my computer from the Ax-12 while giving the program runs between the AX-12 and the Arduino. I was wondering how you make non-serial ports work as serial ports (although that seems to be already incorporated into the example that is made)?

    Thank you!

  153. avatar pabloxid Dice:

    That’s part of the original Michael Ferguson development for Arbotix; he uses a “one-way” receive buffer rather than a circular buffer, as Arduino software does. This solution is intended only to receive AX12 messages and not for general purpose.

    The clock frequency affects all other microcontroller speeds, it’s the “master frequency”, all the timers and clocks for the various microcontroller functions are derived from there.

    NewSoftwareSerial library is responsible for “turning into serial” pins other than 0 and 1, but it’s not mine. Check here for more information about it http://arduiniana.org/libraries/newsoftserial/

  154. avatar Ax-12 Dice:

    Hello Pablo!

    I tried to compile this code (from the ax12test2.pde)

    Then I got an error that says this when i tried to compile:

    ax12test2.cpp: In function ‘void setup()':
    ax12test2:18: error: no matching function for call to ‘AX12::autoDetect(int [2], int)’
    C:\Documents and Settings\강우혁\My Documents\arduino-0021\libraries\ax12/ax12.h:94: note: candidates are: static byte AX12::autoDetect(byte*, byte)
    ax12test2.cpp: In function ‘void loop()':
    ax12test2:34: error: ‘class AX12′ has no member named ‘status_error’
    ax12test2:41: error: ‘class AX12′ has no member named ‘status_error’

    —————————————-
    // dinamyxel ax-12 servo test for Arduino 0017

    //#include
    #include

    //SoftwareSerial swSerial (2, 3);

    AX12 motor[2] = {AX12 (), AX12 ()}; // define 2 motores AX12

    void setup() {

    pinMode(13, OUTPUT);
    Serial.begin (57600); // inicializa el SoftSerial a 115,2 Kb/s

    AX12::init (1000000); // inicializa los AX12 a 1 Mb/s
    //AX12::init (1000000); // inicializa los AX12 a 1 Mb/s
    int detect[2]; // array para detectar automáticamente las ID de 2 motores
    AX12::autoDetect (detect, 2); // detección de IDs
    for (byte i=0; i<2; i++) {
    motor[i].id = detect[i]; // asigna las ID detectadas a los motores definidos previamente
    }
    motor[0].inverse = true; // asigna la propiedad "inverse" a uno de los motores
    motor_init ();

    }

    void loop() {

    int a = motor[0].writeInfo (MOVING_SPEED, random(1024));

    Serial.print ("internal error ");
    Serial.println(a, DEC);
    Serial.print ("AX12 error ");
    Serial.println(motor[0].status_error, DEC);

    a = motor[1].writeInfo (MOVING_SPEED, random(1024));

    Serial.print ("internal error ");
    Serial.println(a, DEC);
    Serial.print ("AX12 error ");
    Serial.println(motor[0].status_error, DEC);

    //movimiento (2, 500);

    delay (500);
    }

    void motor_init () {

    for (int i=0; i>1));
    }

  155. avatar Ax-12 Dice:

    To follow up, I am not going to communicate with the PC for now (because I am quite confused as to how I could even with the NewSoftSerial.h since I am using Duemilanove)

    I simply would like to see this working!
    Please tell me why that error is occuring and ways that I can fix it (I’ll try my best to understand rather than simply take everything you tell me for granted)

    Thank you.

  156. avatar pabloxid Dice:

    The example that you’re using is not for this library. Try this code, instead:

    #include

    AX12 motor;

    void setup() {

    AX12::init (1000000);

    byte detect[1];

    byte num = AX12::autoDetect (detect, 1);

    motor.id = detect[0];
    motor.SRL = 2;
    motor.torqueOn;
    }

    void loop() {

    motor.setPosVel (random (1024), random (200, 500));

    delay(500);

    }

  157. avatar Ax-12 Dice:

    Hello Pablo!

    I tried the code you posted.
    I encountered the first problem when I connected the computer-Duemilanove simultaneously with the AX-12 and got this message:

    avrdude: stk500_getsync(): not in sync: resp=0xfe
    avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

    And remembering that i should probably disconnect AX12 while uploading I did that.

    Still, the Ax-12 was not functioning at all. I wondered if I set the ID number incorrectly and set the ID number as 0 using CM-5.

    I am not sure what went wrong. (For the hardware part, I am using a breadboard to short-circuit RX0 and TX1)

    Thank you.

  158. avatar pabloxid Dice:

    Try reseting the Ax-12 to factory defaults using your CM-5.

    Then replace these lines:

    byte num = AX12::autoDetect (detect, 1);
    motor.id = detect[0];

    by this:

    //byte num = AX12::autoDetect (detect, 1);
    motor.id = 1;

    … and try again.

  159. avatar Ax-12 Dice:

    Hmmm.
    I just tried the code just now and still get nothing.

    One thing i did notice is that once I upload the sketch(Ax-12 not connected) and then connect the AX-12, i see that the “tx” LED on my Duemilanove blinks according to the delay time (I doubled, quadrupled and saw a clear difference.)

    Once I have the short-circuited Rx and TX pins connected, then the Tx LED blinks.

    But when I disconnect the short-circuited Rx and TX pins (connected to the AX-12) the Tx LED stops blinking. OR when I disconnect the Computer-Arduino connection, the Tx LED stops blinking as well.

    Therefore, my guess is that motor.setPosVel (random (1024), random (200, 500)); is a function that sends string of commands.

    But the question is, is the computer sending that command through the serial port? If so, wouldn’t I need to connect the AX-12-Arduino and the PC-Arduino simulatenously? (which is not possible, as far as I see it and thus requires me to buy a Mega.)

    Or once I upload the sketch, how is
    motor.setPosVel (random (1024), random (200, 500));
    command sent to the AX-12? Does the microcontroller store the command in its memory and send the string command to the serial ports automatically?

    Thank you.

  160. avatar pabloxid Dice:

    1) Reset Ax12 to factory defaults.

    2) Power your Arduino with an external power supply and disconnect the USB cable once you have uploaded the program.

  161. avatar Ax-12 Dice:

    Pablo!!!

    Thank you so much!!!
    It turned out that the AX-12 that i was experimenting with was sort of broken!!

    I tried with a new servo and it’s working superbly!!

    Now I have some questions about the programming:

    AX12 motor-> what does this line do?

    AX12:: init (1000000); -> set baud rate at 1Mbps for the motor? how does this initiate 1Mbps for the microcontroller?

    byte detect[1]; -> this one? what does this mean

    and for Status Return Level, does 2 mean “Return_All?”

    Now I’ll study the library!

    Thanks~

  162. avatar pabloxid Dice:

    AX12 motor-> what does this line do? -> It declares an AX12 class object, called ‘motor’

    AX12:: init (1000000); -> set baud rate at 1Mbps for the motor? how does this initiate 1Mbps for the microcontroller? -> Microcontroller; the motor is already set to 1Mb/s; if the motor is configured to another baudrate, then here is to put the same baudrate.

    byte detect[1]; -> this one? what does this mean -> well, in fact, this is a mistake, it’s the result of canging another code quickly. Indeed this line should read:

    byte detect; // and the following:
    byte num = AX12::autoDetect (&detect, 1);

    and for Status Return Level, does 2 mean “Return_All?” -> Yes.

  163. avatar prax Dice:

    Hey Pablo!

    thats great I cant wait to try it on a new project!
    what parts and code do I need to get 2 RX servos controlled?

    is there any documentation on the part setup?

  164. avatar pabloxid Dice:

    Hi Prax.

    The setup is very simple, you should use a MAX485, and connection diagram is here:

    http://support.robotis.com/en/images/product/dynamixel/rx_series/rx_series_circuit.png

    The AX12 library needs a slight modification, since you have to use an Arduino digital pin to control the data direction in the MAX485.

    I will publish soon that change, meantime you can see it in the Arbotix software, which is exactly the same in this regard.

    Regards,

    P.G.

  165. avatar JimK Dice:

    Hi, Pablo,
    Awesome job on the AX12 library. After trying your codes (both the 1.0 and 2.2 version) and also the arbotix code, I found a very serious problem that I cant solve. If we keep sending a lot of data to the AX12 through serial port, after a while the AX12 just stops responding. It feels like there is a bucket inside. Once it is full, you cannot fill any more water inside. The faster you pour the water, the shorter time it takes to fill the bucket. Do you know what may have caused that problem? I am begging for your help here. Thank you in advance.

  166. avatar pabloxid Dice:

    Hi Jimk, thank you very much for your comment.

    I would like to know more details about the test you are doing.

    There is actually a “bucket” into the AX12, its own Serial receive buffer. You should avoid sending to the motor more data than is reasonably necessary to fulfill its function.

    I don’t know what happens, for example, if you send 1000 GOAL_POSITION messages in a second, but certainly the AX12 will not be able to move to any destination, so, there is no need to send so many messages.

  167. avatar Tiago Dice:

    Hi Pablo,

    Nice job with the AX-12! Your library seems to fit all needs that the AX-12 requires!!

    I have a hardware question.

    I used the old version of your library with both an arduino duemilanove and arduino mega 1280.
    Works so fine!

    Now I would like to use the latest version of your library (2.2) with an arduino Mega 2560 (the latest one).
    Is your library compatible with it? If it is, Can use it like the old arduino Mega 1280 (by uncomment the lines in Hardware.cpp) ??

    Thanks, And continue your good job!

    Tiago

  168. avatar JimK Dice:

    Hi, Pablo, thank you for your fast response. I am sending data from Processing to Arduino through serial port. Basically I am using an interface created by Processing to control AX12 servos. After I click a button or hit a key for certain number of times (doesn’t have to be fast), the communication will abort. Any ideas how to fix that?

  169. avatar JimK Dice:

    There is one thing I noticed. When the communication works properly, as I send data from Processing to Arduino Mega, both the RX and Tx will blink. When AX12 stops working, I can still see the RX light blinks, but the TX light is off.

  170. avatar pabloxid Dice:

    Tiago:

    I have not tried the library with Arduino 2560, but I think it should work. The procedure is similar, you have to comment in Hardwareserial.cpp the USART2 ISR definition, but keep in mind that, in IDE 0022, code looks slightly different than in previous versions.

    Thank you for your comment.

  171. avatar pabloxid Dice:

    JimK:

    It seems that the program hangs. I don’t know if that has to do with the AX12. Test to drive something else, for example a LED, to see if the problem continues to manifest itself without the AX12.

  172. avatar Tiago Dice:

    Thanks for your answer Pablo!

    I’ll try this tonight!
    In which way the code looks different in the version 022 of the Arduino’s IDE ?

    Thanks,

  173. avatar Tiago Dice:

    Pablo, I just take a look on what you said…

    Just to be clear, I have to comment this part :

    SIGNAL(SIG_USART2_RECV)
    {
    unsigned char c = UDR2;
    store_char(c, &rx_buffer2);
    }

    What the purpose of doing this ? And why especially the USART2? not the USART0, 1 or 3 ?

    thanks for your time!

    Tiago

  174. avatar pabloxid Dice:

    Sorry, it’s USART1! The same used for AX12 bus, I repeat: USART1, forget what I said before.

    The purpose is to avoid double definition of this ISR, as the Ax12 library already defines its own USART1 ISR.

    Regards,

    P.G.

  175. avatar Tiago Dice:

    Thank you for the informations. It’s very useful.

    Until next question,

    Regards,

    Tiago

  176. avatar Tiago Dice:

    Hi again Pablo,

    I got some issues with this configuration I mentioned in my previous post.

    I tried this code :

    #include

    AX12 motor;

    void setup() {
    motor = AX12();

    Serial.begin (9600); // inicializa el Serial a 115,2 Kb/s
    AX12::init (1000000); // inicializa los AX12 a 1 Mb/s

    byte detect; // array para detectar automáticamente las ID de 18 motores
    byte num = AX12::autoDetect (&detect, 1); // detección de IDs

    Serial.print (” deteccion: “);
    Serial.println (num, DEC);

    motor.id = detect; // asigna las ID detectadas a los motores definidos previamente
    motor.SRL = 2;
    Serial.print (“motor : “);
    Serial.print (” ID detectado: “);
    Serial.println (detect, DEC);
    Serial.print (” delay: “);
    AX12info test = motor.readInfo (RETURN_DELAY_TIME);
    Serial.println (test.value, DEC);
    Serial.print (” error lectura: “);
    Serial.println (test.error, DEC);
    }

    void loop() {
    }

    And the Monitor display this :

    deteccion: 0
    motor : ID detectado: 107
    delay: 0
    error lectura: 1920

    I’ve got only one servo, the ID should be 1 (by default)
    And what’s the error 1920 ?

    Thanks for your help.

    Regards,

    Tiago

  177. avatar pabloxid Dice:

    deteccion: 0 -> means that the autodetect did not detect any AX12 motor;

    ID detectado: 107 -> this is the random variable initialization value, is not the real motor ID;

    delay: 0 -> this data is also not valid;

    Read error: 1920 -> the first 7 bits of error message are the same AX12 error. The upper bits, which are those that are activated in this case, means that not a valid AX12 message is received.

    Everything points to a possible communication error, cables, power, etc.

    Try manually assign the ID, like this:

    motor.id = 1;

  178. avatar Tiago Dice:

    Good evening Pablo,

    Hum… I tried what you said (motor.id=1;)
    But no effect.. :(

    I tried too the old version of your library (v2.0) with this code :

    // dinamyxel ax-12 servo test for Arduino 0017

    #include

    AX12 motor = AX12 (); // define 2 motores AX12

    void setup() {

    pinMode(13, OUTPUT);
    Serial.begin (9600); // inicializa el SoftSerial a 115,2 Kb/s

    AX12::init (1000000); // inicializa los AX12 a 1 Mb/s
    int detect; // array para detectar automáticamente las ID de 2 motores
    AX12::autoDetect (&detect, 1); // detección de IDs
    motor.id = 1; // asigna las ID detectadas a los motores definidos previamente
    motor.inverse = true; // asigna la propiedad “inverse” a uno de los motores
    motor_init ();

    }

    void loop() {

    int a = motor.writeInfo (MOVING_SPEED, random(1024));

    Serial.print (“internal error “);
    Serial.println(a, DEC);
    Serial.print (“AX12 error “);
    Serial.println(motor.status_error, DEC);

    a = motor.writeInfo (MOVING_SPEED, random(1024));

    Serial.print (“internal error “);
    Serial.println(a, DEC);
    Serial.print (“AX12 error “);
    Serial.println(motor.status_error, DEC);

    delay (500);
    }

    void motor_init () {
    motor.writeInfo (TORQUE_ENABLE, 1); // habilita el torque
    motor.setEndlessTurnMode(true); // lo pone en modo de rotación continua
    // setear la inercia y todo eso
    motor.writeInfo (CW_COMPLIANCE_MARGIN, 0);
    motor.writeInfo (CCW_COMPLIANCE_MARGIN, 0);
    motor.writeInfo (CW_COMPLIANCE_SLOPE, 95);
    motor.writeInfo (CCW_COMPLIANCE_SLOPE, 95);
    motor.writeInfo (PUNCH, 150);
    motor.writeInfo (MAX_TORQUE, 1023);
    motor.writeInfo (LIMIT_TEMPERATURE, 85);
    motor.writeInfo (DOWN_LIMIT_VOLTAGE, 60);
    motor.writeInfo (DOWN_LIMIT_VOLTAGE, 190);
    motor.writeInfo (RETURN_DELAY_TIME, 150);
    // test motor
    motor.endlessTurn (500); delay (500);
    motor.endlessTurn (-500); delay (500);
    motor.endlessTurn (0);
    }

    void movimiento (byte direccion, int velocidad) {
    motor.endlessTurn (-velocidad*bin2sign(direccion&1));
    }

    and the result is :

    internal error 7
    AX12 error -1

    Maybe the microprocessor 2560 isn’t compatible but I assume that they make it compatible..

    I’m a bit lost ^^

    Regards,

    Tiago

  179. avatar pabloxid Dice:

    Tiago:

    I have a Mega 2560 here. I’ll try and tell you the results. Sorry for the inconvenience.

    Regards,

    Pablo.

  180. avatar Tiago Dice:

    Thanks a lot Pablo, It’s very nice of you!

    Tell me as soon as you get the results!

    Regards,

    Tiago.

  181. avatar pabloxid Dice:

    Tiago:

    go to the download section

    http://www.pablogindel.com/descargas/

    and get the new library version 2.3.

    Compatible with Mega 2560, IDE 0022, tested, with spanish manual and example sketch included.

    Enjoy.

  182. avatar Tiago Dice:

    Pablo,

    You’re just amazing that works perfectly!

    Thanks for your help and your time!

    Regards,

    Tiago

  183. avatar Anderz Rush Dice:

    Pablo eres todo un maestro!

    Estoy trabajando en un proyecto que usa exactamente el arduino uno y 3 ax-12; quería saber si se pueden controlar los motores por medio de otros pines que no sean el 0 y el 1… la librería esta hecha para que los motores usen el usart y la comunicacion el softwareserial… se pueden usar al revés? es decir, comunicarme a la PC por 0 y 1 y usar otros pines para los ax-12… que modificaciones tendría que hacer?

    De antemano muchisimas gracias! y sigue asi (Y)

  184. avatar pabloxid Dice:

    Muchas gracias Anderz!

    No, la verdad es que no se puede. No hay manera de manejar los AX12 con otra cosa que no sea el USART, debido su alto baudrate.

    Aun si se configuraran los motores a un baudrate mucho más bajo, la biblioteca está hecha para trabajar con el hardware del AVR a bajo nivel, y habría que adaptarla para usar SoftwareSerial.

    Existe una biblioteca desarrollada por uno de los usuarios que han comentado aquí, que utiliza la “Serial” de Arduino a alto nivel, talvez ahi sí puedas lograr lo que te propones.

    Saludos,

    P.G.

  185. avatar pabloxid Dice:

    …pero si lo que quieres es aprovechar el chip conversor USBSerial que trae la Arduino, aun puedes usar el truco de desconectarlo de los pines 1 y 2 y usarlo con la SoftwareSerial en otros pines, ¿me explico?

    Desconectas el chip de los pines 1 y 2 cortando el circuito impreso.

    Saludos.

  186. avatar pabloxid Dice:

    SAMSA II, un hexápodo de 18 motores AX-12+ controlados por Arduino Mega:

  187. avatar Jay Dice:

    Very nice job on your hexapod and thanks for sharing your work on the AX12 library it is just what I am looking for. I am trying to implement it on a arduino Mega 2560 and have gotten the test program to compile, but the communication with the ax12 servos is not working.
    For hardware I tied pins 18 & 19 together on the Mega and then connected them to the data pin on my ax-12 servo (id=1). I ran 9v power and ground to the ax-12 (connecting the power ground also to the arduino). The servo led blink ok when I first applied power as it should.

    For the software I commented out the section of HardwareSerial.cpp file as follows:

    /* remove serial 1 since it is used by ax-12 library
    //#if defined(SIG_USART1_RECV)
    #if defined(USART1_RX_vect)
    //SIGNAL(SIG_USART1_RECV)
    SIGNAL(USART1_RX_vect)
    {
    unsigned char c = UDR1;
    store_char(c, &rx_buffer1);
    }
    #elif defined(SIG_USART1_RECV)
    #error SIG_USART1_RECV
    #endif
    end removed code for serial 1 */

    Note that the signal define is a bit different from your examples

    But when I ran the test program the servo could not be found (or something is messed up)
    The number of ids the autoDetect found was 0 and the test.error return showed all true on bits 7-10 and zero on the others. If I disconnect the power to the Ax-12, bit 0-3 are return true.

    I check the servo with the RoboPlus manager and it is working fine.
    Any thoughts as I would love to be able to use your library and get rid of the CM-510.

    Jay

  188. avatar pabloxid Dice:

    Hi Jay, thanks for your comment.

    I’ve seen that sometimes the AX-12 does not work with the library after you handle it with the CM-5 or the PC. Try resetting the AX-12 to its factory settings.

  189. avatar Jay Dice:

    Thanks Pablo for your reply. This turns out, like a lot of things, to be user error. Someday I will learn that the pin out on the male header (in this case on the servo) is not the same orientation as that of the cable. The test file is working fine now that I reversed the wires to the servo–and no damage to anything from my mistake.

    Now I can exercise your library and start using it. By the way I have been translating your manual to English for my own use and can send it to you when I am done if you want?

    Next is to hook-up the Zig100/110 pair to one of the other serial ports and start working on the control software now that I know this is going to work. By the way, did you derive your ik software from the that developed by Jeroen Janssen? Kurt Eckhardt converted the Arbotix code to C and the Arduino and I was going to take the next step and try and convert it from pwm type servos to Dynamixels.

    Thanks again for continuing to develop the very useful ax-12 library.

  190. avatar pabloxid Dice:

    Hi Jay.

    I also often make mistakes with the pinout, even if I look it many times, then I connect it wrong anyway.

    Please send me your translation to palmer@pablogindel.com so I include it along with the distribution. Do not forget to sign it. It’s a great contribution, thank you for doing it :)

    I used my own inverse kinematics development, I did not know about the Jeroen Janssen code. I just download it now from Lynxmotion site, thanks for the tip.

    Regards,

    P.G.

  191. avatar Jay Dice:

    There are a bunch of different version of the phoenix code floating around the Lynxmotion site. This is the forum thread that had the version I found most useful http://www.lynxmotion.net/viewtopic.php?f=20&t=6730 –wrong servos and it uses the SSC-32 servo controller board, but it is in C and for the arduino mega. Wasn’t sure which one you got.

  192. avatar pabloxid Dice:

    Hi Jay,

    I had taken a version that claimed to be the last, but was in BASIC. This version is much more useful to me. Thanks again.

  193. avatar Ax-12 Dice:

    Hi Pablo.

    I am sorry that I have been out for a while, I was busy with college applications and other things…

    Anyhow, I have tried to interface two motors at once.

    I set one motor as motor1 and another as motor2.

    So on my first trial, I did

    motor1.setPosVel (random (0, 1024), 500)
    motor2.setPosVel void continuousRotation

    then motor 2 started to spin in one direction.

    However, when I fixed the motor2 code identical to motor1, motor2 still rotated continuously.

    I am confused as how to un-do my continous motor setting.

    Thank you

  194. avatar pabloxid Dice:

    1) make sure that the two motors have different IDs.

    2) use motor2.setEndlessTurnMode(false) to disable continuous rotation.

    Regards.

  195. avatar prax Dice:

    Hi Pablo!
    I want to try your library on two RX10 motors (finally) im very exited!!!
    but i need some help with the code, maybe you have got some minutes to tell me how to change the code in order to use the MAX485 and the data direction change. I never saw the Arbotix software, so you might can give me a brief explanation of the code changes?
    And a second question:
    I cant find a simple MAX485 my dealer has got these:
    MAX485CPA+
    MAX485CSA+
    MAX485ECPA+
    MAX485ECSA+
    MAX485EPA+
    MAX485ESA+

    any idea which one is the right one?

    thanks for any help!

  196. avatar pabloxid Dice:

    Hi prax.

    I think that any of the models can do the job, differences are about the package and temperature range. CPA is the standard.

    For RX series, the changes in the library are as follows:

    At the beginning of setTX() (before the #if defined) place this:

    void AX12:: setTX () {
    digitalWrite (2, HIGH);

    (where ‘2’ is the MAX485 direction control pin).

    Then, at the end of setRX() (after the #endif) place this:

    delayMicroseconds (150);
    digitalWrite (2, LOW);
    ax_rx_Pointer = 0;

    You must also initialize motors at 57142 baud, as follows:

    AX12:: init (57142)

    That’s it :)

  197. avatar Roberto Dice:

    Hola Pablo
    Teoricamente cuantos Ax12 son direccionables en daisy chain con un modulo apropiado para estos modelos??
    Como puedo utilizar la USART del Arduino para direccionar un cantidad grande de servos??
    y es posible utilizar los giros continuos del servo para contar las vueltas que dan de 360 grados??

    Gracias por tu amable ayuda.
    Atte. Roberto Mejia

  198. avatar pabloxid Dice:

    Hola Roberto.

    Teóricamente puedes manejar hasta 254 motores en un mismo bus. Personalmente yo he probado hasta 18, supongo que el límite práctico estará determinado por razones eléctricas, más que nada.

    Respecto a tu segunda pregunta, todo lo que necesitas para manejar una cadena de AX12, por más grande que esta sea, es la biblioteca que aquí presentamos.

    Con respecto a la tercer pregunta, sí, puedes usar el servo en modo de giro contínuo. Contar la cantidad de giros completos que éste da, dependerá de tu programa. El motor sólo reporta su posición angular instantánea, siempre que no esté en la “zona ciega” (entre los 300 y los 360 grados) pero con esa información te alcanza para contabilizar las vueltas.

    Saludos,
    P.G.

  199. avatar Anderz Rush Dice:

    Muchisimas gracias Pablo!!

    Tu sugerencia me dio una buena idea… use un multiplexor e interrupciones para usar el chip USB del arduino para comunicar el micro con los motores y aparte comunicar el micro con la pc mediante una interfaz en java que diseñe, todo usando el mismo cable y sin necesidad de softserial ni de un FTDI… asi puedo dar ordenes a los AX-12 desde la computadora y tambien monitorearlos con una interfaz gráfica sin tener que comprar el convertidor :D cuando este terminado el proyecto te lo muestro, va? Muchisimas gracias!!! Tu biblioteca me hizo un parote (:

    …una duda rápida (no lo investigo todavia) se puede hacer que el AX-12 avise cuando termine una operacion de movimiento sin necesidad de solicitarselo? para detener la ejecucion del programa hasta que haya terminado su movimiento sin necesidad de usar un delay arbitrario… Gracias!!

  200. avatar Fred Dice:

    Hello Pablo,

    Thanks to your library, it took me about 10 minutes to get an AX-12 up and running with my brand new arduino uno. That’s my first project and I would qualify your library “a Great job!”.

    Now, if i may, i’d like to ask for help with how the load/torque control work with the AX-12, I’ve been experimenting for the last 3 days and I’m now out of ideas to get this to work.

    Basically, what i understood from the robotis documentation is that once the Torque limit is set, the servo will use this value to move to the requested goal position. It seems that the bigger this torque limit is, the faster the motor reaches its goal position (independently of any velocity set)

    Now, setting the overload bit in the ALARM_LED and ALARM_SHUTDOWN registers i would expect that if I manually immobilize the servo output while in motion, the servo should shutdown (the TORQUE_ENABLE should turns to zero) and the led should blink.(right ?)

    Well, this is where i must be missing something cause it does not work. i can block the output but as soon as i release it, here it goes again, just like nothing happened. I switched to wheel mode just to check, and it does not seem to make things work better…

    Essentially, do you have any idea or suggestion on how to check if my AX-12 overload alarm is working normally or not?

    cheers.

  201. avatar pabloxid Dice:

    Anderz:

    Pienso que no, el AX-12 no envia información alguna si no se le solicita mediante un comando de lectura. Lo que sí tiene es un registro “is_moving” (o de nombre similar) al cual se puede consultar periódicamente para saber si terminó de moverse, o también se puede consultar la posición, etc.

  202. avatar pabloxid Dice:

    Hi Fred, thank you for your feedback.

    Regarding the Alarm Shutdown register, I have never tested it, but remember that each of its bits enables a different shutdown alarm:

    Bit 6 Instruction Error
    Bit 5 Overload Error
    Bit 4 CheckSum Error
    Bit 3 Range Error
    Bit 2 OverHeating Error
    Bit 1 Angle Limit Error
    Bit 0 Input Voltage Error

    It works the same way as the Alarm Led. but it’s a separate register.

  203. avatar Fred Dice:

    Hey Pablo,

    Yes, I think we both understood the same thing from the documentation: setting a bit in the ALARM_SHUTDOWN register and optionally setting the same bit in the ALARM_LED register should theorically shutdown the servo and should make the led blinking (if matching bit of ALARM_LED was set)

    I set the bit 5 (overload) and tried to trigger it by creating a mechanical overload… It does not seem to work at all.

    How do you check if one of your AX-12 is on overload? Is there another way to do this other than relying on the ALARM_SHUTDOWN register??

    Is there any chance you could try the ALARM_SHUTDOWN function for the overload bit on your own AX-12 so i would know if my AX-12 has a defect or not?

  204. avatar prax Dice:

    Hey pablo,
    I tried very hard but i didnt manage to get a proper communication with the rx28.

    here is the changed ax12.cpp:

    void AX12::setTX () {

    digitalWrite(2,HIGH);

    #if defined (__AVR_ATmega168__) || defined (__AVR_ATmega328P__)
    bitClear(UCSR0B, RXCIE0); // deshabilita la interrupción de recepción
    bitClear(UCSR0B, RXEN0); // deshabilila la recepción
    bitSet(UCSR0B, TXEN0); // habilita la trasmisión
    #elif defined (__AVR_ATmega1280__) || defined (__AVR_ATmega128__)
    bitClear(UCSR1B, RXCIE1); // deshabilita la interrupción de recepción
    bitClear(UCSR1B, RXEN1); // deshabilila la recepción
    bitSet(UCSR1B, TXEN1); // habilita la trasmisión
    #elif defined (__AVR_ATmega8__)
    bitClear(UCSRB, RXCIE); // deshabilita la interrupción de recepción
    bitClear(UCSRB, RXEN); // deshabilila la recepción
    bitSet(UCSRB, TXEN); // habilita la trasmisión
    #endif

    }

    void AX12::setRX () {
    #if defined (__AVR_ATmega168__) || defined (__AVR_ATmega328P__)
    bitClear(UCSR0B, TXEN0); // deshabilita la trasmisión
    bitSet(UCSR0B, RXEN0); // habilita la recepción
    bitSet(UCSR0B, RXCIE0); // habilita la interrupción de recepción
    #elif defined (__AVR_ATmega1280__) || defined (__AVR_ATmega128__)
    bitClear(UCSR1B, TXEN1); // deshabilita la trasmisión
    bitSet(UCSR1B, RXEN1); // habilita la recepción
    bitSet(UCSR1B, RXCIE1); // habilita la interrupción de recepción
    #elif defined (__AVR_ATmega8__)
    bitClear(UCSRB, TXEN); // deshabilita la trasmisión
    bitSet(UCSRB, RXEN); // habilita la recepción
    bitSet(UCSRB, RXCIE); // habilita la interrupción de recepción
    #endif

    delayMicroseconds (150);
    digitalWrite (2, LOW);
    ax_rx_Pointer = 0; // resetea el puntero del buffer
    }

    And I am running this Code with the Arduino Mega:

    #include
    AX12 motor[2] = {
    AX12(), AX12()};

    void setup() {
    Serial.begin (9600);
    AX12::init (57142);
    byte detect[2];

    byte num = AX12::autoDetect (detect, 2);

    Serial.print (” deteccion: “);
    Serial.println (num, DEC);

    for (byte i=0; i<num; i++) {
    motor[i].id = detect[i];
    motor[i].SRL = 2;
    motor[i].setEndlessTurnMode (false);
    motor[i].torqueOn;
    Serial.print ("motor ");
    Serial.print (i, DEC);
    Serial.print (" ID detectado: ");
    Serial.println (detect[i], DEC);
    }
    }

    void loop() {
    Serial.println("loop");
    delay(1000);
    //motor[0].writeInfo (ID, 0); // change motor ID
    }

    The arduino Code works well with the AX12+ Servo Motors. (with AX12::init (1000000))

    I checked the connection to the MAX485 for times and the RX28 runs if i just connect it to the THX1 port of the arduino and give it some movement orders.

    Have you might got any idea what I am doing wrong? I would love to run and receive data from my new RX28…

    greetigns prax

  205. avatar prax Dice:

    I recognized I do not have understand to connection advised on your jpeg completely.

    Do i need the 2200uF?

    and what is the 104 supposed to mean?

    I marked them with 2 arrows and a ellipse.
    here is the jpeg:
    http://suraki.host.sk/MAX485_with_RX28.jpeg

    greetings prax

  206. avatar pabloxid Dice:

    Fred:

    Try to read actual load of the motor using getLoad(), to see what is happening.

    Prax:

    Software modifications are right. I cannot see your schematic jpeg (I get a forbidden error). Tonight I will upload my own schematic to clarify this.

    Regards.

  207. avatar prax Dice:

    Sorry!
    Maybe the main folder is not accessible. This link should work.

    http://suraki.host.sk/pics/MAX485_with_RX28.jpeg

  208. avatar prax Dice:

    omg again forbidden…
    Its not my day..

    Here, you probably already know what I mean.

    (premium download no waiting required)
    http://rapidshare.com/files/457466228/MAX485_with_RX28.jpeg

  209. avatar pabloxid Dice:

    Prax:

    the capacitors are not very important.

    Personally, I’ve not tested the MAX485 myself, but I do it with MAX489, which is more difficult to connect and not so performant as 485.

    Maybe this schematic can help you, I draw it to help another user, using a SparkFun’s RS-485 breakboard, that you can purchase also:

    http://www.pablogindel.com/images/rx28.png

    Keep me aware of your results.

  210. avatar prax Dice:

    mh… ok
    i dont have access to that breakout board in the moment. Will take some weeks to get it.

    I will try to solve my problem quicker. I let you know my result.

    thanks!

  211. avatar pabloxid Dice:

    Prax:

    The schematic is basically the same for any RS485–Serial converter.

    The issue is to assign functions to specific pin numbers of the MAX485. See if this scheme can help:

    http://aquaticus.info/files/atmega8_max485_0.png

    Pay attention to the Arduino digital output 2, that is connected to the RS485 control pin, which, in the case of MAX485, is the union of the pins 2 and 3.

    So far, proof that it never hurts to do is to swap TX-RX, and the same with the 2 data-pins from RX28. In my experience, regardless of the care we put in following a circuit, we can always connect in reverse things that are symmetrical.

    Regards,
    P.G.

  212. avatar pabloxid Dice:

    P.S. Remember to power the MAX485!

  213. avatar Tomas Alvarez Dice:

    Hola Pablo
    Las instrucciones que se mandan a los ax-12 y rx-24f son exactamente las mismas? Lo unico que cambia es el protocolo half duplex vs rs485?

    Si entiendo bien, entonces un programa hecho para mover dynamixels de la serie ax-12 deberia funcionar sin modificaciones para mover dynamixels de la serie rx. Es esto correcto?

    De antemano, gracias

  214. avatar pabloxid Dice:

    Así es.

    Las diferencias en el “lenguaje” son mínimas, y tienen que ver con las características propias de cada serie, por ejemplo, los límites angulares, la escala de velocidad, de torque, etc., pero las direcciones de los registros son esencialmente las mismas.

    Saludos.

  215. avatar RAFAEL Dice:

    hola pablo es que tengo un problema

    tengo un arduino mega 2560 hago lo que le dijiste a jonatan hago la carpeta en libraries guardo las cosas coloco la progracion y me da este error:

    AX_12_EXAMPLE.cpp:1:30: error: SoftwareSerial.h : No such file or directory
    AX_12_EXAMPLE.cpp:2:20: error: ax12.h : No such file or directory
    AX_12_EXAMPLE:16: error: stray ‘\’ in program
    AX_12_EXAMPLE:3: error: ‘SoftwareSerial’ does not name a type

    saludos y gracias de antemano

  216. avatar pabloxid Dice:

    Estimado RAFAEL:

    Me gustaría saber qué software estás probando y en qué entorno de programación, porque esos errores son rarísimos.
    Si tienes una Arduino Mega 2560, no hay ninguna razón para usar SoftwareSerial.h. Por otro lado, la única versión de la biblioteca compatible con 2560 es la versión 2.3.

    Por lo tanto, lo que te aconsejo es que vayas a la sección “descargas” de este blog, descargues la versión 2.3, borres tu versión actual de la biblioteca y la sustituyas por esta, y luego pruebes el ejemplo que viene incluido, con el IDE Arduino 0022 perfectamente configurado para la Mega 2560.

    De paso puedes apreciar el nuevo botón “donate” que he instalado, y talvez darle un golpecito ;)

    Saludos.

  217. avatar luis Dice:

    Hola,

    Seria posible hablar en privado sobre el robot. Enviame un correo a la direccion que te proporcione. Gracias

  218. avatar pabloxid Dice:

    Luis:

    te mandé un mensaje a esta dirección pero me rebotó: laf509@ohm.york.ac.uk

    Mandame vos a palmer@pablogindel.com

  219. avatar RAFAEL Dice:

    hola pablo tengo el mismo error quiero saber q sucede

  220. avatar pabloxid Dice:

    No puedes tener “el mismo” error si estas haciendo lo que yo te digo. Talvez tengas otro error pero no el mismo, porque en el programa de ejemplo de la 2.3 no hay ninguna referencia a SoftwareSerial.h

  221. avatar RAFAEL Dice:

    hola pablo ahora me da este error

    AX_12_EXAMPLE.cpp:2:20: error: ax12.h : No such file or directory
    AX_12_EXAMPLE.cpp: In function ‘void setup()':
    AX_12_EXAMPLE:6: error: ‘ax12Init’ was not declared in this scope

  222. avatar pabloxid Dice:

    asegúrate de que los archivos “ax12.h” y “ax12.cpp” están en la carpeta correspondiente dentro de libraries de arduino.

    Verifica en el código en la línea que dice #include ‘ax12.h’, el ax12.h debe ir entre signos de menor y mayor (que acá no los deja poner)

  223. avatar RAFAEL Dice:

    si asi tengo en el codigo pero las carpetas no las tengo

    de donde las descargo

  224. avatar pabloxid Dice:

    http://www.pablogindel.com/descargas/

    busca la version 2.3, allí están los archivos y el código.

  225. avatar RAFAEL Dice:

    si pablo ya tengo ese codigo lo coloco lo empiezo y sale el siguiente error:

    AX_12_EXAMPLE.cpp:1:30: error: SoftwareSerial.h : No such file or directory
    AX_12_EXAMPLE.cpp:2:20: error: ax12.h : No such file or directory
    AX_12_EXAMPLE:16: error: stray ‘\’ in program

    ayudame por favor necesito poner a correr eso ya

  226. avatar pabloxid Dice:

    No sé qué software estás probando, pero evidentemente no es el que yo te digo.

    El que yo te digo se llama ax12_test.pde y no AX_12_EXAMPLE

  227. avatar RAFAEL Dice:

    si pablo ya la tengo y la abri se llama ax12_test.pde lo pongo a funcionar y me da el siguiente error:

    ax12_test.cpp:1:18: error: ax12.h: No such file or directory

    por que?

  228. avatar pabloxid Dice:

    el error se debe a que el archivo ax12.h no se encuentra en la carpeta de librerias de arduino.

    Te aconsejo que leas el manual que viene en la carpeta junto con la biblioteca.

    Saludos.

  229. avatar prax Dice:

    hey Pablo,
    i have got the SparkFun’s RS-485 breakoutboard, but still it is not passible to move the rx10 or rx28 or get any feedback of the servos.

    I checked every connection with the multimeter and the software modification is like i posted above…

    I swapped the RX THX and the D+ D- in every possible way.

    I further checked the switching of the digitalPin 2 with switching an LED the same time.

    I am completely lost.

    Any more ideas?

  230. avatar pabloxid Dice:

    You can move the motor in some other way, for example with the interface from Robotis?

  231. avatar RAFAEL Dice:

    HOLA PABLO

    quiero saber como conecto el servo dynamixel a la tarjeta arduino mega 2560

    saludos

  232. avatar pabloxid Dice:

    RAFAEL:

    conecta el pin de data del motor a los pines 18 y 19 de la Arduino Mega 2560.

    El pin GND a GND y el de alimentación a 12V.

  233. avatar prax Dice:

    @ Pablo

    i can move them if i just connect the TX of the arduino with the D- and D+ of the servo

  234. avatar pabloxid Dice:

    @ Prax:

    you mean that you can move the servos connecting D- and D+ directly to TX, without the MAX485??

  235. avatar RAFAEL Dice:

    hola pablo que pena incomodarte pero ya hice lo que me dices y me sale este error:

    cc1plus.exe: error: ax12_test.cpp: No such file or directory

  236. avatar pabloxid Dice:

    @RAFAEL:

    Ese es un error muy raro, del compilador.

    Pregunta: ¿los sketchs de ejemplo del IDE Arduino te funcionan?

    Los archivos deben ir con la misma estructura de directorios que aparecen en el .rar, todo bajo la carpeta “libraries” del Arduino 0022.

  237. avatar RAFAEL Dice:

    hola pablo es que organizo las carpetas .h y .cpp en las librerias de arduino junto al codigo de archivo que se llama ax12_test.pde lo pongo a funcionar y me da el siguiente error:

    ax12_test.cpp:1:18: error: ax12.h: No such file or directory

    que sucede?

  238. avatar pabloxid Dice:

    Las carpetas deben ir así:

    | arduino-0022
    + | libraries
    + + | ax12 <-- aquí van "ax12.h" y "ax12.cpp"
    + + + | examples
    + + + + | ax12_test <-- aquí va "ax12_test.pde"

    Saludos.

  239. avatar RAFAEL Dice:

    hola pablo lo tengo como lo dices ahi pero me sigue dando el error pasado

    que puede ser

  240. avatar pabloxid Dice:

    RAFAEL:

    Contestame por favor esta pregunta:

    ¿El programa de AX12 es lo único que no te funciona, o nigún programa te anda en esa Arduino?

    ¿Probaste correr algún otro sketch, por ejemplo los que vienen de muestra en el propio IDE?

  241. avatar prax Dice:

    @ pablo
    “you mean that you can move the servos connecting D- and D+ directly to TX, without the MAX485??”

    YES. but i cannot change the servo ID without getting a feedback. Your code just gets “dedeccion 0″ so i cannot send any id changes.

    Or am i wrong?

  242. avatar prax Dice:

    like i said i can move them but cant control them with their IDs.

    for (byte i=0; i<num; i++) {
    motor[i].id = detect[i];
    motor[i].SRL = 2;
    motor[i].setEndlessTurnMode (false);
    motor[i].torqueOn;
    Serial.print ("motor ");
    Serial.print (i, DEC);
    Serial.print (" ID detectado: ");
    Serial.println (detect[i], DEC);

    this loop doesnt work become no data is coming back from the servos (byte num = AX12::autoDetect (detect, 2); is not working)

    i could manage to change the servos ID with the Dynamixel USB hardware.

    But than i need to tell the motor[] array what servo has which ID.

    Can i do that in any why?

    something like:
    motor[0] = 0; (0 for ID 0)
    motor[1] = 1;

  243. avatar pabloxid Dice:

    @ prax:

    You can change the object id AX12 as follows:

    motor [0]. id = 1;
    motor [1]. id = 2;
    etc.

    You can even specify an ID when you construct the object, for example:

    motor = AX12 (1); // this defines a motor with id=1

    I find it very strange that you can control the motor without the MAX485. Please try this: connecting the motor through the MAX485, disconnect the control pin (MAX485’s pins 2 and 3) from Arduino’s digital out 2, and connect to ground or +5 V, and then test if you can move the motor, without feedback, only move motor.

  244. avatar prax Dice:

    yes that works aswell…

    BUT: the servo sometimes doesnt move. it moves 5 times than 3 times not, than 4 times again, thanone not…

    im using that code to move it:

    motor[0].setVel (200);
    motor[0].setPos (300);
    Serial.println(“200,300″);
    delay(2000);

    motor[0].setVel (700);
    motor[0].setPos (700);
    Serial.println(“700,700″);
    delay(2000);

    anything wrong with it?

  245. avatar prax Dice:

    note:

    it also srews up the motor[0].setVel setting.

    sometimes it turns both positions in 200 speed sometimes both in 700 and sometimes first in 200 secound in 700 (like it should be)

  246. avatar prax Dice:

    ok… it seems to be the code I just posted. it doesnt work, its bugged some how.

    I tried a old one which I used to move AX12 Servos and it worked. I can use this lines to change IDs (if I know the Servo ID)

    motor[0]. id = 1; // need to know the motor has the ID 1
    motor[0].writeInfo (ID, 2); // change motor ID from 1 to 2

    when I power the direction PIN of the 485 Breakoutboard (i bought one) I can move the servos.

    But I dont really understand why the two way communication doesnt work, although I did the software changes right…

    But thank you so much for helping out again!!!!

  247. avatar pabloxid Dice:

    just in case, try THIS library version.

  248. avatar prax Dice:

    thanks i will try it!

  249. avatar prax Dice:

    dosnt work. :(

    but i can use your help to change the servos IDs and move them by giving the directionpin 5V.

    thats enough for the upcoming project.

    I will try to fix my bug later.

    THANK YOU AGAIN!!

  250. avatar Jay Dice:

    Well, thanks to you getting me started, I have successfully combined 18 AX12 servos, a RC100 controller, a pair of Zig100, an Arduino mega 2560 board with your AX12 library and the Phonix IK
    “engine” to get a pretty functional Hexapod with 6 gates and body translate and roll.

    The one aspect I am not happy with is the test needed to determine if the 18 servos are still moving from the last command before issuing another. Rather than test all the servos I just test the one that had the greatest distance to move from the last command (I’m also using that determination to set the speed of the 18 servos so they all complete together). My first try was to poll the MOVING register, but that created a pause as the register did not seem to get updated fast enough. Now I’m checking the position of my test servo to see if it has reached its goal, but in certain instances the servo never reaches its goal (or the close proximity I set) and the program hangs in the polling loop.

    What method did you use on your hex SAMSA II. Thanks in advance for any help you might provide.

  251. avatar pabloxid Dice:

    Hi Jay, I’m glad you managed to build your hexapod, when you have some video, please show it here (or in SAMSA II entry).

    Regarding your question:
    simply, I do not do that verification. I set the speed for each motor, so they complete their movement at some known time. After that time, I trust that the motor is actually in that position, and usually it is.

    I found that when it fails, it’s due to power supply problems. By powering them with a LiPo battery that can deliver up to 16A peaks, the motors never fail, because they have an onboard microcontroller, so there’s no need to do the same check that the motor itself is doing.

  252. avatar Jay Dice:

    Absolutely wonderful suggestion. I would much rather shorten a servo move than have it hang in a timing loop. Some quick tests with 2 milliseconds per servo step (1-1024) seems to work nicely at full speed with only some flickering of the delay loop led. Now I can fine tune and make adjustment for changes in step speed, it already works nicely with lengthen step strides.

    Right now I’m dragging the 12 volt power brick that came with my original Bioloid set behind the hex. I have the LiPo battery that came with the set installed, I’m just waiting on a jumper cord so I can charge it. Since I don’t want the LiPo to go below 8 volts anyway I don’t think power changes will make a difference.

    Now to start adding sensors and get this thing out on its own.

    Thanks again.

  253. avatar gute Dice:

    hi pablo
    i saw your video( play dynamixel rx-24)
    can i use to play Rx-24 by your ax library?

    i want to use 4 RX-24 motors by ax12 library

  254. avatar pabloxid Dice:

    Yes. In addition, you need a MAX485 chip and a slightly modified version of this library.

    Look at this scheme:

    http://support.robotis.com/en/images/product/dynamixel/rx_series/rx_series_circuit.png

    …And make this modificatios to ax12.cpp:

    At the beginning of setTX() (before the #if defined) place this:

    void AX12:: setTX () {
    digitalWrite (2, HIGH);

    (where ’2′ is the MAX485 direction control pin).

    Then, at the end of setRX() (after the #endif) place this:

    delayMicroseconds (150);
    digitalWrite (2, LOW);
    ax_rx_Pointer = 0;

    You must also initialize motors at 57142 baud, as follows:

    AX12::init (57142)

  255. avatar gute Dice:

    Thank you for letting me know how to amend the library.
    And I have some more question

    Is it possible to run ‘rx24′ with arduino duemilanove or UNO?
    i saw to only use arduino mega in your video

    and, Could you show me some other informations such as connecting Max485 with rx24 and connecting power,and max485, etc ?

  256. avatar pabloxid Dice:

    I’m starting this page:

    http://www.pablogindel.com/informacion/the-arduinodynamixel-resource-page/

    I will turn it into a wiki for allow you to add content.

  257. avatar gute Dice:

    thanks pablo
    but, i have only arduino UNO and duemilanove
    i have no MEGA

    Is it possible to run ‘rx24′ with arduino duemilanove or UNO?

  258. avatar pabloxid Dice:

    Yes, it is possible.

    Use RX and TX instead of RX1 and TX1, and forget about Arduino Serial library in your sketch, that’s all.

    You can still use NewSoftSerial in order to communicate with your PC.

    Please read AX-12 Library manual, all information is there. It’s spanish, some users have translated it to english, but nobody has sent it to me. If someone give me the translation, I post it here.

    Regards,
    P.G.

  259. avatar RAFAEL Dice:

    hola pablo ya hice la conexion y esta como tu me dices las carpetas y ahora me arroja el siguiente error:

    core.a(HardwareSerial.cpp.o): In function `__vector_36′:
    C:\Users\ALEX\Desktop\arduino-0022\arduino-0022\hardware\arduino\cores\arduino/HardwareSerial.cpp:140: multiple definition of `__vector_36′
    ax12\ax12.cpp.o:C:\Users\ALEX\Desktop\arduino-0022\arduino-0022\libraries\ax12/ax12.cpp:103: first defined here

    que quiere decir

  260. avatar pabloxid Dice:

    @RAFAEL

    El ejemplo que viene es para Arduino Mega. Si tienes una Arduino Uno, elimina del ejemplo todas aquellas líneas que hagan uso de la biblioteca Serial de Arduino.

  261. avatar Pabloxid Dice:

    @RAFAEL

    Si tienes una Mega o una Mega 2560, entonces el problema es que no has comentado la sección del USART1 en HardwareSerial.cpp como indica el manual y como indica esta página:

    http://www.pablogindel.com/informacion/the-arduinodynamixel-resource-page/

  262. avatar gute Dice:

    hi pablo

    i had to modify ax12.cpp

    digitalWrite(2, HIGH);
    delay (150);
    digitalWrite (2, LOW);

    and run arduino example file

    #include

    AX12 motor;

    void setup() {

    motor = AX12();

    Serial.begin (115200); // inicializa el Serial a 115,2 Kb/s
    AX12::init (57142); // inicializa los AX12 a 1 Mb/s

    byte detect;
    byte num = AX12::autoDetect (&detect, 1); // detección de IDs

    Serial.print (” deteccion: “);
    Serial.println (num, DEC);

    motor.id = detect; // asigna las ID detectadas a los motores definidos previamente
    motor.SRL = RETURN_ALL;

    Serial.print (” ID detectado: “);
    Serial.println (detect, DEC);
    Serial.print (” delay: “);
    AX12info test = motor.readInfo (RETURN_DELAY_TIME);
    Serial.println (test.value, DEC);
    Serial.print (” error lectura: “);
    Serial.println (test.error, DEC);

    }

    void loop() {

    motor.setVel (random (100, 300));
    motor.setPos (random (200, 800));

    delay (100);

    int pos = motor.getPos();
    int vel = motor.getSpeed();
    int load = motor.getLoad();

    Serial.println (” “);
    Serial.print (” posicion: “);
    Serial.println (pos, DEC);
    Serial.print (” velocidad: “);
    Serial.println (vel, DEC);
    Serial.print (” carga: “);
    Serial.println (load, DEC);

    delay (1100);

    }

    but it has errors

    d:\background\arduino-0022\arduino-0022\libraries\ax12\ax12.cpp:1: error: stray ‘\357′ in program
    d:\background\arduino-0022\arduino-0022\libraries\ax12\ax12.cpp:1: error: stray ‘\273′ in program
    d:\background\arduino-0022\arduino-0022\libraries\ax12\ax12.cpp:1: error: stray ‘\277′ in program

    what went wrong? help me plz

  263. avatar gute Dice:

    hi , i slove the poblem

    i save ax12.cpp to UTF-8

    but i have still problem

    core.a(HardwareSerial.cpp.o): In function `__vector_18′:
    d:\background\arduino-0022\arduino-0022\hardware\arduino\cores\arduino/HardwareSerial.cpp:81: multiple definition of `__vector_18′
    ax12\ax12.cpp.o:d:\background\arduino-0022\arduino-0022\libraries\ax12/ax12.cpp:99: first defined here

    plz help me

  264. avatar gute Dice:

    In my view, I’ve already used SERIAL.

    I might use the NEW SOFT SERIAL LIBRARY which you adviced before.

    Could you show me an example of NEW SOFT SERIAL LIBRARY using AX12.CPP sample code?

  265. avatar pabloxid Dice:

    Simply take this same code, define a newSoftSerial object (see newSoftSerial documentation), name it to something, say “softSerial”, and then you replace all “Serial” occurrences to “softSerial” in the code.

    This will make the code compile, but to ensure that effectively communicates with the PC, you need to connect a USB-Serial converter on pins you used for the newSoftSerial. This can be done by modifying the circuit of your Arduino.

  266. avatar RAFAEL Dice:

    HOLA PABLO

    ES UN arduino mega 2560
    pero me da ese error

  267. avatar pabloxid Dice:

    3) Uso concurrente de la biblioteca Serial de Arduino

    En las placas basadas en ATmega1280 (Mega), ATmega128 (Wiring) y Atmega2560 (Mega 2560), la bliblioteca AX12 utiliza el USART1 y se pueden utilizar los restantes puertos con la Serial de Arduino, pero para ello hay que modificar el archivo HardwareSerial.cpp que se encuentra en los cores de Arduino, de la siguiente manera:

    // modificación para usar la biblioteca AX12

    /*SIGNAL(SIG_USART1_RECV)
    {
    unsigned char c = UDR1;
    store_char(c, &rx_buffer1);
    }*/

    // fin de la modificación

    Ello se debe a que la biblioteca AX12 utiliza su propia ISR para atender la interrupción del USART1, y el core de Arduino declara las ISR para los 4 puertos aunque sólo se utilice uno de ellos.

    Si no se hace esta modificación, no puede utilizarse la Serial de Arduino junto con la AX12, o de lo contrario habrá errores de compilación.

  268. avatar RAFAEL Dice:

    hola pablo ya lo voy a probar pero el motor debe ir alimentado a 7.10 y a la vez el arduino a su cable de alimentacion ?

  269. avatar pabloxid Dice:

    @RAFAEL:

    lo más sencillo es que alimentes el Arduino con 12V, y saques la alimentación para los motores del pin “VIN” del propio Arduino.

    Saludos.

  270. avatar RAFAEL Dice:

    hola pablo me equivoque pero ahora ya corregi la cosa en los cores de arduino

    ahora me da este error

    C:\Users\ALEX\Desktop\arduino-0022\arduino-0022\hardware\arduino\cores\arduino\HardwareSerial.cpp: In function ‘void __vector_36()':
    C:\Users\ALEX\Desktop\arduino-0022\arduino-0022\hardware\arduino\cores\arduino\HardwareSerial.cpp:140: error: redefinition of ‘void __vector_36()’
    C:\Users\ALEX\Desktop\arduino-0022\arduino-0022\hardware\arduino\cores\arduino\HardwareSerial.cpp:93: error: ‘void __vector_36()’ previously defined here

  271. avatar pabloxid Dice:

    el archivo HardwareSerial.cpp debe quedar así:

    /* comentado para usar AX12
    //#if defined(SIG_USART1_RECV)
    #if defined(USART1_RX_vect)
    //SIGNAL(SIG_USART1_RECV)
    SIGNAL(USART1_RX_vect)
    {
    unsigned char c = UDR1;
    store_char(c, &rx_buffer1);
    }
    #elif defined(SIG_USART1_RECV)
    #error SIG_USART1_RECV
    #endif
    */

  272. avatar Trey Dice:

    Pablo,

    I have been a fan for the last couple weeks and have been inspired to work on my own project. I’ve manage to get everything working on my Arduino Uno, but currently not able read the information from my Ax-12. If I am correct I need to purchase an usb to serial converter (FTDI). As a complete beginner I am hesitant that I’ll purchase the wrong part.

    Is this what I’m looking for:
    http://www.sparkfun.com/products/9716

    Also, I’ve been messing with the code trying to teach myself the last couple days. I am trying to manually control 3 servos. I have assigned them different IDs (I think). When I run the “random” code below, it runs perfectly. When I use the other code, it does not run continuously. It will change one servo per loop.

    motor.setPosVel (random (1024), random (200, 500));
    motor1.setPosVel (random (1024), random (200, 500));
    motor2.setPosVel (random (1024), random (200, 500));
    delay(2000);

    —-

    motor.setPosVel (600, 444);
    motor1.setPosVel (600, 444);
    motor2.setPosVel (600, 444);
    delay(2000);

    If you find the time, could you please help me understand the difference.

    Thanks for your time!

  273. avatar pabloxid Dice:

    Hi Trey.

    Yes, the SparkFun FTDI Breakout is a good choice.

    Regarding your code, how do you expect it to behave? From what I can see, it will move the 3 servos to position “600” with a speed of “444”, and then froze in that position.

  274. avatar Trey Dice:

    Pablo,

    Yes, correct, but it does not always behave this way. I’ve attached a couple videos to help explain. Also, I’m not trying to do anything in particular. I want to understand why the servos move like they do.

    This works good.

    http://s99.photobucket.com/albums/l287/paintballerz99/?action=view&current=1234209.mp4

    AX-12 in Video:
    LEFT is Servo ID 6 (motor)
    MIDDLE is Servo ID 7 (motor1)
    Right is Servo ID 5 (motor2)

    motor.setPosVel (800, 444);
    motor1.setPosVel (800, 444);
    motor2.setPosVel (800, 444);
    delay(1500);

    I do not understand why Servo ID 6 moves first, Servo ID 5 moves second, Servo ID 7 moves third. Each time I connect the power, it changes.

    ——

    When I include :

    motor.setPosVel (800, 444);
    motor1.setPosVel (800, 444);
    motor2.setPosVel (800, 444);
    delay(1500);

    motor.setPosVel (200, 444);
    motor1.setPosVel (200, 444);
    motor2.setPosVel (200, 444);
    delay(1500);

    http://s99.photobucket.com/albums/l287/paintballerz99/?action=view&current=1234211.mp4

    http://s99.photobucket.com/albums/l287/paintballerz99/?action=view&current=1234210.mp4

    I expected the servos to rotate all one way, then nearly 180 degrees the other way. But this is not the case.

    Here’s all my code:

    #include

    AX12 motor;
    AX12 motor1;
    AX12 motor2;

    void setup() {

    AX12::init (1000000);

    motor.id = 5;
    motor.SRL = 2;
    //motor.setEndlessTurnMode (false);
    motor.torqueOn;

    motor1.id = 7;
    motor1.SRL = 2;
    //motor1.setEndlessTurnMode (false);
    motor1.torqueOn;

    motor2.id = 6;
    motor2.SRL = 2;
    //motor2.setEndlessTurnMode (false);
    motor2.torqueOn;
    }

    void loop() {

    motor.setPosVel (800, 444);
    motor1.setPosVel (800, 444);
    motor2.setPosVel (800, 444);

    delay(1500);

    motor.setPosVel (200, 444);
    motor1.setPosVel (200, 444);
    motor2.setPosVel (200, 444);
    delay(1500);

    //motor.setPosVel (random (1024), random (200, 1000));
    //motor1.setPosVel (random (1024), random (200, 1000));
    //motor2.setPosVel (random (1024), random (200, 1000));
    //delay(1500);
    }

    Any help is highly appreciated!
    Also I noticed when I change the delay() it changes the behavior.. Not sure why, but some research on my part wouldn’t hurt ;)

    I do intend to Donate as your website, the previous comments and your Manual has helped and inspired me greatly! Thanks again.

  275. avatar pabloxid Dice:

    Trey:

    I think this is a problem with the power supply. Be sure to feed the servos with a 12V/5000mA power source.

    The strange behavior of the first video is easily explained: when a servo moves, the others fail due to lack of energy. On the next round, the first motor consumes no power because it is already in the goal position, then one of the other servos has a chance to move. Finally, the third servo does his job; the order is completely random.

    You can make a donation in the download page. Thank you.

    Regards.

  276. avatar andres Dice:

    Saludos a todos.
    Desde hace unos días he estado tratando de utilizar esta librería para un arduino mega 2560 pero la verdad no he podido lograr mucho.
    el problema que tengo es el arduino mega 2560 tiene 3 puertos disponibles para comunicacion serial ademas del tx0 y rx0 q traen todos los arduino este tiene tx1, rx1 ; tx2,rx2; tx3,rx3. mi problema es que yo quiero comunicar mi arduino y el servo por medio del tx2,rx2. agradesco cualquier ayuda que me puedan brindar porfavor para lograr la comunicacion del servo y del arduino por medio del tx2 rx2. de antemano muchas gracias. saludos.

  277. avatar pabloxid Dice:

    Esta biblioteca trabaja únicamente en el RX1 y TX1. Para cambiarla al TX2 y RX2 debes editar tú mismo el código fuente y cambiar todos los nombres de los registros.

  278. avatar rabit Dice:

    Pablo, do you think you could give me an example of how setMultiPosVel works? Trying to learn the code and not sure about this one. Sorry I am new.

    Also is it possible to make it rotate 720 degrees continuously?

  279. avatar pabloxid Dice:

    @rabit

    This is the main update motor routine, taken from the code of my hexapod SAMSA II, which uses setMultiPosVel() to drive all the 18 AX12s (sorry: no tabs in WordPress :().


    byte motor_update () {
    static int ang_act [6][3];
    byte target_len = 0;
    byte targets [18];
    int positions [18];
    int velocities [18];
    for (byte pata=0; pata<6; pata++) {
    for (byte anillo=0; anillo<3; anillo++) {
    int dif = ang_act[pata][anillo] - ang_des[pata][anillo];
    if (dif != 0) {
    targets [target_len] = ids [pata][anillo];
    positions [target_len] = ang_des[pata][anillo];
    velocities [target_len] = abs(dif) / dur_des [pata][anillo];
    target_len ++;
    ang_act[pata][anillo] = ang_des[pata][anillo];
    }
    }
    }
    if (target_len > 0) {
    AX12::setMultiPosVel (target_len, targets, positions, velocities);
    }
    return target_len;
    }

    To rotate the ax12 720 degrees, set it to freewheel mode and track the PRESENT_POSITION register value, to know what angle has been covered. Note that there is a “blind zone” in which the motor gives no position information (outside the 300 degrees servo mode range).

    If you need precise angular information at any time, then you have to use an external encoder.

  280. avatar pablo stanic Dice:

    una pregunta, es necesario que utilice, la parte usb aparte para ver los datos del servo(que no me interesan),y otra pregunta si uso el arduino mega no puedo emviar las directrices por otros pines seriales, y emviar la informacion del servo por el pin 0, y 1

  281. avatar pabloxid Dice:

    @pablo stanic:

    La primera pregunta, la respuesta es no, no es necesario que utilices la parte USB.

    La segunda pregunta no la entiendo..

  282. avatar Bruno Dice:

    Hello,
    I have a problem with a servo. When autodetecting i get a error 1920 . Do you know what it could be? The thing is I changed the baud rate of the motor to 9600 with another library( http://savageelectronics.blogspot.com/2011/01/arduino-y-dynamixel-ax-12.html ) but I can’t change it back with it. Is there a way to change it with your library? I tryed them boath and yours seems to have more options and works better but I had no luck with fixing this poblem.

    In the serial monitor I get:
    deteccion: 0
    ID detectado: 1
    delay: 0
    error lectura: 1920

  283. avatar pabloxid Dice:

    Hi Bruno, you have 2 options:

    1) reset the servo with Dynamixel CM-5 brick.

    2) try to use this library @9600 bps.

    Simply replace the “AX12::init(1000000);” by “AX12::init(9600);”.

    Verify that the motor is detected correctly, and then use the reset command, this way:

    mortor.reset();

    Good luck.

  284. avatar Bruno Dice:

    Yes I tryed the code but no luck. I even tryed initializing on every baudrate posible(254 diferent baudrates) and still no luck.
    I was hoping that I won’t have to buy anything extra (CM-5 or the USB2Dynamixel). I found a forum thread( http://robosavvy.com/forum/viewtopic.php?t=3719&sid=8662c017d2038e743ef53d9bb67cc20c ) on how to hard reset the servo but I’m not shure if it could be done with an arduino.

  285. avatar pabloxid Dice:

    But you still able to communicate with the savage library? If so, you can still try to reset it from there, sending the bytes manually.

  286. avatar Gerard Dice:

    Hola Pablo estoy trabajando con una arduino mega2560 y con tu libreria para hacer andar un ax-12. En cuanto al programa funciona todo correctamente y me hace el upload. El problema viene cuando conecto el servo que me sale lo siguiente en el serial monitor ademas que el led del servo no para de parpadear(asi que sera un problema de alimentacion):

    deteccion: 1
    ID detected: 8
    delay: 0
    error lectura: 0

    position: 312
    speed: 0
    load: 0
    temperature: 27

    position: -9739
    speed: -501
    load: -501
    temperature: 245

    position: -2571
    speed: -501
    load: -501
    temperature: 245

    La placa de arduino la tengo alimentada por medio del usb, y hago la programacion directamente.Los pines 18 y 19 estan conectados entre si y al data. Y el ax esta alimentado por una fuente exterior a 9V. Alguna idea?por que le he dado 1000 vueltas y nada. Muchas gracias de antemano por la respuesta

    Saludos!

  287. avatar pabloxid Dice:

    La fuente que alimenta los AX12 tiene que ser “polenta”, no se te ocurra usar uno de esos transformadores de pared. Utiliza una fuente de 12V / 1,5A para un solo motor. (la fuente de Bioloid es de 5A, para que te hagas una idea).

    Me inclino por un problema de fuente, ya que la primer lectura la hace bien, pero cuando intenta mover el motor, empieza a dar errores, eso es típico de una fuente que “agacha”, resetea el motor y por eso la luz vuelve a parpadear.

    A propósito, qué versión es ese programa de ejemplo? no parece ser el último.

    Saludos.

  288. avatar gerard Dice:

    Efectivamente era problema de la fuente, utilizé otra diferente y ya funciona correctamente. En cuanto a la version del programa es el obtenido de la pagina de descargas viene de ejemplo en la ultima version de la libreria algo modificado, para ver la temperatura y traducido al ingles simplemente jeje.

    Muchas gracias, un saludo!

  289. avatar gutte Dice:

    Hi pablo…

    I don’t know how to modify HardwareSerial.cpp

    So, can you send Modified file to me?

    cwoosuk7@nate.com

  290. avatar gutte Dice:

    hi pablo
    ————————————-
    arduino Duemilanove
    arduino0022
    2 RX – 24f
    max485

    ————————————–

    2 servos to rotate same way,
    i want to ratate each other..
    What;s wrong??

    ——code——–

    #include

    AX12 motor;
    AX12 motor1;

    void setup() {

    AX12::init (57142);

    motor.id = 1;
    motor.SRL = 2;
    motor.torqueOn;

    motor1.id = 2;
    motor1.SRL = 2;
    motor1.torqueOn;

    }

    void loop() {

    motor.setPosVel (random (100, 1000),random (100, 1000));
    delay (1000);
    motor1.setPosVel (random (100, 1000),random (100, 1000));
    delay(1000);

    }

    http://vimeo.com/27015969

  291. avatar pabloxid Dice:

    If you want the servos move the same way, you have to send the same data to the two.

    You can also use the setMultiPosVel() command or define a broadcast motor.

  292. avatar gutte Dice:

    pablo, no..

    i expect
    2 Servos want to move each

    However, However, unlike the above code, the motor moves the same way

  293. avatar pabloxid Dice:

    Ah, ok, then what may be happening is that the 2 servos have the same ID.

  294. avatar gutte Dice:

    #include

    AX12 motor;
    AX12 motor1;

    void setup() {

    AX12::init (57142);

    motor.id = 1;
    motor.SRL = 2;
    motor.torqueOn;

    motor1.id = 2;
    motor1.SRL = 2;
    motor1.torqueOn;

    }

    void loop() {

    motor.setPosVel (random (100, 1000),random (100, 1000));
    delay (1000);
    motor1.setPosVel (random (100, 1000),random (100, 1000));
    delay(1000);

    }

    is it wrong?

    Could you show me 2 servos id example code

  295. avatar gutte Dice:

    #include

    AX12 motor[2] = {AX12(), AX12()};

    void setup() {
    AX12::init (57142);
    byte detect[2];
    byte num = AX12::autoDetect (detect, 2);

    for (byte i=0; i<num; i++) {
    motor[i].id = detect[i];
    motor[i].SRL = 2;
    motor[i].torqueOn;
    }
    }

    void loop() {
    motor[1].setPosVel (20, 10);
    delay(500);
    motor[0].setPosVel (200, 1000);
    delay(500);
    motor[1].setPosVel (600, 10);
    delay(500);
    motor[0].setPosVel (1000, 1000);
    delay(500);
    }

    If I verify code above,
    it makes two motors run together at the same time.
    But I want to rotate the ID number one first, after that, the ID number two be rotated.
    How do I make it by turns?
    Plz help me!!!!!!

  296. avatar pabloxid Dice:

    I mean the motors have the same ID, not the code, do you understand?

    The code is OK, maybe you can enlarge the delay times, but I think your motors have the same ID themselfs.

  297. avatar RAFAEL Dice:

    HOLA PABLO HACE RATO NO TE ESCRIBIA
    quiro mencionarte lo que paso tengo el mismo eror pasado asi que lo volvi desde el comienzo
    pero la biblioteca que es la 2.3 me descargaga pero no me abre

    por que

  298. avatar pabloxid Dice:

    necesitas el Winrar versión 3.6 o superior

  299. avatar RAFAEL Dice:

    listo pablo problema resuelto

    ahora tengo este error de compilacion:

    C:\Documents and Settings\TALENTOS\Mis documentos\arduino-0022\hardware\arduino\cores\arduino\HardwareSerial.cpp:32:1: error: unterminated #if

    /* que quiere decir */

  300. avatar pabloxid Dice:

    quiere decir que cometiste un error al comentar lo que había que comentar en el archivo HardwareSerial.cpp

  301. avatar RAFAEL Dice:

    sabes que error puede ser ?

  302. avatar pabloxid Dice:

    El problema es que HardwareSerial.cpp es un archivo que varía según la versión de Arduino que estés usando (recomiendo la 0022).

    El instructivo que hay es para la versión 0018, yo lamentablemente no tengo tiempo de fijarme ahora, pero el error que cometiste es el que dice ahí, comentaste un “#endif” y dejaste colgado un “#ifdef” con toda seguridad.

    Espero que algún otro usuario de este foro pueda ayudarte, hay muchísima gente que ya está usando la biblioteca desde hace mucho tiempo.

  303. avatar gutte Dice:

    hi pablo
    i read your AX12 manual file

    but i don’t know well

    can you tell me How to change motor ID?

    please change ID arduino code!!!!

  304. avatar pabloxid Dice:

    If you can, use the CM5 brick to change the motor ID.

    Otherwise, use this code:

    #include «ax12.h»
    AX12 motor;

    void setup () {
    motor = AX12();
    AX12::init (1000000);
    detect byte;
    byte num = AX12::Autodetect (&detect, 1);
    motor.id = detect;
    motor.SRL = RETURN_ALL;
    motor.changeID (new_id);
    }

    void loop () { }

  305. avatar Trey Dice:

    Hey pablo, is there a way to send a command to the ax12s while its connected to the Arduino and computer (by FTDI)?

    I understand you can monitor the results with putty but I am not sure how I can command the ax12s to a specific position without communication directly to Arduino.

    I have created a pan/tilt camera that identifies and tracks a persons movement (by facial recognition). I used Processing to capture an individuals face. Next was to send data to an Arduino to control the motors. This is a problem with the ax12 since usb connection to the Arduino wont work with the ax12s.

    My next step was to explore the “Processing serial library” but wanted to see if you have any ideas!

    Any advice would help! Thanks in advance!

  306. avatar pabloxid Dice:

    @Trey:

    not quite understand your question. Look in the slide at http://www.pablogindel.com/2010/03/xy-motion-control/ which is below the 2 videos, maybe that will clear any doubts.

    regards.

  307. avatar Trey Dice:

    Thanks Pablo! My answer is probably within xy-motion-control! I’ll now work on translating the documentation!

    Sorry for the confusion^^

  308. avatar gutte Dice:

    hi pablo
    i have little problem

    – code –
    #include

    AX12 motor;

    void setup () {
    motor = AX12();
    AX12::init (57142);
    byte detect;
    byte num = AX12:: autoDetect (&detect, 1);
    motor.id = detect;
    motor.SRL = RETURN_ALL;
    motor.changeID (2);
    }

    void loop () { }

    this code is no error
    but don’t change ID

    i want change ID(2)

    what is the wrong?

  309. avatar pabloxid Dice:

    what is your motor current ID?

  310. avatar gutte Dice:

    It’s originaly set an ‘ID1’ .
    I’d like to change it to ‘ID2’, so I trie it.
    There is no error, but it isn’t changed . I don’t know how change the name.

  311. avatar pabloxid Dice:

    ‘ID’ isn’t a name, it’s a number. Are we talking about the same thing?

    AX12 library auto-detects your motor ID, so you can, in the code, name it as you like and work with it perfectly, without knowing its ID.

    My question is: how do you know that your engine has the ID ‘1’?

    Either way, that code does actually change the id of your motor to ‘2’. To be quite sure, put a ‘delay(200);’ before ‘motor.changeID(2);’, and you can also put ‘motor.changeID(2);’ inside the loop () {} section. Finally, try resetting the Arduino a few times with the motor connected to it, and powered.

  312. avatar marcel nijssen Dice:

    Hello i have a problem a have 2 ax-12 servos , but they have work in the beginning
    but i try to change the ids of them so a can command them separtly , but now they are not working anymore i use the arduino uno board , connect the data of servos to pin 1 tx , supply for servos on the board vin , gnd .
    the led light up when i connect them ,
    i use the new version from u v2.3 , and the Hardware.ccp a have disable the part that you tell about in the manual.
    what do i wrong , i cant see the information he send over , because i wants to use the LiquidCristal_i2c for that but first they must reacts on the example
    here is my code :
    #include

    AX12 motor;

    void setup() {

    motor = AX12();
    AX12::init (1000000); // inicializa los AX12 a 1 Mb/s

    byte detect;
    byte num = AX12::autoDetect (&detect,254); // detección de IDs

    motor.id = detect; // asigna las ID detectadas a los motores definidos previamente
    motor.SRL = RETURN_ALL;

    AX12info test = motor.readInfo (RETURN_DELAY_TIME);
    pinMode(13, OUTPUT);
    }

    void loop() {

    delay(200);
    motor.reset();
    delay(200);
    digitalWrite(13, HIGH);

    delay (1100);
    digitalWrite(13, LOW);

    }

    i have try also to set the id numbers to 1
    nothing happens ,i try to reset the arduino for several times but dont work .
    i had try this to set to 1 id number
    byte num = AX12::autoDetect (&detect,1); // detección de IDs
    Can you help me thanks.

  313. avatar pabloxid Dice:

    Marcel, try this:

    1) connect 1 servo only, supply it with 12V/1A.

    2) compile and upload this code:

    #include <ax12.h>

    AX12 motor;

    void setup() {

    motor = AX12();
    AX12::init (1000000);
    byte detect;
    byte num = AX12::autoDetect (&detect,1);
    motor.id = detect;
    motor.SRL = RETURN_ALL;

    }

    void loop() {

    motor.setVel (random (100, 300));
    motor.setPos (random (200, 800));
    delay (800);

    }

    3) try this with every AX12.

  314. avatar marcel nijssen Dice:

    hi thanks for your help , i try them both , 1 by 1 but nothing happens , i think the have no ID anymore if i try to detect 2 or more servos nothing happens , how can i reset them and give then a other id ,
    thank you for the help

  315. avatar pabloxid Dice:

    Marcel:

    In order autodetection to work you must connect AX12 data pin to both TX and RX pins on the Arduino.

    If you don’t connect RX then you don’t have any motor feedback, then software don’t know motor ID and then motor can’t be controlled.

  316. avatar marcel nijssen Dice:

    Ok thanks the work now , that was what wash wrong , thanx , but how can i change the id of one motor , because i will control them sepertly , thank you for your help

  317. avatar pabloxid Dice:

    try this code, with 1 motor:

    #include <ax12.h>
    AX12 motor;

    void setup () {
    motor = AX12();
    AX12::init (1000000);
    detect byte;
    byte num = AX12::Autodetect (&detect, 1);
    motor.id = detect;
    motor.SRL = RETURN_ALL;
    delay (300);
    motor.changeID (–put here the new id–);
    }

    void loop () { }

  318. avatar marcel nijssen Dice:

    Ok thank you i think its work the change of the motor id , but i connect then both the dont work , but if i connect them 1 of then they work what im a doing wrong now .
    #include

    AX12 motor;

    void setup() {

    motor = AX12();
    AX12::init (1000000);
    byte detect;
    byte num = AX12::autoDetect (&detect,2);
    motor.id = detect;
    motor.SRL = RETURN_ALL;
    delay (300);
    //motor.changeID (2);

    }

    void loop() {

    motor.setVel (random (100, 300));
    motor.setPos (random (200, 800));
    delay (800);

    }
    and there was a little foult you write detect byte;

    but it was
    byte detect

    but im greatful for your help if i can use them both then im really happy .

  319. avatar marcel nijssen Dice:

    Or is the power supply to low for 2 motors i use 12V/1A and is there a posability to use a LuiqidCristal_i2c lcd to use this motor if a try to impletate the library there are errors to compline ,but im releaved that the motor work now , and that there are not broke.

  320. avatar marcel nijssen Dice:

    if i disconnect the power of 1 motor then reset the adro then the motor moves , and then connect the other then they work both if i then disable the power of the 12v of the ardo or reset then dont work , if i repeat this they work ,do you know what that can be and how can i let motor 2 go to opposite direction of motor 1 ,
    thanks this is great help ,i will try of i can get this solved by my self .

  321. avatar pabloxid Dice:

    Marcel:

    that code is not suitable to control 2 motors. Search the forum for a 2 motors example, it has been posted several times.

    P.G.

  322. avatar marcel nijssen Dice:

    Ok thank you for your support , you help me a lot im very greatfull.

    but itry this motor to turn opposite but then dont i try i think the id number wont change from one motor to 2 .
    i try it several times to change nothing happens ,if i use this they both turn
    and if i disable text of motor one nothing happens

    #include

    AX12 motor[2] = {AX12(), AX12()};

    void setup() {
    AX12::init (1000000);
    byte detect[2];
    byte num = AX12::autoDetect (detect, 2);

    for (byte i=1; i<num; i++) {
    motor[i].id = detect[i];
    motor[i].SRL = RETURN_ALL;
    motor[i].torqueOn;
    }
    // delay (1100);
    //motor[1].changeID(2);
    //delay (1100);

    }

    void loop() {
    motor[2].setPosVel (100, 100);
    delay(500);
    motor[2].setPosVel (200, 100);
    delay(500);

    motor[1].setPosVel (200, 100);
    delay(500);
    motor[1].setPosVel (100, 100);
    delay(500);

    delay (1100);
    }
    what could it be that the motor dont take a new adress (then i have turn 1 motor off)
    because or they both change.
    whit this script the motors shout turn to opposite directions or not

  323. avatar pabloxid Dice:

    Yes, with that program both motors should move, each in its turn, and in opposite directions.

    Obviously, both continue with the same ID. I suggest you do the following:

    Connect 1 motor only, use the example that I gave you to change ID, ​​and assign an ID other than 1 or 2. Reset Arduino several times with the motor connected and powered, to make sure you change the ID. Also, make sure that the other motor is NOT connected.

    Then connect both motors and try again with the latter program (change firmware BEFORE connecting motors).

  324. avatar marcel nijssen Dice:

    he i have to try him set the ids sereral time but nothing change , but if i reset him the led of the ax12 on/off a few times .
    the reset function is working very well,
    what can there be wrong , can you try to change one of your ids of the motor , i have change then in serveral numbers .
    and try to set then in a for loop but dont work eather but that not so importand .
    txs for the help i know thats i asking very much sorry for that but you the only one who can help me .

  325. avatar pabloxid Dice:

    I changed the 18 motor ID’s of my hexapod that way.

    What you have to reset is not the AX12 but the Arduino; leave AX12 connected and reset the Arduino to run the code when motor is ready to receive commands.

    If you take away the power, then the AX12 takes a few seconds (or milliseconds, whatever) to start and never receives the command to change the ID, I mean?

  326. avatar marcel nijssen Dice:

    i understands , but that i have try a many times reset the ardo and ax-12 but it seems not to work , i got now well 2 error codes i think thats the problem thats he is not recieving .
    the erro codes :
    avrdude : stk500-getsync():not in sync :resp=0x30
    and
    avrdude : stk500-disable():protocolerror,expect=0x14,resp=0x51

    i change the ccp file , can you tell what you think this is normal i disconnect the rx comp,upload ,connect and then reset ardo ,
    but wrong or not ?

  327. avatar pabloxid Dice:

    Make things as follows:

    1) disconnect all stuff
    2) upload ID changing program to Arduino
    3) connect 1 motor to arduino, and power it
    4) PRESS RESET BUTTON ON ARDUINO
    5) wait a few seconds, and press reset button again
    6) one more time

    ID changing program is that one:

    #include <ax12.h>

    AX12 motor;

    void setup () {
    motor = AX12();
    AX12::init (1000000);
    byte detect;
    byte num = AX12::autoDetect (&detect, 1);
    motor.id = detect;
    motor.SRL = RETURN_ALL;
    delay (500);
    motor.changeID (_new_id_);
    }

    void loop () { }

  328. avatar marcel nijssen Dice:

    if i try your method and then the example with to drive motor 2 then nothing happens , when i try the same example to drive motor 1 they drive and the rx isnt connected , i disconnect rx most of the time or else a have 2 errors see above ,
    what can that be, he needs the tx/rx at the same time, every time i upload , i reset arduino board a few times, but wont change ?are they broke ?

  329. avatar pabloxid Dice:

    Of course you cannot upload anything to Arduino if you have TX and RX connected together.

    Also, for Arduino Uno there is no hardwareSerial.cpp change needed at all.

    Try to understand how the AX12-Arduino Library works, all information is here on the forum and in the manual. It has been tested many times, so it’s virtually free of errors at this time.

    Sorry, I can’t help you more than this.

  330. avatar marcel nijssen Dice:

    Ok thank you for your pattions for the help , am greatful that the are working , i change the hardware back to normal , i try to what i am doing wrong if i know whats i am doing wrong i post it here ,maybe because i change the hardware.ccp , is that the problem , thanks for the help so far .

  331. avatar marcel nijssen Dice:

    Hi pabloxid gives only the error that he can not communicate whit the pc , i think i blow him up when uploading whit the rx and tx together connected , but i have connect my adruino mega 1260 ,and now i can see that id in the serail screen and your write , the id wash changed but whit the program to move the motor 1 turn to the opposite of the other he reacts sometimes good but sometimes motor 2 spins around ,
    how can i make that , the motor 1 , turns from 100-1000 and at the same time motor 2 turns from 1000-100 , because a have reed the setmultipos but whit this function you can set them both on the same position and not 1 to the opposit position at the same time , thanks for the help so far the problem of my id was it was changed but i could see .

  332. avatar marcel nijssen Dice:

    Hello can some explain how to use the .
    setMultiPosVel function to use , i try but i cant get it done .
    i want to control them by my rc receiver , but they must both turn to the opposite ,
    if i use a for loop then they move not exactly the same ,and they must, because the two motors turn something up and down , 1 motor left of the canon and 1 motor right,
    can someone help me whit this.
    thanks .

  333. avatar g. Dice:

    Querido pabloxid,

    thanks for your library. Nice job. I would like to bother with an info request.

    I successfull made an AX12+ motor move with Arduino UNO. It might be usefull to the readers to know that I had a problem with the autodetection of the ID, I finally solved by reading the ID with the Bioloid software and giving it as constant in the Arduino code.

    Btw, now I would like to connect the PC to the Arduino (and an acelerometer too) and I would like to ask your adive on the USB-serial converter (I’m a newby…).

    It seems to me that I can not take whatever converter right? it is to naive to take the GND, RX, TX pins of the serial port (I do not know chip and brand…) and use them?

    In case a specific brand is required I read that the FTDI chip is appropriate. Do you have any schematics or photograph on how to connect the serial part to the Arduino? I do not have any idea…

    hola,
    g.

  334. avatar pabloxid Dice:

    Dear g.:

    Your problem with autodetection is probably due to TX and RX do not short.

    Regarding the USB-serial adapter, it must be used in combination with Arduino NewSoftSerial library. My preference is to use the USB-serial that is already in the Arduino board, disconnecting it from pins 1-2 and and then connecting to pins 3-4, for example, as shown in the picture.

    hacked arduino

  335. avatar g. Dice:

    Thanks a lot for your kind reply.

    Based on various considerations I took a FTDI-based USB/serial converter.

    Feliz navidad,
    g.

  336. avatar Akshay Dice:

    Hello Pablo,

    Thank you for the amazing AX-12 library. I set it up on my Arduino Mega and it works perfectly.

    I need some help with some code to control multiple servos in a daisy chain. I want to set different positions for different motor (from ID=1 to ID=7).

  337. avatar pabloxid Dice:

    //define an array of motors
    AX12 motor [7];

    //setup static members
    AX12::init (1000000);

    //you initialize each motor
    motor [i] = AX12(_id);
    motor [i].SRL = RETURN_ALL;
    motor [i].torqueOn;

    //and then you send pos/vel commands to any motor as you wish

  338. avatar jaycon Dice:
  339. avatar Akshay Dice:

    Hi Pablo. Thanks for the example. I have a problem when I connect 7 servo motor in a daisy chain. the first 3 motors respond, and then the next ones only respond sometimes. I am using a 12V 5.2A supply.

    This is my sample code:

    //define an array of motors
    AX12 motor [7];

    //setup static members
    AX12::init (1000000);

    //initialize each motor – I do this for all 7 servos.

    motor [0].id = 1;
    motor [0].SRL = RETURN_ALL;
    motor [0].torqueOn;

    motor [1].id = 2;
    motor [1].SRL = RETURN_ALL;
    motor [1].torqueOn;

    motor [2].id = 3;
    motor [2].SRL = RETURN_ALL;
    motor [2].torqueOn;

    motor [3].id = 4;
    motor [3].SRL = RETURN_ALL;
    motor [3].torqueOn;

    motor [4].id = 5;
    motor [4].SRL = RETURN_ALL;
    motor [4].torqueOn;

    motor [5].id = 6;
    motor [5].SRL = RETURN_ALL;
    motor [5].torqueOn;

    motor [6].id = 7;
    motor [6].SRL = RETURN_ALL;
    motor [6].torqueOn;

    void loop() {

    motor [0].setVel (100);
    motor [0].setPos (random (500, 750));

    motor [1].setVel (100);
    motor [1].setPos (random (500, 750));

    motor [2].setVel (100);
    motor [2].setPos (random (500, 750));

    motor [3].setVel (100);
    motor [3].setPos (random (500, 750));

    motor [4].setVel (100);
    motor [4].setPos (random (500, 750));

    motor [5].setVel (100);
    motor [5].setPos (random (500, 750));

    motor [6].setVel (100);
    motor [6].setPos (random (500, 750));
    }

    Servo 4 and 5 do not move sometimes for almost 30s. Could the servos be spoilt?

    thanks for your help

  340. avatar pabloxid Dice:

    Seems to be a hardware problem. Determine whether, when the motor stop moving, the led begins to flash indicating an error.

  341. avatar Akshay Dice:

    The motors don’t flash, so it doesn’t seem to be an error. The motors connected after these motors work perfectly. So it could be a hardware fault but like I said, the led does not flash so I am not sure what the problem is. Thanks anyway.

  342. avatar pabloxid Dice:

    Well, I don’t know what’s going on.

    BTW, try to put some delay() inside the loop() section, I see you are sending too many messages continously…

  343. avatar cleo Dice:

    Pessoal,
    Acesse o site da EMPRETECNET, eles fabricam um KIT com uma placa compatível com arduino duemilanove, uma placa de rele, de potenciômetro, de sensor de luz, de sensor de luminosidade, de buzzer, de botão e demais componentes que podem ser realizados vários experimentos sem a necessidade de solda. Qualidade excelente!!

  344. avatar lentin Dice:

    Hi Pablo
           This site is very useful for me .I have some query related to dynamixel module for arduino .I am using arduino 1.0 and board is Arduino Mega.I need to interface a sabertooth and dynamixel with arduino .I got sabertooth module for arduino from there site and dynamixel module from ur site .This module is perfectly working in Arduino 017 .I tested it ,but the issue is sabertooth module only work in new arduino software .So how can i port your module to new arduino software edition ??and i need to interface RX series servo instead of AX  .So pls help me if you get time 

    Regards
    Lentin

  345. avatar pabloxid Dice:

    Hi lentin, cute gravatar.
     
    I guess the problem is Arduino Serial library, send me more details and I try to solve it.
     
    With regard to control RX series, first of all you need to connect things like this: http://www.pablogindel.com/images/rx28.png

  346. avatar César Dice:

    Hi Pablo,
    Amazing knowledge from you and even best you sharing it for us all to learn through our own projects. BIG THANKS
    I can't compile and it seems related to working with arduino 1.01:
    1.- HardwareSerial.cpp is found in C:\Program Files\arduino-1.0.1\hardware\arduino\cores\arduino (changed path)
    2.- Text to be commented in HardwareSerial.cpp is not found anymore
    3.- Compiling errors:
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:28:76: error: wiring.h: No such file or directory
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp: In static member function 'static void AX12::setTX()':
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:44: error: 'bitClear' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:46: error: 'bitSet' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp: In static member function 'static void AX12::setRX()':
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:61: error: 'bitClear' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:63: error: 'bitSet' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp: In static member function 'static void AX12::setNone()':
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:81: error: 'bitClear' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:84: error: 'bitSet' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp: In static member function 'static void AX12::init(long int)':
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:135: error: 'bitSet' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp: In member function 'int AX12::writeData(byte, byte, byte*, boolean)':
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:319: error: 'delay' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp: In member function 'int AX12::writeInfo(byte, int, boolean)':
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:366: error: 'lowByte' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:367: error: 'highByte' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp: In static member function 'static void AX12::syncInfo(byte, byte, byte*, int*)':
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:378: error: 'lowByte' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:379: error: 'highByte' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp: In member function 'void AX12::endlessTurn(int)':
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:402: error: 'abs' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp: In member function 'int AX12::setPosVel(int, int)':
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:429: error: 'lowByte' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:430: error: 'highByte' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp: In static member function 'static void AX12::setMultiPosVel(byte, byte*, int*, int*)':
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:440: error: 'lowByte' was not declared in this scope
    C:\Program Files\arduino-1.0.1\libraries\ax12\ax12.cpp:441: error: 'highByte' was not declared in this scope
    Is it hard to adapt to new ide or are you planning on it or should I stick to previous versions?
    Thanks again
    César
     

  347. avatar pabloxid Dice:

    Hola César, te contesto en español. Para usar la biblioteca AX12 en Arduino 1.01, sigue los siguientes pasos:

    1) utiliza la versión 2.3 de la biblioteca AX12

    2) sustituye #include <Wiring.h> por #include <Arduino.h> (en AX12.cpp)

    3) en HardwareSerial.cpp, localiza el siguiente texto y coméntalo con /* */

    SIGNAL(USART1_RX_vect)
    {
    unsigned char c = UDR1;
    store_char(c, &rx_buffer1);
    }

    4) eso es todo

  348. avatar César Dice:

    Genial Pablo!!
    Esta noche lo pruebo.
    gracias de nuevo

  349. avatar Concepcion Dice:

    Pretty great post. I just stumbled upon your blog and wanted to say that I’ve truly loved browsing your weblog posts. After all I’ll be subscribing to your feed and I hope you write again very soon!

  350. avatar alonso martinez Dice:

     

    Hi Pablo,


    I'm having trouble connecting my uino to my mx-28 servo and I don't know what I'm doing wrong.


    Here are the components I'm using:


    MX-28T servo 
    Arduino Mega 1280 
    Arduino 1.0.1 IDE 
    Dynamixel AX-12+ Arduino Library, v2.3 


    I modified the "ax12.cpp" and "HardwareSerial.cpp" like the instructions said.


    In the example file I changed the baud rate and motor ID since to match the default for the MX-28t servo using these lines:


    AX12::init (57600); 
    motor.id = 1; 


    This is how I set up the wiring:


    For the power pin  I connected a couple of batteries in series to give me a voltage of 12.71


    For ground pin I connected the ground from the arduino, the ground of the battery


    For the data pin I connected Tx1 and Rx1 


    Here are some images:


    https://dl.dropbox.com/u/46736930/IMG_1790.JPG
    https://dl.dropbox.com/u/46736930/IMG_1796.JPG


    https://dl.dropbox.com/u/46736930/IMG_1791.JPG


    Any idea of what's going on?

  351. avatar alonso martinez Dice:

    Oops sorry por el formato tan extraño de texto!

  352. avatar pabloxid Dice:

     
    1) qué versión de la biblioteca AX12 usas?
    2) qué modificación hiciste en AX12.cpp?
    3) prueba inicializar así: 
    AX12::init (57142);

  353. avatar pabloxid Dice:

    4) la fuente de alimentación no es apropiada. Utiliza una fuente de 12V /2A

  354. avatar alonso martinez Dice:

    Muchisimas gracias Pablo! voy a comprar una bateria adequada y luego te mando un mensaje si jalo!
    Saludos,
    -Alonso

  355. avatar alonso martinez Dice:

    Hola Pablo,
    Ya me llego mi bateria LiPo y un USB2Dynamixel para probar todo y jala genial con el USB2Dynamixel pero todavia no con el Arduino! Todavia me esta dando este mensaje:
    deteccion: 0
    ID detectado: 1
    delay: 0
    error lectura: 1920
     
    Usando el Dynamixel Wizard de USB2Dynamixel puedo ver el baud rate (57142) y el motor ID (1) que los trate de usar en ax12_test.pde cambiando la lineas:
    void setup() {
     
      motor = AX12();
      Serial.begin (115200);  // inicializa el Serial a 115,2 Kb/s
      AX12::init (57142); //cambiando el baud rate para que sea el mismo de el MX28T
      byte detect = 1; //forzando que el motor ID sea 1
      motor.id = detect; // asigna las ID detectadas a los motores definidos previamente
      motor.SRL = RETURN_ALL;
     
      Serial.print (" ID detectado: ");
      Serial.println (detect, DEC);
      Serial.print (" delay: ");
      AX12info test = motor.readInfo (RETURN_DELAY_TIME);
      Serial.println (test.value, DEC);
      Serial.print (" error lectura: ");
      Serial.println (test.error, DEC);
    }
    En el archivo ax12.cpp cambie "Wriring.h" por "Arduino.h" por que estoy usando un Arduino IDE nuevo.
    El archivo HardwareSerial.cpp cambie:
    /*SIGNAL(USART1_RX_vect)
    {
        unsigned char c = UDR1;

    store_char(c, &rx_buffer1);
    }*/
     

  356. avatar alonso martinez Dice:

    Estoy usando el Rx1 y Tx1 (pin 18 y 19) en mi Arduino 1280 Mega.
    connecto esos dos pines a la misma linea en el breadboard que el data pin de Dynamixel. Eso es todo lo que tengo que hacer no?
    Muchisimas gracias Pablo!!
    -Alonso

  357. avatar pabloxid Dice:

    Mi sugerencia es que dejes la rutina de autodetección como estaba en el ejemplo, por si la ID del motor no es efectivamente la 1.
    Prueba enviar comandos de movimiento al motor, dado que el error 1920 lo que indica es que no se está recibiendo absolutamente nada del motor, pero eso no quiere decir que no funcione.
    Las conexiones son las correctas, en teoría, pero revisa que no estén fallando en la práctica.
     

  358. avatar alonso martinez Dice:

    Hola Pablo,
    Si tambien tratre originalmente el codigo sin tratar de forzar el motor ID, pero tampoco no jalo.
    Estaba mandando mensajes de movimento usando tu ejemplo ax12_test.pde pero no escribi todo el codigo en mi ultimo mensaje.
    Voy a tratar de mandar paquetes de serial escritos manual mente a ver si me puedo connectar con el servo.
    Te aviso como me va!
    Muchas gracias por todo!
    -Alonso Martinez

  359. avatar alonso martinez Dice:

    Buenos dias Pablo!
    Se me hace que tiene que ver con mi version nueva de arduino. Estoy usando Arduino 1.0.1 que creo el archivo HardwareSeria.cpp es un poquito diferente a los anteriores.
    Aqui esta el archivo que modifique para que lo puedas ver.
    https://dl.dropbox.com/u/46736930/HardwareSerial.cpp
    Como siempre muchas gracias =)
    -Alonso

  360. avatar alonso martinez Dice:

    Es mejor darle clic derecho y "Save Target As" que seguir el link =)
    -Alonso

  361. avatar pabloxid Dice:

    Yo he movido los MX28 con Arduino 1.01 sin problemas. No obstante, la cantidad de variables en juego es tan grande que se hace difícil resolver este problema por este medio. Búscame en Skype y vemos qué se puede hacer.
     
    Saludos.

  362. avatar alonso martinez Dice:

    Ya te agregue!
    Saludos
    -Alonso

  363. avatar Daniel Dice:

    Hello Pablo,
    I'm sorry to bother after all the hard work that you have done. But I am new to Arduino and I don't know what to do.
    I have an Arduino UNO and I want to control two Dynamixel MX-28T motors using a Wii Nunchuck.
    I have the code to have the Wii Nunchuck move two normal servo motors with PMW output.
    But when I plugged in the Dynamixel motors, nothing happened.
    So I tried to update my library with the example you showed us, but my arduino environment version 1.0.1 doesn't have a HardwareSerial.cpp file.
    Also, I heard from some people that the Arduino UNO has only one TX and RX port and thus it's hard to control the Dynamixel motor with it.
    But that is all I have and I don't even know what TX and RX is. Please help me.
    Thank you so much.
    -Daniel

  364. avatar Daniel Dice:

    And as an update, I downloaded the previous version of the arduino environment, version 1.0, which does have a HardwareSerial.cpp. I udpated that file and the ax12.cpp file as according to http://arduino.cc/forum/index.php/topic,116011.0.html, but I keep getting the error that AX12 does not name a type. Please help soon.
    Thanks,
    Daniel

  365. avatar WesternCape Dice:

    You are an excessively skilled blogger. I’ve joined your feed and look ahead to in the hunt for more of your fantastic posts. Also, I have shared your web site in my social networks

  366. avatar pabloxid Dice:

    Los MX-28T requieren una pequeña modificación en el código, que ya tengo implementada.. En estos dias la voy a subir.

  367. avatar pabloxid Dice:

    MX-28T users should download this library version.

  368. avatar Ravi Dice:

    Hi Pablo
     
    I am very appreciative of the libraries you have provided and all of the intructions in the comments are very helpful. I'm using some RX-24f servos for my final year honours project (electronic engineering), and am having difficulties.
     
    I am struggling to get the Dynamixel rx-24f servos working with your library, and any help would be very useful.
     
    I'm using an arduino mega 2560, ax12_v2.3 library, Arduino 1.0.1 IDE and RS485 breakout from sparkfun. I have closely followed all the instructions I could find. I have correctly wired it all up (http://www.pablogindel.com/images/rx28.png) and have ensured there is plenty of power from a 12V, 3A desktop power supply. The grounds are all connected.
     

    I have tried running the example provided in the library, also initializing to 57142 baud rate, with no success. I can't even get a simple ping to work. Attached are some scope shots of the loop part of the example. Hopefully they are helpful.
       
    void loop() {
       
        motor.setVel (random (100, 300));
        motor.setPos (random (200, 800));
       
        delay (100);
       
        int pos = motor.ping();
        int vel = motor.getSpeed();
        int load = motor.getLoad();
        Serial.println (" ");
        Serial.print (" posicion: ");
        Serial.println (pos, DEC);
       Serial.print (" velocidad: ");
       Serial.println (vel, DEC);
        Serial.print (" carga: ");
       Serial.println (load, DEC);
           
        delay (1100);
     
    }

    Scope shot 1: http://imageshack.us/photo/my-images/42/undq.png/
    Scope shot 2: http://imageshack.us/photo/my-images/822/15uq.png/
     
    Thank you very much for any additional help you provide.
     
    Regards
    Ravi

  369. avatar andres Dice:

    Hola amigo tengo un problema con la libreria de AX12 como puedo utilizarla, tengo Windows 8, afecta n algo… 

  370. avatar pabloxid Dice:

    No creo que el windows 8 afecte… ¿Cuál es el problema?

  371. avatar andres Dice:

    Hola pabloxid, ya arregle mi problema pero tengo otro, creo q qme un ax12, como comprobaria su funcionamiento, o q podria pasar. gracias

  372. avatar pabloxid Dice:

    Si al conectarle la alimentación, el LED del motor se prende durante medio segundo y luego se apaga, significa que el motor está “vivo”.

RSS alimentación de los comentarios de esta entrada. TrackBack URL

Dejar un comentario