The same balancing problem, but now the PID output is a force in newtons pushed into a cart with mass. The gains take back their textbook roles. Change them while it runs, push the pole, and compare with the velocity-commanded version.
A force goes straight into acceleration, so the pole feels the controller output directly. Gravity makes upright an unstable equilibrium, and the controller has to supply a restoring "spring" plus damping. Linearized around upright, with the cart mass M, pole mass m and length L:
It must beat gravity: Kp > (M+m)·g = 11.8 N/rad here. Below that the pole falls no matter what else you do. Higher Kp gives a stiffer, faster response and bigger forces.
Without it, the pole rocks around upright and motor lag makes the rocking grow. Kd is what kills it. It also passes sensor noise straight into the force.
It adds a third pole and eats phase. Stability needs Kd·(Kp − 11.8) > M·L·Ki, shown live as "Largest stable Ki". It cannot fix the problems you would expect it to fix (see below).
| Gain | Commanding velocity | Commanding force |
|---|---|---|
| Kp | Damper | Spring, must exceed (M+m)·g |
| Ki | Spring, must exceed g·L | Optional, limited by Routh |
| Kd | Extra mass, keep small | Damper, required |
| Units | m/s per rad | N per rad |
The velocity servo in the first lab was itself a controller that hid the cart's mass. That inner loop integrated your command once, which shifted every gain's job up a derivative. With raw force there is no hidden loop, so PD does the work.
| What you see | Likely cause | Try |
|---|---|---|
| Pole falls in the first second, cart chases it | Kp ≤ 11.8: spring weaker than gravity | Raise Kp |
| Steady rocking that grows over a few seconds | Too little Kd, or motor lag eating phase | Raise Kd, lower τ |
| Slow wobble that builds even with good Kp and Kd | Ki past the Routh limit | Lower Ki |
| Pole creeps back slowly, cart moves a lot | Overdamped, Kd too large for Kp | Lower Kd or raise Kp |
| Fuzzy force trace | D term amplifying sensor noise | Lower Kd |
| Force flat at the limit after a push | Motor saturation | Softer gains or a stronger motor |
| Cart cruises or accelerates away while the pole looks fine | No position feedback, or a sensor offset | Turn on the centering loop |
Set the sensor offset to 1°. The controller now holds the measured angle at zero, so the real pole leans 1° the other way. A pole can only stay leaned if the cart keeps accelerating under it, so the cart speeds off and never stops. Adding Ki doesn't help, because from the angle alone the controller cannot tell an offset from a real lean.
The fix is information, not a gain. Turn on the Centering loop: the outer loop sees the cart running away and leans θ_ref until the cart stops, which finds the true upright on its own. The cart settles a little off center, and adding an integrator to the outer loop would remove that last bit. Keep the outer loop much slower than the inner one.
The plant has an unstable pole p = √((M+m)g/(M·L)) ≈ 3.4 rad/s. That changes the rules you may know from stable plants: the Nyquist curve must circle −1 counter-clockwise once, and a positive phase margin alone proves nothing. Load "Kp below (M+m)g" to see a 60°+ phase margin on a loop that falls over.