# [Moved] A problem : pic16f877a with servo motor

Status
Not open for further replies.

#### Ibrahim El Ayas

##### Newbie level 2
Alsalamo Alykom

hi

i want to make a servo motor rotates by an angle
the PWM code is

Code:
while (1)
{
portc.f0=1;

delay_us(2000);

portc.f0=0;
delay_us(18000);

}

you must change these values to gain an angle

i want to know for 1 degree how much Hi period does it take ...

Thank you ...

#### enjunear

Re: A problem : pic16f877a with servo motor

Look at the specs for your servo. The manufacturer should give you information regarding max/min pulse widths for max/min angles of rotation.

#### Ibrahim El Ayas

##### Newbie level 2

but my problem is that the delay function did not work .. i am thinking about timers ...

#### cubanflyer

##### Full Member level 5
What you need to do is take the normal rotation of a servo which is 180 degree.

Now take the pulse width for the rotation which is normally 1ms. ( the 2 ends are 1ms and 2ms).

So from the 1ms position to move 1 degree the pulse needs to (1*(1/180))+1ms = 1.006ms approx (1006us).

These calcs are based on a normal RC servo.

HTH

Status
Not open for further replies.