Quick Start for Dynamixel Pro v1.00b
// int GoalPos = 151875; // for 42-series
int
GoalVel = -3000l
int
GoalTorque = 120;
int
result = COMM_TXFAIL;
int
error = 0;
int
val1, val2, val3;
...
// open device and set baud rate here
if( DXL.Connect() == 0 )
...
// Torque Enable is off by default
// The following line is not necessary but it ensures
// Torque Enable is off regardless
DXL.WriteByte(1, TORQUE_ENABLE, 0,
...
While(1); {
switch(_getch()) {
case
0x1b:
DXL.WriteByte(1, TORQUE_ENABLE, 0, 0);
usleep(CONTROL_PERIOD*100);
DXL.WriteByte(1, OPERATING_MODE, 3, 0);
break; }
case
0x30:
// "0" key to set in Torque Mode
DXL.WriteByte(1, OPERATING_MODE, 0, 0);
usleep(CONTROL_PERIOD*100);
DXL.WriteByte(1, TORQUE_ENABLE, 1, 0);
usleep(CONTROL_PERIOD*100);
// Goal Torque (604) size is 2 bytes (a
// WriteWord is the appropriate function
DXL.WriteWord(1, GOAL_TORQUE, GoalTorque, &error);
usleep(CONTROL_PERIOD*200);
// after an arbitrary period (i.e. 2 secs in this case)
// output onscreen
// Present Current (621) size is 2 bytes (a word)
// ReadWord is the appropriate function
result = DXL.ReadWord(1, PRESENT_CURRENT, &val1, &error);
if(result ==
break; }
case
0x31:
// "1" key to set in Wheel Mode
DXL.WriteByte(1, OPERATING_MODE, 1, 0);
usleep(CONTROL_PERIOD*100);
DXL.WriteByte(1, TORQUE_ENABLE, 1, 0);
usleep(CONTROL_PERIOD*100);
// Goal Velocity (600) size is 4 bytes (a double-word)
// WriteDWord is the appropriate function
DXL.WriteDWord(1, GOAL_VELOCITY, GoalVel, &error);
usleep(CONTROL_PERIOD*200);
// after an arbitrary period (i.e. 2 secs in this case)
// output onscreen
// use simply switch loop to change between modes
// ESC key to set to default settings
COMM_RXSUCCESS)
printf( "%d\n", val1);
0);
word)/
Page 125 / 139
Need help?
Do you have a question about the Dynamixel Pro and is the answer not in the manual?
Questions and answers