PID stands for "Proportional" "Integral" "Derivative"

The input to the algorithm is the error - the difference between the current measured value from your physical plant (say, position) and the desired value for that output.

The output of the control algorithm is the sum of three values - a value proportional to the magnitude of the error, a value proportional to the error integrated over time, and a value proportional to the rate of change (derivative) of the error.

Output = Kp* error + Ki * Integral(error) + Kd*derror/dt

where Kp, Ki and Kd are the "gains" for each of the three terms, Integral(error) is essentially the running sum of the error, and derror/dt is the rate of change of the error

When your error is large, Kp * error will be large as the error gets smaller, that part of the control output will get smaller. Proportional control tends to be quick, but does not give zero error.

As long as the error is non-zero, the Ki * Integral(error) will continue to update. The correction from this term will be a result of both the magnitude of the error and how long it has been present. This term will drive the steady state error to zero.

Any change in the error results in a output of Kd*derror/dt. For a practical use of this, the signal has to be properly filtered so it doesn't just react to signal noise. Personally, I would usually avoid implementing this part of the algorithm - but in this case I would make an exception.

Obviously, the output from a PI is not going to give you a constant velocity. The output from the controller will vary with the magnitude and time based behavior of the error.

Now, you have another problem. You want to measure position, but control via power /velocity. This means that the output of your motor (velocity) is integrated to get to the position that you are measuring. This extra integration in the system will tend to result in stability issues if you just blindly apply a P-I controller. This extra integration in the plant effectively makes the P term in your controller work like an integral term. The D term works more like P and the Integral term becomes essentially a double integral which is a problem for stability.

I would recommend implementing a simple P-D controller.

For tuning, I would use rules for a P-I controller applied to the D - P controller. Set the P gain = 0, and play with the D gain until it is on the edge of oscillating - then cut the D gain in half. Then play with the P gain until it is again just oscillating - then cut it in half. Done.