Gray Matter
WorkshopPID Tuning in Tuner X
WPILib 2027 is still in alpha: these pages change as the APIs settle.
LESSON 06

PID Tuning in Tuner X

The TalonFX runs the control loop itself. Tuner X sends the setpoint, plots the response, and saves the gains onto the motor.

8 minutes
You’ll need
  • Motor, encoder direction, and mechanism zero verified in Motor Setup & CAN IDs.
  • Tuner X connected to the CANivore, with CANivore USB on.
  • The mechanism, with a clear path to swing, and no obstacles.

How to tune

CTRE has an excellent guide already that explains how to properly tune a PID loop. We strongly suggest following the steps in the guide.

After you follow this guide, come back here and we'll explain how to implement it.

CTRE: Manual PID tuning

Play with the gains

Drag a gain and watch what happens. Find out what too much kP looks like here, where it costs nothing, rather than on a real gearbox.

Switch between the three. The arm holds an angle, and gravity pulls on it everywhere, so it never rests at zero output. The flywheel holds a speed. Nothing drags it off target, but holding that speed costs output, and a game piece steals it at once. The elevator is the other gravity case, a constant pull.

Choose mechanism
loading playground…

Build the plot

Before running this, fully power cycle the CANivore and mechanism to prevent any old positions from being read.

  1. Open Signal & Control and add the TalonFX you are tuning.
  2. Plot two signals: the target and the measured position (or velocity for flywheels). Put target and measurement in one group so you can read the gap between them.

Tune the gains

Note

Before you tune

In the control panel, pick a voltage-based position or velocity request and select Slot 0. Enter a small target: 0.1 rotations for position, 10 rps for velocity.

Follow the CTRE tuning guide on your actual mechanism.

A tuned arm sounds like one motion and then silence. If the motor is still working after the mechanism stopped, kP is too high.

Three failure shapes

Nearly everything that goes wrong on a mechanism looks like one of these. Read the plot, not the mechanism.

Runs away
Wrong direction
Error grows instead of shrinking and output pins. Disable now. The sensor or the motor is inverted, so go back to Motor Setup.
Buzzes
Too much gain
Voltage chatters and the mechanism hums at rest. Cut kP before reaching for kD. Damping will not fix a loop that is too stiff.
Falls short
Not enough output (position control)
Error settles at a constant gap. Increase your kP to correct this, likely followed by a kD to dampen the overshoot.

Check your work

Drive the mechanism to its target in both directions, from a standstill, three times. You are done when all three runs look alike.

Check

You should see

  • The measured trace meets the target and stays there.
  • Closed-loop error settles near zero and does not drift back out.
  • Voltage is steady at rest, not chattering.
  • The same gains behave across the full range of travel.

Check yourself

You set every gain to zero, send a position target, and enable. The arm does nothing. What is wrong?

Your arm holds its angle perfectly at 90 degrees and sags badly at 30. Which term is wrong?

What order do you tune an arm in?

The arm reaches its target and then buzzes, sitting still. What do you reach for first?

Pick an answer for each.