I found the post from "Eriswerks" in this group on February 12th that described my problem exactly: my Futaba 3004 servo turns clockwise 90-180 degrees when pulsed by my PIC 16F84A (code attached below). I've selected pulse widths from 0-1000 counts, which is supposedly 0-10ms with my 4MHz crystal. I've also varied the low part of each pulse from 10 to 1800, which is supposed to be in milliseconds in the PICBasic Pro PULSOUT command. Regardless of these values the result is about the same: the servo rotates
90-180 degrees clockwise (viewed from the top) per set of cycles. I'd really appreciate any help. --BuddyHere's the latest version of my servo calibration routine with the shortest pulse widths I've tested (it's supposed to work with 100-200 counts per pulse but did not):
*************************************************************************** Include "modedefs.bas" ' Include serial modestrisa = %00000000 ' set porta to outputs trisb = %00000000 ' set portb to outputs
lcd var PORTA.3 'lcd signal on 16F84A pin 2 piezo var PORTB.4 left_led var PORTB.0 right_led var PORTB.1 servo var PORTB.7 'servo signal on 16F84A pin 13 baud con N2400 timer var Byte width var byte width_init var byte
high left_led ' turn on left LED low right_led ' turn off right LED
Serout lcd,baud,[254,1] ' clear lcd screen
pause 1000 ' give time to initialize lcd
Serout lcd,baud,[254,128,"- Servo cal -"] ' display program title on the LCD
Serout lcd,baud,[254,192,"Pulse: "] ' set up the LCD display
pause 5000 ' wait for 5 seconds
low left_led ' turn off left LED high right_led ' turn on right LED sound piezo,[125,50] low piezo
width_init = 0 ' set initial pulse width width = width_init ' initial pulse width variable low servo ' initialize servo pin
main:
Serout lcd,baud,[254,200,#width," "] ' display the pulse width in counts
for timer = 1 to 20 ' send pulses to servo pulsout servo,width pause 15 next timer
pause 4000
toggle left_led ' toggle left LED toggle right_led ' toggle right LED
if width < 100 then ' increase width through max then repeat width = width + 10 else width = width_init sound piezo,[125,50] low piezo endif
Goto main
end
**************************************************************************