What holiday ghosts can teach us about PID control (and ship autopilot systems)

Almost 200 years ago, Charles Dickens wrote A Christmas Carol. This timeless story is about the selfish, miserly Scrooge, who is visited by several ghosts throughout the night. The ghosts give him visions of Christmas past, present, and future, and haunted by what he sees, it gives Scrooge new perspective on life. He awakens, convinced to change the course of his life for the better.
Likewise, we can all benefit from the perspectives given to us from the past, what’s going on around us in the present, and anticipating what might happen in the future. Similarly, automatic control systems often work by using measurements over time. In this article, we’re going to explore how the visiting spirits in A Christmas Carol are similar to PID automatic control systems, like a ship’s autopilot. Of course, I’m not talking about creepy ghosts steering a ship for you so you can do other things, like go snack on holiday treats. Yet it’s the insight gained from estimating what’s happening in the past, present, and future that’s important. However, unlike Scrooge, you don’t want to make big changes – you want your autopilot system keeping your ship on course, whether you’re asleep or awake. Now, let’s get into the details of how PID and ship autopilot control are very much like the Ghosts of Charles Dickens’ imagination.
What is PID control?
PID control is a particular kind of feedback control algorithm. What this means is that it’s an algorithm that uses a measured difference from a desired set point to set a control action. This continuous difference, sometimes called an error signal, is the feedback that it gets to adjust the control action. Of course, the general idea is that control actions are taken to minimize error over time.
PID control is very simple to set up
You don’t need an intricate understanding of how the thing you are trying to control works. You need a way to measure an error signal and a way to take control action. One example is a ship autopilot. An autopilot might measure actual ship heading against a desired set point. The autopilot would then use the error signal from this to drive control action, in this case, the rudder angle, to make a correction over time. So, as the wind, current, and waves push a ship away from its course, the controller makes little automatic rudder actions to bring it back on track. Now, what does PID mean, more specifically?

PID means Proportional, Integral, and Derivative, and gives a hint about how it shapes feedback to control
This stems from three ways feedback from the error signal is used. Really, the algorithm is straightforward in that there are three coefficients used, sometimes referred to as gains: P, I, and D, and they are used in a specific way with the error signal to generate a specific control action. It’s not obvious what coefficients should be for every kind of application in advance. Sometimes you need a balance of all, and sometimes you only need one type of control. But now we will delve into the meaning of each facet of PID – Proportional Control, Integral Control, and Derivative Control – and its individual characteristics. And this is where our Christmas Ghosts come into the scene. The first Ghost who will visit is Integral Control.
The Ghost of Christmas Past is like Integral Control
This spirit showed Scrooge what happened in times gone by. In a similar way, Integral Control is about factoring in what’s happened in the past. More specifically, Integral Control is about adding up the error signal over time. This summation, also known as integration, of the error signal, is then multiplied by the I gain and added to the resulting control action. In this way, the past history of how much error the system has moved away from where it should be forms the basis of Integral Control.
Why is Integral Control important?
One of the most important characteristics of Integral Control is that it manages steady-state errors. Because it accumulates the error signal over time, it helps provide corrective action regardless of what is disturbing the system. In the case of a ship autopilot, this could be useful to maintain a heading or a specific course as the ship drifts off from currents or waves. The downside is that Integral Control tends to respond very slowly. And if you use an Integral gain that is too high, it can act like a heavy hand on the helm, where you constantly overshoot past your set point. So in many applications, a small amount of integral control is most beneficial. Now, while Integral Control is slow, the other facets of PID control are very quick. And this brings us to the second Christmas Carol spirit, the Ghost of Christmas Present.
The Ghost of Christmas Present is like Proportional Control
In A Christmas Carol, this ghost comes to show Scrooge what is happening in the world around him at that moment in time. Likewise, Proportional Control looks at what is happening now in the error signal and provides direct action. The Proportional Control gain is multiplied directly by the instantaneous value of the error signal, and this is added right into the control action.
Why is Proportional Control important?
Unlike Integral Control, Proportional Control is fast. You don’t need to wait for errors to build up over time for a control action response, as with Integral Control. Another advantage is that it is conceptually simple and generally acts as an intuitive, direct response to a disturbance. The greater the disturbance in moving the system away, the greater the counter-response in control action to bring it back to the set point. In the context of a ship autopilot, Proportional Control can rapidly compensate for rapid disturbances, such as those from ocean waves.
However, one downside to Proportional Control is that control action actually requires some error for any response. Also, small disturbances will result in small control actions. This makes it almost impossible for Proportional Control to ever eliminate steady state errors. For example, a slight drift from a mean wind or current on a ship hull could mean a few degrees of error in heading, but it doesn’t result in enough proportional rudder action change to correct. This is why it’s common to see Proportional and Integral Control, or PI Control, together in many applications, because Integral Control eliminates those small errors over time. This brings us to the final remaining facet of PID control – the D – and the final visit from our final Dickensian Ghosts.

The Ghost of Christmas Yet To Come is like Derivative Control
In the story, this chilling ghost brings Scrooge visions of the future. These unsettling visions show what might happen if Scrooge doesn’t change his ways. Yet these visions aren’t necessarily certain. Derivative Control works in a similar fashion. It anticipates what might happen to the error signal in the future, and gives an opportunity for change. The way this works is by tracking the rate of change, or derivative, of the error signal. This rate of change multiplied by the D gain coefficient is then added to the control action.
In ship systems, sometimes the Derivative gain coefficient shows up with the name velocity gain. For example, in an autopilot system, a heading velocity gain coefficient. This is exactly the same thing as Derivative Control for heading, because the rate of change of heading is heading velocity.
Why is the Derivative Control important?
The real advantage this provides is the ability to anticipate short-term changes. For example, wind gusts are dynamic and take some time to ramp up. As the wind starts to ramp up, the error signal of a ship accelerates as the vessel drifts from its heading. A derivative gain would sense this rate of change and amplify a rapid corrective response. This can make control action even faster compared to Proportional Control, because Derivative Control responds to the rate of change of error, while the actual error value itself may still be small. As the error builds up, Proportional Gain would help maintain continuous control as things stabilize.
However, there are downsides to Derivative Control. The derivative is a crude approximation of how the error is changing. It doesn’t give a complete picture of exactly what will happen next, and in complex systems it could be inaccurate. As such, an important downside to Derivative Control is that it can be sensitive to noise in the error signal. The Ghost of Christmas Yet To Come showed a vision of the future, but it was uncertain. Similarly, a noisy error signal, whether from measurements or the nature of disturbances, makes anticipating reliable control action uncertain. Systems that might be jittery or have turbulent disturbance effects could produce noisy and chaotic error signals, triggering noisy and messy Derivative Control action that makes things worse. Each facet of PID has advantages and disadvantages, and together or in different combinations – like P, PI, PD, or PID – can be a versatile and powerful system.
But how do you figure out what values to use for the PID gains?
It’s rarely obvious to know what values to use for the gains. For similar systems, there may often be guidelines for gain values to use or steps to tune the gains that rely on experience. For example, ships of a similar form, general displacement, and rudder size could use tuning rules to determine the gains or even just use similar PID gains.
However, another way to size the gains is through a trial and error approach, either with the real system or with a numerical model of the system. This is possible, for example, in ProteusDS, for setting up a ship and exploring autopilot or fin stabilizer PID control gains. For a basic vessel autopilot, the PID gains produce a control action on rudder angle. A simple scenario might be Proportional Control only, which reads the difference between ship heading and a desired set point as the error signal. The control action would then be the rudder angle set by the error between the desired heading and the actual heading multiplied by the P gain coefficient. Of course, we could improve this by adding a small amount of Integral Control to remove any steady state error, say from mean wind and current effects. And finally, in more severe sea states and wind conditions, it may be useful to incorporate Derivative Control if very tight requirements for maintaining ship course.
Of course, it’s wise to test, check, and recheck performance as much as possible to ensure you have good control behavior in a wide range of conditions. Any gains set too high can lead to control actions that are too aggressive, resulting in unfavorable behavior and even destabilizing performance.
Summary
We covered a few facets of PID control in the context of a ship autopilot, and now it’s time to summarize. The name PID comes from Proportional, Integral, and Derivative Control. This is a type of feedback control system, which measures the difference of a system from a desired set point, referred to as an error signal. It’s simple to use, because you only need to be able to measure something from your system without necessarily having a deep understanding of how it all works. As disturbances move the system away from the set point, a PID algorithm uses feedback from a measurement to take control action. Integral Control is slow, but inexorable, as it eliminates steady state error over time. Proportional Control acts immediately on the current value of the error signal, providing a simple, intuitive control action. And finally, Derivative Control anticipates changes by tracking the rate of change of the error signal and applying control action accordingly. Much like Scrooge, who wakes on Christmas morning with a desire to change, we have many choices in a PID framework for designing an autopilot control.
Next step
We covered generally how a simple PID automatic control autopilot system could work. Now see what it looks like to adjust the PID control gains in a specific scenario with the Generic Fishing Vessel in the video tutorial below. The video highlights how gains that are too high can cause aggressive motions and accelerations, and how you can quickly adjust them to get a smoother response. Click the image below to see the video on the DSA Ocean YouTube channel.

