Servo motor

Discussion in 'The Projects Forum' started by sara--22, Jan 31, 2009.

  1. sara--22

    Thread Starter New Member

    Jan 31, 2009
    I'm a begining in the world of programation with PIC ...
    the first thing ,i have a PIC 16f876 and i want control my servo motor via pic ( PWM mode ) ... i have 3 buttons (stop-right-left) .
    when i put my finger in the button -right- ,how the pic know if i want to move the servo motor to right or left or i want stop it.
    i means what's the relation between the buttons and PWM mode ( output CCP1 )
    so i needs your helps .
  2. jpanhalt


    Jan 18, 2008
    If you are referring to RC model servos, they work on pulse width, which is similar to PWM, but not exactly the same. Most servos have mechanical stops and are designed for limited rotation, usually something like +/- 60° from center. The servo interprets a pulse width of about 1.5 mS as center. A shorter pulse width moves it one way; a longer pulse width moves it the other way. The range of pulse width is usually 1.0 to 2.0 mS, but some go higher and lower.

    The pulse is repeated about once every 20 mS (i.e., 50 Hz, "frame rate"), but model servos are quite tolerant to different repeat rates. That comes in handy with PIC controls using CCP1, as it can be hard to get to 50 Hz, if the PIC is operating at 4 MHz or higher. There is no way to know for sure how high a repeat rate you can use. I have used 80 to 120 Hz with no problems. If the frequency is too high, the servo will tell you, but will not be harmed.

    Thus, the button you push controls the pulse width generated, which tells the servo how far and in which direction it should rotate.