PID Tuning Practice - Shooter
Overview
Shooters run in velocity mode: hold a spin rate, not a position. This lesson finds kV (volts per rotation per second) by temporarily tuning kS at a 1 r/s setpoint, copies that into kV, converts graph units, sets a match RPM target, and adds a small kP when balls or load disturb the wheel.
Browser practice
Open PID Simulation on Mantik for a zero-install first pass. Choose Flywheel, pick REV or CTRE to match your hardware, and tune with SpringTune while watching wheel RPM on TraceView. Setpoint and gains use motor rot/s in code (same as SparkMax / Talon FX velocity mode); the graph shows wheel RPM.
Video Tutorial
Flywheel velocity tuning:
Prerequisites
AdvantageScope 2026 installed; simulation running from the setup lesson.
Initial Setup
Enable teleop and live tuning. In AdvantageScope, graph velocity only (position clutters a flywheel tune). Turn on editable tunables (slider icon by the search bar).
Tuning Steps
- Tune kS (static feedforward). kS compensates for static friction - the minimum voltage needed to start the flywheel moving. Start with kS = 0.1. Set the setpoint to a nonzero value (e.g., 1 rotation per second). In simulation, this may not be necessary due to lack of friction, but it’s important for real hardware. If needed, adjust kS to find the minimum voltage that gets the flywheel moving. Make kS as small as possible while still starting motion. Zoom the graph to show 1-2 seconds of data (prevents lag later).
- Tune kV (velocity feedforward) using kS temporarily. kV is the voltage required to maintain 1 rotation per second. Temporarily use the kS parameter to find this value:
- Set the velocity setpoint to 1
- Start with a very small kS value (e.g., 0.1)
- Watch the velocity graph - it should reach and maintain 1 rotation per second
- If the velocity is too low, double the kS value (0.1 to 0.2 to 0.4 to …)
- Keep doubling until the velocity hovers around 1 rotation per second
- Fine-tune by decreasing slightly if it stays slightly above 1, or increasing if it’s below
- Once stable at 1 rotation per second, copy this kS value into kV
- Note: kV depends on velocity, so we use kS to tune at 1 rotation per second before setting up P
- Convert units in AdvantageScope. The velocity graph shows rotations per second, but the setpoint uses degrees per second. Click the three dots on the velocity graph. Select “Edit Units”. Choose “Angular Velocity” (not regular velocity - angular is for rotation/spinning). Convert from rotations per second to degrees per second. Ignore any “extra factor” mentioned in the conversion dialog. The graph should now match the setpoint units.
- Set target velocity. Convert from RPM to degrees per second to set your setpoint. Say you want to set the flywheel to 417 RPM. To convert from RPM to rotations per second, divide by 60 (60 seconds in a minute). Example: 417 ÷ 60 = 6.94 rotations per second. To convert from rotations per second to degrees per second, multiply by 360 (one rotation equals 360 degrees). Example: 6.94 × 360 = 2500 degrees per second. Set the setpoint to this calculated value. Verify the flywheel reaches and maintains this velocity. If it can’t reach the target, it may exceed the motor’s maximum capability - reduce to a realistic value.
- Tune kP (proportional gain). kP helps the motor recover quickly from disturbances (like when a ball passes through). kP values are typically very small (three decimal places, e.g., 0.001). Even though the number looks small, it can add significant voltage. Example: 2500 degrees per second times 0.001 equals 2.5 volts. This 2.5V is added on top of the kV voltage. Increase if the flywheel is slow to reach setpoint or recover from disturbances. kV should do most of the work; kP helps with accuracy and disturbance rejection.
Key Points
Process and important notes:
- Process: Graph velocity, use kS temporarily at 1 rps to find kV, copy to kV, convert units (rotations/sec to degrees/sec), set target (RPM ÷60 ×360), fine-tune kP
- Mechanisms: Flywheel/Shooter uses velocity-based (kV, kP). Arm/Turret uses position-based. Elevator uses kG + position control
- Units: Velocity graph shows rotations per second, setpoint may use degrees per second (convert with ×360). Phoenix Tuner/REV Hardware Client also use rotations per second - always verify units
- kV is critical for velocity control (does most work), kP is very small (0.001-0.01), kI/kD usually 0. Watch velocity graph, not position
- Common mistakes: Wrong units, kP too high (causes oscillation), kV incorrect, forgetting kS in real hardware, wrong setpoint for finding kV (must use 1 rps)
- Real hardware: Verify tuning on physical mechanism, kS more important in real life, test with game pieces, same process applies to Phoenix Tuner/REV Hardware Client