I am using 8051 microcontroller and a dc motor.What to do if i have to rotate the motor at any fixed rpm. Let's say 120rpm.

And if it is possible by generating pwm,how to do the calculations for the relation between duty cycle and rpm?


4 Answers 4


It depends! In case you are going to attach either nothing or a constant load to your motor, one can calculate/approximate a relation between duty cycle and rpm by performing a series of input-output measurements or given the motor parameters $K_{mf}\ J \ L\ R\ b$ (see here) by analytical derivation.

The relation between the motor input voltage $V$ your supply voltage $V_\text{sup}$ and the duty-cycle $\nu \in [0,1]$ is approximately given as

$V = \nu\, V_{sup}$

Given the motors transfer-function (Angualr velocity $\omega$):

$\dfrac{\omega(s)}{V(s)} = \dfrac{K}{(J\,s+b)\,(L\,s+R)+K^2} $,

you can calculate the unit-step response of the motor as

$\lim_{s\rightarrow 0}\ \dfrac{1}{s} \dfrac{\omega(s)}{V(s)} \, s = \dfrac{K}{b\, R+K^2}$.

Thus your free running motor's verlocity should settle at approximately yield

$\omega = \dfrac{K}{b\, R+K^2}\, \nu \, V_{sup}$

However you must be lucky to be given precise motor parameters. Note due to modelling errors (neglecting many disturbances, heat, ...) this is only a rough approximation.

I recently did a comparison of a motor's step response to different input voltages (PWM controlled) and the theoretical step response of a modelled DC-Motor: Model vs. "real" motor

However, if the load or respectively the torque you're applying at the motor's shaft is not constant, you most certainly will have to implement a control loop, measuring the momentary rpm of the motor, calculating the deviation from the reference velocity and applying a duty-cycle that depends on this deviation. This can be done by using simple controler such as a PI-controler and is extensively discussed in literature. Tuning for the controller parameters can be done by "intelligent trying", approximative rules (Ziegler-Nichols) or given that you have the parameters of your motor, by numerical optimization techniques.


No, you cannot get an exact RPM from PWM, and you probably cannot even get a close RPM from PWM without a good model of the system.

As Jacen notes in their answer, the voltage constant gives motor RPM for a given terminal voltage for an unloaded motor, but, thanks to friction, the motor is always under load. Worse, because of viscous friction, the load varies with RPM.

You could try to guess rpm based on voltage (which you could get from PWM duty cycle) and current, but the issue there is that motor output power is a combination of frictional losses, load losses, and acceleration torque. That is, if you have half voltage and full current, you could be accelerating from a stop to half speed or you could be operating at half speed under heavy load. It is not possible to divine contributions due to load and acceleration from output power alone.

That said, you can command an exact RPM by simply adding an encoder to the motor. With feedback you can read RPM exactly and implement a simple PID controller to drive output RPM to whatever you desire.


In the real world, this cannot be calculated. You have three options, from best to worst:

  1. Measure the actual RPM in real time and make appropriate adjustments to the motor's input power (such as with a PID).
  2. Use a stepper motor, control the step rate, and assume that it will never stall.
  3. Allow "fixed RPM" to mean "bell curve of acceptable RPMs". Then, characterize the motor's commanded speed versus its actual speed, base your calculations on that, and be prepared to do it again when the motor's characteristics inevitably drift (due to load, lubrication, ambient temperature, etc) and cause your RPMs to move out of the acceptable range.

This would be possible if you had a perfect motor. The speed of a motor is basically fixed by the voltage you apply on it. More precisely, the speed is proportional to the back EMF of the motor, and, with no current, BEMF is equal to the voltage you apply on the motor.

No current means no torque, so no mechanical power. If you have current, you'll have loss in the wiring of your motor (which is resistive), on the iron core and in the rotor, due to magnetic hysteresis and Foucault currents in the rotor (iron losses).

So, on a real motor, you can't know the exact rotation speed from the voltage you apply on the motor.

One solution is to put a sensor on the rotor to measure the rotor speed, and put a speed regulator in your 8051.

There is a more sophisticated solution: if you know the resistance and the iron losses of your motor, by sensing the current in your motor, and knowing the voltage you apply, you can compute the actual speed, and then run you speed regulation.

And, finally, a more basic solution, very easier: if your load is always the same (for instance, you have a propeller on your motor), you can measure the speed at different voltage, and rebuild mathematically a conversion law from PWM to speed, and use it to command your motor. If your load is very small, or roughly constant, you may even assume that speed is proportional to the voltage.


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.