Manual
53
{
servo[i][j].attach(servo_pin[i][j]);
delay(100);
}
}
while (1);
Here set the shaft of the each servo in the center position so as to minimize the error during the
installation. After servos are installed, run the calibration program to check whether all the servo
are in the center position. Activate ADJUST line and start the calibration:
/* Installation and Adjustment -----------------------------------------------
*/
//#define INSTALL //uncomment only this to install the robot
#define ADJUST //uncomment only this to adjust the servos
//#define VERIFY //uncomment only this to verify the adjustment
The program still waits in the loop in setup. Set a set of calibration coordinates manually. Then
obtain the real coordinates via the calibration chart provided in the kit and a ruler (also an acrylic
one included), and then modify the default real coordinates in the sketch.
const float real_site[4][3] = { { 115, 68, 42 }, { 105, 66, 60 },
{ 92, 70, 56 }, { 92, 70, 56 } };
Activate VERIFY and store the coordinates just obtained. Calculate the error and add it every
time the servo rotates, so the accuracy of each segment moving can be ensured.
When all the calibration above mentioned is done, comment the three lines under Installation
and Adjustment. After initialization, enter the loop. Here the servo service program runs in the
frequency of 50Hz.
During this period, the main function waits for the remote control commands, so the robot moves
accordingly under different command, while the service function is executed all the time,
constantly determines whether there is a new target position, and drives the servo to rotate to
the position by the functions cartesian_to_polar and polar_to_servo. Thus, when you push the
joystick of the remote control, the corresponding command sent can be executed.
After all the explanation, you may hopefully be able to solve the problem encountered in coding
and gain a lot from the kit now. Then try to make your own projects by modifying the code!
SunFounder