# Does PWM control DC motor's speed or position? How to control DC Motor's position?

The type of motor that I am working with is a 12V brushed permanent magnet DC motor.

By following this video by Mr. Paul McWhorter I was able to control the speed of my DC motor by using the analogWrite() command of Arduino. I came to the conclusion that by changing the duty cycle of the PWM signal the average voltage across the motor could be changed, which would naturally change the speed of the motor. I had used my motor without any load inertia to be driven. No load torque was applied on the motor's shaft. I believe this is called the "no-load" running condition.

Now I am actually interested in position control of the motor shaft instead of simple speed control. Now this video by DroneBot Workshop suggests that the duty cycle of the PWM input signal to the motor controls motor shaft position. But won't the duty cycle of the PWM input signal actually control the speed of the motor instead of its position? I am quite confused regarding this.

EDIT : I am trying to carry out closed loop position control of a simple DC motor. The details of how I get the position reading of the motor shaft and by what kind of sensor are not relevant to this question. Assuming that I have a sensor signal that I can use as a feedback signal, how do I control my DC motor's position? Do I need to change the PWM duty cycle, or its frequency? I think changing duty cycle will affect the speed and to get the position I'll have to integrate the speed with respect to time. But then how to control the acceleration and deceleration phases? How do I even know how much time time the motor takes to accelerate/decelerate and what kind of speed vs time curve the motor follows during these phases?

I am purposefully using a simple DC motor here for learning purpose. I do not intend to use a servo or stepper motor. My goal is to do closed loop position control of a simple DC motor for a project.

EDIT 2 : The details of the closed loop control by PID or some method is not relevant to this question. What I am simply asking is what kind of input voltage signal do I need to give my motor for a desired position and which one of the above two videos should I follow.

• Is the second video talking about a servo? Because that's how you control a servo. May 26, 2022 at 15:04
• @Hearth In the second video a simple DC Motor is converted to a servo motor by using positional feedback. May 26, 2022 at 15:16
• Your edit turns this into an entirely different question, and you're now asking about control theory. That's a perfectly valid question, but should probably be a separate question. And you should mention how much you know about control theory already, like how familiar are you with Laplace-domain representations and machine modelling, do you know what the Park transform is, and so on. May 26, 2022 at 15:27
• The details of the closed-loop control very much do matter, because those details are how you control the motor's position. The only thing you can directly affect is the motor's torque, and your control system has to do the rest. May 26, 2022 at 15:36
• Think of when driving a car. Your arms are the motor that applies a turning force to the steering wheel. Your eyes determine if you are following the correct path. Your brain tells your arms when to turn and how fast. Once you’ve achieved the required path, your arms no longer turn the steering wheel.if you wander off the path, the arms apply a correction force. PWM is used to start/stop the motor. Note that for a servo system you need to control the motor direction as well. May 26, 2022 at 17:30