Played a bit
Here is a working example on a 16F876
'==========================================
'P van Biljon
'Servo test program
'Text for two servo,s
'29 June 2006
'Pic 16F876-04
'Good for two Servo's
'==========================================
potCW1 var portc.0
potccw1 var portc.1
Servo1 var portc.2
potCW2 var portc.3
potccw2 var portc.4
Servo2 var portc.5
rcrt1 var word
rclf1 var word
Pos1 var word
rcrt2 var word
rclf2 var word
Pos2 var word
'==========================================
DEFINE LOADER_USED 1 ' If using bootloader to program pic
Init:
adcon1 = 7
trisc = %00000000
Main: gosub pot1
gosub pot2
pot1:
HIGH potcw1
HIGH potccw1
pause 5
rctime potcw1,1,rcrt1
rctime potccw1,1,rclf1
rcrt1 = rcrt1 */ $0068 max 250
rclf1 = rclf1 */ $0068 max 250
pos1 = rcrt1 - rclf1
pulsout servo1,(200 + pos1)
pause 5
return
Pot2:
HIGH potcw2
HIGH potccw2
Pause 5
rctime potcw2,1,rcrt2
rctime potccw2,1,rclf2
rcrt2 = rcrt2 */ $0068 max 250
rclf2 = rclf2 */ $0068 max 250
pos2 = rcrt2 - rclf2
pulsout servo2,(200 + pos2)
pause 5
goto main
with .1qF caps on pot connected to +5 Volts
Patrick
Bookmarks