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.