I’ve spent some time playing around the idea of using stepper or brushless motors as rotary encoders.
Stepper acts as a high impedance AC voltage source outputing sinusoidal waveform, it’s just a matter of apmlifying and converting this signal to a square wave:
R1 and R2 set up a reference voltage, R3 and C2 low-pass filter the signal from a motor - when this signal goes above the reference voltage, comparator changes it’s output producing a nice square wave.
The same effect can be obtained using a high gain noninverting op amp circuit, but as opamps are not really ment to be operated in saturation regions, I’ve decided to go with a comparator.
You have to do this to two phases of a stepper motor - one phase will lag the other - this way you can determine a direction of rotation.
Here is a piece of arduinized avr code that reads the encoder and drives a single digit 7 segment display: