measure linear speed from optic rotary encoder

Hi all,

I have simple project that must measured linear speed for wheel diameter 40 cm from optic rotary encoder that has two signals(A and B) and gives 60 pulses per round (from its datasheet).

what is the main equation and how can i write the code?

thank you ;)

linear speed = 2*PI*(wheel radius)*rpm in units of distance traveled per minute.

And of course you only need to use one of the encoder channels to read rpm if direction determination is not required or an issue. Keep the ISR short and sweet as latency time will set a upper limit of how fast an rpm you can determine. Another way is using a single 'speed sensor' rather then a 2 channel encoder and you have to just keep up with the time of one pulse per revolution rather then the XX steps per revolution that your encoder uses.

A hall sensor sensing a wheel mounted magnet is useful for this kind of measurement.


can you help me with simple RPM encoder reader code

Google helps those who help themselves: