ViewWiki

The world, a little closer

Feedback and control.

Balancing a broom on your hand means watching it and moving all the time. Teach a motor to do it, and find out how hard it should push back.

Explore the scene Interactive article

01 / The experiment

Too gentle, too eager, or just right.

Change the controller gain and watch the cart catch each tap on the pole, then switch on Show the feedback to see the loop and the tilt over time.

Still of the Feedback and control 3D scene, which explores: Why can a controller that pushes harder make a balancing robot worse?
Interactive scene

Loading the interactive version…

The explanation below is available while the scene loads.

A 1 kg cart on a 1.8 m rail balances a 0.8 m, 150 g pole. The motor can push at most 25 newtons, each tilt reading reaches it 50 milliseconds late, and the pole is set upright and tapped every 5 seconds. Time runs at half speed.The motion is computed from the equations of motion of the cart and pole, not drawn by hand. The motor is treated as a force that follows each command at once, friction is kept simple, and the pole can only tip left or right. A gentle second loop draws the cart back towards the middle of the rail.

02 / Three gains

Same tap, three controllers.

Each trace is the pole's tilt over four seconds after the same tap, from the simulation in the scene.

Slow to react01
time →tilt

Too little gain

The motor pushes too gently to get the cart back under the lean, so gravity wins and the pole topples.

Gain
0.2 N per degree
After the tap
Falls 0.7 s later
Motor push
Never above 6 N
A steady hand02
time →tilt

Enough gain

The cart darts under the pole, the push eases off as it comes upright, and a couple of small swings die away.

Gain
1.0 N per degree
After the tap
Leans 4°, then settles
Motor push
Up to 6 N
Over-steering03
time →tilt

Too much gain

Each strong push answers a reading that is already 50 ms old, overshoots, and the next one overshoots more.

Gain
2.6 N per degree
After the tap
Shakes ±10°, never settles
Motor push
Slams to the 25 N limit
The big idea

Feedback needs the right strength: enough push to beat gravity's pull, but not so much that a late reading turns every correction into an overshoot.

F = k(θ + 0.1 s·θ̇)

Balancing is a loop

Try standing a broom upright on the palm of your hand. You cannot set it up once and walk away. You watch the handle, see it start to lean, and move your hand under it. The broom leans again, a different way, and you move again. Seeing, deciding and moving run round and round in a circle, many times a second.

That circle is called feedback: the result of what you did (where the broom ended up) is fed back into what you do next. Machines balance, steer and hold a temperature with the same circle, a control loop. Something measures, a controller decides, and a motor or heater acts.

An upright pole needs the loop because it is unstable. Any lean, however small, lets gravity pull the top further over, and the further it leans the harder it is pulled. Left alone, a lean of one degree becomes a fall in about a second.

The rig in the scene

The cart runs on two steel rods and is pulled by a toothed belt from a motor at the left end. The pole sits on a hinge on the cart. On the hinge’s axle is an encoder, a disc with fine slots that a light sensor counts, so it reports the tilt a hundred times a second. The grey box is the controller. Its rule is simple: push the cart towards the side the pole leans to, with a force proportional to the lean.

How hard it pushes for each degree is the gain, in newtons per degree. The controller also adds a little for how fast the tilt is changing. That part acts like a shock absorber: as the pole swings back towards upright it eases off the push before the pole gets there.

Too little gain

Moving the cart under the pole is what straightens it. If the cart accelerates towards the lean faster than gravity tips the pole, the pole comes back. For this rig the bare minimum works out at the combined weight of cart and pole, 11.3 newtons, for every radian (57°) of tilt: about 0.2 newtons per degree. Below it the motor never pushes hard enough, and the pole falls.

A little above that minimum the cart does catch the pole, but so slowly that it has to chase it a long way, and in the scene it runs into the end of the rail first.

Enough gain

With about 1 newton per degree the tap tips the pole by about 4°, the cart darts some 40 centimetres under it, and after a couple of smaller swings the pole stands upright again. The cart then drifts back to the middle.

Try it: slide Controller gain up to 2.6 N/° and choose On under Show the feedback. On the strip chart the tilt swings wider with every push until the motor slams from one force limit to the other.

Back to the experiment

Too much gain

Why should pushing harder be worse? Because every reading is old news. Sensing, filtering, computing and getting the motor going take time, here 50 milliseconds. A strong controller reacts hard to where the pole was, and by the time its push arrives the pole has already moved. The push carries the pole past upright, the next reading says it now leans the other way, and the next big push comes late too. Each correction overshoots more than the one before.

From about 1.7 newtons per degree the swings still die away, but slowly. From about 2.2 they grow instead, until the motor reaches its 25 newton limit and the pole shakes back and forth for good. It is the same as adjusting a shower whose hot water takes seconds to arrive: turn the tap hard each time it feels wrong and you swing between too hot and too cold.

Engineers call the room between “too little” and “too much” the stability margin. They choose gains in the middle of it, and they work to make the loop faster, because the shorter the delay, the harder the controller can push before it starts to overshoot.

Feedback everywhere

The same loop keeps a room at its set temperature, a car at its cruising speed, a drone level in a gust and a rocket upright on its flame. Your body runs it too: you stand still only because your muscles are corrected, many times a second, by what your inner ear and your feet report.

What this model leaves out

The pole only tips left and right; a real one can fall in any direction and needs a second cart axis or a wheeled base. The motor is an ideal force with a limit, ignoring the belt’s stretch and the time the motor’s current takes to build. All the delays are lumped into one 50 millisecond lag; good rigs are faster, which lets them use higher gains. The second loop that brings the cart back to the middle, by asking the pole to lean very slightly, is part of the controller but is not one of the controls. Between tests the scene stands the fallen pole back up by itself, which a real rig would do with a swing-up routine or a person’s hand. And the scene runs at half speed so the swings can be seen.

Reuse with credit to ViewWiki and a link to this page.

04 / Learn this in a course

Practise it, step by step.

This lesson teaches the topic with checked questions.

  1. A feedback loop Computer science · Computing in the real world