Encoder to velocity project

Hi everyone, I want to calculate the rotational velocity of dc motor using simulink as attached figure,I have polulu optical encoder and I can claculate the rotation number,But I need an algorithm to calculate the rotational velocoty.

Do you mean the angular velocity?

Circumference is 2Pir. Angular velocity is just unit distance per second. So how many pulses per revolution, what is the circumference? Circumference divided by pulses per revolution = distance per pulse. Measure the time per pulse, distance per pulse divided by time per pulse = distance/time.

Friend, there is two pulse input A and B, and each one has 12 pulse per each revolution. if A is before B then positive rotation. I can just calculate the rotation number, for calculating the angular velocity I need some good algorithm to add to this simulink, or if you can please send me an arduino platform code.

Hang on, maybe I'm confusing my terms.

Do you want to know how many degrees or radians per second, or distance per second (cm/s, in/s, etc)?

I have this pololu encoder: http://www.pololu.com/product/1217, and I want to measure DC motor RPM with this encoder. I need a code or algorithm for this, I try to calculate rpm with time delay block in matlab as shown in picture but it is not good, so I need somthing better. the code can be arduino or matlab based. thanks

OK, so what you want to calculate is RPM?

Don't use delay(). That is a horrible little command.


You may also use micros() in there for better accuracy at higher RPMs.

Have you tried just searching for
arduino tachometer
arduino rpm