# PID auto tuning problem.

Hi. My boat (catamaran) is equipped with compass and GPS. I use a simple PID loop to control two motors. When I manage to set the appropriate Kp. it's ok. But sometimes when there's a big wave or wind, I have to manually increase the Kp to keep the boat going in a straight line. On the other hand, when I have too much Kp. the boat is too sensitive, how to auto-tune Kp? I found auto tuning methods, but they are very complicated, I only need to tune Kp.

Could you use multiple PIDs? Have one for light airs, one for a stiffer breeze and one for a gale. Switch between them based on what you're measuring for wind speed.

You might find it necessary to vary your PIDs based on apparent wind angle too of course.

This is the problem with PID - it has no idea what it is controlling. You might get better results building a system that does.

My problem is that either the boat is too little steer or too much, everything in relation to Kp. Maybe some sampling?

The odd thing is though, PID was designed after watching how helmsmen keep a boat on a constant heading. It should be just right for your purposes. How did you decide that the Kp component is the problem?

I have to manually increase the Kp to keep the boat going in a straight line.

PID just holds to a [u]predefined heading[/u].

PID alone cannot compensate if the boat is suddenly driven perpendicular to the heading by wind, waves or current. You have to redetermine the heading from the new position to fix that, and the resulting trajectory will not be a straight line.

Yes, I use predefined heading. I have another question. If the GPS heading shows a difference of, for example +10 degrees in relation to the compass (e.g. when it is incorrectly calibrated), it is better to give +10 to the PID value or setpoint?

Most people use PID to steer toward a setpoint of zero. The PID error value is (heading - bearing).

Be careful to correct error values exceeding 180 degrees.