Running DC motor at constant speed by measuring current?

Hello. I want to run a DC motor at constant speed independent of its load.
The load varies over time and I cannot predict that.
Currently, I'm just using an Arduino RP2040 Connect and a L293D motor controller.

The problem is that the motor itself is in a very tiny spot that can hardly contain the motor itself. There just isn't enough room to place an encoder, a magnet or an infrared sensor there. I just have the two wires coming from the motor to work with.

From what I found, torque of a motor linearly depends on its current. So my idea was that I could measure the current on the output of the L293D and calculate the torque.

I found exactly zero hints that anyone has ever done anything like that. So I'm expecting that my idea will just not work. But where is my misconception? Do you have any alternative ideas that could work?

If the load varies then I would expect the current draw to vary too

Well, I don't think you could use constant current as a speed control.
The current drawn by a direct current (DC) motor depends not only on the rotational speed, but also on the load applied to the motor shaft.
When the motor is running without load (with only mechanical and electrical losses), the current depends on the rotational speed, but when the motor is under load, the required torque increases. To generate more torque, the motor must draw more current, since the electromagnetic torque is proportional to the current (T=k⋅I). If the load increases, the speed can decrease slightly, reducing the induced emf and increasing the current to compensate.

@docdoc: That's exactly what I'm talking about. So the idea is that the current gives an indication on how big the load currently is and my arduino can then adjust the PWM output accordingly. (Higher PWM for high loads, smaller PWM for small loads.)

I'm just being sceptical that it could be that easy, because nobody seems to have done something like that before.

The max current occurs when the motor is stalled. So no, controlling current does not control speed. Although there are obvious reasons why you might want to limit current.

Generally, to control speed, you need a speed feedback. A traditional method is to use Hall sensors on the shaft, or other methods such as encoders.

You are also right, people have been looking for the absolute cheapest way to control a motor. For certain applications, there is a way to remove the Hall sensors. You can use a flux estimator implemented in hardware to generate a pulse every rotation. However, this method is unreliable at low speed, so you would need to use an open loop control for startup.

You haven´t any misconception. You can do the speed control as you think. Of course, if you don't need much precision. As you say it would be better with a speed encoder but you can do it. So, you need to model the motor, i.e., calculate the k (Vel = Velocity = k * Vi) and the Ri (internal winding resistance). Then:
Vo = Vi + I * Ri ==> Vo = (Vel / k) + I * Ri

@cheyenne1: Thanks. Having a little precision is better than nothing I guess. Let's see if it will be within the tolerance I can handle.
@bobcousins: I'm typically having speeds around 10000 RPM (in words: ten thousand, according to the motor datasheet). So I'm not working with slow speeds I guess.

Without any feedback other than the current, I'm still convinced that you can't effectively control the rotating speed with a real and useful precision due to the factors to be taken in account: voltage and current (bond together for Ohm's law with internal motor resistance), physical load, and rotational speed. Even if you make some tests to try and interpolate current with physical load applied to the motor to get a constant speed, if the current increases it seems to me hard to calculate the required current to be reached to get a constant speed, or at least with a reasonable precision.
And remember DC motor speed is primarily dependent on voltage and can be affected by factors like load changes, friction, and temperature.

The only thing is to make tests, collect the different values, then write an algorithm to make the best interpolation possible and see if it works. Good luck!

If you are using PWM to control the speed, then you can measure the back EMF to determine the RPMs.

So I guess, you @cheyenne1 are the optimist here and you @docdoc are the pessimist. I would say, let's try it.
As for the voltage source: I could actually put a volatage regulator in front of the whole circuit if needed. For now, I'll just use my voltmeter to see if voltage drops or increases significantly over time.

@jim-p: Thank's for your advice, but as I said, the motor is in a tiny spot. There are only the wires coming from the motor and the motor itself is about 10 centimeters away from the rest of the circuit. So I doubt that back EMF could be measured over this distance.

Why do you doubt that?
The RPMs will be directly proportional to the back EMF
10cm is not a long distance.

Rather than measure the current that the motor draws, a better method might be as follows:

  • Briefly stop powering the motor.
  • Read the voltage that the motor is generating. This should be proportional to the speed.
  • Re-power the motor.
  • Take appropriate action to adjust the speed.

@JohnLincoln: Interesting idea, thanks.

@jim-p: Correct me if I'm wrong, but the idea behind back EMF is to measure the magnetic field that the motor produces, right? Magnetic fields go down with distance powered by three, so I doubt that this tiny (about 2 centimeter diameter) motor can produce a strong enough magnetic field that you can measure that with a cheap magnetometer.
Also: What if there is something like e.g. a microwave neaby? (Afaik, microwave ovens produce strong magnetic fields, right?)

No
@JohnLincoln idea is measuring back EMF the same as my idea. Back EMF is a voltage not a magnetic field.

arduno24,

jim-p and I are talking about the same thing. We just said it in a different way.

@jim-p: Ok, then ignore everything I said.

Are you using PWM to control the speed?

@jim-p: Yes, as I said, I'm using PWM signals that go into a L293D motor controller.

So when the PWM is off, you measure the voltage across the motor.

Yep! :smiling_face_with_sunglasses:

Obviously I hope you'll find a way to do it, but I'm still skeptical for my generic college-level physics knowledge, but I would be happy to be proven wrong (along with a scientific explanation and/ or laboratory date, to learn something new to me).