Bukit Mertajam, Penang

Measuring DC Motor RPM Through Built-in Hall Sensor Encoder


When we deal with controlling motor speed, normally we just provide PWM and the motor will rotate accordingly to the voltage reach at motor terminal. To have a better speed controlling, we can monitor RPM. Revolutions per minute (abbreviated rpm, RPM, rev/min, r/min) is the number of turns in one minute. It is a standard unit of rotational speed or the frequency of rotation around a fixed axis.

To monitor RPM, we need to have a feedback or sensor to sense shaft rotation. Luckily, nowadays, there have many DC motor in the market comes with built-in hall sensor encoder attach to the motor shaft. There have a few options offered by Cytron Technologies:

  1. SPG30 With Encoder (Spur Gear)
  2. IG32 With Encoder (Planetary Gear)
  3. IG42 With Encoder (Planetary Gear)


How it works? Please check on this video.  😉

MD10C: +Battery +ve
MD30C: –Battery -ve
MD30C: AMotor red/black wire
MD30C: BMotor red/black wire
MD30C: PWMMaker UNO: pin 10
MD30C: DIRMaker UNO: pin 12
Motor brown wire (Hall sensor VCC)Maker UNO: 5V
Motor green wire (Hall sensor GND)Maker UNO: GND
Motor blue wire (Hall sensor A)Maker UNO: pin 3
Motor purple wire (Hall sensor B)Not connected

Sample Code

This is sample code used in the video. Enjoy it!

Thank you

Thank you for reading this tutorial and we hope it helps your project development. If you have any technical inquiry, please post at Cytron Technical Forum.

Related Posts

Comments (2)

hi. how to calculate distance from starter point to where the robot goes? what item that i need to use?

when i put a PWM value from serial monitor (0 to 255) for motorPwm then the values from encoder reading is not correct anymore.Can u discuss about this please .thank u

Leave a comment