Servo Tuning: Position, Velocity and Current Loops Explained

Servo Tuning: Position, Velocity and Current Loops Explained

Key Takeaway

Servo tuning is three nested loops: current, velocity and position. Tune them in that order: current first, then velocity, then position. Each loop must be 5 to 10 times slower than the one inside it, and the loop inside must be stable before the loop outside is touched.

The Three Nested Servo Loops CURRENT LOOP Runs at 50 to 100 us Controls torque output Needs encoder feedback Set first, then leave alone VELOCITY LOOP Runs at about 250 us P gain sets stiffness I gain removes droop Bandwidth 5x current loop POSITION LOOP Runs at 1 to 10 ms P gain on position error Follows the profile 5 to 10x slower than velocity FEEDFORWARD Inertia feedforward Velocity feedforward Filters to keep it clean Cuts following error Tune current, then velocity, then position Each loop 5 to 10x slower than the one inside Inertia feedforward cuts lag, not gain Raise the loop, watch the following error

Figure 1: The three nested servo loops – current, velocity, position, feedforward

1. Current Loop: The Fastest Loop

What the current loop does

The current loop is the innermost loop of a servo drive. It reads the motor current (usually from shunt resistors on the motor phases), compares it to the current command from the velocity loop, and adjusts the PWM duty cycle to make them match. It runs at 50 to 100 microseconds, which is the fastest loop in the drive.

The current loop output is torque. Torque is proportional to current, so the current loop directly controls how hard the motor pushes. Everything outside the current loop — velocity, position, the whole machine — works through torque.

Tuning the current loop

Most modern servo drives have the current loop pre-tuned at the factory. The user rarely touches it. The parameters that matter are the current loop bandwidth and the current filter, and both are usually fixed. The one thing to check is that the motor’s current loop parameters match the motor nameplate: rated current, peak current, resistance and inductance. A wrong motor parameter in the drive makes the current loop unstable or sluggish, and every loop outside it inherits the problem.

Why it must be set first

The current loop is inside the velocity loop, which is inside the position loop. If the current loop is slow or unstable, nothing outside it can be fast or stable. Set the current loop first, verify it, and then never touch it again.

2. Velocity Loop: Stiffness and Droop

What the velocity loop does

The velocity loop sits outside the current loop. It reads the motor velocity (from the encoder), compares it to the velocity command from the position loop, and commands current to close the error. It runs at about 250 microseconds, roughly 5 to 10 times slower than the current loop.

The velocity loop output is a current command. That current command becomes torque, which accelerates the motor. So the velocity loop controls how fast the motor spins, by controlling torque.

P gain: stiffness

Velocity loop P gain sets stiffness. Higher P gain means the motor resists speed changes more strongly. If you push the motor shaft by hand, a high P gain fights you harder. A low P gain lets the motor be pushed around.

But higher P gain also means less stability. At some point, higher P gain makes the velocity loop oscillate, and that oscillation shows up as a humming or growling sound from the motor. The limit is when the loop starts to ring.

I gain: droop

Velocity loop I gain removes droop. Droop is the steady-state error: the velocity settles slightly below the command because friction or load torque opposes the motor. I gain integrates the velocity error over time and adds current to eliminate it.

Too much I gain makes the velocity loop slow and oscillatory. Too little I gain means the velocity settles below the command, and the position loop sees a constant error that it has to correct with position P gain.

The velocity loop bandwidth rule

The velocity loop bandwidth must be 5 to 10 times lower than the current loop bandwidth. If the current loop runs at 5 kHz, the velocity loop should run at 500 to 1000 Hz. If the velocity loop is faster than that, it excites the current loop and the whole drive oscillates.

3. Position Loop: Following the Command

What the position loop does

The position loop sits outside the velocity loop. It reads the motor position (from the encoder), compares it to the position command from the controller, and commands velocity to close the error. It runs at 1 to 10 milliseconds, roughly 5 to 10 times slower than the velocity loop.

The position loop output is a velocity command. That velocity command becomes current, which becomes torque, which moves the motor. So the position loop controls where the motor goes, by controlling velocity.

Position P gain

Position loop P gain sets how aggressively the drive follows position error. Higher P gain means the drive reacts faster to position error and follows the command more tightly. But higher P gain also means more overshoot, more oscillation, and more noise.

The position loop bandwidth must be 5 to 10 times lower than the velocity loop bandwidth. If the velocity loop runs at 500 Hz, the position loop should run at 50 to 100 Hz. If the position loop is faster, it excites the velocity loop and the whole axis oscillates.

Position loop limits

Position P gain is limited by two things: the velocity loop bandwidth (which sets how fast the drive can actually deliver velocity), and the machine structure (which sets how much acceleration the mechanics can take without ringing).

You cannot tune position P gain independently of the velocity loop. If the velocity loop is slow, the position loop must be slow too. Trying to make the position loop fast with a slow velocity loop just makes the axis oscillate.

4. Feedforward: Inertia and Velocity

Why feedforward exists

Feedback loops react to error. They wait until there is a position error, then command velocity to correct it. That means there is always some error before the drive does anything. Feedforward removes the error before it happens, by predicting what the drive needs to do.

Velocity feedforward

Velocity feedforward adds a velocity command proportional to the commanded velocity. If the profile says the motor should move at 1 m/s, velocity feedforward adds enough current command to produce 1 m/s without waiting for position error. Velocity feedforward removes most of the following error during constant-velocity moves.

Inertia feedforward

Inertia feedforward adds a current command proportional to the commanded acceleration. If the profile says the motor should accelerate at 10 rad/s^2, inertia feedforward adds enough torque to accelerate the motor inertia at that rate. Inertia feedforward removes most of the following error during acceleration and deceleration.

Feedforward filters

Feedforward commands are sharp: they start and stop abruptly. Sharp commands excite the structure. Feedforward filters smooth the feedforward command so it does not excite the machine. A low-pass filter on velocity feedforward and on inertia feedforward keeps the structure quiet.

Feedforward and feedback together

Feedforward does most of the work; feedback cleans up what is left. With good feedforward, the position loop P gain can be lower, which means less overshoot and less noise. Without feedforward, the position loop has to do all the work, which means higher P gain and more ring.

5. Tuning Order and the 5x Rule

The order

  1. Current loop first.Verify the motor parameters match the nameplate. Verify the current loop is stable. Leave it alone after that.
  2. Velocity loop second.Tune velocity P gain for stiffness without oscillation. Add I gain to remove droop. Verify the velocity loop bandwidth is 5 to 10 times lower than the current loop bandwidth.
  3. Position loop third.Tune position P gain for following error without overshoot. Verify the position loop bandwidth is 5 to 10 times lower than the velocity loop bandwidth.
  4. Feedforward last.Add velocity feedforward to remove constant-velocity error. Add inertia feedforward to remove acceleration error. Filter the feedforward so it does not excite the structure.

The 5x rule

Each loop must be 5 to 10 times slower than the one inside it. Current loop: 50 to 100 us. Velocity loop: 250 us to 1 ms. Position loop: 1 to 10 ms. These are not arbitrary numbers; they are the separation that keeps each loop from exciting the one inside it.

Why the order matters

Tune the position loop first and you are tuning a loop whose inside (velocity) is not stable yet. Every position P gain change changes the velocity demand, which changes the current demand, which changes the current loop behavior. You end up chasing your own tail.

Tune from the inside out, and each loop sees a stable loop inside it. The current loop is stable, so the velocity loop sees a stable current command. The velocity loop is stable, so the position loop sees a stable velocity command.

What happens if you skip the order

  • Position loop too fast for velocity loop: the axis oscillates at the velocity loop frequency.
  • Velocity loop too fast for current loop: the drive growls or hums, and the current loop saturates.
  • Feedforward without feedback tuning: the axis follows the profile but overshoots at the end, because there is no feedback to remove the final error.

6. Following Error and Settling

What following error is

Following error is the difference between the commanded position and the actual position. It is the error the position loop sees and tries to correct. Every axis has some following error during a move; the question is how much and whether it matters.

What causes following error

  • Inertia.Accelerating a mass requires torque, and torque requires current, and current requires position error. The position loop cannot command torque without error.
  • Friction and load.A load opposing the motion requires current to overcome, and current requires error.
  • Velocity loop bandwidth.The velocity loop cannot deliver infinite acceleration instantly, so there is lag.
  • Position loop bandwidth.The position loop cannot command infinite velocity instantly, so there is lag.

Reducing following error

  • Increase position P gain.More gain means more velocity command per unit error, which means less error for the same torque demand. But more gain means more overshoot and more noise.
  • Add inertia feedforward.Inertia feedforward supplies the acceleration torque directly, so the position loop does not have to create error to get it. Inertia feedforward is the most effective following error reducer.
  • Add velocity feedforward.Velocity feedforward supplies the cruise velocity directly, so the position loop does not have to create error for cruise.
  • Reduce the load.Less mass means less torque needed for the same acceleration, which means less error.

Settling time

Settling time is the time from when the move ends to when the position error stays within a small band (usually a few encoder counts). Settling time is dominated by the position loop bandwidth and by any resonance the move excited. A well-tuned axis with good feedforward settles in a few milliseconds. A poorly tuned axis settles in hundreds of milliseconds or never.

Settling and cycle time

Cycle time is move time plus settling time. On a pick-and-place axis making hundreds of moves per hour, settling time dominates cycle time. Reducing settling time from 100 ms to 10 ms on a 10 moves per minute axis saves 90 seconds per hour, or 15 percent of cycle time.

Sources

  1. Yaskawa, Sigma-7 Servo Drive Tuning Guide (current, velocity, position loops)
  2. Rockwell Automation, Servo Drive Tuning and Performance
  3. Siemens, SINAMICS Servo Drive Commissioning and Tuning
  4. IEC 61800-5-1, Adjustable speed electrical power drive systems: Safety requirements

Key Takeaways

  • Servo tuning is three nested loops: current (torque), velocity and position. Tune them in that order, inside out.
  • Each loop must be 5 to 10 times slower than the one inside it: current 50-100 us, velocity 250 us-1 ms, position 1-10 ms.
  • Current loop P gain sets torque response; velocity loop P gain sets stiffness; position loop P gain sets following error response.
  • Velocity loop I gain removes steady-state droop; too much I gain makes the loop oscillate.
  • Feedforward removes most following error before the feedback loop sees it; inertia feedforward for acceleration, velocity feedforward for cruise.
  • Following error is unavoidable but reducible: more position P gain, more feedforward, less load, or a faster velocity loop.

Leave a Reply