I've tried all the tips you guys gave, and have also been trying any and all PicBasic servo control code I could find on the net, but something is still not right. I've tried four different servos that I know to be functional. I've tried a 16F690 and a 16F628A, with the internal oscillator and with an external 4MHz crystal. I've tried changing the pulsewidths and pauses to every reasonable and many unreasonable numbers. I've switched breadboards. I'm shopping around for a goat to sacrifice to the PIC.
Here's what I'm trying to use now, with a 16F628a:
trisb = 0
cont var byte
cont = 0
led var PORTB.1
hither:
low led
for cont = 0 to 50
pulsout PORTB.0,110
pause 18
next cont
goto yon
yon:
high led
for cont = 0 to 50
pulsout PORTB.0,190
pause 18
next cont
goto hither
It is a slightly modified version of some code from the rentron site, which was meant for a 16F84. My include file (not the whole thing of course) looks like:
device pic16F628A, xt_osc, wdt_on, mclr_on, lvp_off, protect_off
My LED does flash convincingly, but still my servo heads to one extreme and stays there. This is keeping me awake at night now. What mistakes might I still be making? Does anyone know of an example of a working servo controller written in PicBasic, including a circuit diagram and not intended for a 16F84? I just need something functional to build on.
You're probably sick of this thread by now, but any help would be appreciated.
Bookmarks