
Originally Posted by
Glenn
Well, it swings the servoarm to one endpoint, stops for a while, then all the way to the other endpoint (or near it anyway) and directly start to go back again and repeats everything.
Its not a very smooth movement but it looks ok.
Ok, that's good...at least you know stuff is working.
Now take the program and modify it to 'pull the endpoints' in a bit until you get to the actual endpoints.
When it 'stops for awhile', the program is probably trying to drive the servo past it's endpoints. The program goes to 0ms pulse width, but the servo can only actually drive to a 1ms pulse width, actually it'll probably drive farther than that, a lot farther, just not all the way to zero, or by the same token, won't drive all the way to 2.55 ms pulse width.
Code:
@ device HS_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
DEFINE OSC 4
temp var byte
main:
for temp = 100 to 200
pulsout portb.0, temp
pause 17 'try lower numbers until it starts acting even stupider than it's acting now
next temp
for temp = 200 to 100 step -1
pulsout portb.0, temp
pause 18 'try lower numbers until it starts acting even stupider than it's acting now
next temp
goto main
END
Decrease the 100 until it starts pausing at one end (meaning the PIC is trying to over-drive the servo) and increase the 200 until it starts pausing at the other end (again, meaning the PIC is trying to over-drive the servo in the other direction).
Bookmarks