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

Day 27 of 365 · Beginner · Month 1: First steps

Project: simple thermostat

Project: a thermostat with the target in the housing, a heater, a coloured display and protection against nonsense targets – without any conditional jumps.

Project 30 min Week 4

What you learn today

  • Switch a heater by temperature
  • Show the state in colour
  • Set the target via the housing

Your habitat module should stay warm, and you want to change the target without touching the code. Everything you need you know from this week and the previous ones: set instructions, select, min, max and round.

The setup

PinDevice
d0gas sensor in the room
d1wall heater
d2LED display
dbhousing: target in °C

The target in the housing

The program reads the target from db Setting, in degrees Celsius. In the game it later comes from another device or chip, in the simulator you set it by hand. Two safeguards belong to it:

  • If the housing still holds 0, 20 °C applies. That way a freshly inserted chip does not cool the room down to 0 °C.
  • The target is limited to 5 to 35 °C. A typo like 300 does not turn the module into a sauna.
l r1 db Setting        # target in C
seqz r2 r1             # 1 = nothing entered
select r1 r2 20 r1     # then 20 C
max r1 r1 5
min r1 r1 35

Heating and colour

The heater runs when it is more than 1 °C colder than the target. A real hysteresis with memory comes in week 7, today the band from week 4 is enough.

The display shows the temperature in °C with one decimal, mode Celsius, and takes on a colour:

StateColour
heater runningblue (0)
more than 1 °C too warmred (4)
otherwisegreen (2)

Two select in a row do that. The second overwrites the first when the heater is running:

select r6 r5 4 2       # red or green
select r6 r4 0 r6      # blue while heating

Milestones

  1. Cold: heater on.
  2. Warm enough: heater off, display green.
  3. Display in °C with one decimal, mode Celsius.
  4. Blue while heating, red when too warm.
  5. Without a target 20 °C applies.
  6. Target limited to 5 to 35 °C.
Tip

Convert to Celsius early and compare in Celsius – the target in the housing is in Celsius too. Never compare Kelvin with Celsius.

Diagram

Comparison and select as a switch temp = 313 sgt r1 temp 303 r1 = 1 select Color.Red Color.Green 4 if r1 ≠ 0 if r1 = 0
Comparisons return 0 or 1, select uses that to pick colour and fallback value.

Project task

Task

Build the thermostat from the lesson, without conditional jumps (only j start):

  • Target in °C from db Setting; 0 means 20 °C; limited to 5 to 35 °C.
  • Heater d1 on when the temperature is more than 1 °C below the target.
  • Display d2: temperature in °C, one decimal, Mode 4.
  • Colour: blue (0) while heating, red (4) when more than 1 °C too warm, otherwise green (2).

Milestones

  1. Milestone 1: cold – heater on
  2. Milestone 2: warm enough – heater off, green
  3. Milestone 3: display in °C with one decimal
  4. Milestone 4: blue while heating, red when too warm
  5. Milestone 5: without a target 20 °C applies
  6. Milestone 6: target limited to 5 to 35 °C

Hints

Hint 1

Fallback: seqz r2 r1, then select r1 r2 20 r1.

Hint 2

Deviation r3 = actual − target. Heater: add r4 r3 1 and sltz r4 r4.

Hint 3

Colour with two select, display with times 10, round, divided by 10.

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