Optical encoder

I'm building a homebrew optical encoder using one of those U-shaped photointerrupters. In the interests of keeping the circuit simple, I'm trying to run the photo transistor directly into the Arduino input without using an amp like an LM393. Seems like it works fine, but I worry about noise causing multiple counts. Anyone done this before? Is it okay?

Thanks!

Taiwanguy:
I'm trying to run the photo transistor directly into the Arduino input without using an amp like an LM393.

I can't imagine why you would need an amplifier. If your interrupter is working properly, it is either off or on.

Taiwanguy:
Seems like it works fine, but I worry about noise causing multiple counts. Anyone done this before? Is it okay?

What noise?

What you need, is hysteresis. But this is provided - see section 31.7.9 of the manual.

So long as you sample both A and B together and account for every edge, multiple
counts won't matter (assuming the channels are aligned correctly so they don't both
fluctuate at the same time). This is a fundamental problem you have to deal with anyway
if there is vibration in the system while it rotates slowly. Quadrature signals are unambiguous
if handled correctly.

Indeed. Works very well. I built a RPM sensor with a piece of plastic and my cordless drill. Pretty simple sketch. Measures RPM consistently as fast as my drill will go, 1600RPM, which is way beyond what I need for this project. And the "encoder wheel" I used had 3 holes, so it was about 80 pulses per second. The comment about slow speed vibration might be an issue like MarkT mentioned. I'm planning to build in a 1 rev marker pulse into this to continuously check for small miscounts and adjust if necessary. It will also have a home sensor on the device that will be verified every time it passes it. That should keep me in calibrated.

Thanks for the great feedback.