but when i input the value manually using code, i can get full 180 even more and could risk damaging the servo for over movement, but with potentiometer it only get about 90, i tried to use an on off switch to increment the value every cycle as the code below
#include <p18f458.inc>
ORG 0X00
GOTO main
ORG 0X08
RETFIE
ORG 0X18
RETFIE
CBLOCK 0X20
ServoPosH,ServoPosL,src1,src2,dst1,dst2,src1a,src2b
endc
main movlw 1
movwf src1a
movwf src2b
bsf TRISC,A
bcf PORTC,A
movlw 0x00
MOVWF OSCCON
bcf TRISB,3 ;make servo pin output
bcf LATB,3 ;Servo output off
movlw b'00001011' ;Special event trigger
movwf CCP1CON
movlw b'10100001' ;Timer 1 on with Pre=4
movwf T1CON
movlw 0x01 ;set servo to min position
movwf ServoPosH
movwf CCPR1H ;and set CCP initial value
movlw 0xf4
movwf ServoPosL
movwf CCPR1L
start btfss PIR1,CCP1IF ;wait for CCP interrupt bit
goto start
bcf LATB,3 ;end pulse
movlw 0x4e ;Off time = 20ms - Servo Time
movwf src1
movlw 0x20
movwf src2
movff ServoPosH,dst1
movff ServoPosL,dst2
call sub16
movff dst1,CCPR1H
movff dst2,CCPR1L
bcf PIR1,CCP1IF ;clear int flag
btfsc PORTC,0,A
call forward
btfsc PORTC,1,A
CALL reverse
movff src1a,src1
movff src2b,src2
movlw 0x01
movwf dst1
movlw 0xf4
movwf dst2
call add16
movff dst1,ServoPosH
movff dst2,ServoPosL
wait btfss PIR1,CCP1IF ;wait for int flag
goto wait
bsf LATB,3 ;start pulse
movff ServoPosH,CCPR1H ;Servo time in uS
movff ServoPosL,CCPR1L
bcf PIR1,CCP1IF ;clear int flag
goto start
sub16 movf src2,W
subwf dst2,F
movf src1,W
btfss STATUS,C
incf src1,W
subwf dst1,F
return
add16 movf src2,W
addwf dst2,F
movf src1,W
btfsc STATUS,C
incf src1,W
addwf dst1,F
return
forward incf src2b
btfsc STATUS,OV
incf src1a
return
reverse decf src1a
btfsc STATUS,Z
decf src2b
RETURN
end
BUT IT DOESN'T SEEMS TO WORK.....
I DON'T KNOW HOW TO POST THE CODE PROPERLY.....SORRY