Advanced8–12 h (estimate, mostly tuning)7 parts
PID ball-and-beam balancer
Keep a ping-pong ball at a set distance on a servo-tilted beam.
Overview
A beam pivots in the middle and a servo tilts it. An ultrasonic sensor at one end measures where the ball is. A PID controller turns the position error into a beam angle so the ball rolls to the setpoint and stays there.
It is a classic control lab because the ball accelerates whenever the beam is tilted, so P alone oscillates: you will need D for damping, a filter for the noisy distance readings, and limits on the beam angle.
You will learn
- · Tuning a real PID loop (P, then D, then a little I)
- · Filtering noisy feedback without adding too much lag
- · Output limits and anti-windup
- · Fixed-rate control loops with millis()
Parts list
| Part (generic) | Qty | Note |
|---|---|---|
| Arduino Uno-compatible board (5 V logic) | 1 | |
| Standard hobby servo (metal gears recommended) | 1 | |
| Ultrasonic distance sensor module (HC-SR04-type, 5 V) | 1 | Readings on a small round ball are noisy; filtering is part of the build. |
| Straight beam with side rails or a U-channel, about 30–40 cm | 1 | |
| Ping-pong ball | 1 | |
| Pivot (hinge or bolt through a bracket), linkage rod, base | 1 set | |
| Separate 5 V servo supply with a capacitor across it | 1 |
Generic part names only. Pinouts and logic levels vary between modules of the same type, so check the documentation of the exact module you have.
Tools
- · USB cable and the Arduino IDE (Serial Plotter)
- · Drill and saw for the frame
- · Ruler
- · Spirit level
Safety
- · Clamp the frame to the table; the beam can flick the ball off quickly.
- · Start with small angle limits until the loop is tuned.
Learn the ideas first
Full build
- 01Build the beam, pivot and servo linkage
- 02Measure ball position and filter it
- 03Find the level angle and set angle limits
- 04P control (expect oscillation)
- 05Add D for damping, then a little I
- 06Tune with the Serial Plotter and record step responses
Checking your account…