How can I regulate motor RPMs in software?

I'm trying to control some 24 volt DC brush motors using Pololu Trex Jr's. I don't have any inputs into the Ardunio to detect the motor RPM, but I need to be able to set specific RPMs from the Ardunio. So I can control the voltage sent to the motor, but I'm having issues overcoming the inertia/friction that is needed to get the wheels the motors to start turning at all.

So if X volts are required to get the wheel turning at all, once the wheel is turning, it is going much faster than some of the speeds I want to run it at. So if X volts gets it running at say 100 RPM, if I want it to go at 50 RPM, I have to first give it X volts, then drop the voltage to something less than X (call it Y). And if I just give it Y volts in the first place, the motor doesn't turn at all.

I know this is a well understood aspect of controlling DC motors, but what I don't know is if there are standard equations or algorithms available to get a motor to run at specific speeds in a non-feedback system, or if I need to just give it a higher voltage to start it turning and then drop the voltage, determining what voltages to get what RPMs through trial and error...

Or should I switch to motor controllers that have current feedback? Maybe that would be easier?

Can anyone point me in the right direction on this?


You won't have satisfactory results trying to compensate for friction in an open loop controller - the best you can do is try a pulse of higher drive for a moment whenever starting at a low speed, but friction is variable and cussed, you need closed loop control really.

Yikes. The more I learn in this project, the more I realize I don't know. So what is the math for this? Can I assume that speed is linearly proportional to voltage, but for lower speeds I need to first pulse the motor briefly with a higher voltage, to get it moving, and then reduce the voltage to the voltage that corresponds with the speed I'm trying to achieve?

I don't think you can assume anything: friction is indeed "cussed" as MarkT says, which is why he suggests closed-loop control. And your external load is unlikely to be 100% known.

That means you need a sensor of some description to suss the actual speed, and then some code to get that to home in on the required speed, according to some algorithm or other.

So you may want to check the Playground for terms like rpm, encoder, pid, hall effect.

Thanks, but I don’t have the option to add any kind of sensor. I’m building a controller for people to use to program drills from their iPhone to control a ball machine used for ping pong practice. The machine is what it is, I can’t add any sensors to it. The existing controller that comes with it is able to control the motor speeds without any sensors, so this must be doable!

Luckily, the external load is 100% known at least. I guess I’ll try pulsing the motors with a higher voltage to get the wheels moving at low speed. If anyone has any other thoughts or suggestions, please let me know.


Your best bet is to look at PWM control - this gives much closer to 100% torque than does trying to pulse the motor voltage on and off. You may still have to look at a higher duty cycle to overcome initial inertia.

Surely you would be able to make some form of drop in hall effect sensor to measure the actual RPM - or some other portion of the mechanism that has a relatiionship to RPM.

Although i have not seen the unit you are talking about - i would assume it is somewhat similar to a cricket ball/tennis ball/baseball launcher ? and would work on a set of rotating wheels that accelerated the ball along a pseudo track ?


Yes, I am using PWM to control motor speed.

I can't add anything physically to the ball machine other than my controller. The motor drivers I'm using do have current sensing.

So from the equations here, it follows that I could calculate motor speed from current and input voltage, if I knew the motor's resistance. Which I don't. Ugh. I don't know the specs on these motors. (I actually started a thread on that a while back.)

So, ... what if I measured the motor resistance R using my voltmeter, connecting it to the motor leads? Could I then plug that into the equation Speed = (Vs-IR)/k (where k is the motor's constant)


Seems like that could work!


The existing controller that comes with it is able to control the motor speeds without any sensors, so this must be doable!

Can you post a picture of the existing controller and the motor, along with model numbers if possible.
The fact that their is no starting problems with this controller could be a clue to how we fix it with problem with the pololu unit.

Tom… :slight_smile:
Merry Christmas…


If you know I and can measure the motors R [u]accurately[/u] then this equation works fairly well.

dc motor speed = V - IR

R ( motor armature resistance ) is to be considered a constant I is the Armature Current V is the applied voltage or your pulse equiv.

IR = Armature Current multiplied by Resistance of the Armature winding

NOTE:- Excessive compensation of IR can cause overcompensation and may tend to increase the speed as the load increases... you could then end up with a runaway condition...this is not desired.

Here's a method of getting a fair approx of the motors armature resistance.

Hi, there have been some PWM DC motor controllers that use the zero drive period between drive pulses to measure the back-emf of the motor. The back-emf is proportional to the motor speed. I'll check which copy of "Silicon Chip" magazine it was that published some model railway controllers, NOT DCC, that used this principle.

Tom.... :) try

If it isn't already too late, many of Pololu's small motors can be ordered with an encoder for an additional $20.

Having actual VELOCITY feedback is the preferred way to control motor speed.