ROS Robot Control Board Guide - Controlling Multiple Serial Bus Servos
1. Preparation
1.1 Wiring Instructions
This tutorial uses the following hardware: seven LX-824HV high voltage serial bus servos, an ROS robot control board, an 11.1 V lithium battery, and a Type-C data cable. The Type-C data cable is used to connect the board to a computer for program flashing.
This tutorial applies to the full range of Hiwonder serial bus servos, except magnetic encoder motors. For different servo models, use the matching connection cables and a battery with the proper supply voltage for the servo.
The seven servos used in this tutorial have already been assigned IDs 1-7. Before following this tutorial, use a serial bus servo controller and the TTL / USB Debugging Board to set the servo IDs.
If the serial bus servo controller and TTL debugging board are not available, refer to the 1. RRC Bus Servo ID Writing and Source Code Analysis in the following directory: ROS Robot Control Board/3. RosRobot Controller Program Analysis/Lesson 8 RRC Bus Servo Control and Source Code Analysis .
2. Operating Steps
2.1 Modify the Source Code
- Find the
RosRobotControllerM4_serial_servo_run.rarcompressed package in the following path:ROS Robot Control Board/3. RosRobot Controller Program Analysis/Lesson 8 RRC Bus Servo Control and Source Code Analysis/RRC Bus Servo Control Routine. Extract the package to the computer desktop or to a project folder in the root directory of a drive.
- After extraction is complete, open the project folder. Follow the path shown below, then click the Keil startup file
RosRobotControllerM4.uvprojxto open the project.
- After the project opens, find the
Hiwonder/Systemdirectory in the Project panel on the left side of Keil, then openapp.c.
- After
app.copens, select the content on lines 32-45, then click the comment button in the Keil toolbar to comment out the selected code, as shown below.
- After commenting out the code, add the following code below
serial_servo_init();on line 30:
while(1)
{
// Move servos 1-7 to position 0. Move time: 1000 ms
serial_servo_set_position(&serial_servo_controller , 1 , 0 , 1000);
serial_servo_set_position(&serial_servo_controller , 2 , 0 , 1000);
serial_servo_set_position(&serial_servo_controller , 3 , 0 , 1000);
serial_servo_set_position(&serial_servo_controller , 4 , 0 , 1000);
serial_servo_set_position(&serial_servo_controller , 5 , 0 , 1000);
serial_servo_set_position(&serial_servo_controller , 6 , 0 , 1000);
serial_servo_set_position(&serial_servo_controller , 7 , 0 , 1000);
osDelay(1000);
// Move servos 1-7 to position 1000. Move time: 1000 ms
serial_servo_set_position(&serial_servo_controller , 1 , 1000 , 1000);
serial_servo_set_position(&serial_servo_controller , 2 , 1000 , 1000);
serial_servo_set_position(&serial_servo_controller , 3 , 1000 , 1000);
serial_servo_set_position(&serial_servo_controller , 4 , 1000 , 1000);
serial_servo_set_position(&serial_servo_controller , 5 , 1000 , 1000);
serial_servo_set_position(&serial_servo_controller , 6 , 1000 , 1000);
serial_servo_set_position(&serial_servo_controller , 7 , 1000 , 1000);
osDelay(1000);
}
This code is only a basic control example for multiple servos. To use other servo function calls, open the serial_servo.h and serial_servo.c files in the project folder for reference.
- After modifying the code, press
Ctrl+Sto save it. Then click the Compile button shown below. When compilation is complete, the Build Output window at the bottom displays0 errors, as shown below.
2.2 Flash the Program
- After the program has been compiled, open the project folder and search for
hexin the search box at the upper right, as shown below.
- Copy
RosRobotControllerM4.hexto the desktop. Open the ATK-XISP flashing tool, selectRosRobotControllerM4.hex, configure the settings as shown below, then click Start Programming to begin flashing. If a serial port error appears after clicking Start Programming, click Start Programming again to start flashing.