profmason.com

January 8, 2013

CM-900 Set Device ID for Dynamixel

Filed under: Daily — profmason @ 11:06 pm

Set the Device ID on a Dynamixel Motor:

Each Dynamixel device must have a unique device ID.  From the factory they all have an ID of 1, so if you connect two of them together there will be a device conflict.  The CM-900 can change the device ID by writing to the new  ID address (3) on the servo through the RS485 bus.

  1. Connect a dynamixel servo (AX-12+) to one of the TTL connectors on the board.
  2. Insert a 12V power supply into the 5.1mm barrel connector on the CM900 board.
  3. Connect a USB->TTL device to the Zigbee port of the CM-900 board.  This could be either a Robotis BT-100A board or any other USB -> TTL board.  We will be using the CP2102 USB-TTL board.
    1. Connect the ground pins together
    2. Connect TX on the CP2102 to RX on the CM900
    3. Connect RX on the CP2102 to TX on the CM900
    4. Leave the 3.3V connector disconnected.
    5. Enter the code shown below into the IDE window.
  1. Enter the code shown below into the IDE window.

  1. Setup your board as the compiler target by selecting “Tools” -> “Board” -> “Robotis CM-900”
  2. Choose the appropriate port  by selecting “Tools” -> “Serial Port” -> the port number indicated by your device manager when you installed the VCP driver in the getting started section above.
  3. Press the Arrow Icon just below the menu bar.  The IDE will report that the program is being sent to the CM-900 board and will report “Excute new application” when it is done.
  4. You will observe that a device list is enumerate on your Serial terminal which contains the new device.

Explaining the code:

Initialization:

  • Setup the desired IDs using the CurrentID and NewID variables.

Setup:  Setup is run once when either the CM-900 is powered on or the reset button is pressed.

  • dxlBegin()  This function initializes the dynamixel bus and creates an object called Dxl which has a set of functions associated with it.  See Table 1 below for a list of these functions.
  • Serial2.being(57600)  This function initializes the serial debug port to a baud rate of 57600.
  • Dxl.writeByte( CurrentID, 3, NewID );  This command writes a Byte instead of a word.  Up to this point we have used the Dxl.writeWord() command.  A word consists of two bytes and thus fills two address on the Dynamixel.  In this case we only want to write the NewID to the ID register(3) of the Dynamixel at CurrentID.
  • Note the dxlBegin and writeWord commands require some time to initialize so there are delays built in to allow this to work properly.

Loop: Loop runs continually as long as the CM-900 is powered.  Think of it as a while loop with no termination condition.

  • Serial2.print(“Goal Position : “);  The Serial2.print command prints something to the serial port. The print command can only take a single string or variable and doesn’t have powerful parsing abilities.
  • The remainder of the code loops over the first 32 dynamixel devices and displays if they are present and their type.

 

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress