Hi, just an update:

today i tried a code using polling (i think that is called), and i got better results but still not what i need, these es the part of the code i tried:
avance:
ban= encoder
high motor
av:
if ban<>encoder then
ban=encoder
counter= counter+1
endif
if counter= medida then motstop
goto av

motstop:
low motor
high brake
pause 300
low brake
contador= contador+ counter
counter=0
goto rutpal