profmason.com

December 23, 2012

CM-900: Drive a Dynamixel Motor

Filed under: Daily — profmason @ 3:47 am

Drive a Dynamixel Motor:

The CM-900 has four ports that use the RS485 protocol.  Two ports have three pins and use a half duplex TTL level protocol.  Two ports have 4 pins and use a full duplex differential EIA-485 protocol. 

  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. Enter the code shown below into the IDE window (if you don’t want to enter it choose “File” -> “Examples” -> “Dynamixel” -> “Basic” )Setup your board as the compiler target by selecting “Tools” -> “Board” -> “Robotis CM-900”
  4. 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.
  5. 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.
  6. You should observe that the motor connected to your board will spin forward and the reverse.

Explaining the code:

Each program must have two functions, setup and loop:

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.

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

  • Dxl.writeword(1,30,100) sends to ID 1, ADDRESS 30 the value 100. Address 30 is the POSITION register of the servo, so this will cause the servo to move to a position register of 30.  A list of all registers is given in Table 2.
  • delay (time in milliseconds) causes the CM-900 to halt execution for the specified time.

Table 1:

Command Action Returns
dxl_ping( id ); Ping dynamixel device specified by ID. Nothing*
dxl_reset( id ); Sends the reset command to the device specified by ID. Nothing*
dxl_write_byte( id, address, value ); Writes a single value to the specified ADDRESS to the device specified by ID. Nothing*
dxl_write_word( id, address, value ); Writes a word consisting of a HIGH byte and LOW byte to the specified ADDRESS to the device specified by ID. Nothing*
dxl_read_byte(  id, address ); Reads a single value from the specified ADDRESS from the device specified by ID. INT
 dxl_read_word( id, address ); Reads a word from the specified ADDRESS from the device specified by ID. LONG
dxl_get_result(); Reads the COMM_STATUS flag INT

*The global COMM_STATUS flag will change.

Table 2:  Based on Dynamixel AX-12 Documentation

Area

Address

Name

Description

Access

Initial Value

E

E

P

R

O

M

0 (0X00)

Model Number(L)

Lowest byte of model number

R

12 (0X0C)

1 (0X01)

Model Number(H)

Highest byte of model number

R

0 (0X00)

2 (0X02)

Version of Firmware

Information on the version of firmware

R

-

3 (0X03)

ID

ID of Dynamixel

RW

1 (0X01)

4 (0X04)

Baud Rate

Baud Rate of Dynamixel

RW

1 (0X01)

5 (0X05)

Return Delay Time

Return Delay Time

RW

250 (0XFA)

6 (0X06)

CW Angle Limit(L)

Lowest byte of clockwise Angle Limit

RW

0 (0X00)

7 (0X07)

CW Angle Limit(H)

Highest byte of clockwise Angle Limit

RW

0 (0X00)

8 (0X08)

CCW Angle Limit(L)

Lowest byte of counterclockwise Angle Limit

RW

255 (0XFF)

9 (0X09)

CCW Angle Limit(H)

Highest byte of counterclockwise Angle Limit

RW

3 (0X03)

11 (0X0B)

the Highest Limit Temperature

Internal Limit Temperature

 RW

70 (0X46)

12 (0X0C)

the Lowest Limit Voltage

Lowest Limit Voltage

RW

60 (0X3C)

13 (0X0D)

the Highest Limit Voltage

Highest Limit Voltage

RW

140 (0XBE)

14 (0X0E)

Max Torque(L)

Lowest byte of Max. Torque

RW

255 (0XFF)

15 (0X0F)

Max Torque(H)

Highest byte of Max. Torque

RW

3 (0X03)

16 (0X10)

Status Return Level

Status Return Level

RW

2 (0X02)

17 (0X11)

Alarm LED

LED for Alarm

RW

36(0×24)

18 (0X12)

Alarm Shutdown

Shutdown for Alarm

RW

36(0×24)

R

A

M

24 (0X18)

Torque Enable

Torque On/Off

RW

0 (0X00)

25 (0X19)

LED

LED On/Off

RW

0 (0X00)

26 (0X1A)

CW Compliance Margin

CW Compliance margin

RW

1 (0X01)

27 (0X1B)

 CCW Compliance Margin

CCW Compliance margin

RW

1 (0X01)

28 (0X1C)

CW Compliance Slope

CW Compliance slope

RW

32 (0X20)

29 (0X1D)

CCW Compliance Slope

CCW Compliance slope

RW

32 (0X20)

30 (0X1E)

Goal Position(L)

Lowest byte of Goal Position

RW

-

31 (0X1F)

Goal Position(H)

Highest byte of Goal Position

RW

-

32 (0X20)

Moving Speed(L)

Lowest byte of Moving Speed

RW

-

33 (0X21)

Moving Speed(H)

Highest byte of Moving Speed

RW

-

34 (0X22)

Torque Limit(L)

Lowest byte of Torque Limit

RW

ADD14

35 (0X23)

Torque Limit(H)

Highest byte of Torque Limit

RW

ADD15

36 (0X24)

Present Position(L)

Lowest byte of Current Position

R

-

37 (0X25)

Present Position(H)

Highest byte of Current Position

R

-

38 (0X26)

Present Speed(L)

Lowest byte of Current Speed

R

-

39 (0X27)

Present Speed(H)

Highest byte of Current Speed

R

-

40 (0X28)

Present Load(L)

Lowest byte of Current Load

R

-

41 (0X29)

Present Load(H)

Highest byte of Current Load

R

-

42 (0X2A)

Present Voltage

Current Voltage

R

-

43 (0X2B)

Present Temperature

Current Temperature

R

-

44 (0X2C)

Registered

Means if Instruction is registered

R

0 (0X00)

46 (0X2E)

Moving

Means if there is any movement

R

0 (0X00)

47 (0X2F)

Lock

Locking EEPROM

RW

0 (0X00)

48 (0X30)

Punch(L)

Lowest byte of Punch

RW

32 (0X20)

49 (0X31)

Punch(H)

Highest byte of Punch

RW

0 (0X00)

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