I have an optical shaft encoder that has rather big resolution - 2500 pulses per rotation. The problem is that false pulses get registered from environmental vibrations - if I shake it in my hand or slap a hand holding it with other hand - I get several pulses forth, then several back, then forth again - it looks like decaying sinusoide.
One way to deal with that is to count some amount of pulses that are in the same direction before registering "ok, the rotation has started".
Does anyone know some clever tricks to deal with this kind of problem in microcontroller code?