Boat autopilot - PID not centralizing rudder.

Tobbera:
Another thing, very visible in Test run 2 & 3, is that the PID output value starts off way out of centre. Its starts at 16,62 and keeps that value until there is a error to correct. The problem is that if it is starting off with a value like that (full rudder port) there is definitely going to be an error to correct, and the boat is going to take a proper detour before its on the right course again. I need to wind up the PID controller output to about 90 degrees before the PID Output is somewhat centered and can be mechanically connected to the rudder tiller. Is there anyway of making the Output start off in the middle of its extremes. Or I might need a wrapper around it to wind it up.

Yes, there is! :slight_smile: Just found out how. Set the output limits to start at a negative value, and end at a positive. Then map the output to 0-180 degrees for the servo. Like this:

myPID.SetOutputLimits(-90, 90);
myPID.Compute();
PIDOutputTemp = map(PIDOutput, -90, 90, 0, 180);
RudderServo.write(PIDOutputTemp);

Source: Arduino PID Library - News - Arduino Forum