Motor PID Lab / closed-loop test stand

A simulated DC motor holds an arm at a target angle, or spins a flywheel at a target speed. Change the P, I and D gains and watch how the response changes.

← Nova Pyra
Angle
0.0°
Target
0°
Error
0.0°
Motor
0.00 V
drag to orbit · scroll to zoom
Overshoot
—
peak past target
Rise time
—
10% → 90% of step
Settling
—
within 2% band
Steady error
—
averaged, last 0.3 s

Response · shaft angle

MeasuredSetpoint

Controller output · volts

P term I term D term Motor voltage (after limit)

Guided experiments

Each one loads a set of gains and conditions in position mode. Read what to watch for, then press Load.

How the loop works

Every millisecond the controller reads the encoder, compares it with the setpoint, and sets the motor voltage. The difference is the error, e.

setpoint r Σ −+ e PID controller P + I + D u (V) Motor + load J·θ̈ = τ − bθ̇ disturbance θ or ω Encoder

P · present

Kp·e. Big error, big push. Alone it leaves a small offset whenever a steady load (like gravity) needs a constant voltage to hold.

I · past

Ki·∫e. Keeps growing while any error remains, so it finds the holding voltage by itself. Slow to react, and it can overshoot.

D · future

Kd·de/dt. Opposes fast change, acting like a shock absorber. Reduces overshoot, but noisy sensors make it jittery.

Model: J·θ̈ = 50·u − 2·θ̇ − load − disturbance (rad/s², u in volts, clamped to ±12 V). The controller and physics run at 1 kHz with a 10 ms derivative filter. Units are scaled for teaching, not a specific motor datasheet.