What you learn today
- D term from the change
- Damp noise
- When PID is overkill
The filling station for gas canisters sits on a short line with a turbo volume pump. The PI controller holds the pressure, but when starting up it overshoots the target by a good margin every time: when the pressure arrives, the I term is still large and the pump keeps running. A third term can brake before that happens. It does not look at how far the pressure is from the target but at how fast it moves.
The D term from the change
The D term (D for derivative) compares the reading with the one from the last tick:
d = KD · (old − new)
If the pressure rises quickly, old − new is negative and d takes output away. If the pressure stands still, d is zero and does not interfere.
sub d old press # pressure rising makes d negative
mul d d KD
add u u d # add to the P and I term
move old press # remember for the next tick
Why from the reading and not from the error? When you turn the setpoint, e jumps in one go. A D term built from e would see this jump as a huge change and give the pump a kick. The reading, on the other hand, only changes as fast as the gas really flows.
Damping noise
Readings twitch: a canister is connected, gas spreads out, the value jumps by a few kPa from tick to tick. The D term multiplies exactly these jumps. That is why it gets a smoothed reading, as you built it on day 145:
lerp smooth smooth raw SMOOTH # 0.5: half old, half new
The smaller SMOOTH, the calmer the value – and the later the controller notices a real change. Smoothing is always a trade: less twitching for more sluggishness.
Set smooth and old to the first valid reading itself. If they start at 0, the controller sees a jump from 0 to 1500 kPa in the first tick and reacts to it.
When PID is overkill
| Task | usually enough |
|---|---|
wall heater, lights, doors (only On) | hysteresis |
| large room, large tank (sluggish) | P or PI |
| short line, fast pump, overshoot | PI plus D |
Many devices in Stationeers only know on and off. And rooms and tanks react so slowly that a D term hardly gets to see anything – except noise. Start with hysteresis or PI and only add D when you really see an overshoot.
A reading that jumps by 20 kPa from tick to tick gives a swing of 40 with KD = 2 – the turbo pump twitches between almost off and half open. Smooth first, then take the change, and start with a small KD.
The game also has a ready-made logic unit “PID Controller” (StructureLogicPidController) with the LogicTypes Setpoint, ProportionalGain, IntegralGain, DerivativeGain, Minimum, Maximum and Reset. Here you build what happens inside such a unit yourself – then you also know what its values do.
Exercise
Task
The pipe analyzer “Leitung” measures the pressure, the turbo volume pump “Fueller” (Setting 0 to 100) fills. So far the P controller uses the raw reading. Rework it:
smooth(r1) = smoothed pressure:lerpwith SMOOTH- e = TARGET − smooth, P term = KP · e
- D term = KD · (old − smooth), then
old= smooth - Setting = P + D, limited to 0 to 100
- Analyzer gone: pump off,
smoothstays unchanged
Leave out the I term here so you see the effect of D on its own. Setting the start values at the first reading is already there.
Hints
Hint 1
lerp smooth smooth raw SMOOTH right after the label go:.
Hint 2
sub e TARGET smooth instead of using raw.
Hint 3
sub d old smooth, mul d d KD, add u u d, then move old smooth – only then clamp.
Quiz
5 questions. You pass from 60 % – the server does the grading.
Complete the day
- Passed the simulator exercise
- Passed the quiz with at least 60 %
Without an account progress is saved in this browser only.
Report a mistake in this lesson
Please sign in to report. Sign in