Source: https://mokxi.com/teachers/plans/control-systems-pid
Updated: 2026-11-11

Lesson plan

# 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.

5 chapters, 7 lessons, about 7 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## 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.

Chapter 1. About 1 h 10 min

## Feedback

Why measuring and correcting beats a good guess.

Lesson | Time | What students do

Open loop, closed loop Drive 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

- Run it: a motor on a guess
- Watch it come up to speed
- Pull the supply down
- Close the loop
- Same sag, closed loop
- The four numbers
- Ask for a different speed

### 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".

Chapter 2. About 2 h

## P, I and D

Each term on its own: what it fixes and what it breaks.

Lesson | Time | What students do

P, then I Proportional 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

- Run it: proportional control
- The offset P always leaves
- Crank it, and it hunts
- I: the term with a memory
- Windup
- Anti-windup

D: damping A 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

- Run it: P on position
- A softer spring is no cure
- Add D
- Too much D
- Write the damper in
- The last degree

### 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".

Chapter 3. About 2 h

## Tuning and sensing

Step tests and Ziegler-Nichols, and the encoder every loop leans on.

Lesson | Time | What students do

Tuning by the numbers Step 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

- Run it: a step test
- Ziegler and Nichols, part 1
- The ultimate gain
- Ziegler and Nichols, part 2
- Refine it to the spec
- Ship the tune

Encoder speed Count 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

- Run it: edges in an interrupt
- Which way? The quadrature trick
- Hold 30 rpm by counting
- Time the edges instead
- Read it safely
- Four times the edges

### 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".

Chapter 4. About 1 h

## Unstable plants

A balancing robot, where the controller is all that keeps it up.

Lesson | Time | What students do

Balance control PID 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

- Run it: an unstable plant
- Push it
- Take D away
- Take I away
- Stand it back up
- A stiffer tune

### 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".

Chapter 5. About 1 h

## Boss

Hold a motor speed through a sag, a surge and a stall.

Lesson | Time | What students do

Boss: hold the speed The 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

- Run it: meet the referee
- Round 1: the start
- Round 2: the sag
- Round 3: the surge
- Round 4: the stall
- Win it in the code

### 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".

Your class

## 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.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
