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:
How it works? Please check on this video. 😉
|MD10C: +||Battery +ve|
|MD30C: –||Battery -ve|
|MD30C: A||Motor red/black wire|
|MD30C: B||Motor red/black wire|
|MD30C: GND||Maker UNO: GND|
|MD30C: PWM||Maker UNO: pin 10|
|MD30C: DIR||Maker 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|
This is sample code used in the video. Enjoy it!