Skimask - Thanks for the info - this would explain why I have been able to do this task on other chips - I have always been using a 20 mHz resonator. This is the first time that I am not. I'll try this out and post my results.
Thanks again!
Skimask - Thanks for the info - this would explain why I have been able to do this task on other chips - I have always been using a 20 mHz resonator. This is the first time that I am not. I'll try this out and post my results.
Thanks again!
Skimask - Your info worked perfectly. My pot-controlled servo is now working just fine! Thanks for your help!!!
Here is my updated 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
'produce a value between 75 and 255 when running at 4 mhz
posit = 75 + rcval + (rcval / 2)
'produce a value between 350 and 950 when running at 20 mhz
'Posit = 350 + RCVAL
PULSOUT Servo, posit ' move the servo
pause 25
goto MoveServo
ReadPot:
'At 4 mhz, returns 0-120. At 20 mhz, returns 0-600
' with a 10K pot and 0.1 uf cap
high potin
pause 1
rctime potin, 1, rcval
return
End
I think I'd change your 'Pause 25' to something a bit lower.
Servo's want to be updated at about 50-60hz. You've got it set up for no more than 37hz update rate (pause 25 + 1ms minimum pot read + 1ms minimum pulsout).
I'd put it somewhere around Pause 14 or so...to give a minimum of 50hz.
Bookmarks