I think I see what you're getting at, but if I've interpreted your question incorrectly, please clarify.
In the standard formulation of a PID controller, all three controllers (proportional, integral, derivative) use an error signal defined as
Code:
<error> = <set point> - <measured>
Using this with solely positive angle values will, as you say, cause the controller to never command the system past zero (assuming a perfect controller, anyway). To correct this, I would apply some sort of modulus to keep the error signal within -PI<=err<PI (radians, or -180<=err<180 degrees). In C code:
Code:
float computeError(float setPoint, float measurement) {
float err = setPoint - measurement;
err -= (2*M_PI) * rint(err / (2*M_PI));
return err;
}
Replace instances of (2*M_PI) with 360.0 for degrees. rint(...) rounds to nearest integer value.
The issue with this is you now have discontinuities in your error function, so you'll want to provide some sort of protection so your derivative term doesn't blow up (e.g. if your error signal jumps from -3.14 to +3.14, derr/dt ~= 6.28 / (0.0333 sec) = 188.4).
--Ryan
P.S. If someone needs helping converting into Java or LabVIEW (or Python or ...), let me know