Control systems: PID lesson plan
Feedback control on real physics: open and closed loops, P, I and D one at a time, tuning by the numbers, encoders, a balancing robot, and a motor that holds its speed whatever you throw at it.
Objectives and materials
By the end, students can
- Why measuring and correcting beats a good guess.
- Each term on its own: what it fixes and what it breaks.
- Step tests and Ziegler-Nichols, and the encoder every loop leans on.
- A balancing robot, where the controller is all that keeps it up.
- Hold a motor speed through a sag, a surge and a stall.
Materials for the whole unit
- Arduino Uno R3
- Bench power supply
- Gear motor with encoder
- Half breadboard
- Motor driver, L9110S
- OLED display, 128x64
- Potentiometer x 3
- Self-balancing robot
Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.
Feedback
Why measuring and correcting beats a good guess.
| Lesson | Time | What students do |
|---|---|---|
| Open loop, closed loopDrive a gear motor at a fixed PWM and watch the speed drift the moment the supply sags. Then close the loop: measure, compare, correct, and the speed comes back on its own. | 70 min |
|
Materials
- Arduino Uno R3
- Bench power supply
- Gear motor with encoder
- Motor driver, L9110S
Check for understanding
Each student finishes "Open loop, closed loop" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Ask for a different speed".
P, I and D
Each term on its own: what it fixes and what it breaks.
| Lesson | Time | What students do |
|---|---|---|
| P, then IProportional control and the offset it always leaves, why cranking the gain makes it hunt instead, the integral term that wipes the offset out, and the windup that bites when the output hits its limit. | 60 min |
|
| D: dampingA position loop that turns the wheel to an angle: P alone acts as a spring and overshoots, D acts as a damper and stops it clean, friction leaves the last few degrees, and too much D buzzes. | 60 min |
|
Materials
- Arduino Uno R3
- Bench power supply
- Gear motor with encoder
- Motor driver, L9110S
Check for understanding
Each student finishes "D: damping" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "The last degree".
Tuning and sensing
Step tests and Ziegler-Nichols, and the encoder every loop leans on.
| Lesson | Time | What students do |
|---|---|---|
| Tuning by the numbersStep tests that measure rise time, overshoot, settling time and steady-state error, the Ziegler-Nichols experiment for finding the ultimate gain and period, and a tune refined until it meets a written spec. | 60 min |
|
| Encoder speedCount a quadrature encoder in interrupts: direction from the phase between A and B, x1, x2 and x4 decoding, speed by counting edges or by timing them, and how the measurement decides how steadily a loop can hold 30 rpm. | 60 min |
|
Materials
- Arduino Uno R3
- Bench power supply
- Gear motor with encoder
- Motor driver, L9110S
Check for understanding
Each student finishes "Encoder speed" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Four times the edges".
Unstable plants
A balancing robot, where the controller is all that keeps it up.
| Lesson | Time | What students do |
|---|---|---|
| Balance controlPID on an unstable plant: the balance bot’s tilt held at zero, each term knocked out to see what it was doing, pushes measured, and a stiffer tune written into the code. | 60 min |
|
Materials
- Arduino Uno R3
- Half breadboard
- OLED display, 128x64
- Potentiometer x 3
- Self-balancing robot
Check for understanding
Each student finishes "Balance control" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A stiffer tune".
Boss
Hold a motor speed through a sag, a surge and a stall.
| Lesson | Time | What students do |
|---|---|---|
| Boss: hold the speedThe final fight: a clean start to 120 rpm, a supply sag, a surge, and a stall no controller can win, refereed round by round by the sketch. Beat all four with your own gains and anti-windup. | 60 min |
|
Materials
- Arduino Uno R3
- Bench power supply
- Gear motor with encoder
- Motor driver, L9110S
Check for understanding
Each student finishes "Boss: hold the speed" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Win it in the code".
Teach this unit as a class
Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.
The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.