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

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

Project: PI heater controller

A PI controller holds the lab at its target temperature: wall heater by pulse width, setpoint from a dial, anti-windup, trend on two displays and a safe state on sensor failure.

Project 35 min Week 23

What you learn today

  • Hold a room with a PI controller
  • Anti-windup
  • Show the trend

This week showed P, PI, D, tuning and cascades in small pieces. Now you build a controller that really holds a room: the lab with a wall heater, a dial for the setpoint and two displays for the trend.

The plant

DevicePrefabName
gas sensor in the roomStructureGasSensor“Raum”
wall heaterStructureWallHeater“Heizung”
dialStructureLogicDial“Soll” (setpoint in °C)
LED displayStructureConsoleLED5“Leistung” (output in %)
LED displayStructureConsoleLED5“Abweichung” (in K)

The wall heater gives off 1000 J per tick and only runs above 6.3 kPa. It knows only On – no Setting, no half power.

PI controller with pulse width

The PI controller computes an output u between 0 and 1. Because the heater can only be on or off, you turn that into pulse width modulation (PWM): in a window of 10 ticks the heater is on for as many ticks as u says. u = 0.3 means 3 ticks on, 7 off.

add tick tick 1
mod tick tick WINDOW      # 0 to 9, then start over
mul tmp u WINDOW
slt on tick tmp           # on while tick < u * 10

A room is sluggish enough not to notice switching on and off within a 5-second window. It only feels the average power.

The controller itself is the one from day 156, only in kelvin and with u from 0 to 1:

sub e target t
mul tmp e KI
add i i tmp
clamp i i 0 1             # anti-windup: never more than full power
mul u e KP
add u u i
clamp u u 0 1

Setpoint and failures

  • The dial delivers °C. add target target CELSIUSOFFSET turns it into kelvin. If the dial is missing, target is NaN – then TARGET_STD (20 °C) applies.
  • If the sensor is missing, t is NaN. Then: heater off, “Leistung” shows −1, “Abweichung” 0, and i is not touched. Otherwise the controller is poisoned after the repair.

Milestones

  1. Cold room: heater on, “Leistung” 100, “Abweichung” in K
  2. Close to the setpoint the I term pushes on and holds the output once the setpoint is reached
  3. PWM: at u = 0.5 the heater is on in the first half of the window and off in the second
  4. Anti-windup: after a long cold spell the heater switches off as soon as the room is above the setpoint
  5. Setpoint from the dial, 20 °C without the dial
  6. Sensor gone: heater off, “Leistung” −1, i stays put
Tip

The registers i (r3) and tick (r5) are fixed in the starter code. The tests set them directly for the PWM check – keep that assignment.

Warning

Without clamp i i 0 1 the I term collects values far above 1 during a cold night. In the morning the heater then keeps heating at full power for a long time even though the room is long warm.

Project task

Task

Build the PI heater controller following the sections above. The defines, aliases and reading the sensor are already there. Missing are the setpoint, the NaN check, the controller with anti-windup, PWM, both displays and the fault branch.

Milestones

  1. Milestone 1: cold room, full output
  2. Milestone 2: I term pushes on and holds
  3. Milestone 3: PWM in a window of 10 ticks
  4. Milestone 4: anti-windup after a long cold spell
  5. Milestone 5: setpoint from the dial
  6. Milestone 6: sensor gone, safe state

Hints

Hint 1

Setpoint: lbn target DIAL HASH("Soll") Setting Average, add target target CELSIUSOFFSET, then snan tmp target and select target tmp TARGET_STD target.

Hint 2

Right after reading the sensor bnan t fault. In the fault: branch switch the heater off and set the displays – do not touch i.

Hint 3

Controller: first accumulate i and limit it with clamp i i 0 1, then u = KP · e + i, also limited to 0 to 1.

Hint 4

PWM: add tick tick 1, mod tick tick WINDOW, mul tmp u WINDOW, slt on tick tmp.

Quiz

2 questions. You pass from 60 % – the server does the grading.

Complete the day

  • Passed all milestones of the project
  • 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