ROV Voyager II uses the PID (proportional integral derivative) controller to implement depth control underwater. The PID controller is an instrument used in industrial control applications to regulate temperature, flow, pressure, speed and other process variables. The PID controller uses a control loop feedback mechanism to control process variables and is the most accurate and stable controller.
The source code of Depth-Control PID controller is enhanced from the PID C++ implementation byBradley Snyder by adding more parameters to meet the requirement for ROV depth control. Please refer to this link for the Depth-Control source code of Voyager II. The shared code is integrated into ROV BSP, which is a driver running on the ROV Baroque Board.
The cockpit of Voyager II, which provides the user with an interface for tuning the parameter of the Depth-Control PID controller, can be found on the system setting of the main menus. The following is the window for tuning Voyager II PID controller.

The following is the description of parameters used in Depth-Control PID controller in Voyager II.

Tuning the PID controller is no easy job in every domain. There is more than one way to work out the parameters for the PID controller.
For Voyager II PID controller model, we suggest tuning Kp first.
The Kp Value will decide the Depth Ctl Dead zone range in which Voyager II the PID controller will activate ROV thrusters.
pwm = error * kp* factor
Let’s suppose that kp is 6, the factor is 1 and the pwm input range of the ESC Dead Zone is 22.
If the error is larger than 3.7cm or smaller than -3.7cm, the pwm signal will escape the ESC Dead Zone and the ROV thruster will start functioning. Then the Depth Ctl Dead Zone is error ±3.7cm when kp is 6.
On the other hand, if ROV moves 16 cm away from the target depth. If the pwm value is 1600 and the ESC midpoint is 1500, then the PID controller will generate another 100 pwm offset value for the thruster to push the ROV back. In some thruster system, 100 pwm will generate too much thruster power and cause the ROV to move up and down within the Depth Ctl Dead Zone and even lock out of it. That is why we also define the out_max and out_min parameters.

Kd is a derivate factor and should be tuned after Kp is decided.
Kd is related to how the ROV goes against the sudden force. The bigger the kd value is, the better it can withstand the in-coming force. However, if the kd value is too big, the ESC quality will be challenged. If sudden reverse rotation of the brushless motor happens, this will generate big currents that can impact the ESC and even cause it to shut down and restart.
The Kd value will also reduce the range of Depth Ctl Dead Zone since motion of the ROV will generate partial pwm value and trigger the thruster.
The Ki is an integration factor and is the last parameter to consider. The larger Ki could reduce the error between target depth and actual one when PID enter stable state. However, the integration has memory effect in which the previous behavior will affect the current PID calculation.

