PDA

View Full Version : Servo Code problem



ALFRED
- 25th February 2006, 00:29
Hi, I recently wrote a program to control 12 servos. The program ran perfectly on my PIC16F84-A but when I tried to run it off my 16F88 it did not control all of the servos properly. The F88 caused some servos to move back and forth rapidly and others worked fine. I thought the problem could be in the fuse data but I looked through it and everything seemed to be in order (although I am not 100% sure). Does anyone have any ideas of what could be happening?
Thanks

P.S. My code looks something like this:

for i = 1 to 50

Low portb.0
Pulsout portb.0, 150

low bortb.2
pulsout portb.2, 150 ...

next i

btaylor
- 2nd March 2006, 03:30
I assume you are using a 4 MHz crystal where the PULSOUT unit time would be 10 uS per count giving 1500 uS for a centred servo.

Your code will loop extremely fast - way too fast for a servo thst is looking for a refresh rate around 50 per second.

Try putting
PAUSE 18
in youf FOR/NEXT I loop and it should centre the servo.

HTH
Brian