Quick Start for Dynamixel Pro v1.00b
ii. Operating Dynamixel PRO using C programming language.
-
As explained in 1.1, Dynamixel PRO's Control Table's Goal Position address is
562. Also, Goal Position is assigned 4 bytes of memory.
-
Therefore, a function called dxl_write_dword function controls Goal position.
(See 2.4.3)
-
The program's entire source is shown below.
main.cpp
#include
<stdio.h>
#include
<conio.h>
#include
"dynamixel.h"
#define
COM_PORT_NUM
#define
BAUD_RATE_NUM
#define
P_TORQUE_ENABLE
#define
P_GOAL_POSITION
#define
ID
int
main(void)
{
SerialPort sp = {0,0,0,0,0};
SerialPort *Port = &sp;
//Open the port of USB2DXL
if(dxl_initialize(Port, COM_PORT_NUM, BAUD_RATE_NUM) == COMM_RXSUCCESS )
printf("Succeed to open
else
{
printf(
printf(
_getch();
return
}
int
Result, ErrorStatus;
//Torque ON
printf(
"Torque On...\n"
Result = dxl_write_byte(Port, ID, P_TORQUE_ENABLE, 1, &ErrorStatus);
if( Result != COMM_RXSUCCESS )
{
printf(
printf(
_getch();
return
}
int
Goal_Pos1 = 100000, Goal_Pos2 = -100000;
17
1
562
596
//Address of Goal Position in Control Table
1
//ID of Dynamixel PRO you use
USB2Dynamixel!\n");
"Failed to open USB2Dynamixel!\n"
"Press any key to terminate...\n"
0;
);
"Failed to write!\n"
);
"Press any key to terminate...\n"
0;
//Comport Number of USB2DXL
//Baudrate Number of Dynamixel PRO. 1 is 57600 bps
//Address of Torque Enable in Control Table
);
);
);
Page 45 / 139
Need help?
Do you have a question about the Dynamixel Pro and is the answer not in the manual?
Questions and answers