Well I did a search and found
this. Unfortunately the so called 'datasheet' is next to useless. It also contains a link to code examples which don't exist
I'm sure someone will know where to find the relevant information, but Techsupplies aren't making it easy. In the mean time...
This line from the PDF: "The bottom of the worm gear (attached to the motor) must be carefully modified so that it is half black and half white in colour.", implies a simple single phase reflective sensor. I've no idea if it has built in amplification, hysteresis, and/or TTL signal levels. But assuming it does...
Interrupt might not be the best way to go. I expect the worm gear will be rotating quite fast, maybe 2000RPM (educated guess in the absence of data). That's a HIGH logic change followed by a LOW logic change, roughly every 500uS. A better strategy might be to begin a movement, count the pulses and stop the movement after a certain number of pulses. With such rapid pulses, you really don't want to be doing much else other than counting pulses. An interrupt every 500uS could mess up your main routine and at the very least, occasionally make your count data inaccurate or out-of-date. Especially if you use any blocking commands (Like SOUND) which do not get interrupted.
So something like this:
Code:
'Pseudocode
move_forward:
Forward motor1,motor2
do
pulsin encoder_pin,1,word_variable
inc position_counter
loop until position_counter>distance_to_travel or word_variable>50000
stop motor1,motor2
return
PULSIN is a blocking command which has a timeout of about half a second if no pulses are detected. It has a resolution (@4MHz) of 10uS, so should have no problem catching a 500uS pulse. The Word_variable will contain the duration of the pulse, but for this application that information is redundant. Before entering the subroutine, set the variable Distance_to_travel to the number of pulses you want for the distance you want. The "or word_variable>50000" will exit the loop if for some reason the motor stops turning before the count is up. Similar subroutines can be written for Backward, Left, Right, etc..
I've had to make many assumptions, and they could be wrong, but I think the idea is sound.