← Mechanical Systems Studio
🎛️

PID Motor Control Simulator

Tune Kp, Ki, and Kd for a closed-loop DC motor speed controller against a first-order motor plant. Watch the step response and read off rise time, overshoot, settling time, and steady-state error in real time.

0RPM (target 1500)Control Output (Duty %)0.0%setpoint 1500 RPM21000Motor speed ω(t), RPM — sliding 8s window
PID Gains
0.60
1.50
0.010
1500 RPM
0.30 s
20 RPM/%
Rise Time
seconds (0→90%)
Overshoot
0.0%
peak 0 RPM
Results
Current speed ω0.0 RPM
Setpoint1500 RPM
Settling time (±2% band)0.00 s
Steady-state error1500.0 RPM
Control output u0.0 %
Simulation time t0.00 s
Key Formulas
u(t) = Kp·e + Ki·∫e dt + Kd·de/dt
Motor plant: τ·ω′ + ω = K·u
e(t) = setpoint − ω(t)
Overshoot % = (peak − SP)/SP × 100

About the PID Motor Control Simulator

This simulator closes a PID feedback loop around a simple first-order DC motor speed model, integrated numerically in real time. It's the same architecture used in motor drives, servo loops, and process control: a proportional-integral-derivative controller comparing a setpoint against measured speed and driving a control effort to close the gap.

The plant and controller model

The motor is modeled as a first-order system: τ·ω′ + ω = K·u, where ω is shaft speed (RPM), u is the control effort (duty cycle, −100% to +100%), τ is the mechanical time constant (how quickly the motor responds to a change in drive signal), and K is the motor gain (steady-state RPM per percent duty). This captures the dominant dynamic of a DC motor with reasonable inertia and electrical time constants much faster than mechanical ones — a standard simplification in motor control coursework.

The controller computes u(t) = Kp·e(t) + Ki·∫e(t)dt + Kd·de(t)/dt, where e(t) = setpoint − ω(t). Proportional action responds to the present error, integral action eliminates steady-state error by accumulating past error over time, and derivative action anticipates future error from its current rate of change. The control output is clamped to ±100% with an anti-windup scheme that stops the integral term from accumulating further once the output is saturated, preventing the large overshoot that unconstrained integral windup would otherwise cause.

Reading the step response metrics

Rise time is the time for the response to first reach 90% of the setpoint from rest — a measure of how quickly the loop responds. Overshoot is how far the peak response exceeds the setpoint, expressed as a percentage — driven mainly by derivative-light, high-proportional-gain tuning and by underdamped closed-loop poles. Settling time is the time after which the response stays within a ±2% band of the setpoint — a practical measure of when the system can be considered "arrived." Steady-state error is the persistent gap between setpoint and actual speed once transients die out; with a properly functioning integral term (Ki > 0) this converges to zero for a step input, but a pure P or PD controller always leaves some residual steady-state error under load.

Tuning guidance

Start with Kp alone (Ki = Kd = 0) and increase it until the response is reasonably fast without excessive overshoot or oscillation. Add Ki to eliminate steady-state error, but watch for increased overshoot and settling time — too much Ki causes slow oscillatory "wind-up" behavior. Add a small amount of Kd to damp overshoot and speed settling, but too much Kd amplifies measurement noise (not modeled here, but a very real problem in physical systems) and can cause high-frequency chatter. Methods like Ziegler-Nichols give a systematic starting point: find the gain Ku at which the closed loop with pure P control first sustains oscillation at period Tu, then set Kp ≈ 0.6·Ku, Ki ≈ 1.2·Ku/Tu, Kd ≈ 0.075·Ku·Tu for a classic PID tuning.

Frequently asked questions

Why does the response overshoot with high Kp?

High proportional gain drives a large control effort while the error is still large, which accelerates the motor past the setpoint before the controller has time to reduce the drive signal — the motor's own inertia and the plant time constant τ mean the correction always lags the actual state slightly. This lag is exactly what integral and derivative terms are designed to help manage: derivative action predicts the overshoot from the current rate of change and pulls back early.

What is integral windup and why does anti-windup matter?

When the control output saturates (hits its ±100% limit) while a large error persists, a naive integral term keeps accumulating (winding up) even though the extra integral contribution can't actually be applied. When the error finally reverses sign, the wound-up integral term keeps driving the output in the wrong direction for a while, causing large overshoot and slow recovery. This simulator freezes the integral accumulator whenever the computed output is saturated, a standard anti-windup technique called conditional integration or clamping.

Why is there steady-state error with Ki = 0?

With only proportional control, the control output at equilibrium must equal Kp times whatever residual error remains — since a nonzero output is needed to hold the motor at any nonzero speed (u = ω/K at steady state per the plant equation), a purely proportional controller can only reach equilibrium with some nonzero error remaining. Integral action removes this because it keeps accumulating (and thus keeps increasing the output) as long as any error exists at all, only stopping once the error is exactly zero.

How realistic is the first-order motor model here?

A first-order model captures the mechanical (torque-to-speed) response of many DC motors well when the electrical time constant (armature inductance/resistance) is much faster than the mechanical time constant (inertia/friction) — a common and reasonable approximation. Real motor drives also contend with measurement noise, sensor quantization, PWM switching dynamics, load torque disturbances, and nonlinearities like static friction and voltage/current limits, none of which are modeled here.

🎓

Try our Mechanical Studio

More calculators, simulators, and guides for this discipline.

Related tools & guides

Shaft Power CalculatorMechanical Vibration SimulatorFlow Meter SelectorMachine Design Fundamentals Guide