#picaxe 08m2
#no_data
pause 500
setfreq m8 ' use m8 for better pulsin resolution, must use PULSOUT since no M8 for SERVO

'FORUM EDIT
'RIGHT WHEEL MASTER, LEFT WHEEL SLAVE

'c.1 left servo output
'c.2 right servo output
'c.3 left encoder input
'c.4 right encoder input

'Left encoder increases clockwise (reverse) 6-216 
'Left servo pulses 320forward 305deadslowforward 300stop 292deadslowreverse 280reverse

do
pulsin 4,1,b1 ' read right encoder 6-216  pulsin decreases CCW (reverse right)
b0=222-b1     ' swap encoder values L/R to match 

pulsin 3,1,b1 '20-120  read left encoder  pulsin decreases CCW (forward left)

if b1>b0 then CCW ' if encoder value>goal then CCW

CW:

b2=b0-b1' error
w3=250
if b2<12 then let w3=260:endif 
if b2<5 then let w3=293:endif 
if b2<1 then let w3=300:endif
goto sendpulse

CCW:

b2=b1-b0' error
w3=350
if b2<12 then let w3=330:endif 
if b2<5 then let w3=307:endif  
if b2<1 then let w3=300:endif

sendpulse:pulsout 1,w3    '   send pulse to left servo

loop