stationeers.de Mod workshop · Dominik1199
DE Sign in
  1. Home
  2. IC10 academy
  3. Day 155

Day 155 of 365 · Advanced · Month 6: Atmosphere and control

The P controller

The P controller makes the output proportional to the error. You learn how to choose the gain and why a steady-state error remains in the end.

Lesson 15 min Week 23

What you learn today

  • Output proportional to the error
  • Choose the gain
  • Steady-state error

The buffer tank in front of the air supply should hold 2000 kPa. The base keeps drawing air from it, sometimes more, sometimes less. With a hysteresis the volume pump either runs at full power or not at all: the pressure saws back and forth between the thresholds and the pump switches every few seconds. Better is a pump that delivers exactly as much as is missing right now. That is what a P controller (P for proportional) does.

Error and output

You need three terms all week:

TermMeaningin the example
Setpointwhere you want to be2000 kPa
Process valuewhat the sensor measuresPressure of the pipe analyzer
Outputwhat the chip writes to the deviceSetting of the pump, 0 to 10

The error e is setpoint minus process value. The P controller turns it into the output by multiplying it with the gain KP:

sub e TARGET press        # e > 0: pressure too low
mul u e KP                # output proportional to e
clamp u u 0 MAXPUMP       # only what the pump can do

Double the error, double the pump output. If nothing is missing, the pump stands still. You already know clamp from day 57: otherwise an empty tank would ask for Setting 40 and an overfull one for a negative value.

Choosing the gain

KP says how much Setting you give per kPa of error. The easiest way to find it is the question: at which error should the pump run at full power? If it should be at the limit 500 kPa below the setpoint, KP = 10 / 500 = 0.02.

define KP 0.02            # 10 / 500 kPa: full at 500 kPa short
KPfull fromBehaviour
0.0052000 kPasluggish, stays far below the setpoint
0.02500 kPacalm, small remainder
0.520 kPaalmost on/off, tends to oscillate

If KP is too large, the output jumps from 0 to 10 at the tiniest error. Because the pressure does not react to the pump instantly, it then overshoots the target, the pump switches off, the pressure drops, the pump goes back to full – the controller oscillates.

The steady-state error

Now the catch. Suppose the base uses so much that the pump permanently needs Setting 4. A P controller only delivers 4 while there is an error: e = 4 / KP = 4 / 0.02 = 200 kPa. So the tank settles at 1800 kPa, not at 2000. Waiting longer changes nothing – at 2000 kPa e would be 0 and the pump would be off.

This steady-state error is not a bug in the code, it belongs to the P controller. A larger KP makes it smaller but makes the controller more restless. If you roughly know the consumption, a fixed base value helps, the feed-forward:

mul u e KP
add u u BASE              # known base load, e.g. 4
clamp u u 0 MAXPUMP

If the consumption changes, the remainder is back. Only the I term makes it disappear for good – that is tomorrow.

Warning

Watch the sign. For a pump that fills, e > 0 means “do more”, so e = setpoint − process value. For cooling it is the other way round: too warm means cool more, so e = process value − setpoint. With the wrong sign the controller works against you and runs at full power when it should be off.

Diagram

Pump output depending on tank pressure 10 0 Setting (L/tick) 4000 5000 tank pressure in kPa clamp: at most 10 (target − pressure) / 100 off
The closer the tank gets to the target pressure, the less the pump delivers. The gain KP sets how steeply the output rises with the error.

Exercise

Task

A pipe analyzer “Puffer” measures the pressure in the buffer tank, the volume pump “Nachschub” fills it.

  • Error e = TARGET − pressure
  • Pump Setting = KP · e, limited to 0 to 10
  • On = 1 as soon as the Setting is greater than 0
  • Analyzer gone: Setting 0 and pump off

The defines and reading the pressure are already there.

Hints

Hint 1

sub e TARGET press, then mul u e KP and clamp u u 0 MAXPUMP.

Hint 2

sgtz on u gives 1 when u is greater than zero.

Hint 3

Right after reading, bnan press fault. Under the label fault: you write Setting 0 and On 0 and jump back.

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

Esc
↑ ↓ selectEnter open/ opens search anywhere