I'm doing a project on arduino. I'm using a online simulator to design the circuit. I have a dc motor. How do we measure the rpm,speed at that rpm,distance covered by the motor in a given time. For example,

When motor starts, it starts rotating slowly and gradually increases it's RPM. When it covered a distance of 50 meters, the motor slows down and stops. After 10 seconds, the motor starts again at that 50 meter point and goes to 100 meters point and stops. Like this it stops for every 50m. For this we need to keep track of the distance travelled by motor and control it's speed.

How do I achieve the above working. I have tried alot and verified many tutorials but couldn't understand what to do. Please help me out. (The online simulator I'm using has a L293D motor driver, IR sensor and a ultrasonic distance sensor in it's component list.)

  • 3
    Put an encoder on the shaft; this way you will be able to "read" the rotational speed. Whis is linked to the vehicle by a constant. And integrating the speed (summing up) will give you the distance travelled.
    – frarugi87
    Jun 14, 2017 at 9:27
  • Rather than computing and integrating the speed (which amount to computing the integral of a derivative), you just have to count the pulses from the encoder. Jun 14, 2017 at 9:44
  • @EdgarBonet yes, in fact summing up the "frequencies" that you read is equivalent to counting the pulses... I tend to overcomplicate things ;)
    – frarugi87
    Jun 14, 2017 at 11:52

1 Answer 1


They key point here is to know the distance. The simplest way of finding that distance is to know how many times the wheel has completed an entire revolution. Multiply that number of revolutions by the circumference of your wheel and you have the distance the wheel has covered.

Depending on how precisely you want to measure that distance you may get away with a simple magnet and hall effect sensor. Place the magnet on the wheel, and locate the hall effect sensor so the magnet passes it close enough to trigger. Each pulse from the sensor is one rotation of the wheel.

You could increase the resolution by adding more magnets - 4 magnets set at 90° points around the wheel will give you a pulse for each quarter of a revolution (so multiply pulses by a quarter of your circumference).

If you want better resolution and accuracy you could attach a rotary encoder to the axle of the wheel. This, depending on the encoder, can give you far better resolution than simple magnets. Some will also give you the angle the wheel is at (not that such information would be of interest in this project).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.