Servo programming actually very easy, especially the standard servo, with a radius of 180-degree rotation. we only give 1 ms pulse to rotate the servo to the left, and 2 ms to play the servo to the right, or given a logic high or low to stop.
There are several ways to program a servo, here I will give one cypress servo ways to program in C using micro ATMega 8535.
Main Course (Program.C) will be processed as follows:
1. The first process is the initialization done PB0 as output.
2. The next process is to fill the data variable with a value of 200.
3. Having completed the data variables, the program will call the next procedure to putar_servo
servo motor drive in accordance with the variable data. In turn the servo procedures performed giving
pulse to the servo motor with pulse width high (logic ‘1 ‘) for 10? sx variable data as well as giving
Delay for 20 ms, pulse process is conducted as many as 75 times. If the credit ratings less
(eg only 10 times) the position of servo motor rotation is not possible to reach a position in accordance
pulse is given, such as servo position at full CCW (0 °) and then rotated full CW (180 °) then
possible rotation position only until half-cycle (90 °).
4. After that the program will reduce the value of the variable data with 20. If the results are not the same reduction
with a value of 20 then the program back to step number 3. If the result of a reduction equal to the value of 20
then refill data variable with a value of 200 then the program back to step number 3.
So in the example program above, the servo motor will start from the position of full CCW. Lntas motor rotates from a position of full
CCW to full CW position slowly (each 22.5 o). Once up to full CW position, servo motors back to
full CCW position, moving slowly to full CW position, so the program is repeated continuously.
Visit Robotic Technology for more about Robotic