Closed-Loop Rotary Servo Actuators: PID and Optical Encoders

This article provides a comprehensive overview of how closed-loop rotary servo actuators achieve and maintain precise shaft positioning in modern automation electronics. It examines the foundational mechanics of closed-loop feedback systems, details the operational principles of optical encoders in translating physical rotation into digital data, and explains how Proportional-Integral-Derivative (PID) control algorithms process this data to correct positioning errors in real time. By understanding the synergy between physical sensors and mathematical algorithms, engineers and technicians can better appreciate how automated machinery achieves sub-millimeter accuracy under varying load conditions.

Understanding Closed-Loop Rotary Servo Actuators

In automation electronics, a rotary servo actuator is a mechanical device that translates electrical signals into precise rotational motion. Unlike open-loop systems, such as standard stepper motors that move based on assumed steps without verifying the physical outcome, closed-loop systems actively monitor their own output.

A closed-loop rotary servo actuator consists of a motor, a gear train, a feedback sensor, and a controller. The system continuously compares the desired target position (the command signal) with the actual physical position of the output shaft. If a discrepancy exists between the target and the actual position, the controller adjusts the electrical power sent to the motor until the error is eliminated.

The Role of Optical Encoders in Position Feedback

To know the exact position of the actuator’s shaft at any given millisecond, the system relies on an optical encoder. Mounted directly to the motor shaft or the final output shaft, the optical encoder acts as the eyes of the servo system, converting mechanical motion into electrical pulses.

The optical encoder operates using three primary components:

  • A Light Source: Typically an infrared LED that emits a steady beam of light.
  • A Code Disk: A circular disk attached to the rotating shaft, patterned with alternating opaque and transparent segments (lines or slots).
  • A Photodetector: A sensor positioned on the opposite side of the disk that detects the light passing through the transparent slots.

As the shaft rotates, the code disk spins, interrupting the light beam. The photodetector reads these interruptions as a series of high and low voltage pulses. The controller counts these pulses to determine the exact angle, speed, and direction of the shaft.

In automation, two main types of optical encoders are used:

  1. Incremental Encoders: These generate pulses only while the shaft is moving. They use two output channels (A and B) slightly offset from one another—a technique called quadrature encoding—to detect the direction of rotation. A third index channel provides a single pulse per revolution to establish a home reference point.
  2. Absolute Encoders: These feature complex, multi-track patterns on the code disk. Every distinct angle of the shaft corresponds to a unique digital binary code. Even if power is lost and restored, an absolute encoder immediately knows the exact position of the shaft without needing to return to a home position.

PID Control Algorithms Explained

Once the optical encoder provides the actual shaft position to the servo drive controller, the system must decide how much current to send to the motor to reach or maintain the desired position. This decision is governed by the PID (Proportional-Integral-Derivative) control algorithm.

The PID algorithm calculates the "error" (\(e\)), which is the mathematical difference between the Setpoint (desired position) and the Process Variable (actual position read by the encoder). It then applies three distinct mathematical terms to this error to generate a precise motor drive signal.

The Proportional (P) Term

The Proportional term produces an output value that is directly proportional to the current error value. If the shaft is far away from its target position, the P term applies a large amount of power to the motor to move it quickly. As the shaft gets closer to the target, the error decreases, and the P term reduces the power proportionally. However, relying solely on the P term often results in "steady-state error" (droop), where the motor lacks the final push needed to overcome friction and reach the exact target.

The Integral (I) Term

The Integral term addresses the limitations of the Proportional term by looking at the history of the error. It sums the instantaneous error over time. If a small steady-state error persists because a heavy load is pulling against the actuator shaft, the error accumulates over time. The I term responds to this accumulation by steadily increasing the power to the motor until the shaft reaches the exact target position and the error is completely reduced to zero.

The Derivative (D) Term

The Derivative term predicts future system behavior by calculating the rate of change of the error. When the actuator moves rapidly toward its target, momentum can cause the shaft to overshoot the desired position, leading to oscillation (hunting back and forth). The D term acts as a brake. If it detects that the error is shrinking very rapidly, it applies a counter-signal to slow the motor down just before it reaches the setpoint, ensuring a smooth, critically damped stop.

How the System Works Together in Real Time

In active automation electronics, the optical encoder and the PID loop operate in a continuous, high-speed cycle, often executing thousands of times per second.

  1. Command: The main programmable logic controller (PLC) commands the actuator to rotate to 90 degrees.
  2. Drive: The PID controller sees a massive error (target is 90, current position is 0). The Proportional term dominates, sending high current to the motor.
  3. Feedback: As the shaft accelerates, the optical encoder disk spins, sending rapid quadrature pulses back to the controller.
  4. Damping: The controller tracks the pulses and calculates that the shaft is approaching 90 degrees rapidly. The Derivative term intervenes, reducing motor current to prevent overshooting the 90-degree mark.
  5. Correction: The shaft stops at 89.8 degrees due to mechanical friction. The encoder reports this slight discrepancy. The Integral term accumulates this 0.2-degree error over a few milliseconds and boosts the motor current just enough to nudge the shaft to exactly 90.0 degrees.
  6. Holding: If an external force attempts to push the shaft out of position, the optical encoder immediately detects the microscopic movement, and the PID loop instantly applies counter-torque to hold the shaft rigid.