Log inStart free
LESSON 20.06 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

PID control

Watch a PID controller balance the pole from three terms of one error.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 20.06 · CONTROL BAYT 1.2 S · θ 5.1° · F +2.8 N
01
Stage 1 of 6 · Feedback loop
Each step, the PID controller reads the pole and the cart, then pushes the cart. This loop is feedback.
Explain it simply

You see a cart with a pole on top. Below it, three lines show the angle, the force and the cart over time. Each step, the controller measures and then pushes. Nobody tells it about the tap at 1 second. It only sees what it measures, and it reacts.

The cart at 0.01 m with the pole at 5.1 degrees at 1.2 s. The force is 2.8 N. Arrows run from the cart to the controller and back.

measured runforce terms, target leanerror, wind, tap, limitsangle loop only
2.4 m−2.4 mwind 1 N−12012angle θ (°)−10010force F (N)−2.402.4cart x (m)0 s1 s2 s3 s4 s5 s6 s7 s8 stapfeedbackmeasure5.1°error e8.2°P +5.8I −0.5D −2.5force F+2.8 N+2.8 NFfeedback loop2.4 m−2.4 mwind 1 N−12012angle θ (°)−10010force F (N)−2.402.4cart x (m)0 s1 s2 s3 s4 s5 s6 s7 s8 stapfeedbackmeasure5.1°error e8.2°P +5.8I −0.5D −2.5force F+2.8 N+2.8 NFfeedback loop
Toy: the 20.C1 cart-pole for 8 s, with a steady 1 N wind
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
Fk=PID(θk, xk)\sy{F}{param}{F_k} = \mathrm{PID}(\sy{th}{data}{\theta_k},\ \sy{x}{data}{x_k})
F=PID(5.06∘, 0.01 m)=2.77 NF = \mathrm{PID}(5.06^\circ,\ 0.01\,\mathrm{m}) = 2.77\,\mathrm{N}

Each force uses the angle and the cart measured this step.

Common mix-ups

MYTHPushing in proportion to the lean is enough.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With PD in the wind, does the cart end at the track's centre?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.