Servo motors are controlled by PWM (Pulse Width Module). most of Servo motors works on 50Hz in frequency. The time duration for PWM can be calculated as below:
Time=1/Frequency
T=1/50
T=20ms
So to control a servo motor we need to have a 50Hz or 20ms PWM.
After setting the duration we need to set the necessary duty cycle of PWM. This duty cycle will control the position of the servo motor.
For example the servo that I use works in 50Hz and duty cycle between 0.5ms to 1.5ms. lets see what is that means.
For example we want to have a PWM with 50Hz duration and 50% duty cycle. That means we need signal duration of 20ms which is 10ms on and 10ms off.
Now my servo motor need 50Hz and a range between 0.5ms for zero degrees and 1.5ms for 180 degrees.
Any other position that we want to reach has a linear relation to these numbers. if you put your desired position into this equation you will get the duty cycle in ms;
DutyCycle=((1/180)*degree)+0.5
in the next post I will explain how to use a timer and generate PWM in MSP430