Thanks for the suggestions!. It worked out Sai ----- Original Message ----- From: Bob Ammerman To: Microcontroller discussion list - Public. Cc:=20 Sent: Friday, February 10, 2012 10:54 AM Subject: Re: [PIC] Servo motor speed control using PIC12F675 You will have to change the pulse width gradually to move from end-to-end a= t=20 a given rate. If you just change the pulse width instantly the servo will operate at max= =20 speed to the new position. -- Bob Ammerman RAm Systems ----- Original Message -----=20 From: "Tamas Rudnai" To: "Microcontroller discussion list - Public." Sent: Friday, February 10, 2012 9:52 AM Subject: Re: [PIC] Servo motor speed control using PIC12F675 > You need to introduce a variable for the delay for this, and slowly > increase/decrease it as needed and feed your control loop with that. > > And because of this you need a higher resolution of delay than the > __delay_ms() function. I have suggested this only for testing purposes. > > if(GPIO & (1<<3)) > { >=A0 =A0 inc =3D 1; > } > else > { >=A0 =A0 inc =3D -1; > } > > // add the increment here > towait +=3D inc; > // make sure you are limiting the value > if ( towait < 1000) towait =3D 1000; > if ( towait > 2000) towait =3D 2000; > > GPIO |=3D(1<<2); > __delay_us(towait); > GPIO &=3D~(1<<2); > > Something like that... If you need even more resolution then you might=20 > need > to calculate with floats... > > Tamas > > > > On 10 February 2012 14:08, yamanoor sairam wrote: > >> Hello All, >> I am controlling a servo motor using the PIC12F675. The servo rotates in >> opposite directions. I am controlling the servo as follows: >> >> >> if(GPIO & (1<<3)) >> { >> GPIO |=3D(1<<2); >>=A0 __delay_ms(1); >>=A0 GPIO &=3D~(1<<2); >> } >>=A0 else >> { >>=A0 GPIO |=3D(1<<2); >>=A0 __delay_ms(2); >>=A0 GPIO &=3D~(1<<2); >>=A0 } >>=A0 __delay_ms(18); >> I would like to control the rate at which the servo reaches the opposite >> ends. I tried looking for articles related to speed control, I found it= =20 >> to >> be too complicated to control the rate of sweep. I am looking for >> suggestions for the same. Increasing the delay=A0 did not help me contro= l=20 >> the >> speeds. I am planning to control the speed using a potentiometer. Any >> suggestions would be helpful. >> >> Sai >> >> -- >> http://www.piclist.com PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist >> > > > > --=20 > int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; > printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", > q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } > --=20 > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist=20 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .