PID Control for Position

PID position control with servo motor encoder and motion controller

PID Control for Position: The Position Loop Is Only the Outer Layer of a Servo System

Position control is used when a mechanical axis must move to a commanded location and remain there with acceptable accuracy, repeatability and settling time.

Typical examples include CNC axes, robots, indexing tables, packaging machinery, antenna drives and precision servo mechanisms.

A simplified feedback loop is:

Position command → Position feedback → Position error → Controller → Mechanical axis

That representation is useful, but a modern servo motor system normally contains several nested control layers.

A typical architecture is:

Position loop → Velocity reference

Velocity loop → Torque / current reference

Current loop → Motor voltage / PWM

The position controller normally does not drive the motor phases directly. It commands faster inner velocity and current or torque loops.

This layered architecture is fundamental to modern motion control.

What Is Position Error?

The basic relationship is:

Position error = Command position - Actual position

If the actual axis lags behind the command, the controller produces corrective action.

If the axis passes the target, the sign of the error reverses.

During motion, the difference between commanded and actual position is often called following error.

A small following error during acceleration or high-speed motion is not automatically a sensor fault.

The important question is whether the error remains inside the performance limits required by the machine.

Why Following Error Exists During Motion

A moving axis requires motor torque.

Torque requires motor current.

In a pure feedback architecture, some position or velocity error may have to appear before the control loops generate the required motor effort.

This is one reason high-performance servo systems do not depend entirely on feedback gain.

They also use feedforward.

Rockwell motion systems, for example, distinguish following error from static positioning error and provide dedicated velocity and acceleration feedforward functions to reduce dynamic lag.

The difference between feedback and feedforward control becomes very clear in servo positioning.

Velocity Feedforward Reduces Dynamic Position Lag

The motion controller already knows the velocity required by the commanded trajectory.

Instead of waiting for position error to develop before producing the required velocity reference, part of that known command can be sent forward directly.

A simplified structure becomes:

Position feedback correction + Command velocity feedforward → Velocity reference

This can reduce following error substantially during constant-speed motion.

It also means position gain does not have to be increased aggressively just to force the axis to keep up with the trajectory.

Acceleration Feedforward Handles the Torque Needed to Accelerate the Load

Acceleration requires torque.

For a rotating system, a simplified relationship is:

Torque ≈ Inertia × Angular acceleration

If the controller already knows the commanded acceleration, it can estimate part of the required motor effort before large feedback error appears.

Acceleration feedforward therefore helps the servo generate the required torque during acceleration and deceleration.

This creates a natural connection between position control and servo torque control.

Why the Inner Loops Must Be Faster

The current loop is normally the fastest servo layer.

The velocity loop operates outside it.

The position loop is slower again.

In simplified form:

Current-loop bandwidth > Velocity-loop bandwidth > Position-loop bandwidth

Yaskawa servo documentation explicitly separates position, speed and current loops and notes that the inner loops require the faster response.

If the position loop is made aggressive while the velocity loop cannot respond adequately, the resulting speed reference can oscillate and positioning performance can become worse rather than better.

This is why speed-loop control and current-loop control are directly relevant to position performance.

The Encoder Is Part of the Control System, Not Just a Position Display

An encoder provides feedback about motor or load motion.

Depending on the system, feedback may come from:

an incremental encoder,

an absolute encoder,

a resolver,

a linear scale,

or another position-measurement device.

The quality of the feedback affects:

position accuracy,

velocity estimation,

servo stiffness,

low-speed behaviour,

repeatability.

A controller cannot correct motion that its feedback system cannot resolve or observe.

Encoder Resolution Is Not the Same as Machine Accuracy

A motor encoder may provide millions of counts per revolution.

That does not mean the tool, carriage or workpiece is positioned to the equivalent mechanical accuracy.

Real machine accuracy is also affected by:

gearbox backlash,

ballscrew pitch error,

belt elasticity,

bearing clearance,

thermal expansion,

structural deflection.

High encoder resolution improves measurement capability, but it does not magically remove mechanical error between the motor and the load.

Motor-Side Feedback Versus Load-Side Feedback

A motor encoder measures the motor shaft.

If the machine contains a gearbox, long shaft, belt, ballscrew or flexible coupling, the actual load position can differ from the motor position.

For high-accuracy systems, a second sensor may be mounted directly on the load.

Examples include:

a linear scale on a machine axis,

a load-side rotary encoder,

a direct measuring system.

This allows the controller to observe mechanical error that is invisible to the motor encoder.

Such systems may use a dual-loop or load-side feedback architecture.

Backlash Appears Most Clearly During Direction Reversal

Backlash is mechanical free movement between motor-side motion and load-side motion.

When direction reverses, the motor may rotate while the load remains stationary until the mechanical clearance has been taken up.

The controller can interpret this temporary lack of load movement as additional position error.

Once the backlash closes, the stored command can create a sudden movement.

Siemens motion-control systems therefore provide dedicated backlash compensation functions for axes where feedback is taken on the motor side.

Backlash is a mechanical transmission problem. Increasing position gain does not remove the physical clearance.

What Does Position P Gain Do?

Position proportional gain determines how strongly the controller responds to a given position error.

If gain is too low, the axis can feel:

soft,

slow,

poorly resistant to external disturbance.

If gain is increased, the servo becomes stiffer and responds more strongly to error.

But excessive position gain can excite:

mechanical resonance,

velocity-loop oscillation,

overshoot,

servo hunting.

Position gain therefore has to be tuned together with the mechanical system and the inner velocity loop.

What Is Position Integral Gain For?

Integral action can remove a persistent static or quasi-static position error.

For example, an external constant load may require continuous motor torque.

A proportional-only loop may need a small position error to generate that effort.

Integral action can reduce that remaining error over time.

But position integral is not normally the best tool for removing high-speed following error.

For dynamic motion, velocity and acceleration feedforward are generally faster tools.

Too much integral can also create:

slow oscillation,

overshoot,

integral windup.

Derivative Does Not Predict the Future

A common simplified explanation says that derivative action “predicts where the axis will be”.

That is not technically accurate.

Derivative action responds to the rate of change of error or measurement.

In an appropriate plant this can add a damping effect.

But high-resolution position feedback can also contain:

quantization,

velocity-estimation noise,

mechanical vibration.

A derivative term can amplify those fast components.

Modern servo systems already obtain major damping and velocity-feedback effects from the inner velocity loop, so the user does not necessarily need a classic P+I+D structure in the outer position loop.

For the general role of these terms, see P, I and D components.

A Good Motion Profile Reduces the Work the Feedback Loop Must Do

A servo axis should not normally be commanded to jump from zero velocity to full speed instantaneously.

Motion controllers generate trajectories with defined:

velocity,

acceleration,

deceleration,

and sometimes jerk.

A good trajectory keeps motor torque demand inside the real capability of the system and reduces unnecessary mechanical excitation.

Good tuning cannot fully compensate for an impossible motion profile.

Why Jerk Matters

Jerk is the rate of change of acceleration.

An abrupt acceleration transition produces a rapid torque change.

On a flexible machine this can excite:

load oscillation,

structural resonance,

belt or coupling vibration.

Jerk-limited or S-curve trajectories can reduce this excitation and improve settling.

The connection with vibration control is direct.

Settling Time Can Matter More Than Raw Move Time

A machine may complete the commanded motion very quickly but then spend another 200 ms oscillating around the target.

For the actual production cycle, that axis is not finished.

The useful performance metric may therefore be:

move time + settling time

rather than move time alone.

This is why excessively aggressive position gain can make a theoretical move faster while making the complete machine cycle slower.

Load Inertia Changes the Servo

A lightly loaded axis and a heavily loaded axis are not the same mechanical plant.

Higher load inertia requires more torque for the same acceleration.

It can also change:

optimal servo gains,

resonant frequencies,

settling behaviour.

A system tuned with an empty fixture may therefore behave poorly with the real production payload.

This is especially important in robotic positioning, where effective inertia changes with both payload and robot configuration.

Autotuning Is a Starting Tool, Not a Mechanical Repair

Modern servo drives can estimate load inertia and automatically suggest or adapt servo gains.

This can greatly simplify commissioning.

However, autotuning cannot repair:

backlash,

a loose coupling,

poor gearbox condition,

an undersized motor,

incorrect encoder scaling.

Automatic tuning should therefore be verified with the real load and real motion profile.

Mechanical Resonance Sets a Real Limit on Position Gain

Increasing position and velocity-loop gain increases servo stiffness until the mechanical system becomes the limiting factor.

Flexible couplings, belts, gearboxes and long shafts can produce resonant modes.

Once the control bandwidth approaches a problematic mode, the axis may begin to:

whine,

vibrate,

overshoot,

produce current oscillation.

The correct solution may involve:

notch filtering,

vibration suppression,

reduced bandwidth,

mechanical improvement.

This is another reason position tuning should not be reduced to “increase Kp until the axis becomes fast”.

In-Position Window Defines When the Axis Is Finished

A real mechanical axis does not normally need mathematical zero error at every instant.

A controller may define a permitted position window around the target.

For example:

Target position ± 0.02 mm

combined with a sufficiently low velocity may be considered “in position”.

If the window is unrealistically narrow, the servo can continue making unnecessary microscopic corrections and increase machine settling time.

The tolerance should match the real manufacturing requirement.

Following-Error Limits Are Diagnostic Tools

If actual position falls too far behind command position, something may be wrong.

Possible causes include:

insufficient torque,

excessive acceleration,

mechanical binding,

incorrect feedback,

excessive load.

A motion system can therefore use a following-error limit to detect loss of expected axis performance.

Increasing the following-error limit only to stop the alarm can hide a real mechanical or servo problem.

Torque and Current Saturation Limit Position Performance

The position controller can request fast correction, but the motor has finite torque.

If the drive has already reached its torque or current limit, the axis cannot accelerate any harder.

Following error then increases even if the position-loop gain is high.

Possible causes include:

undersized motor,

high reflected inertia,

excessive commanded acceleration,

mechanical friction,

current limiting.

This is where PID troubleshooting must distinguish control gain from physical actuator capacity.

Homing and Absolute Position

An incremental-feedback axis may not know its absolute mechanical position after power-up.

A homing routine can establish the machine coordinate using:

a home switch,

encoder index,

mechanical reference.

An absolute encoder can retain position information across power cycles, depending on the system architecture.

But even with absolute feedback, mechanical commissioning still has to establish the correct relationship between encoder coordinates and real machine coordinates.

Software Limits Are Not Mechanical Safety Stops

A motion controller can define maximum and minimum allowable axis positions.

These software travel limits are useful for normal machine operation.

But they should not automatically be treated as the only protection against dangerous travel.

Depending on the machine risk, physical limit switches, safety-rated functions or mechanical stops may also be required.

Normal motion control and safety protection remain separate engineering functions.

What Does the PLC or Motion Controller Do?

A PLC or motion controller can manage:

position commands,

trajectory generation,

velocity and acceleration limits,

homing,

electronic gearing,

cam profiles,

machine interlocks.

But it normally leaves the fastest motor-current regulation to the servo drive.

The distinction between external machine control and the drive's internal loops is important in PID control with PLCs.

Real-Time Timing Matters in Coordinated Motion

Single-axis positioning can tolerate more timing variation than tightly synchronized multi-axis control.

Electronic gearing, camming, robotics and coordinated CNC motion depend on deterministic updates.

Network jitter, task jitter and feedback delay can appear as position error or synchronization error.

This is why real-time control timing becomes part of motion performance.

What Should Be Recorded During Commissioning?

A useful servo trace should include:

Command position

Actual position

Following error

Command velocity

Actual velocity

Torque command

Motor current

Torque/current limit state

In-position state

Axis fault state

A normal SCADA trend can show slower operating behaviour, but a fast servo problem is often better investigated with the drive's high-speed trace or motion-controller logging.

Common Position-Control Problems

The axis reaches the target but vibrates: position gain may be excessive, the velocity loop may be poorly balanced, or mechanical resonance may be active.

Following error is large during motion: inspect velocity feedforward, acceleration feedforward, available torque, motion profile and loop gains.

Position error appears during direction reversal: investigate backlash and mechanical clearance.

Motor encoder looks correct but the load is misplaced: inspect gearbox, ballscrew, belt compliance and load-side feedback.

The empty machine is stable but the loaded machine oscillates: effective inertia and mechanical resonance have changed.

The axis overshoots the final position: review gain, feedforward, deceleration and jerk together.

The load keeps moving after the motor has settled: load-side compliance or mechanical vibration may be involved.

Following-error faults occur during acceleration: check available peak torque before increasing the alarm threshold.

The axis makes constant tiny corrections at standstill: inspect encoder noise, backlash, gain and the in-position tolerance.

Typical Position-Control Applications

CNC machinery: precise control of tool and table axes.

Robotics: coordinated joint positioning and trajectory tracking.

Packaging machinery: indexing, cutting and registration control.

Pick-and-place systems: high-speed repeated positioning.

Antenna positioning: angular tracking and orientation.

Servo presses and test systems: combining position with force or torque control.

In robotic control, position loops also operate underneath trajectory generation, kinematics and multi-axis coordination.

Position-Control Commissioning Check

1. Is motor and encoder direction correct?

2. Is feedback scaled into the correct engineering units?

3. Are gear ratio and mechanical pitch correct?

4. Is motor-side position actually representative of load position?

5. Is backlash significant?

6. Are position, velocity and current-loop responsibilities clearly separated?

7. Are the inner loops faster than the outer position loop?

8. Is load inertia realistic?

9. Are velocity and acceleration feedforward required?

10. Are acceleration and jerk appropriate for the mechanics?

11. Is the drive reaching torque or current limits?

12. Is mechanical resonance present?

13. Is the following-error limit realistic rather than merely large?

14. Is the in-position window matched to the real machine tolerance?

15. Has the final tuning been verified at maximum real payload and production speed?

Related PID, Servo and Position-Control Topics

PID and servo fundamentals: What Is PID? - P, I and D Components - PID with Servo Motors - Motion Control

Nested servo loops: PID Speed Control - PID Torque Control - PID Current Control - Encoders

Tuning and dynamics: PID Gain and Tuning - Real-Time PID - PID Vibration Control - PID Troubleshooting

Control architecture: PID with PLCs - PID with SCADA - PID in Robotics - PID and Other Control Strategies

Servo positioning performance depends on much more than position-loop gain. Feedback architecture, load inertia, velocity and current-loop response, feedforward, motion-profile design, backlash, mechanical resonance and actuator torque limits all determine the final machine behaviour.