question on two variable PID control

Hi everyone I hope you are having a fantastic day!

well, in my project I’m using a dc motor with an encoder that is connected to a timing belt and is moving laterally to position my drill bit. the user is supposed to enter the desired position and speed of the travel and my drill bit has to move to that point with the speed that the user entered. I searched relentlessly on the web and I came across something called PID control that could help me out, but there is one problem. all the PID examples I saw online were only on either position control or speed control. I was wondering if anyone has any idea how I can implement both speed and position control at the same time?

here is the motor I’m using: www.servocity.com/5202-series-yellow-jacket-planetary-gear-motor-50-9-1-ratio-117-rpm-3-3-5v-encoder

p.s. not that it matters much but I’m converting the position from cm to number of encoder counts and my speed is m/s.
Thanks

That motor has a built in encoder so why do you need PID ?

because my drill bit is heavy and the whole moving part gains momentum and it keeps moving even after I stop the motor, which makes the system extremely inaccurate. so I want to use a PID to make sure that my position is bang on. plus i want to have a constant speed throughout the movement.

You need TWO PIDs to do that. One controlling position, the other velocity. There are numerous ways to combine the two, depending on your performance requirements. Google dual-PID motor control, or dual-loop motor control.

Regards,
Ray L.

thanks ill check it out.