An Electronic Counter Project for Digital and Analog Signals, including Quadrature Encoders
http://www.robotroom.com/Counter.html