Hello - I am trying to use a 676 to control a servo motor via a pot using RCTIME. I have done this many times with other PICs with no problem but for some reason I can't get it to work with the 676. I have poured over the posts and the datasheet and still no results. When I power up the PIC, the servo runs over full clock-wise and pegs out. Any ideas on what I am missing? Thanks! Atom058
Here is the code:
@ DEVICE pic16F676, INTRC_OSC_NOCLKOUT
CMCON = 7
ANSEL = %00000000 ' Turn off analog input
TRISC = %00000001
RCVal var Word
Posit var word
PotIn var PORTC.0
Servo var PORTC.3
low servo
MoveServo:
gosub ReadPot
posit = rcval + 350
PULSOUT Servo, posit ' move the servo
pause 25
goto MoveServo
ReadPot:
high potin
pause 1
rctime potin, 1, rcval
return
End
Bookmarks