How to connect wheel encoders to 3pi? (pins, timer)

I consider using wheel encoders with my line-follower robot which is designed very similar to 3pi.
Which timer and pins would you use for the encoders if you were upgrading 3pi?

It would be nice to see some encoder-related functions in the next version of Pololu AVR library.
PS: Thank you for developing the new encoders https://www.pololu.com/catalog/product/1217. I already have motors wheels, and brackets, so the encoders would fit nicely. They are already on my wish list.

Hello.

I’m glad to hear you’re excited about our new encoders! We definitely plan on adding encoder support to the Pololu AVR library, along with a more detailed encoder user’s guide.

The 3pi robot is physically incompatible with the encoders, but if you’re building your own 3pi-like robot, there are a few things worth noting. The first is that the encoders change the plane of the motors by the PCB thickness. The second is that there are not a lot of free I/O lines on the 3pi, and all of the timers are being used by the on-board hardware (timers 0 and 2 are used by the motors, and timer 1 is used by the buzzer). To add two encoders, you would probably need to give up the LCD and use the three LCD control lines as encoder inputs, perhaps along with pin PC5. You would probably also need to use timer 1, which means giving up the buzzer, though you might be able to get by with clever use of one of the motor timers (this is how we time the QTR-RC sensors). Because of this, you might consider using a second microcontroller to process the encoder outputs and relay this information to your robot serially.

You can set up pin-change interrupts on any of the ATmega168 digital I/O lines, which can be useful in capturing every encoder transition as it happens, or you can poll the state of the encoder outputs if you have a timer interrupt that happens approximately once per millisecond (or slower if your wheels aren’t turning very fast). Paul has already written some AVR code for the encoders, so perhaps he will have some additional (or more specific) thoughs on how to best use them.

- Ben

BEn, Thank you for the reply. I killed my LCD so now I do have legs for the encodes. Will try your advices at the next upgrade of my robot.

What did you do to kill your LCD?

I think I shorted some pins and sent battery voltage to data pins. Not sure though.