Saturday, February 04, 2006

Servo info

Excellent link that describes how servos operate:
Servos are controlled by sending them a pulse of variable width. The control wire is used to send this pulse. The parameters for this pulse are that it has a minimum pulse, a maximum pulse, and a repetition rate. Given the rotation constraints of the servo, neutral is defined to be the position where the servo has exactly the same amount of potential rotation in the clockwise direction as it does in the counter clockwise direction. It is important to note that different servos will have different constraints on their rotation but they all have a neutral position, and that position is always around 1.5 milliseconds (ms).

The angle is determined by the duration of a pulse that is applied to the control wire. This is called Pulse width Modulation. The servo expects to see a pulse every 20 ms. The length of the pulse will determine how far the motor turns. For example, a 1.5 ms pulse will make the motor turn to the 90 degree position (neutral position).

When these servos are commanded to move they will move to the position and hold that position. If an external force pushes against the servo while the servo is holding a position, the servo will resist from moving out of that position. The maximum amount of force the servo can exert is the torque rating of the servo. Servos will not hold their position forever though; the position pulse must be repeated to instruct the servo to stay in position.


So the goal for using the HCS08 board is to control the servo operation programatically via a timer. So how to find the duty cycle of a given period that equates to the required PWM?

According to this site the servo expects to see a pulse every 20ms, in which case that would equate to 1/.02 = 50hz. So once the timer is configured for the appropriate frequency, the duty cycle can then be adjusted as needed to control the servo. A pulse with a duty cycle of 5% @ .02s would be 1ms, which would then move the servo in the counter clockwise position, according to the first site, at 0 degrees. Whereas if the duty cycle were 10%, 2ms, the servo would rotate the shaft to 180 degrees. Adjusting the duty to 7.5%, 1.5ms, would return the shaft to neutral position.

No comments: