Arduino y Dynamixel AX-12

sábado, 22 de enero de 2011

Después de un largo tiempo he aquí una Biblioteca para controlar los actuadores Ax-12A de Dynamixel.
Estos Servos son bastante increíbles, parece que no les podría faltar nada, ya que pueden devolver Temperatura interna, Voltaje, Posición y Velocidad; Esto lo logra ya que tiene un microcontrolador ATmega8 el cual se comunica atravez de Half Duplex UART-TTL.

Estas bibliotecas sirven para comunicarse con los servomotores Dynamixel de varias formas en diferentes pines de las placas Arduino.

La comunicación se realiza a través del puerto Serie (UART o USART) del Arduino por lo que estos puertos utilizados se volverán exclusivos para comunicarse con el servomotor Dynamixel.

La alimentación de estos Servos es con una fuente de 9.6v y uniendo la tierra del arduino con la tierra de la fuente del Servo para que la comunicación no tenga errores de interpretación y la biblioteca pueda funcionar correctamente.La alimentación del Servo y del Arduino también puede ser de la misma fuente por lo que Vin del Arduino tendrá que tener un voltaje de 9.6v (Este es el voltaje sugerido por Robotis).


Las conexiones de alimentación del Servo con otras versiones y modelos de arduino funcionan de la misma forma.

Para utilizar estas bibliotecas se necesita un buffer tri-estado, se puede hacer con dos circuitos integrados 74HC04 y 74HC126 tal como recomienda Bioloid y utiliza en sus controladores o pueden usar un solo circuito integrado 74LS241 que yo recomiendo ya que es más sencillo de utilizar y/o conectar. Los pines de comunicación cambiaran según sea la Biblioteca que se quiera utilizar.



Circuito Savage Electronics - Dynamixel Serial:

Circuito Savage Electronics - Dynamixel Serial1:


Circuito Savage Electronics - Dynamixel Serial2:


Circuito Savage Electronics - Dynamixel Serial3:


Circuito Savage Electronics - Dynamixel SoftSerial:




Video Demostrativo:


382 Comentarios, Dejar un Comentario:

«El más antiguo   ‹Más antiguo   1 – 200 de 382   Más reciente›   El más reciente»
  • Ricardo Dias

    Hello!
    Very interesting.

    Could you post an example code for usage with this library?
    The constructor is not self-explaining about the arguments.

    Greetings from Portugal ;)
    Ricardo Dias

  • Savage

    Hi Ricardo, AX12 is the name of the object and its methods are: ping, move, movespeed, etc.
    so that all instructions start with AX12, for example:

    Ax12.ledStatus (1,ON); // This function sends USART data necessary to turn on the LED of servo with ID 1.


    #include "Dynamixel.h" // Include the Dynamixel Library

    void setup(){ // Configuration

    Ax12.begin(1000000,2); // Configure the usart at 1mbps
    // The digital pin 2 will make the switch from tx to rx
    }

    void loop(){

    Ax12.move(1,random(200,800)); // Move the servo with ID 1
    // to a random position between 200 and 800
    // Ax12.move(1,Position); Position from 0 to 1023 Resolution

    delay(1000);

    Ax12.moveSpeed(1,random(160,860),random(256,1023));// Move the servo with ID 1
    // at a random position and speed.
    // Ax12.move(1,Position,Speed); Position and Speed from 0 to 1023 Resolution
    delay(1000);
    }


    Hope that helps. :P

  • Ricardo Dias

    Hi Savage ;)

    Yes, that helped a lot :) you could include that as an example along with the source code.

    Greetings :)

  • Ericbot

    Hi, how could I modify your codes to use it for Arduino Mega with Atmega1280? Thank you.

  • Savage

    Hi Ericbot, I do not have an Arduino Mega, but I think you should add something like this to the h file :

    #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
    Serial_buffer rx_buffer1 = { { 0 }, 0, 0 };
    Serial_buffer rx_buffer2 = { { 0 }, 0, 0 };
    Serial_buffer rx_buffer3 = { { 0 }, 0, 0 };
    #endif

    #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

    ISR(USART_RX_vect)
    {
    rx_buffer.buffer[(_rx_buffer.head++)] = UDR0;
    }

    ISR(USART1_RX_vect)
    {
    rx_buffer.buffer1[(_rx_buffer.head++)] = UDR1;
    }

    Note:it is no code to copy and paste, I recommend you to based in the Hardware Serial Library.
    And modified the constructor:

    Ax12Class::Ax12Class(Serial_buffer *rx_buffer,volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
    volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
    volatile uint8_t *udr, uint8_t rxen, uint8_t txen,
    uint8_t rxcie, uint8_t udre)
    {
    _rx_buffer = rx_buffer;

    And the Preinstantiate Objects

    #if defined(__AVR_ATmega8__)
    Ax12Class Ax12(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE);
    #else
    Ax12Class Ax12(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0);
    #endif


    #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
    Ax12Class Ax12_1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1);
    Ax12Class Ax12_2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2);
    Ax12Class Ax12_3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3);
    #endif

    You can donate an Arduino Mega so that i can do the library with those micros XD.
    Good Look :P

  • Tomas Alvarez

    Muy interesante. Tengo algunas dudas espero me puedas contestar.

    1. Cómo lograste hacer que el UART llegue a 1mps, tenia entendido que por las librerias de Arduino esto no era posible?

    2. En cuanto al cableado del sn74:
    Los pines 19 y 1 se conectan entre si y esto va a un pin del arduino? A que pin?

    RX y TX se conectan a sus correspondientes en el arduino?

    La linea de data roja es la que va los dynamixels? Se tiene que poner el pull up de 10k?

    De antemano, gracias

  • Savage

    Hola Tomas, Respondiendo tus preguntas:

    1. La libreria Hardware Serial del arduino es muy lenta como para guardar todos los datos en el buffer a 1mbps, por lo que he simplificado la forma en que guarda en el buffer.

    2. Así es los dos están conectados entres si, al pin que tu quieras, lo defines con

    Ax12.begin(1000000,2) Velocidad 1MBps, Pin Digital 2, puedes poner cualquier pin: 3 , 4 , 5 ...
    Rx y Tx se conectan a sus correspondientes del Arduino. Rx con pin 0 (Rx) del arduino y Tx con pin 1 (Tx) del arduino.

    En cuanto al resistor es opcional funciona de cualquier forma, pero no esta demás ponerlo. :P

    Espero haberte ayudado, suerte. :P

  • Increíble tu trabajo!

    Estoy trabajando en un proyecto usando igual un arduino UNO y varios dynamixel AX-12+ queria saber si hay alguna manera para controlar los motores usando otros pines que no sean el 0 y 1 para dejarlo libre para el USB.

    Supongo que se puede lograr usando SoftwareSerial pero no se como podría modificar la biblioteca para usar un puerto por software en lugar del USART de hardware... alguna idea?

    Espero me puedas ayudar... y sigue asi Savage!!

  • Savage

    Hola Anderz Rush, No no se puede utilizar otros pines del arduino salvo que quieres trabajar con tus servos a una velocidad de 9600kbps y no la poderosa velocidad que ofrece el servo de 1Mbps.Pero por supuesto que puedes comunicarte con el PC con otros pines por medio de SoftWare, te recomiendo la Biblioteca NewSoftwareSerial, es tan sencillo como utilizar la Hardware Serial pero con la ventaja que puedes usar cualquier pin del arduino y bastaría con conectar un FTDI a esos pines para comunicarte con el PC.
    Ejemplo:

    #include "NewSoftSerial.h"

    NewSoftSerial SSerial(3,2);

    void setup(){
    SSerial.begin(9600);
    }

    void loop(){

    SSerial.print("Hola Mundo");

    delay(1000);
    }

    En este ejemplo SSerial es nuestro nuevo puerto USART por software conectado a los pines 3 y 2.
    Espero haberte ayudado. :P Saludos

  • Buenas tardes Savage , tengo una pequeña duda con tu liberia de dynamixel , estoy trabajando en un proyecto en el cual me es necesario usar estos servos Ax-12 y controlarlos con un potenciometro y me gustaria que me instruyeras un poco si es esto posible con la libreria que cordialmente compartiste. Al pareces necesito una función que me permita escribir los datos de la posición del potenciometro en el servo. Espero tu pronta respuesta y te agradezco por la libreria.

  • Savage

    Hola, ok es muy sencillo: Supongamos que queremos mover el Servo con ID 1 en la posición que un potenciometro le indique.
    Solo recuerda que estos motores tienen limites fijados, máximos y mínimos para moverse, aseguraste de que lo que le envíes no se pase de esos limites, por ejemplo yo tengo los limites alrededor de 160 a 860, y no los 0 a 1023 que deberían ser, de esa forma puse un map de 200 a 800. Espero te sirva el ejemplo. Saludos :P

    //**************************************************************

    #include "Dynamixel.h"

    int Pot = 0; // Potenciometro conectado al pin analogico 0

    void setup(){
    Ax12.begin(1000000,2); // 1mbps pin de control " 2 "
    }

    void loop(){
    int val = map(analogRead(Pot),0,1023,200,800); // Mapea Pot
    Ax12.move(1,val); // Mueve servo 1
    delay(50); // Espera 50 ms, puede ser lo que tu quieras. :P
    }

    //************************************************

  • Para poder controlar 2 servos con 2 potenciometros diferentes es necesario que el ID se modifique de tal manera que modifique de esta manera:

    #include "Dynamixel.h"

    int Pot = 0; // Potenciometro conectado al pin analogico 0
    int Pot2=1;
    void setup(){
    Ax12.begin(1000000,2); // 1mbps pin de control " 2 "
    }

    void loop(){
    int val = map(analogRead(Pot),0,1023,200,800); // Mapea Pot
    Ax12.move(1,val); // Mueve servo 1
    int val2= map(analogRead(Pot),0,1023,200,800);
    Ax12.move(2,val2);
    delay(50); // Espera 50 ms, puede ser lo que tu quieras. :P
    }

    De manera coherente creo que asi deberia funcionar con 2 potenciometros diferentes y estos dos servos, el problema es que una vez conectado no funciona y ninguno de estos se mueve, me gustaria que me pudieras aconsejar , probablemente este haciendo algo mal. De nuevo gracias y disculpa las molestias.

  • Savage

    Claro, tienes un pequeño error en tu código.
    int val2= map(analogRead(Pot),0,1023,200,800); // En esta linea estas diciendo que los dos motores se mueven con el mismo potenciometro por lo que deberías cambiar Pot a Pot2:

    int val2= map(analogRead(Pot2),0,1023,200,800);

    ¿Lograste hacer que se mueva solo un servo con el programa que escribí yo?, si no es asi hay que checar que el Baud Rate sea el correcto al igual que el ID del Motor.El ID de cada motor lo puedes cambiar con la instrucción :

    Ax12.setID(1,2); // Cambia el ID del Servo de 1 a 2, si no conoces el ID del motor hazlo como a continuación:
    Ax12.setID(254,2); // Cambia el ID del Servo conectado a 2.
    Al cambiar el ID recuerda que este conectado solo el servo que le quieres cambiar el ID, ya que con 254 le estas hablando a todos los servos conectados. Suerte. :P

  • Tomas Alvarez

    Hola que tal?
    Hace poco más de un mes te hice unas preguntas con respecto a la librería y el circutio. Ya finalmente logré hacer tiempo para jugar con tu librería. Compré unos SN74LS241, los conecté siguiendo cuidadosamente tu diagrama, cargué un sketch basado en un ejemplo que diste en los primeros posts, desconecté el usb del arduino y lo conecté al eliminador que viene con el bioloid (el que va al controlador cm-5), se encendió y apagó el led del dynamixel (entiendo que esto quiere decir que el motor está correctamente conectado) pero no sucede nada, el dynamixel no da senal de vida.

    Estoy usando un arduino uno con el ide ver22 para mac y la única modificación que le hice a tu programa de ejemplo es el id del motor.

    #include

    void setup(){ // Configuration

    Ax12.begin(1000000,4); // Configure the usart at 1mbps
    // The digital pin 2 will make the switch from tx to rx
    }

    void loop(){

    Ax12.move(9,random(200,800)); // Move the servo with ID 1
    // to a random position between 200 and 800
    // Ax12.move(1,Position); Position from 0 to 1023 Resolution

    delay(1000);

    Ax12.moveSpeed(9,random(160,860),random(256,1023));// Move the servo with ID 1
    // at a random position and speed.
    // Ax12.move(1,Position,Speed); Position and Speed from 0 to 1023 Resolution
    delay(1000);
    }

    El SN está funcionando correctamente y ya revisé que la línea de datos esté activa (usando un programa de terminal).

    No veo que estoy haciendo mal
    Además de instalar la librería normalmente hay que hacer algún otro cambio? No me meto con el hardware serial?
    El SN lleva alguna otra conexión que no esté indicada en el diagrama?
    Podrá ser que no me funcione la librería por la versión de firmware de mis dynamixels?

    Perdon por las molestias
    Un saludo
    Tomás

  • Savage

    Hola Tomas, ok veamos donde esta el problema, por el momento olvida el 74LS241, vas a conectar el pin Data del Servo al pin Tx del Arduino (El servo a su respectiva alimentación),No olvides unir las tierras del servo y de la que esta alimentado el arduino, ya que si no los pones así el servo no entendera lo que le mandas, ahora graba el siguiente programa en tu arduino y me dices si se mueve de lado a lado.

    #include "Dynamixel.h"

    void setup(){
    Ax12.begin(1000000,2);
    delay(1000);
    }

    void loop(){
    Ax12.move(1,800);
    delay(1000);
    Ax12.move(1,200);
    delay(1000);
    }

    Si observas que se mueve solo una cuantas veces es recomendable agregar una capacitor electrolitico en la fuente para evitar ruido. Suerte :P

  • Savage

    Ahh verifica que este correcto el ID de tu servo, me parece que tu lo tienes como 9, solo remplaza eso en el programa. :P

  • Tomas Alvarez

    Del tx del arduino directo al data del dynamixel, y un capcitor entre 12 y 0v de la fuente. Las tierras del arduino y del dynamixel están compartidas, no se movió :S

  • Savage

    Ok, entonces es el problema esta más atrás, ¿Estas seguro de que el ID que pones es el correcto?,¿La Velocidad ?, solo habría que checar eso, una forma de ver si es el ID el incorrecto es con el sig. programa:

    #include "Dynamixel.h"

    void setup(){
    Ax12.begin(1000000,2);
    delay(1000);
    }

    void loop(){
    Ax12.move(254,800);
    delay(1000);
    Ax12.move(254,200);
    delay(1000);
    }

    Con el 254 le hablas a todos los Servos conectados, si después de esto sigue sin moverse la velocidad es la que debe ser diferente. podrías comprobar las siguientes:
    9600,19200,57600,115200,200000,500000. entre otras como se puede ver en el PDF del servo.

  • Tomas Alvarez

    Si, en efecto es la velocidad, con el dynamixel wizard revisé los motores y el baud rate estaba configurado a otra velocidad. Muchisimas gracias por la ayuda en tiempo real, ya se esta moviendo mi servo. Felicitaciones por tu trabajo.

    De casualidad no tienes algo que ver con un maestro de robótica de la facultad de ingeniería de la UNAM que se apellida savage?

    Saludos

  • Savage

    Me alegra haber sido de ayuda y no lo lamento, Estudio en ESIME-IPN, ademas que no me apellido Savage, es tan solo un sobrenombre. Rara casualidad. :P

  • hola, que tal, la verdad es que soy nuevo en esto de la programacion, tengo una duda muy grande, y me gustaria que me ayudaras. mi AX-12 prende en color rojo, que significa esto y como lo puedo resolver

  • Savage

    Hola, eso significa que hay un error, si el led empieza a parpadear lo mas seguro es que lo estés alimentando mal. Este motor debes alimentarlo típicamente a 9v pero puedes conectarlo de 7v a 12v y funciona bien. Suerte. :P

  • Hi Savage, could u please show an example about how to change dynamixel´s ID? I mean the hole code.... ´couse am a dummy with this kind of things... kidding, am usually good at it but... thanks for it!

  • Savage

    Hi, dont worry, it's pretty simple. :P

    //////////////////////////////////////////////////

    #include "Dynamixel.h"

    void setup(){
    Ax12.begin(1000000,2);
    pinMode(13,OUTPUT);
    }

    void loop(){
    Ax12.setID(1,2); // Changing the ID from 1 to 2.
    digitalWrite(13,HIGH);
    }
    //////////////////////////////////////////////////

    If you don't Know what's the Dynamixel ID use ( 254 )
    Ax12.setID(254,2); // Changing the ID to 2. When the LED (13) turns ON the ID has now been changed. Good Luck. :P

  • Hola, Estoy intentando comunicar dos servos pero empiezan a funcionar cuando desconecto el esclavo y empieza a girar el maestro; después ya conecto el esclavo y ya funciona y sigue al maestro que es lo que busco. Pero como debo hacerle para no estarlo desconectando? Es un problema con las ID? En todo caso, como puedo mandar una acción a ambos servos para que lo realicen al mismo tiempo. Sólo he visto que con 254 le llamas a todos los servos conectados.

    Saludos

  • Savage

    Hola, espero haber entendido bien, lo que quieres hacer es que un servo llamado esclavo haga justo lo que hace un servo llamado maestro. no debería haber ningún problema solicitando a uno la posición y diciendole al otro que se mueve a esa posición. Se me ocurre que puedes hacer eso con la siguiente linea:

    Ax12.move(2,Ax12.readPosition(1)); //Siendo ID 1 el Maestro e ID 2 el Esclavo.

    Si se puede establecer comunicación con todos los servos con el ID 254 solo que no regresa respuesta, por ejemplo si quieres la temperatura de servo no podrás utilizar el ID 254 ya que no te responderá nada, hay una función llamada SyncWrite que sirve para hablarale a diferentes servos y decirles que hagan diferentes cosas solo que desafortunadamente aun no he agregado esa función en la biblioteca. Suerte, espero haberte ayudado.

  • Hello, I am currently having trouble with the Arduino Duemilanove (ATMEGA328). The Arduino is connected to a servo motor (Dynamixel AX-12+) and I'm trying to communicate between the servo motor and pc via the USB port. However, there is a conflict between the libraries causing error compiling. I'm using Arduino-0022 compiler.

    The error is as follows:
    core.a(HardwareSerial.cpp.o): In function `__vector_18':
    C:\arduino-0022\hardware\arduino\cores\arduino/HardwareSerial.cpp:81: multiple definition of `__vector_18'
    Dynamixel\Dynamixel.cpp.o:C:\arduino-0022\libraries\Dynamixel/Dynamixel.cpp:45: first defined here

    Thanks in advance,
    Veerachart

  • Savage

    Hi, Ok Note that you can't use the Dynamixel Library and the HardwareSerial Library at the same sketch, cause the Dynamixel.h already use the Serial port. If you use the Ax12.begin(); you can not use the Serial.begin(); cause is the same Serial port, but if you want to comunicate with computer you can use the NewSoftSerial with the digital pins of the arduino and a FTDI Chip. :P

    Hope that helps.

  • Thanks for your answer.
    I've find out more about the FTDI chip. That's a good way to deal with this. But I would like to find the way to solve this by software.

    Is it possible to make Dynamixel.h communicate with the motor through other pins by using NewSoftSerial? (As I understand, NewSoftSerial makes other pins work as Rx and Tx pins.) If yes, where should we modify the library? I don't have knowledge in C++, but I can do C and some JAVA.

    Veerachart

  • Savage

    Hi, yes you can modify the Dynamixel.h to use NewSoftSerial but the NewSoftSerial works with 115200bps Max and the Servo works at 1Mbps, you can slow down the servo speed to 115200bps but it has an error of 2.124% of the USART comunication. To modify the library replace every usart_write, usart_read, usart_peek and usart_available for the NewSoftSerial Objet and method. Example:

    NewSoftSerial NewSerial(4,3);

    usart_write to NewSerial.write, usart_read to NewSerial.read
    And delete this in the Dynamixel.h:

    Ax12Class constructor and de usart_write(); usart_read(); …. methods.

    If you want i can modify the library for that configurations and i will uploded rigth away. (one or two days).

  • I tried replacing every usart_write, usart_read, usart_peek and usart_available for the NewSoftSerial Object and method, but I found out that NewSoftSerial has no "peek" method.

    Besides, "write" method is private method.
    And from this URL : http://arduiniana.org/libraries/NewSoftSerial/

    Any time you “use” an object by calling its begin(), available(), read(), or print[ln]() methods, it becomes the “active” object, and the previously active object is deactivated and its RX buffer discarded. An important point here is that object.available() always returns 0 unless object is already active. This means that you can’t write code like this:
    void loop()
    {
    if (device1.available() > 0)
    {
    int c = device1.read();
    ...
    }
    if (device2.available() > 0)
    {
    int c = device2.read();
    ...
    }
    }
    This code will never do anything but activate one device after the other.
    When I replaced usart_read() by NewSerial.read(), the code looks like the above.

    Can you help me modify the library, please? I still don't understand about the addresses and variables used in the library.
    Thank you very much.
    Veerachart

  • In addition, I use "NewSoftSerial" Version 10c

  • Savage

    Yes, your right but there is the beta version of NewSoftSerial that comes with peek an write methods, both publics, i'll upload the library with that modifications as soon as i can. :P

  • Savage

    Hi, this is the Library with the NewsoftSerial Modifications:

    http://www.megaupload.com/?d=GI5N1EL2

    I have tested and it seems to work fine, so this a little example code:

    #include "Dynamixel_V2.h"
    #include "SoftwareSerial.h"
    // Servo conected to pin d2 and d3 - SoftwareSerial

    void setup(){
    Ax12.begin(9600,5); //Servo speed and Control pin
    Serial.begin(115200); // Serial speed for PC
    delay(1000);
    }

    void loop(){
    Ax12.move(1,random(200,800)); // Ax12 move.
    Serial.println("Sending Data to PC and making the servo moves");
    delay(1000);
    }

    Hope that helps. :P

  • Thank you for the code and modification.

    Our earlier code that didn't use the SoftwareSerial, we used Ax12.begin(1000000,2); and the servo moves. However, as we used your code here, the output "Sending Data to PC and making the servo moves" is printed out, however the servo doesn't actually move. Could this be due to a possibilty that the speed isn't high enough for the servo to turn? and if so, what did you implement further to create such a movement at a lower speed?

  • Savage

    Yes in the previous code it was 1Mbps (1000000 bps), but SoftwareSerial only accepts baud rates lower than 115200, so you should modify the servo speed as i do change to 9600bps and just then the servo will move with SoftwareSerial Library. You can change the baud rate of the servo with the previous library with this lines:

    #include "Dynamixel.h"

    void setup(){
    pinMode(13,OUTPUT);
    Ax12.begin(1000000,2);
    Ax12.setBD(1,207);
    }

    void loop(){
    digitalWrite(13,ON); // When the led turn on the servo is already to 9600bps
    }

    So now you can work with the Dynamixel_V2 library.
    Good luck. :P

  • Thank you for your answer. ^^

    by the way, I still have not tried it yet, I can try it on 6th Friday.
    I will let u know the result at that time. :D

  • andres

    tu publicación me ha sido de demasiada utilidad me gustaría pedirte el favor a ti o a alguien que lea este comentario si me podría ayudar a controlar el servo desde un arduino mega at2560 desde el puerto seria 2. Como información el arduino atmega2560 tiene diferentes puertos serial tiene 4 en si para ser mas exacto. asi q si alguien me puede ayudar a controlar el servo desde el arduino atmega2560 desde el puerto serial 2. muchas gracias.

  • Savage

    Hola Andres, desafortunadamente no cuento con un Arduino Mega pero voy a intentar hacer las modificaciones necesarias esperando que funcione. Aun no se cuanto tiempo me tarde en publicar la libreria que sugieres pero en cuanto la tenga la subo. Saludos.

  • andres

    muchas gracias savage cualquier colaboracion que me puedas dar te la agradecere.saludos.

  • Hi Savage,
    great work with the library but i hit a problem. I changed the baud rate with the folowing code as you sugested so i could use it with the new v2 library but my motor then became unresponsive.

    #include "Dynamixel.h"

    void setup(){
    pinMode(13,OUTPUT);
    Ax12.begin(1000000,0);
    Ax12.setBD(1,207);
    }

    What does the 207 in setBD stand for? Shouldn't it be 9600? How can I turn it back to 1000000?

  • Savage

    Hi, yes 207 is 9600bps according with AX-12 Manual you can turn it back with the Dynamixel Configurator, just short the rx and tx of the arduino and connect to the Servo also share the grounds from the arduino and the servo source power.

    I recommend to use different pin for data flow control:

    Ax12.begin(1000000,2); // do not use pin 0 and 1.

  • Savage

    Hola Andres he tenido problemas para leer la información que regresa el servo, pero ya he hecho una version que funciona con cualquier puerto serial, en tu caso esta lista para usar el Serial2, intentare resolver el problema de la lectura lo mas pronto posible.

    Biblioteca Dynamixel V3 Serial2.

    http://www.megaupload.com/?d=2XBN8HT0

  • Is there any way to turn the baud rate back to 1000000 without the Dynamixel Configurator(you ment the USB2Dynamixel?)? I'd prefer if I didn't have to buy the Configurator. I have tryed everything. I connected everything as you said and it still doesn't work. When I plug the power to the servo the LED briefly lights up and that is it. I even tryed
    int Error = Ax12.setBD(1,1) and int Error = Ax12.setBD(1,207)
    but I keep geting -1.

    Any ideas?

  • Savage

    Yo dont have to buy anything, Arduino works like the USB2Dynamixel yo just have to download the Dynamixel Configurator.exe and then try to find the baud rate and returned to 1Mbps. If you have troubles with that i will try to make a program to reset the servo. Good Luck.

  • Me again. :-)
    Sorry for being a pain but do you know where I can download the Dynamixel Configurator? I can't find it on Robotis site or any other for that matter.

  • Savage

    Dynamixel Configurator:

    http://www.besttechnology.co.jp/download/DXCONFINST1.7.4.0.exe

  • You are superfast!!!!

    Thanks!

  • Tryed the code but it doesn't work. I found some forum thread
    http://forum.crustcrawler.com/phpBB3/viewtopic.php?f=12&t=1263
    http://www.robotis.com/xe/qna_en/21779
    http://robosavvy.com/forum/viewtopic.php?t=3719&sid=8662c017d2038e743ef53d9bb67cc20c

    telking about how to hard reset the servo but I can't seem to conect properly with the arduino. The thing is I have to start a Serial connection at a speed of 57600 and start sending a # character and then plug in the power to the motor. In the first 200ms of powering up, the servo can enter something like a BIOS mode where it can be reset. Could you maybe write up some code that can do that? :-)

  • Savage

    Ok, i will probe that method with one of my servos, but i think you should try again with the last program, download again the Dynamixel Library, Replace it, Check your power source for the motor, it should be around 10v and then conect the motor to tx of the arduino and share the grounds.

  • Savage

    #include "Dynamixel.h"

    long BaudRates[] = {1000000,666667,500000,400000,333333,285714,250000,222222,
    200000,181818,166667,153846,142857,133333,125000,117647,111111,105263,100000,
    95238,90909,86957,83333,80000,76923,74074,71429,68966,66667,64516,62500,60606,
    58824,57143,55556,54054,52632,51282,50000,48780,47619,46512,45455,44444,43478,
    42553,41667,40816,40000,39216,38462,37736,37037,36364,35714,35088,34483,33898,
    33333,32787,32258,31746,31250,30769,30303,29851,29412,28986,28571,28169,27778,
    27397,27027,26667,26316,25974,25641,25316,25000,24691,24390,24096,23810,23529,
    23256,22989,22727,22472,22222,21978,21739,21505,21277,21053,20833,20619,20408,
    20202,20000,19802,19608,19417,19231,19048,18868,18692,18519,18349,18182,18018,
    17857,17699,17544,17391,17241,17094,16949,16807,16667,16529,16393,16260,16129,
    16000,15873,15748,15625,15504,15385,15267,15152,15038,14925,14815,14706,14599,
    14493,14388,14286,14184,14085,13986,13889,13793,13699,13605,13514,13423,13333,
    13245,13158,13072,12987,12903,12821,12739,12658,12579,12500,12422,12346,12270,
    12195,12121,12048,11976,11905,11834,11765,11696,11628,11561,11494,11429,11364,
    11299,11236,11173,11111,11050,10989,10929,10870,10811,10753,10695,10638,10582,
    10526,10471,10417,10363,10309,10256,10204,10152,10101,10050,10000,9950,9901,
    9852,9804,9756,9709,9662,9615,9569,9524,9479,9434,9390,9346,9302,9259,9217,
    9174,9132,9091,9050,9009,8969,8929,8889,8850,8811,8772,8734,8696,8658,8621,
    8584,8547,8511,8475,8439,8403,8368,8333,8299,8264,8230,8197,8163,8130,8097,
    8065,8032,8000,7968,7937,7905,7874,7843};


    void setup(){
    pinMode(13,OUTPUT);

    for(int j = 0; j <= 253;j++){
    for ( int i = 0; i <= 254;i++ ){
    Ax12.begin(BaudRates[i],2); // inicializa la comunicacion.
    Ax12.setID(j,1); // Cambia el ID a 1
    Ax12.setBD(1,1); // Cambia el Baud a 1000000 ( 1Mbps )
    }
    }

    Ax12.begin(1000000,2); // Comprobacion.
    }

    void loop(){

    digitalWrite(13,ON);
    Ax12.move(1,random(200,800));
    delay(1000);
    }



    // It can take up to 34 min, be patient. It will work. :P

  • Hey,
    I tryed the code and no luck. :-(

  • Savage

    Thats weird, I've already tried the HardReset but no results. the links you gave says that it will take time and several attempts. I use the code for the HardReset:

    void setup(){
    Serial.begin(57600);
    pinMode(7,OUTPUT);
    }

    void loop(){

    Serial.print('#');
    digitalWrite(7,LOW);
    Serial.print('#');
    Serial.print('#');
    Serial.print('#');

    delay(100000);
    digitalWrite(7,HIGH);

    }

    The ground of the servo is connected to the pin 7 of the arduino, thats going to turn on and off the motor as required.

  • Still no luck. Seems that I'll have to buy the USB2Dynamixel. :(
    This will teatch me to read before I do something. Ah well, thanks anyway.

  • Savage

    You don't have to buy it, the arduino can totally replace it, the arduino interface is almost the same of the USB2Dynamixel, maybe you are not connecting thing right, let me do a tutorial and then if the problem don't get solved then you can buy the USB2Dynamixel.

  • Hello it's me again. I tryed again with your code and reworked it a little bit. Also I added a transistor to switch the motor on and off. I'm using a Arduino Mega so I have Serial1 TX for the outgoing messages and Serial2 RX for receiveing the messages. I'm using this setup becase the code stalled if I had boath read/write on Serial1.
    Here is the code:


    void setup(){
    Serial1.begin(57600);
    Serial2.begin(57600);
    Serial.begin(57600);
    pinMode(7,OUTPUT);
    pinMode(13,OUTPUT);
    }
    char incomingByte = 0;
    int inCount = 0;
    char inString[100];
    void loop(){

    Serial1.print('#');
    digitalWrite(7,HIGH);
    digitalWrite(13,HIGH);
    for(int i=0;i<25;i++){
    Serial.print('#');
    Serial1.print('#');
    }
    inCount = 0;
    delay(200);
    while (Serial2.available()>0) {
    // read the incoming byte:
    inString[inCount] = Serial2.read();
    inCount++;
    if(inCount>99){
    break;
    }
    }
    // say what you got:
    Serial.println();
    Serial.print("I received: ");
    Serial.println(inString);
    //Serial2.flush();
    delay(2000);
    digitalWrite(7,LOW);
    digitalWrite(13,LOW);
    delay(1000);
    }

    This is what I get in the terminal wondow:
    #########################
    I received: #¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ä


    Any ideas? I'm kind of weary to use a functioning motor to test the code because I don't want to risk blocking it too. Also I forgot to mention before that I'm not using a SN54/74LS241 with the arduino. Could this be the problem?

  • Savage

    If you use a transistor in pin 7 to the servo thats not necessary cause we are sending ground. Maybe the SN54/74LS241 will help to understand the received data but i don't think thats a problem. Do you have an Avrisp, Avr Dragon or so, you may copy the program of a functional servo and burned in the unresponsive one.

  • Ok. I found out that Arduino can work as an ISP programer (http://www.arduino.cc/playground/Code/MegaISP) . How do I connect it to the servo?

  • Savage

    Ok, but the arduinos with optiboot can't work as an ISP ( Check the version of your arduino ).
    Inside the servo there's a micro controller ATmega8 copy the hex file of that micro and burned on the unresponsive one.
    There's a photo of the servo micro:
    http://www.bioloid.info/tiki/tiki-index.php?page=AX-12+page

  • Savage

    This is the solution, Good Luck. :P

    http://savageelectronics.blogspot.com/2011/07/reparar-servo-dynamixel-ax-12.html

  • HOLA, muy interesante en verdad este aporte, oye, no se si seria mucho pedir pero podrias publicar como esta realizada la conexión con el arduino y los servos, eso me seria de gran utilidad, y perdon por las molestias aun soy principiante,
    saludos

  • Savage

    Hola, Claro enseguida las subo.
    ----------------------Modificación--------------
    Ya esta vuelve a checar el post. :P

  • wow muchas gracias por tan pronta repuesta! :) me sirvio d mucho

  • sólo una ultima pregunta más, y perdón por ser ignorante, a que te refieres con habilitar los pines 1 y 19 del 74ls241?

  • Savage

    Esos dos pines son lo que controlan el flujo de datos, ya sea que se este enviando datos o recibiendo datos. Con la función Ax12.begin(Baud_Rate, Flow_Control); el baud rate es la velocidad del serial y el Flow Control es el numero de pin del arduino que va a ir conectado a esos dos pines del 74LS241.
    Ejemplo:

    Ax12.begin(1000000,2); Conectar el pin 2 del arduino al pin 1 y 19 del 74LS241.

    De esa forma la Biblioteca se encargara del correcto envío de datos. :P Suerte.

  • OOO gracias ya me quedo claro :9
    muchas gracias hermano por el aporte y por tu pasiencia conmigo ahah saludos y mucha suerte a ti también ojalá y sigas pubicando más proyectos con arduinos y dinamixel servos. Cuidate

  • Savage

    Gracias, pronto publicare una actualización de la librería que permitirá la rotación continua de los servos, entre otras cosas.

  • hola como estas, muy buen video, disculpa la molestia, estoy haciendo un programa para que el arduino pueda leer un acelerometro adxl3xx y enviar esa lectura al cm5 del bioloid, sin embargo no se como hacer esto, me podrias orientar ? te lo agradeceria mucho

  • Savage

    Hola, desafortunadamente no tengo un CM-5 pero tengo una vaga idea de como funciona, al parecer el CM-5 no cuenta con entrada para sensores, salvo el AX-S1. La mejor forma de conectarle un sensor como el acelerómetro que comentas es simulando que le estas hablando a un AX-S1, Esto se logra programando el arduino que funcione con el mismo protocolo que el AX-12 y el AX-S1, Programa el arduino para que solo le haga caso a cadenas como estas: 0xFF-0xFF-0x1A-0x04-0x02-0x24-0x02-0x-B9, esa cadena le pregunta a un servo de ID 26 (0x1A) cual es su posición solo que para tu propósito no será un servo será el arduino con el acelerómetro y harás que el arduino responda así:
    0xFF-0xFF-0x1A-0x04-0x00-(1er Byte)-(2do Byte)-Checksum. como ves tienes dos bytes para responder y enviar la información al CM-5 y ya de ahí programar el CM-5:
    IF - Dynamixel -........Then...... Suerte, si necesitas más información no dudes en preguntar. :p

  • Muchas gracias savage, iré aplicando tu idea, y te avisaré como voy progresando.
    Saludos

  • hola, yo otra vez,
    oye como puedo lograr que el arduino trabaje con el mismo protocolo que el CM 5?

  • Savage

    Hola, la comunicación con el CM5 es Serial por lo que deberás utilizar la Biblioteca HardwareSerial del arduino, el manual del servo describe con más detalle esta comunicación pero intentare resumirlo un poco:

    Los primero dos bytes se llama de Inicio ( Start ): 0xFF 0xFF - toda comunicación empieza con esos dos. El siguiente Byte es el ID del dispositivo, en este caso el Arduino. el siguiente es el numero de bytes que vas a enviar: 0x04, el siguiente es el error: 0x00, los dos siguientes es la información que deseas sea transmitida (Datos acelerometro ) : 0x(1er Byte) 0x(2do Byte) y el ultimo es el checksum que es la suma del ID + LONGITUD + ERROR + DATOS. 0x(Checksum).
    // en setup()
    Serial.begin(Baud_Rate); // Velocidad del Serial, 9600, 115200, 200000 ...
    // en loop()
    Serial.write(0xFF);
    Serial.write(0xFF);
    Serial.write(ID);
    Serial.write(0x04);
    Serial.write(Dato1);
    Serial.write(Dato2);
    Serial.write(Checksum);

    Si gustas puedo hacer una pequeña publicación con un ejemplo de esto. :p

  • si tienes razón, cuando me dijiste acerca del protocolo me imagine te referias a esa linea de datos, porque cuando empeze a trabajar con el cm5 fue una de las cosas que más me llamaron la atención pero no sabia como implementarlos en arduino :s
    , y si me gustaria ver un esa publicacion espero no sea mucho problema, muchas gracias por tu tiempo y tu amabilidad Savage
    Carlos

  • a otra duda, al usar la biblioteca dinamixel.h ya no se puede usar la biblioteca software serial? esq queria poder observar en el puerto com los datos obtenidos de temperatura y posicion del servo

  • es hardware serial, perdon :9

  • Savage

    No, no funciona el HardwareSerial, pero pronto publicare la versión que no dependa de HardwareSerial. Saludos :P

  • lo esperare asioso, saludos

  • Hola amigo, diras que como molesto, pero aun espero el ejemplo de la comunicación del CM5, espero no sonar grosero, sólo quiero ese tip, saludos

  • Savage

    Hola, espero poderlo subir entre hoy y mañana, es que es un proyecto un tanto laborioso. :D

  • :) MUCHAS GRACIAS, EN VERDAD EJEJ

  • Ben Loftin

    Thank you for the lib. I am trying to port it to the Mega (ADK) board, and downloaded the Serial2 version. It appears to work great for sending data to AX-12, but anytime I try to receive, like pink I get error = -1. Any tips? Thanks you.

    Ben

  • Ben Loftin

    Interestingly enough if I hard wire the enable for the receive I see what looks like a reasonable signal so maybe I am having problems with the digital control pin

  • Savage

    Hi, Ben, The -1 means that the arduino didn’t get any response from de servo, de control pins is to decide if the arduino is going to send data or received, if you want to read the incoming data(servo to arduino) you will have to use the 74ls241 and the control pin begin, and the baud rate of the servo an arduino will have to be less the 200000. Good luck. :D Cheers

  • Ben Loftin

    Awesome, thanks for the quick reply. Instead of the 74s241 chip I had the HC126 and HC04 hooked up. I was trying to do the 1Mbs baud rate, I 'll try a slower baud rate next. The end goal is to hook up the Arduino ADK board to the AX-12s so we can control our walking MechWarrior with an Android cell phone. We have had no luck hooking up the pyPose either, but we can wire up an Atmega 644 and talk over i2c or something, just trying to consolidate to just the adk board.

    What's with the speed limit? Is it the way they implement the buffer in the HardwareSerial.cpp? I see the Arbotix board tried it in their implementation of AX-12 library here

    http://code.google.com/p/arbotix/wiki/PyPose

    Thanks again

  • Savage

    The HC126 & HC04 are just fine.The speed limit its for the Hardware Serial, you will have to modified the HarwareSerial.cpp and HardwareSerial.h just like i do in the first version of the Dynamixel Library, and the PyPose its very easy to do check this, that maybe help you someway.

    http://savageelectronics.blogspot.com/2011/03/arduino-y-las-memorias-eeprom-i2c.html

    I pretend to do that the libraries work at 1Mbps but it will take me a while ( couple of weeks ). Nice project by the way.

  • Ben Loftin

    Well I got it working with your original version of the library that uses the interrupt. Go figure, it was the circuit. The signal was a little noisy on the scope, so I put some capacitors on VCC of the HC126 & HC04 chips and a 10uf electrolytic cap across the motor power. Now on to pyPose, which will probably work now... Thanks for all the help, the code change I made for the Arduino ADK can be found here,

    http://code.google.com/p/rbots/source/browse/trunk/AdruinoADK/Dynamixel/Dynamixel.cpp

    Cheers.

  • Savage

    Nice work, good luck with your robot. Cheers :p

  • There its a way to make this work with an RX-64?

  • Savage

    Yes, i think that it can be done with a RS-485.

  • Hola, quiero simplemente mover un AX12, ya descargue la libreria y la pase a la carpeta de arduino, pero cuando compilo, me arroja este error:

    56: error: Dynamixel.h: No such file or directory In function 'void setup()':
    In function 'void loop()':

    No entiendo que estoy haciendo mal... Gracias

  • Savage

    Hola Joseph, Podrias pasarme tu codigo para ver el por que de ese error? que arduino estas utilizando y que bibkioteca bajaste? :-) Saludos

  • Hola savage, ya solucione el problema y era tan tonto que hasta me da pena decir que era... Ahora tengo una duda, cuando voy a conectar un motor o varios no necesito acople de potencia? Gracias.

  • Savage

    Te refieres a la energia requerida para que los motores tengan suficiente voltaje para operar bien? O podrias explicarme un poco mas a que te refieres con acople de potencia.

  • Osea cuando conecto los motores al arduino, toda la corriente pasaria atraves del arduino y podria ser muy alta y dañarlo, porque son varios motores al tiempo, es necesaria hacer algo adicional para mover varios motores. No se daña el arduino, lo pregunto es porque cuando uno trabaja con los PIC como el PIC18F4550, se debe separar la potencia con optoacoples...
    Y la segunda cosita es que ya me estan andando 1 motor, pero el problema ahora es que maximo en la resolucion le puedo poner 200, porque si lo pongo mas alto, ya no gira y no entiendo poruqe, aqui te pongo el codigo, que es basicamente el mismo del ejemplo:

    #include "Dynamixel.h" // Include the Dynamixel Library

    void setup(){ // Configuration

    Ax12.begin(1000000,2); // Configure the usart at 1mbps
    // The digital pin 2 will make the switch from tx to rx
    }

    void loop(){

    Ax12.moveSpeed(6,1000,200);// Move the servo with ID 1
    // at a random position and speed.
    // Ax12.move(1,Position,Speed); Position and Speed from 0 to 1023 Resolution
    delay(5000);

    Ax12.moveSpeed(6,0,200);// Move the servo with ID 1
    // at a random position and speed.
    // Ax12.move(1,Position,Speed); Position and Speed from 0 to 1023 Resolution
    delay(5000);
    }

  • Savage

    Ok, contestando tu primer pregunta, no no necesitas ningun optoacoplador ya que la comunicacion es usart y se realiza entre el arduino y un atmega8 que contienen los ax12 por lo que jamas regresara corrientes no deseadas y con respecto a tu segunda pregunta te recomiendo revisar los limites de velocidad de tu servo con ayuda del manual o bien puedes usar la funcion reset para restaurar los valores de fabrica. :-)

  • Oye tengo una duda no tanto respecto al controlador puesto que la comunicacion la he hecho con las librerias de labview y eso es muy facil el problema es que mi aplicacion necesita que los cables de comunicacion entre 3 ax-12 sean aprox de 80 cm no se si sea una limitante la distancia puesto que se pierde la comunicacion veo que tu para conectar del arduino al primer ax12 usaste cable o alambre?? o donde compras lo conectores que van dentro porque no los encuentro en ningun lado seria de gran ayuda saber eso.

    de ante mano gracias

  • Savage

    Limitantes si si hay después de cierta distancia se pierde o se atenúa la señal lo cual seria sencillo resolver con buffer cada cierta distancia, en cuanto a los conectores me encuentro en la misma situación no los encuentro en ninguna parte que no sea Trossen Robotics o directamente con Robotis, los que yo tengo los he sacado de dos impresoras HP al parecer todas las impresoras de esta marca los utilizan, puedes hallar dos de esos conectores por impresora, quizá puedas ir adonde vendan partes o desechos de impresoras. Suerte, saludos. :D

  • hello ...
    iwant to read position of ax-12, but the position not read,

    this is my program
    //////////////////////////////////////////////////////////

    #include "Dynamixel_Serial.h"
    #include

    NewSoftSerial mySerial(3, 4);

    #define ID 6
    int a;
    void setup () {

    mySerial.begin(9600);
    Ax12.begin(1000000,2);
    Ax12.ping(6);

    mySerial.println("tes");

    }

    void loop ()
    {
    a = Ax12.readPosition(6);
    mySerial.println(a);
    delay(100);

    }
    /////////////////////////////////////////////////

    can you give me example code to read position well..

    thank you..

  • Savage

    Your code its right maybe the error is in the connections of the Dynamixel and the IC 74LS241, I strongly recommend you to check that cause your code is fine it should work. Check the Diagram of the IC above.

  • I've checked the circuit uses two microcontrollers that are both mutually provide data, and the circuit is working properly,

    and then I tried it with dynamixel but from dynamixel not provide data,
    and also had to replace with a new dynamixel, but the result is the same dynamixel not provide data.

    Can you give me a solution, thank you...

    my name Rinaldi

  • whether there may be problems in this program

    ///////////////////////////////////////////

    int Ax12Class::readPosition(unsigned char ID)
    {
    TChecksum = (ID + AX_POS_LENGTH + AX_READ_DATA + AX_PRESENT_POSITION_L + AX_BYTE_READ_POS);
    while ( TChecksum >= 255){
    TChecksum -= 255;
    }
    Checksum = 255 - TChecksum;

    digitalWrite(Direction_Pin,HIGH);
    Serial.write(AX_START);
    Serial.write(AX_START);
    Serial.write(ID);
    Serial.write(AX_POS_LENGTH);
    Serial.write(AX_READ_DATA);
    Serial.write(AX_PRESENT_POSITION_L);
    Serial.write(AX_BYTE_READ_POS);
    Serial.write(Checksum);
    delayMicroseconds(TX_DELAY_TIME);
    digitalWrite(Direction_Pin,LOW); // Set Rx Mode

    Position_Long_Byte = 0;
    Time_Counter = 0;
    while(Serial.available() < 7 & Time_Counter < TIME_OUT){
    Time_Counter++;
    delay(1);
    if( Serial.peek() != 255 ){
    Serial.read();
    }
    }

    while (Serial.available() > 0){
    Incoming_Byte = Serial.read();
    if ( Incoming_Byte == 255 & Serial.peek() == 255 ){
    Serial.read();
    Serial.read();
    Serial.read();
    if( (Error_Byte = Serial.read()) != 0 )
    return (Error_Byte*(-1));

    Position_Low_Byte = Serial.read();
    Position_High_Byte = Serial.read();
    Position_Long_Byte = Position_High_Byte << 8;
    Position_Long_Byte = Position_Long_Byte + Position_Low_Byte;
    }
    }
    return (Position_Long_Byte); // Returns the read position
    }
    //////////////////////////////////////

    this is program from your library......
    thank you

  • Savage

    Ok, I’ll check my code again and tested out. Could you tell what arduino are you using and de Version of the IDE and what circuit uses Two Microcontrollers? I will try to solve the problem around 5:00 PM Mexico’s Time and give a solution. Cheers. :D

  • Savage

    Hi, i have already check and tested the library and its working fine. Whats the return status of your servo. whats is the servo responding to the readPosition instruction ? -1 or random information. The readVoltage and readTemperature functions works?

  • I am using Arduino microcontroller Duemilanove,
    I am using Arduino microcontroller Duemilanove,
    I use the circuit sn74ls241,

    if using under this program
    ////////////////////////////////////
    #include "Dynamixel_Serial.h"
    #include

    NewSoftSerial mySerial(3, 4);

    int b;

    void setup ()
    {
    mySerial.begin(9600);
    Ax12.begin(1000000,2);
    mySerial.println("tes");
    }

    void loop ()
    {
    b = Ax12.readPosition(5);
    mySerial.println(b);
    delay(100);
    }

    ////////////////////////////////////////

    if using the above program " b = Ax12.readPosition (6)" ;
    I use to display additional serial servo position that reads,
    b result is always "0" in the show in the serial monitor never changed even though the servo in the movements,,
    if I disconnect the servo from the voltage source and then I plug it back then the value of b = -255 in the show in the serial monitor and then the value of b = 0 again,

    if I make this program
    //////////////////////////////
    void loop ()
    {
    b = Ax12.readPosition(5);
    mySerial.println(Serial.read());
    delay(100);
    }
    //////////////////////////////

    then the value that comes out is -1, in the serial monitor.

    Can you give an example program reads the correct servo position to me,,
    thank you ..

  • this is my email : agile_katze@yahoo.com

  • Savage

    Ok, i find the problem, its in the Serial.println(); instruction, i not doing a proper cast thats why you always get the 0 (ZERO) value in b. try this code:


    #include "Dynamixel_Serial.h"

    void setup () {
    pinMode(13,OUTPUT);

    Ax12.begin(1000000,2);
    Ax12.ping(1);


    }

    int b = 0;
    char Str1[5];
    void loop ()
    {
    Ax12.move(1,random(200,800));
    if ((b = Ax12.readPosition(1)) == 800)
    digitalWrite(13,ON);
    else
    digitalWrite(13,OFF);
    itoa(b,Str1,10);
    delay(1000);
    Serial.end();
    Serial.begin(9600);
    Serial.print(Str1);
    delay(100);
    Serial.end();
    Serial.begin(1000000);
    delay(100);
    }

    you will only need one arduino connected by usb to the computer and opening the terminal.
    this program do the cast from an int to a string with the function iota(); - > int to ascii. so i have that solve your problem. b gets the value readPosition but Serial.print or in your case mySerial.print(); its not doing the proper cast of b. good luck. :D

  • Savage

    Thanks, i will check my code for an error and uploaded a new version with the fixes. Mean while thats and temporal fix to see on the terminal of the arduino.

  • hello savage,,
    I've tried these programs and the results servo only moves and LED pin 13 is never lit, and display on the serial monitor in the form of a character that is not good,

    and I change the progrm is as below:

    ///////////////////////////////////////////////

    #include "Dynamixel_Serial.h"

    void setup () {
    pinMode(13,OUTPUT);

    Ax12.begin(1000000,2);
    Ax12.ping(1);


    }

    int b = 0;
    char Str1[5];
    void loop ()
    {
    b = Ax12.readPosition(1);
    if (b== 512) {digitalWrite(13,ON);}
    else {digitalWrite(13,OFF);}

    delay(1000);
    Serial.end();
    Serial.begin(9600);
    Serial.print(b);
    delay(100);
    Serial.end();
    Serial.begin(1000000);
    delay(100);
    }

    ///////////////////////////////////////
    and servo I turn it by hand and the value of b is always 0 (zero) on the display monitor serial and LED pin 13 is never lit if the servo is at position 512 ,
    how do you view the position servo is usually..

    and thank you very much because it helped me ..

  • Savage

    Hi, The position is from around 200 and 900 thats because the servo has an ideal 1024 positions, so you will see in the serial monitor as:
    ÿÿ458
    ÿÿ768ÿÿ
    or something like that the symbol ÿÿ is from there serial at 1000000 that can't interpretate in the serial monitor and then the position, thats from the code i wrote before, in your code you’re searching for a 512 position, well that a little hard to get by hand (the exact value of 512), you may do this to make the servo go to 512 an then the led will turn on:

    #include "Dynamixel_Serial.h"

    void setup () {
    pinMode(13,OUTPUT);
    Ax12.begin(1000000,2);
    Ax12.ping(1);

    }
    int b = 0;
    void loop ()
    {
    Ax12.move(1,512);
    b = Ax12.readPosition(1);
    if (b== 512) {digitalWrite(13,ON);}
    else {digitalWrite(13,OFF);}
    delay(100);
    }

    Now the LED should turn ON, remember that the number 1 in Ax12.move(1,512); its the ID of my servo, and the same in the Ax12.readPosition(1); instruction.
    The printed value of b = 0 its from a wrong conversion in my library that i will correct as soon as possible but in the mean time yo will have to use iota(); to convert b in to a string and printed out in the serial monitor as i have done in my previous code. Cheers.

  • Savage

    Hi, i have already upload the new library, now you can print in the serial monitor without any conversion. if in the serial monitor you receive -1 values that means that the servo is not responding. Cheers.

    Example Code:

    #include "Dynamixel_Serial.h"

    void setup () {
    Ax12.begin(1000000,2);
    Ax12.ping(1);
    }
    int a,b,c;

    void loop () {

    Ax12.move(1,random(200,800));
    a = Ax12.readPosition(1);
    b = Ax12.readTemperature(1);
    c = Ax12.readVoltage(1);

    delay(10);
    Serial.end();
    Serial.begin(9600);
    Serial.print(a);Serial.print(" ");
    Serial.print(b);Serial.print(" ");
    Serial.println(c);
    delay(100);
    Serial.end();
    Serial.begin(1000000);
    delay(100);
    }

  • or_ange

    hello,
    can I use the library to connect the AX-12 with firefly experiments for Grasshopper for Rhino? (http://www.fireflyexperiments.com/) FireFly links Rhino with Arduino but you have to upload the firefly firmata code which runs serial communication between the computer and the Arduino. Just wondering if this does interfere with the communication to the AX-12?

  • Savage

    Hi, it will interfere with the communication unless you set the both communications at the same Baud Rate or you can use the Software Serial version of this library and use diferents pins for the communication.Good Luck.Cheers. :D

  • or_ange

    hi savage, thanks for your quick reply! that sounds reasonable especially with the software serial using different pins. i will purchase an ax-12 and test it. cheers ...

  • or_ange

    Hello, I am using an Adruino Uno and the Arduino 1.0 environment. I downloaded your Dynamixel_Serial and Dynamixel_SoftSerial library. I successfully changed the AX-12A baud rate from factory default to 9600 and have no problem getting the following code to work:

    #include Dynamixel_Serial.h

    void setup(){
    Ax12.begin(9600);
    pinMode(13,OUTPUT);
    }

    void loop(){
    Ax12.ledStatus(1,true);
    digitalWrite(13,HIGH);
    delay(1000);

    Ax12.ledStatus(1, false );
    digitalWrite(13,LOW);
    delay(1000);
    }

    but for some reasons I don't understand this code does not work for me:

    #include SoftwareSerial.h
    #include Wire.h
    #include Dynamixel_SoftSerial.h

    void setup(){
    Ax12.begin(9600,2,3,4);
    pinMode(13,OUTPUT);
    }

    void loop(){
    Ax12.ledStatus(1,true);
    digitalWrite(13,HIGH);
    delay(1000);

    Ax12.ledStatus(1, false );
    digitalWrite(13,LOW);
    delay(1000);

    }


    Do you have any idea what might cause the Dynamixel_SoftSerial library to not function? I have to tell you I changed the includes from wireing.h to wire.h as I could not find any wireing.h under Arduino 1.0. Many Thanks, ...

  • Josué Alejandro Savage

    Hi, it could be the version of your arduino environment but maybe it will work changing the pins for Rx an Tx just like this:

    Ax12.begin(9600,5,6,7); // 5 ->Rx 6 -> Tx 7 -> Datacontrol

    Remember that this will work only with the SoftSerial 11 BETA.
    Tell if that works now, if not to find other ways to make it move. :D

  • or_ange

    Hi, no success changing the pins ... I did not use the NewSoftSerial 11 Beta before, so I downloaded it and replaced the Arduino standard one with it. It does not compile under Adruino 1.0 so I tried 0.22 and 0.23 where it compiles but the code still does not turn on the LED on the AX-12A. But the "normal" serial works under 0.22 and 0.23? Strange isn't it? This is the compiler error under Arduio 1.0:

    C:\arduino-1.0\libraries\SoftwareSerial/SoftwareSerial.h:95: error: conflicting return type specified for 'virtual void SoftwareSerial::write(uint8_t)'
    C:\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'

    Did you try it with the Uno and with Arduino 1.0 already? Are you running the Arduino on 16MHZ? May be some timing issues? Is there a way to debug the AX12.begin function while connecting it with the RX pin 0 and looking at it with the serial monitor? Thanks for your many help and advice!

  • Josué Alejandro Savage

    Hi, no i haven’t check the library under Arduino 1.0 but will, I`m already downloading the 1.0 version, yes the arduino is at 16MHz, Timing issues? i think not but i will check that probability.
    Ax12.begin(); its just the normal Serial.begin(Baud Rate); instruction and Control pin declarations, and in SoftSerial version is the SoftSerial Puerto(Rx,Tx); object that creates the SerialPort. The serial monitor will just send you some rare ascii characters so that will be a little strange but if you want to give it a try it will be something like this:

    /////////////////////////////////////////////////////////////

    int TChecksum,Checksum;

    void setup(){
    pinMode(2,OUTPUT);
    Serial.begin(9600);

    TChecksum = (ID + AX_LED_LENGTH + AX_WRITE_DATA + AX_LED + Status);
    while ( TChecksum >= 255){
    TChecksum -= 255;
    }
    Checksum = 255 - TChecksum;

    digitalWrite(2,HIGH); // Set Tx Mode

    SoftSerial.write(AX_START); // Send Instructions over SoftSerial
    SoftSerial.write(AX_START);
    SoftSerial.write(ID);
    SoftSerial.write(AX_LED_LENGTH);
    SoftSerial.write(AX_WRITE_DATA);
    SoftSerial.write(AX_LED);
    SoftSerial.write(Status);
    SoftSerial.write(Checksum);

    delayMicroseconds(600);
    digitalWrite(2,LOW);

    }

    void loop(){}

    ////////////////////////////////////////////////////////////////////

    The servo communication always start with 0xFF - 0xFF (255 - 255 Decimal) continued by the ID of the servo, next the length (how many commands you will send) 0x04 for the LED next the instruction 0x03 (Write or Read) in this case Write next the registrer of the led 0x19 next the state 1 or 0, On or Off (0x1 -On) and finally the checksum, the checksum its the addition of each command after the 0xFF 0xFF so it will be the ID + AX_LED_LENGTH + AX_WRITE_DATA + AX_LED + State, but the checksum should fit 1Byte so you should do this:
    while ( TChecksum >= 255){
    TChecksum -= 255;
    }
    and the do:

    Checksum = 255 - TChecksum; // The checksum its 1byte - (Data that we added before) The addition of all the commands.

    And that will be your new Checksum that you have to send over serial. Cheers :D

  • Josué Alejandro Savage

    So this program is already turning the servo LED on and off every 1 second.

    #define AX_START 255
    #define ID 1
    #define AX_LED_LENGTH 4
    #define AX_WRITE_DATA 3
    #define AX_LED 25


    #include "SoftwareSerial.h"

    SoftwareSerial SoftSerial(2, 3);

    int TChecksum,Checksum;

    void setup(){
    pinMode(4,OUTPUT);
    SoftSerial.begin(9600);



    }

    void loop(){

    TChecksum = (ID + AX_LED_LENGTH + AX_WRITE_DATA + AX_LED + 1);
    while ( TChecksum >= 255){
    TChecksum -= 255;
    }
    Checksum = 255 - TChecksum;

    digitalWrite(4,HIGH); // Set Tx Mode

    SoftSerial.write(AX_START); // Send Instructions over SoftSerial
    SoftSerial.write(AX_START);
    SoftSerial.write(ID);
    SoftSerial.write(AX_LED_LENGTH);
    SoftSerial.write(AX_WRITE_DATA);
    SoftSerial.write(AX_LED);
    SoftSerial.write(0x01);
    SoftSerial.write(Checksum);

    delayMicroseconds(400);
    digitalWrite(4,LOW);


    delay(1000);
    TChecksum = (ID + AX_LED_LENGTH + AX_WRITE_DATA + AX_LED + 0);
    while ( TChecksum >= 255){
    TChecksum -= 255;
    }
    Checksum = 255 - TChecksum;

    digitalWrite(4,HIGH); // Set Tx Mode

    SoftSerial.write(AX_START); // Send Instructions over SoftSerial
    SoftSerial.write(AX_START);
    SoftSerial.write(ID);
    SoftSerial.write(AX_LED_LENGTH);
    SoftSerial.write(AX_WRITE_DATA);
    SoftSerial.write(AX_LED);
    SoftSerial.write(0x00);
    SoftSerial.write(Checksum);

    delayMicroseconds(400);
    digitalWrite(4,LOW);
    delay(1000);

    }

    I will check the library to fix whatever is the error with the arduino 1.0 :D

  • or_ange

    Hi, thank you for writing this code! I can get it to work in Arduino 0.023 and the LED blinks! But as soon as I include the Dynamixel_SoftSerial.h and use the SoftSerial.begin(baud, Rx, Tx,D_Pin) function and the Ax12.ledStatus(ID, Status) nothing goes? Am I using the correct Dynamixel_SoftSerial.h and .cpp library files? You only published one version of it and that's the version which can be found here: http://sourceforge.net/projects/savelectronics.u/files/Dynamixel%20Library/?

  • or_ange

    me again ... I was playing around (only have basic coding skills) with the Dynamixel_SoftSerial library and I have the feeling that line 48 of the .cpp file might not be compiled correctly:

    extern SoftwareSerial SoftSerial(0,1);

    at some point I did get error messages like this one:

    Dynamixel_SoftSerial\Dynamixel_SoftSerial.cpp.o: In function `__static_initialization_and_destruction_0':
    C:\arduino-0023\libraries\Dynamixel_SoftSerial/Dynamixel_SoftSerial.cpp:48: undefined reference to `SoftwareSerial::SoftwareSerial(unsigned char, unsigned char, bool)'
    C:\arduino-0023\libraries\Dynamixel_SoftSerial/Dynamixel_SoftSerial.cpp:48: undefined reference to `SoftwareSerial::~SoftwareSerial()'
    Dynamixel_SoftSerial\Dynamixel_SoftSerial.cpp.o: In function `Ax12Class::read_error()':
    C:\arduino-0023\libraries\Dynamixel_SoftSerial/Dynamixel_SoftSerial.cpp:59: undefined reference to `SoftwareSerial::peek()'

    Does Dynamixel_SoftSerial really create a SoftwareSerial called SoftSerial?

  • or_ange

    and again ... I can get it to work using the Dynamixel_SoftSerial library und Arduino 0.023 when in file Dynamixel_SoftSerial.cpp I change line 48 from:

    extern SoftwareSerial SoftSerial(0,1);

    to:

    extern SoftwareSerial SoftSerial(2,3);

    and when I comment out line 99:

    //SoftwareSerial SoftSerial(DRx,DTx); (that's within the definition: void Ax12Class::begin(long baud,unsigned char Rx, unsigned char Tx, unsigned char D_Pin))

    looks like once the SoftwareSerial SoftSerial(0,1) is created no other instance can over ride or redifine it ... does that make sense?

  • Josué Alejandro Savage

    Hi, yes its a redefinition of the same object already created. I have already fix that problem but I'm checking other things before uploading again. Mean while return to the Arduino 1.0 (Download and Install again), and when i upload the library actualization you will just have to paste the files in the libraries folder. :D Cheers

  • Josué Alejandro Savage

    Hi the libraries are ready, go and download the libraries for Arduino_1.0_IDE. Cheers :D

    https://sourceforge.net/projects/savelectronics.u/files/Dynamixel%20Library/?

  • Hello Josué,
    your libraries are amazing, but your posts and the descriptions are a mess. Very very difficult to understand.
    I think it is important to make order in the posts.
    Can you write a post with a clear description and structure for each library?
    I mean:

    Library: Dynamixel_SoftSerial
    Download link: here (with the link!)
    HW required: Dynamixel, Arduino, 74LS241
    Wiring: (a little picture with the wiring, handmade)
    Other library required: SoftSerial Beta 11. Download here
    Code example: a little code as example




    Library: Dynamixel_Serial
    Download link: here (with the link!)
    HW required: Dynamixel, Arduino, 74LS241, USB2Serial converter
    Wiring: (a little picture with the wiring, handmade)
    Other library required: SoftSerial Beta 11. Download here
    Code example: a little code as example and so on.

    Your work is brilliant, but very difficult to understand. thanks.

  • Josué Alejandro Savage

    Hi and Thanks, :D Yes i understand, ill be thinking in what your saying but it will take me a while, i will create documentation post images and all you suggest as soon as possible. Thanks :D Cheers.

  • Robottini

    Hi Josué,
    I would use the Dynamixel_SoftSerial.h but I don't understand witch is the library SoftwareSerial I have to use.
    Is the NewSoftSerial? Or something else? Can you paste a link to the library?
    I use Arduino IDE 0023 version. I can't compile using the NewSoftSerial or the SoftwareSerial provided with the 0023 IDE version.

  • Josué Alejandro Savage

    Hi Robottini, yes its the NewSoftSerial from arduiniana.

    http://arduiniana.org/2011/01/newsoftserial-11-beta/

    If you have any problem just let me know. Cheers :D

  • Robottini

    Hello Josué, thanks for your help. Some little questions:
    - Can I use the instruction Ax12.begin(1000000,8,9,2) or I have to use a low baud rate (i.e 9600) ?
    - From your documentation: - Ax12.action( ID ) - is not correct. I can use only Ax12.action(), without the ID
    - I don't understand the istruction - Ax12.moveSpeedRW( ID, Position, Speed ) or the instruction Ax12.moveRW(ID, Position). I don't understand the difference from Ax12.moveSpeed or Ax12.move
    - I'm using two servos. If I use these instructions starting from the same position (512):
    Ax12.moveSpeed(1,800,400);
    Ax12.moveSpeed(2,800,400);
    the two servos have different speed. the servo 1 arrives earlier than the servo 2. They don't arrive at the same time. Why?

  • Josué Alejandro Savage

    Hi, No you cant`t set a higher baud rate than 115200 cause its SoftwareSerial.
    - Yes i will create a new documentation correcting those things its just Ax12.action();
    - The difference from Ax12.moveRW(); Ax12.moveSpeedRW(); and Ax12.move Ax12.moveSpeed();
    its when the servos are going to move,Ax12.move(); it will move the servo right away and RW its for recording all the servos movements and executed all at the same time, for example Ax12.moveRW(); will not move until the Ax12.action(); is send.
    - The two servos arrives at different time cause Ax12.moveSpeed(1,800,400); is executed before the
    Ax12.moveSpeed(2,800,400); they are at the same speed but one is excited before the other, the solution will be with the RW instructions for example:

    Ax12.moveSpeedRW(1,800,400);
    Ax12.moveSpeedRW(2,800,400);
    Ax12,action();

    Now the two servos should be in position 800 at the same time. Cheers :D

  • Robottini

    using 115200 it works! thanks.
    I tried to use the Ax12.moveSpeedRW ad I think it works. There is a little delay between the 2 servos, but it is acceptable for my goal. I can reduce the speed in order to have a better result.

    Another question, sorry Josué.
    If I well understand I can use the Dynamixel_SoftSerial without the USB2Serial shield. I can use only the standard serial port via USB and 2 other pins to communicate with the AX-12A servos. So I changed the servos baud rate to 115200. I wired the pin RX(1Y1) of 74LS241 to the pin 5 of Arduino and the pin TX(2A4) to the pin 6 of Arduino. This is the code I used:


    #include
    #include
    #include

    void setup(){ // Configuration

    Ax12.begin(115200,5,6,2); //5=RX, 6=TX, 2=data control
    Serial.begin(9600); //speed of serial port used by SoftwareSerial

    delay(1000);
    Ax12.moveSpeedRW(1,900,400); //go to 900 position with 400 of speed
    Ax12.moveSpeedRW(2,900,400); //go to 900 position with 400 of speed
    Ax12.action();
    delay(3000);

    Ax12.moveSpeedRW(1,200,400); //go to 200 position with 400 of speed
    Ax12.moveSpeedRW(2,200,400); //go to 200 position with 400 of speed
    Ax12.action();
    delay(3000);

    Ax12.move(1,512); //go to 512 position
    Ax12.move(2,512); //go to 512 position
    }

    void loop(){

    // print a random value in the serial port


    Serial.print("Number:");
    Serial.println(random(100));

    }

    The serial port works, but the servos are always stopped. They don't move. What is wrong?

  • Josué Alejandro Savage

    Hi, there is no problem in your code, but i think the error its my Library, try this.
    1- Go to the libraries Folder of the arduino
    2- Open the File Dinamixel_SoftSerial.h in Dinamixel_SoftSerial folder
    3- Replace the line SoftwareSerial SoftSerial(0,1); with SoftwareSerial SoftSerial(5,6);
    4- Compile and try again with the your same code.
    5- Let me know if that solve the problem.

    Or you can try downloading the Library for Arduino IDE 1.0 i think it run on the Arduino IDE 0023 but thats the last update of the library. Cheers.

  • Robottini

    Hi,
    I confirm you the library works perfectly with 1.0 version. I use 115200 baud rate and without modifications it works. Amazing!!!

    With the 0023 version the library doesn't work. I changed the source code of the library and replaced the line SoftwareSerial SoftSerial(0,1); with SoftwareSerial SoftSerial(5,6); in the Dinamixel_SoftSerial.cpp not in the Dinamixel_SoftSerial.h as you wrote. No good results. For me this is a push to change the Arduino IDE version. Thanks a lot.

  • Josué Alejandro Savage

    Hi, thats great good luck with your project. Cheers :D

  • Robottini

    Thanks for the updates to the posts. Clear, simple, complete. Amazing!!

  • Robottini

    Hi,I want use the Dynamixel servos with normal hobby servos at the same time.
    But the servo.h library, used with the Dynamixel library, doesn't work.
    The SoftwareServo.h library works very well with your Dynamixel library. So the Dynamixel servos can be used for 'noble' purposes, while normal servos can be used for 'humble' purposes in the same application. Maybe this information could be useful for someone. Cheers.

  • Josué Alejandro Savage

    Hi, Wow :O thanks for the information. Cheers :D

  • Robottini

    Hello Josuè,
    I have a problem with the Dynamixel_SoftSerial library. It works in TRANSMISSION. I can use Ax12.move(ID, POSITION) or the other possibilities without problems. I have a problem RECEIVING the data from the servos. If I use Ax12.readTemperature(ID) or Ax12.readVoltage(ID) or Ax12.readPosition(ID) I receive always -1.
    I changed the baud rate, i.e. 9600, 38400, 57600, 115200 but it doesn't work. Always -1. I use an Arduino 2009 and 2 AX12-A servos.
    Can you make a test with this code?

    #include
    #include


    void setup(){ // Configuration

    Ax12.begin(57600,5,6,2); //5=RX, 6=TX, 2=data control
    Serial.begin(9600);
    delay(1000);



    Ax12.move(1,512);
    Ax12.move(2,512);

    void loop(){

    Serial.print(" *** Temperatura: ");
    Serial.print(Ax12.readTemperature(1)); // Request and Print the Temperature
    Serial.print(" Voltaje: ");
    Serial.print(Ax12.readVoltage(1)); // Request and Print the Voltage
    Serial.print(" Posicion: ");
    Serial.println(Ax12.readPosition(1)); // Request and Print the Position


    }


    Thanks.

  • Josué Alejandro Savage

    Hi, your code only need a } in the setup(){}, but thats not real error, is the Software Serial that is not reading properly, i will check if the error is in my library or the SoftwareSerial Library and I'm about to upload a newer version of the libraries with 16 new functions, i spect to upload the in a week. Cheers. :d

  • Josué Alejandro Savage

    I make a little program to see what the SoftSerial is reading from the Dynamixel servo and just i suspect the SoftwareSerial library is doing bad readings, i think we will have to wait until arduino solve that error.

    #include "SoftwareSerial.h"
    SoftwareSerial SoftSerial(5,6);

    void setup(){
    Serial.begin(9600);
    pinMode(7,OUTPUT);
    SoftSerial.begin(57600);
    delay(1000);
    }

    void loop(){

    digitalWrite(7,HIGH);
    SoftSerial.write(0xFF);
    SoftSerial.write(0xFF);
    SoftSerial.write(0x01);
    SoftSerial.write(0x04);
    SoftSerial.write(0x02);
    SoftSerial.write(0x2B);
    SoftSerial.write(0x01);
    SoftSerial.write(0xCC);
    SoftSerial.write(0x01);
    digitalWrite(7,LOW);

    delay(1000);

    Serial.print("Returned Data: ");

    while(SoftSerial.available()){
    Serial.print("0x");
    Serial.print(SoftSerial.read(),HEX);
    Serial.print(" - ");
    }

    Serial.println("Thats all.");

    Serial.println("Expected Data: 0xFF - 0xFF - 0x01 - 0x03 - 0x00 - 0x20 - 0xDB - Data");
    Serial.println("START BYTE - START BYTE - ID - Length - Error - Temperature - Checksum");

    delay(1000);
    }

    This program use the same pin configuration of your code. and the serial monitor response is this:

    Returned Data: 0xFF - 0xFF - 0x81 - 0x81 - 0x80 - 0x8A - 0xFE - Thats all.
    Expected Data: 0xFF - 0xFF - 0x01 - 0x03 - 0x00 - 0x20 - 0xDB - Data
    START BYTE - START BYTE - ID - Length - Error - Temperature - Checksum

  • Robottini

    thanks for your analysis. Sorry for the bracket error but It was a copy&paste mistake. I can try your code to verify the response of SoftwareSerial. thanks

  • Hi great job its works great , but is there a way to move 2 motor the exact same time , where one must move the opposite of the other one .
    or is there a way to invert one of my motors , thanks for your help.

    Marcel nijssen the netherlands.

  • Josué Alejandro Savage

    Hi, thanks, you can move both servos at the same time with the moveRW() instruction.

    Dynamixel.moveRW(Servo1,Position1);
    Dynamixel.moveRW(Servo2,Position2);
    Dynamixel.action();

    moveRW() save the position in the Ram memory of the servo and its ejecuted until action() is written.
    Cheers.

  • Yes i kwon ,but my motors working together , and stand to the opposite of each other so when 1 motor stand on pos: 700 the other must invert pos 700 , i have try this ,but they working against each other.
    thanks for your help i try to make a function Dynamixel.setDir(id , 1) and thats mean motor id is invert ,so i not have to calculate the opposites positions , and can they better work together , i try this bij a other class AX12.

  • Hi here marcel i have here my code :

    #include
    int Temperature,Voltage,Position;
    int duration1; // Stores duratiuon of pulse in
    int duration2; // Stores duratiuon of pulse in
    int duration3;
    int duration4;

    int dir1;
    int dir2;
    int rc1 = 22; // Pin kanaal 3 in pin 22 digitaal
    int rc2 = 24; // Pin kanaal 4 in pin 24 digitaal


    void setup(){
    Serial.begin(9600); // Begin Serial Comunication

    Dynamixel.begin(1000000,2); // Inicialize the servo at 1Mbps and Pin Control 2
    Dynamixel.setTempLimit(1,80); // Set Max Temperature to 80 Celcius
    Dynamixel.setVoltageLimit(1,65,160); // Set Operating Voltage from 6.5v to 16v
    Dynamixel.setMaxTorque(1,1023); // 50% of Torque
    Dynamixel.setSRL(1,2); // Set the SRL to Return All
    Dynamixel.setTempLimit(2,80); // Set Max Temperature to 80 Celcius
    Dynamixel.setVoltageLimit(2,65,160); // Set Operating Voltage from 6.5v to 16v
    Dynamixel.setMaxTorque(2,1023); // 50% of Torque
    Dynamixel.setSRL(2,2); // Set the SRL to Return All

    delay(1000);
    }

    void loop(){


    pinMode(rc1, INPUT);
    duration1 = pulseIn(rc1, HIGH); // Puls lezen in micro seconds
    duration3 = pulseIn(rc1, HIGH); // Puls lezen in micro seconds
    duration2 = pulseIn(rc1, LOW);
    pinMode(rc2, INPUT);
    duration4 = pulseIn(rc2, HIGH); // Puls lezen in micro seconds
    if ((duration1 > 1084) && (duration1 < 1840) || ((duration4 > 1084) && (duration4 < 1840))) {
    int gemiddeld = duration1 + duration2;
    dir2 = map(duration3, 1084, 1840, 280 , 570);
    dir1 = map(duration1, 1084, 1840, 743 , 453);

    Serial.print(" dir1 : ");
    // Serial.print(dir1);
    Serial.print(" dir2 : ");
    // Serial.print(dir2);
    Serial.println(" ");

    Dynamixel.moveSpeedRW(1, dir1, 300);
    Dynamixel.moveSpeedRW(2, dir2, 300);

    Dynamixel.action();
    } else {
    Dynamixel.moveSpeed(1, 474, 300);
    Dynamixel.moveSpeed(2, (1023 - 474), 300);
    delay(7000);
    }
    gegevens();
    delay(10);



    }

    void gegevens(){


    Temperature = Dynamixel.readTemperature(2); // Request and Print the Temperature
    Voltage = Dynamixel.readVoltage(2); // Request and Print the Voltage
    Position = Dynamixel.readPosition(2); // Request and Print the Position

    Serial.print("AX2 *** Temperature: "); // Print the variables in the Serial Monitor
    Serial.print(Temperature);
    Serial.print(" Celcius Voltage: ");
    Serial.print(Voltage);
    Serial.print(" Volts Position: ");
    Serial.print(Position);
    Serial.println(" of 1023 resolution");
    Temperature = Dynamixel.readTemperature(1); // Request and Print the Temperature
    Voltage = Dynamixel.readVoltage(1); // Request and Print the Voltage
    Position = Dynamixel.readPosition(1); // Request and Print the Position

    Serial.print("AX1 *** Temperature: "); // Print the variables in the Serial Monitor
    Serial.print(Temperature);
    Serial.print(" Celcius Voltage: ");
    Serial.print(Voltage);
    Serial.print(" Volts Position: ");
    Serial.print(Position);
    Serial.println(" of 1023 resolution");

    }

    and this is now my problem , by reading this it shout work , but i dont , dir2 is the oposite from dir1 but it will not execute that way , do some one else having a solution for this ,sorry for my bad english . thanks for the help , thats why if i had the function to invert one of my motors i can set them whit one var ,to 2 motors , maybe there is a other solution .

    marcel nijssen the netherlands

  • Hi i found out whats going wrong , the motors have work against each other when i try something , and become requily in alarm ,and so he have reset themself i think and set both motor on id 1, do you know of i can protect that part so he not going te reset its ids , thanks for the help.

  • Josué Alejandro Savage

    Hi, if you set the motors to Id 1 you will have to change the status return level to just return data on readings, cause if the both motors return status there will be some errors in the comunication due to the daisy chain. I recomend a stable power source with caps filters. Good luck :)

  • Hi josue thanks for the help , i have a problem your lib works fine whit arduino 1.0 , but whit arduino 0023 i cant get it works ,i download your lib for that place it into the library folder ,but it wont work , i needs it there because i use the apc220 modulles and the lcd crystal i2c and they wont work in arduino 1.0 ,what i doing wrong this my fault code :
    sketch_mar13a.ccp: In fuction 'void setup()'
    sketch_mar13a.19: error: 'Dynamixel' was mot declared in this scope

    i think he cant read the library

    i try to safe this as i scetch , save as ... and then name it
    but that works eather.
    can you help me whit this, thanks for your help

  • Josué Alejandro Savage

    Hi, i have a previous version working in Arduino 0023 here:
    http://sourceforge.net/projects/savelectronics.u/files/Dynamixel%20Library/

  • Hi i have try to instal this but its not working what do i wrong.
    i download it , unpack , place the unpact folder in arduino_0023/libraries .
    i also download the newserialsoftware , place it in the libraries folder, i also copy then and place then in the example folder .
    but when i complimy the program here above , i get only errors that he not reconice the dynamixel.begin() ect , can you tell me what i am doing wrong or forget , thanks for the help
    marcel nijssen

  • Josué Alejandro Savage

    Hi, yes the Dynamixel Library version 0023 will not compile the example of the current version.
    Replace all the Dynamixel. for Ax12. Now it should work. Cheers.

  • Hi josue its works fine now thats whats i did wrong , i have a question when i upload a program :
    the link its to big for here :

    http://hierden4.nl/program.txt

    what will work for my turret controling whit a memsic2125 for when i drive down turret goes a little up its not perfect jet , but thats not my biggeds problem , that problem is when my power is off ,and then when i turn it on then my program is lost because the flash memory , is there a solution to save this skech in the eeprom or a other way to save this in the uc ? how do you store programs or upload you then when you use it first, thank for the help.
    its to big for the eeprom memory right 8742 bytes i use the 328 atmel
    marcel nijssen

  • Hi Josue,

    How About Arduino and Dynamixel Mx-28?

  • Josué Alejandro Savage

    The flash memory problem can be solved with a higher grade microcontroller like an Arduino Mega or by using a computer with processing and firmata sketch. Good luck.

  • Josué Alejandro Savage

    Dynamixel Mx-28 should work with the library just fine with the 74LS241. Try it :P

  • ok thank you for your help

    marcel nijssen

  • Ferchriqulme

    hi savage I would like to know if the library of ax-12 work on dynamixel rx-28???

  • Josué Alejandro Savage

    Hi, I haven't tested but It should work just fine with the MAX485, see the diagram above for wiring the motor.

  • Hola!
    I am trying to control 2 AX-12's with an Uno, and having compile errors when trying to utilize your SoftwareSerial code.
    I get "within this context" when I try to compile Dynamixel_Conf.
    This error highlights "setRXPin(DRx);" under the DynamixelSoftSerial.cpp file. I am trying to use a 74LS241 to compensate for the lack of arduino speed.
    Thanks for your help!
    Craig

  • Josué Alejandro Savage

    Hi, yes you have to do some modifications in order to get working the SoftSerial Dynamixel Library,

    1.- In Arduino Libraries find : Software Serial Folder and open the SoftwareSerial.h file

    2.- Cut and Paste the setTxPin() and setRxPin() in the section private of the class definition and do those public by pasting below the public: line.

  • Jose

    Hola Savage! que gran trabajo el que haz realizado, he visto las bibliotecas y los ejemplos de conf, read y write son para usar los dynamixel como servos, pero si yo quiero usarlos como ruedas que debo hacer? y la otra pregunta es si quiero poner como esclavo algun dynamixel para crear algo asi como un carro (en el caso de dos motores vayan igual como ruedas) o como servo esclavo(en el caso de un brazo que necesite 2 o 3 servos en su base). E s posible que me puedas envia un reference con ls funciones de la biblioteca? muchas gracias de verdad es un trabajo excelente el que haz hecho.

  • Josué Alejandro Savage

    Hola, gracias.

    Para utilizar el servo como ruedas se hace con las siguientes instrucciones

    Dynamixel.setEndless(1,ON); // Servo id 1 and endless on
    Dynamixel.turn(1,LEFT,1000); // Servo id 1 and turn to the left and speed 1000

    Puedes descargar la documentacion en las descargas.
    Saludos.

  • Jose

    HOLA SAVAGE! MUCHAS GRACIAS, AL PARECER NO LO PODIA DESCARGAR POR ALGO DE LOS MIRRORS PERO INTENTE OTRO Y SI LO LOGRE, GRAN TRABAJO UN SALUDO DESDE COLOMBIA

  • Hola Savage, si tengo configurados los dinamixel como ruedas, como hago para decirles con cuanto torque andar? digamos , veo que hay una isntruccion que es el de configurar torque maximo, si quieor que tenga el maximo torque el motor, como lo deberia poner? muchas gracias

  • Josué Alejandro Savage

    Hola, es muy sencillo te dejo un ejemplo a continuación:

    #include"DynamixelSerial.h"

    void setup(){
    Dynamixel.begin(1000000,2);
    Dynamixel.setMaxTorque(1,1023);
    Dynamixel.setEndless(1,ON);
    Dynamixel.turn(1,RIGTH,1020);
    }

    void loop(){}

    Con este pequeño programa se pone al máximo torque, se activa el modo rotación continua y gira hacia la derecha a la velocidad máxima.

  • Hola Savage, mira que consegui un HD74ls241p, esta me sirve? si me sirve como serian las conexiones? Agradezco tu ayuda

  • Josué Alejandro Savage

    Hola, si te sirve, es el mismo circuito que recomiendo, puedes ver la configuracion de este y las conexiones en la imagen de arriba del circuito que dice SN54/74LS241. Saludos

  • Jose

    Hola Savage! hoy probamos todo tal cual como dijiste, funciono perfecto!!!! que gran aporte de verdad muchisimas gracias! un Saludo

  • Josué Alejandro Savage

    Que bien, me alegra que haya sido de ayuda, estoy planeando implementar la función syncwrite, también mejorar y optimizar las funciones, para aprovechar lo que estos servos son capaces de hacer.

  • Jose

    Wowwwww seria de mucha utilidad! esa funcion sirve para sincronizar varios motores a la vez no es asi? que gran aporte de nuevo muchas gracias savage! Hemos estado usando unos dynamixel del kit de bioloid por lo qu todos vienen con ID preestablecido, pero hoy precisamente compramos 6 de estos motores, solo que cuadno uno los compra , ellos vienen con ID 1, para cambiarle el ID a cada uno, se que hay una funcion que hiciste que es Setid, pero como hace el para saber cual es cual si todos los ID son iguales? o debemos cambiar los ID primero con el usb to dynamixel por medio del Dynamixel manager? Un saludo Savage

  • Josué Alejandro Savage

    Asi es, con syncWrite podrás mover todos los servo con una sola instrucción, para cambiar los id de tus servos nuevos deberás conectarlos de 1 en 1 a tu arduino para que lo haga con cada uno. Saludos

  • Bill Bigge

    I've just started using this library on an arduino mega, and with Dynamixel RX24F Servos. I started with the read example, using three servos, but I can only read data from one servo.

    I can set positions, and the LED status for all three servos, I just can't get data back from two of them. I started with a baud rate of 1000000, then dropped it to 117647.

    All three servos respond fine when I use the Dynamixel Wizard, running through a FTDI USB to RS485 converter - I get data back from all three.

    I'm using an SP485 Half-Duplex RS-485 Transceiver connected to the arduino - serial port 3 and control pin 2 (with DynamixelSerial3.h)

    Has anyone encountered a problem like this, or can suggest a solution?

    I've tried plugging each servo in to the arduino individually and still get the same problem - they respond to commands but only one will reply with data - all three will respond and reply when I use the Dynamixel Wizard and my USB interface.

  • Josué Alejandro Savage

    Hi bill, maybe the status return level of the servos that dont respond are in no return, try reseting those servos with this:

    Dynamixel.reset(ID);

    Good luck. :-)

  • Bill Bigge

    Thanks, I realised after posting that I had not put any terminating resistor on my RS485 IC. I added this (but mistakenly added a 220R at first) now I get reliable data from two of the servos and garbage from the third - I am guessing that there is still an issue with my electronics as all three work fine when using the USB to RS485 converter. Just ordered a sparkfun RS485 breakout board to try instead of my breadboarded one.

    Thanks for the suggestion - and thanks for writing the library - great stuff, saved me tons of work.

  • Hi savage, i am currently using a arduino uno and RS485 to generate movement for rx-28 motor. I have tried downloading and using your libraries but it still cant work.Could you please help me thanks in advance.

  • Josué Alejandro Savage

    Hi, what does the motor do? Any error?

  • Hey savage thanks for the response.
    It's this motor, http://crustcrawler.com/motors/RX28/docs/RX28_Manual.pdf
    The problem is now i cant communicate with my motor.. I tried using your library but it cant talk to my dynamixel.
    This is my circuit drawing:http://arduino.cc/forum/index.php?action=dlattach;topic=103204.0;attach=17721;image

  • Josué Alejandro Savage

    In the RS485 pin 2 and 3 goes to dataflow control wich is pin 2 in the arduino, dont forget to join all the grounds together. Good luck.

  • So do i make it High or low for the dataflow control pin?

  • Josué Alejandro Savage

    not high and not low, just connected to the Pin 2 of the arduino with this instruction:

    Dynamixel.begin(1000000,2); // Se second parameter is the DataFlow Control Pin, you can change the pin if you want to, Good Luck.

  • Greetings,

    I'm having a little trouble here. I downloaded from this link:

    Biblioteca Dynamixel Serial
    Descripción: En esta versión se utilizan los pines Seriales del Arduino 0 - Rx y 1 – Tx además de un pin de control de flujo de datos si se desea utilizar el circuito 74LS241.
    Enlace de descarga: Biblioteca - Documentación.
    Hardware requerido: Servomotor Dynamixel , Arduino, IC 74LS241, USB2Serial Converter (opcional).

    I put the DynamixelSerial library in the C:\Program Files\arduino-1.0\libraries folder.

    I then opened the Arduino IDE and loaded your examples, such as Dynamixel_Write, into a project fileI called Ax12v1.

    Upon compiling, I get a slew of errors, the first being:

    "Ax12v1.cpp:1:29: error: DynamixelSerial.h: No such file or directory"

    It doesn't matter which of your example files I paste into my IDE, compilation always returns the same initial issue.

    I tried moving the folder structure around, placing the DynamixelSerial folder (the one that contains the DynamixelSerial.h file) directly into C:\Program Files\arduino-1.0\libraries. So, the path to the header file is in C:\Program Files\arduino-1.0\libraries\DynamixelSerial. That didn't help.

    I've read thru this forum looking for the answer. There seemed, at one time, to be some discrepency between using "Dynamixel" vs "Ax12" as the object. But looking in the header file, I see:

    extern DynamixelClass Dynamixel;

    And I _don't_ see Ax12 as a data type anywhere in there. So, I'm guessing that "Dynamixel" is right.

    But the compiler can't seem to find the DynamixelSerial.h file and complains with the "No such file or directory" error.

    What do I need to do here?

    Thanks in advance,

    http://soundcloud.com/patrick-shannon-mckiernan

  • Problem solved!

    (user error)

    Help, for me, was found by rereading:

    http://arduino.cc/it/Hacking/LibraryTutorial

    and this little tidbit:

    #include "some_lib.h"

    ... with double-quotes expects the file to be in the current folder.

    #include

    ... with angle brackets will look for the file in a "libraries" folder.


    In the IDE, the Sketch + Import Library... menu item will list all libraries installed in the correct location(s). Are the libraries you are having difficulties with in that list?

    Thanks SO MUCH for publishing and sharing your library! My project is now well under way!

    http://soundcloud.com/patrick-shannon-mckiernan

  • Hola Savage, este hilo es verdaderamente Salvage..!!

    Solo una pregunta.. Puedo usar los Dynamixel como servos normales..?? conectados a un receptor de RF para hobby

    Sin arduino ni M5, conectando directamente +,- y S como un servo normal??

    Entiendo ke daria error constantemente, via led pero si no se rompen seria genial para mis propositos.

    Ok, gracias anticipadas

    Salud

  • Josué Alejandro Savage

    Hola desafortunadamente no se puede enviar las mismas señales que en un servo estándar para hacer funcionar este, se puede colocar un microcontrolador como intermediario para traducir la información del radiocontrol a la comunicación dynamixel pero solo de esta forma como la mas sencilla. Saludos

  • Gracias, Savage

    se puede comprar ese microcontrolador, o lo tienes ke montar tu ?

    Realmente lo ke yo keria es aprovechar los frames y articulaciones ke trae el pack de Bioloid y los Dynamixel para hacer un brazo articulado para cámara de video
    Pero usando una emisora de radiocontrol de un coche de RC y su receptor.

    Gracias por la respuesta

    Salud

  • Josué Alejandro Savage

    No conosco ninguna placa que haga la traducción, pero como te comento la puedes hacer tu, necesitarías un microcontrolador ( µC el que más te guste o manejes ), este lo vas a programar para que haga la traducción apulsos. ( Habría que armarlo todo desde regulador de voltaje hasta la programación ), Pienso que en un arduino quedaría de un tamaño bastante reducido y ademas que ya solo quedaría programarlo. Saludos

  • Ok, Gracias Savage

    Nada usare servos normales, Thanks.

    Salud

  • Phillip James

    Hey savage

    I'm starting a project based around your post here using the arduino micro controller with an MX-28 rather than the AX-12. I have the servo connected through a 74ls241n buffer and am running your basic write code, but im not getting any results. the program compiles fine and when i connect everything the servo gives the single blink power confirmation so its powered properly, but there must be something im missing here... i also checked the table for the mx28 and it seems to be the same as the ax12 so all of the commands called by the program you wrote should work fine. I know its sort of a vague question considering you cant be here in person to debug but i was curious if you had any ideas on where to go from here to get it all to work

    thanks!

  • Josué Alejandro Savage

    Hi Phillip, in this type of communications is very important to join the grounds of your power supplies so that the both chips can talk each other correctly. Could be that or maybe some broken wires. Hope that helps.

  • Jose Carlos Rangel Ortiz

    Hola muy buena tu librería, tengo una pregunta acerca de la corriente, según robotis la corriente máxima para los dynamixel es de 900 mA, pero yo tengo adaptadores que mandan 1 A y el conector propio para el cm510 manda 5A, podría usar estos conectores sin que se dañe en dynamixel??, o de que manera podría también alimentar el motor, tengo baterías lipo para arduino pero no me duran mucho. Espero tu respuesta y muchas gracias

  • Josué Alejandro Savage

    Hola, la corriente es algo que se pide y depende básicamente de dos cosas, el voltaje y la impedancia interna del dispositivo, basta con respetar los limites de voltaje de los dynamixel para poder operarlos sin problemas, tomando en cuenta las notas de Robotis esos 900 mA es el máximo de corriente que el motor exigirá por que si tienes una fuente de 1 Amper tienes 100 mA de sobra que no serán utilizados, el que tus adaptadores digan 1A, 5A, 10A... indica la máxima corriente que puede suministrar sin dañarse así mismo, donde hay que cuidar la corriente es en otro tipo de dispositivos como por ejemplo un LED o cosas por el estilo por lo demás no te preocupes demasiado, en conclusión si puedes usar cualquiera de esos mientras estén en el rango de voltaje, Recomendado 10V. Espero haber aclarado tus dudas un poco, Saludos.

  • Jose

    Hola SAvage! voy a usar el serial de arduino para controlar algunas secuencias de movimiento (un brazo con diferentes posiciones), la idea es abrir el serial monitor de arduino, y al poner un numero o una letra, llamar dicha secuencia, la pregunta es, si voy a trabajar con arduinoi con un Serial.begin(9600);, a los dynamixel tambien debo modificarles esa velocidad? o como seria para hacer eso? Mil gracias savage y de nuevo felicidades por esa bilbioteca

  • Josué Alejandro Savage

    Hola Jose, supongo que estas usando el Arduino UNO por lo que si quieres usar el Serial Monitor y el Dynamixel tienes dos opciones:

    1.- Como mencionas poner tanto el Dynamixel como el Serial Monitor a la misma velocidad.
    2.- Puedes usar un SoftSerial para el Dynamixel y el Hardware Serial para el Serial Monitor.

    Saludos.

  • Necro

    Hola Savage. Hace poco empece a trabajar con Arduinos y con este tipo especial de motores. En estos momentos estoy desarrollando el control de la rotación de una plataforma que se debe mover entre 0° y 360°, asi: con pasos de 0, 90, 180 y 270; es decir cuatro pasos por un tiempo determinado. Observando en las especificaciones de Dynamixel veo que el ángulo 0 (360°) no es permitido; que puedo hacer para solucionar este problema? Agradeciendo su ayuda

  • Josué Alejandro Savage

    Hola, desafortunadamente el Ax-12 no lo permite pero hay dynamixels que si pueden aunque son mucho más caros, podrias poner sensores ( red switch por ejemplo) pero no tendria mucho caso usar ese servo para un tarea tan facil. Saludos.

  • Alejandro Daniel Jose Gomez Florez

    Hola Savage. Tengo un problema. Empleé el comando de la libreria para cambiar el baund rate del motor que al estar en 1000000, lo camibié a 9600. Despues de eso, no me funciona y no me responde a nada, intenté cambiarlo, en 9600 a 1000000 y tampoco quiere responder. Como haría para arreglar ese problema que generé? ya los motores no me responden y necesito urgentemente componerlos para un proyecto que debo presentar.

  • Josué Alejandro Savage

    Este programa debería dejar tu Motor como de fabrica, se conecta el motor al serial0 y pin de control D2.
    Suerte, saludos!


    #include "DynamixelSerial.h"

    long BaudRates[] = {1000000,666667,500000,400000,333333,285714,250000,222222,
    200000,181818,166667,153846,142857,133333,125000,117647,111111,105263,100000,
    95238,90909,86957,83333,80000,76923,74074,71429,68966,66667,64516,62500,60606,
    58824,57143,55556,54054,52632,51282,50000,48780,47619,46512,45455,44444,43478,
    42553,41667,40816,40000,39216,38462,37736,37037,36364,35714,35088,34483,33898,
    33333,32787,32258,31746,31250,30769,30303,29851,29412,28986,28571,28169,27778,
    27397,27027,26667,26316,25974,25641,25316,25000,24691,24390,24096,23810,23529,
    23256,22989,22727,22472,22222,21978,21739,21505,21277,21053,20833,20619,20408,
    20202,20000,19802,19608,19417,19231,19048,18868,18692,18519,18349,18182,18018,
    17857,17699,17544,17391,17241,17094,16949,16807,16667,16529,16393,16260,16129,
    16000,15873,15748,15625,15504,15385,15267,15152,15038,14925,14815,14706,14599,
    14493,14388,14286,14184,14085,13986,13889,13793,13699,13605,13514,13423,13333,
    13245,13158,13072,12987,12903,12821,12739,12658,12579,12500,12422,12346,12270,
    12195,12121,12048,11976,11905,11834,11765,11696,11628,11561,11494,11429,11364,
    11299,11236,11173,11111,11050,10989,10929,10870,10811,10753,10695,10638,10582,
    10526,10471,10417,10363,10309,10256,10204,10152,10101,10050,10000,9950,9901,
    9852,9804,9756,9709,9662,9615,9569,9524,9479,9434,9390,9346,9302,9259,9217,
    9174,9132,9091,9050,9009,8969,8929,8889,8850,8811,8772,8734,8696,8658,8621,
    8584,8547,8511,8475,8439,8403,8368,8333,8299,8264,8230,8197,8163,8130,8097,
    8065,8032,8000,7968,7937,7905,7874,7843};


    void setup(){
    pinMode(13,OUTPUT);


    for ( int i = 0; i <= 254;i++ ){
    Dynamixel.begin(BaudRates[i],2); // inicializa la comunicacion.
    Dynamixel.reset(254); // Cambia el Baud a 1000000 ( 1Mbps )
    }


    Dynamixel.begin(1000000,2); // Comprobacion.
    }

    void loop(){

    digitalWrite(13,ON);
    Dynamixel.move(1,random(200,800));
    delay(1000);
    }

  • Alejandro Daniel Jose Gomez Florez

    Hay unos errores en el código, por ejemplo en el for, ya que en la linea Dynamixel.reset(254) realmente es Dynamixel.reset(i). Pero de igual forma muchas gracias.

  • Josué Alejandro Savage

    Hola, Dynamixel.reset(i); me parece que no ya que le estas asignando un ID a cada Velocidad cuando el ID podría ser diferente al que le asignas, 254 es el ID de Broadcast, no importa el ID que tenga el motor con ese responderá y se ejecutara. Saludos

  • «El más antiguo ‹Más antiguo   1 – 200 de 382   Más reciente› El más reciente»

    Publicar un comentario en la entrada