Pwm from npn seen on anlog input

JohnRob:
I would suggest mechanical or optical such as encoders

Could you explain what advantages these would offer over a magnetic? I was thinking the magnetic would be a better option for this since it would be immune dust(optical) and immune to wear (mechanical).

Thank you