See Kevin Watson's code on quadrature encoders
http://www.kevin.org/frc/. FAQ at
http://kevin.org/frc/encoder/. Nice in-depth description at
http://www.chiefdelphi.com/media/papers/1490. A ChiefDelphi thread on encoders at
http://www.chiefdelphi.com/forums/sh...ad.php?t=48756. Wikipedia article
http://en.wikipedia.org/wiki/Rotary_encoder.
Quite simple to use. All digital input. Connect Phase A signal wire to an interrupt pin, Phase B signal wire to a Digital Input pin. Configure the interrupt and catch it in user_routines_fast.c. Phase A pulses on each tick, Phase B pulses earlier or later than Phase A, depending on direction. When interrupt occurs, interrupt service routine checks the Digital Input for HI or LO and that gives you the direction.
You don't get any counts out - you have to count 'em yourself.
There are other types of encoders (absolute positioning?) that may provide encoded information about the precision position, without you having to count.
The trickiest thing about them is probably choosing one that is suitable and determining the method of attaching to your robot.