I do this for the camera head on my ERP. Originally I had the problem of the head spassing out going all crazy n stuff.
I added in what I call 'control damping'. Basically only allowing it to rotate so much per program loop. I also added in a feature that allows me to control the damping with a variable.
The Stampy algorithm also has something similar, where the ramping up is controlled by a threshold value that anyone can tweak.