Tuning controller gains can be difficult, what general strategies work well to get a stable system that converges to the right solution?
For small, low torque motors with little or no gearing, one procedure you can use to get a good baseline tune is to probe it's response to a disturbance.

To tune a PID use the following steps:


Set all gains to zero. 
Increase the P gain until the response to a disturbance is steady oscillation. 
Increase the D gain until the the oscillations go away (i.e. it's critically damped). 
Repeat steps 2 and 3 until increasing the D gain does not stop the oscillations.
Set P and D to the last stable values. 
Increase the I gain until it brings you to the setpoint with the number of oscillations desired (normally zero but a quicker response can be had if you don't mind a couple oscillations of overshoot)


What disturbance you use depends on the mechanism the controller is attached to. Normally moving the mechanism by hand away from the setpoint and letting go is enough. If the oscillations grow bigger and bigger then you need to reduce the P gain.

If you set the D gain too high the system will begin to chatter (vibrate at a higher frequency than the P gain oscillations). If this happens, reduce the D gain until it stops. 

I believe this technique has a name. I'll put it here when I find it.
