Results 1 to 2 of 2

Thread: Dynamixel Servo Control Issues (MX-28 and Arduino Mega)

  1. #1
    JasonT Guest

    Dynamixel Servo Control Issues (MX-28 and Arduino Mega)

    What I'm attempting to do, is to get a firm grasp on the servo's communication protocol. To keep things simple I'm starting with an Arduino Mega and I'm sending the data through an ST485 RS-485 converter chip. I'm having some difficulty when trying to interface with a Dynamixel MX-28


    For the controls, I'm using an Arduino Mega and an RS-485 converter, connected as follows. I've also attached my test sketch to this post. All I'm trying to do is to make the LED blink


    Arduino --- ST485
    Tx3(D14) --- Data In
    Rx3(D15) --- Data out
    D7 ----------- !(Receive Enable) / Transmit Enable


    I have verified that the MX-28 is working using RoboPlus. I have verified the RS-485 output using my scope but it's still not working right.



    Code:
    //*************************************************************
    // TITLE:
    //   Dynamixel RS-485 Test Program
    // 
    // SCOPE: 
    //   This test program is intended to demonstrate the control
    //   of a Dynamixel servo over RS-485. The TTL to RS-485 
    //   conversion is handled by a ST485 transciever on an RS-485
    //   breakout board.
    //
    // TERMINATIONS:
    // 
    //   Arduino          RS-485 Breakout  
    //    D14 - TTL Tx       DI
    //    D15 - TTL Rx       R0
    //    D7  - RS485-EN     DE/RE
    //*************************************************************
    
    
    // *******************************
    // DEFINES
    // *******************************
    
    
    #define RS485_EN 7     // Hardware location of enable line
    byte startAddress;
    byte servoID = 0x01;    // Servo Address
    int i = 0;             // program counter
    byte ledOn = 0x01;
    byte ledOff = 0x00;
    
    
    //*************************************************************
    // FUNCTION: Activate Servos
    // RETURNS: Nothing
    // DESCRIPTION: Activates our servos
    //*************************************************************
    void activateServos(byte servoID, byte newValue) {
      
      int checksum_ACK;
      byte notchecksum;
      unsigned char length = 0x04;
      unsigned char instruction = 0x03;
      startAddress = 0x19;     // Turning on led
       
      checksum_ACK =  servoID + length + instruction + startAddress + newValue;
      notchecksum = ~checksum_ACK;
      
      //noInterrupts();
      
      // Transmission routine
      digitalWrite(RS485_EN,HIGH);      // 1.  Set direction of the RS-485 COM
      delay(15);                        // 1a. Allow this to take effect
      
      Serial3.write(0xFF);              // 2. Sync Byte 1
      Serial3.write(0xFF);              // 3. Sync Byte 2
      Serial3.write(servoID);           // 4. Dynamixel Servo Address
      Serial3.write(length);            // 5. Length of packet
      Serial3.write(instruction);       // 6. Instruction
      Serial3.write(startAddress);      // 7. Start address for data to be written
      Serial3.write(newValue);          // 8. Apply new value of register
      Serial3.write(notchecksum);       // 9. Send the checksum
      
      delay(15);                        // 10. Allow last byte to go through
      digitalWrite(RS485_EN,LOW);       // 11. Set direction of RS-485 COM
      
      //interrupts();
    }
    
    
    //*************************************************************
    // FUNCTION: Setup
    // RETURNS: Nothing
    // DESCRIPTION: Initial setup of our pins and COMs
    //*************************************************************
    void setup() {
      Serial3.begin(57600);
      //Serial3.begin(115200);
      pinMode(RS485_EN, OUTPUT); 
      delay(3000);
    }
    
    
    //*************************************************************
    // FUNCTION: loop
    // RETURNS: Nothing
    // DESCRIPTION: Our main program loop
    //*************************************************************
    void loop() {
      
      //Transmission section
      delay(1);
    
    
      if (i%2 ==0){ 
        activateServos(servoID, ledOn);
        delay(2000);
      } else {
        activateServos(servoID, ledOff);
        delay(2000);
      }
    
    
       i++;
      if (i>1000){
        i=1;
      }  
    }
    Last edited by KevinO; 07-25-2014 at 02:42 PM.

  2. #2

    Re: Dynamixel Servo Control Issues (MX-28 and Arduino Mega)

    The code looks ok - can you post the actual packets your sending (i.e. write them to Serial.print on the serial monitor) just so I can confirm?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Question(s) How to control AX-12A Servo motor through arduino with labview interface?
    By Taslim in forum Arbotix, Microcontrollers, Arduino
    Replies: 6
    Last Post: 06-03-2014, 12:12 AM
  2. 18 Servo High Speed Snake Robot Powered by Arduino Mega
    By jk_hop in forum Project Showcase
    Replies: 3
    Last Post: 08-04-2013, 01:19 PM
  3. Arduino Mega 2560 and Serial Comunication issues
    By DVS in forum Arbotix, Microcontrollers, Arduino
    Replies: 3
    Last Post: 07-10-2013, 02:31 PM
  4. Arduino bluetooth servo control
    By ArduTank in forum Mech Warfare
    Replies: 6
    Last Post: 07-08-2012, 03:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •