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

Day 310 of 365 · Expert · Month 11: Optimisation and debugging

Finding silent errors

Errors without an error message: trace NaN and −inf from batch reads, spot the silent program end and find wrong units.

Lesson 18 min Week 45

What you learn today

  • Trace NaN and −inf
  • Program end
  • Wrong units

Loud errors are the nice ones: the housing names the error and the line, you fix it, done. The dangerous ones are errors where the chip happily keeps running and still does nonsense. The tank cooling never starts, the display shows 320 instead of 47, and nothing lights up anywhere.

NaN and −inf spread

SourceResult
lbn … Average, no device matchesNaN
lbn … Maximum, no device matches−inf
lbn … Minimum or Sum, no device matches0
define with 1e5 or with another define as its valueNaN
div by 0inf, with 0 / 0 NaN

Every calculation with NaN gives NaN again, and every comparison with NaN gives 0. So sgt on t LIMIT is 0, the cooling stays off. With −inf it is trickier: sgt gives 0, but slt gives 1. A heater that switches on “below the limit” then runs forever.

One line catches both if the value is a temperature in Kelvin:

lbn tmax ANALYSE HASH("Tank") Temperature Maximum
sgt ok tmax 0      # Kelvin is always above 0, NaN and -inf never
Warning

select only checks “not equal to 0”. NaN is not equal to 0, so with NaN in r1, select r0 r1 10 20 takes the 10. Feeding select an unchecked reading switches the wrong way when something fails.

The silent program end

If the chip runs past the last line, it stops forever. No error, no light. Typical causes: forgetting the j start at the end, a conditional jump to a label at the very bottom with nothing after it, or a label in a relative jump. The checker in the IC10 coder warns about it, in the game you only notice it because the system no longer reacts.

Wrong units

QuantityUnit in the chiptypical mistake
TemperatureKelvin40 instead of 313.15
PressurekPa101325 instead of 101.325
Ratio…0 to 121 instead of 0.21
sleepsecondssleep 10 waits 20 ticks
sin, cosradiansdegrees without deg2rad

A limit of 40 “degrees” is 40 Kelvin for the chip, so −233 °C. Every tank is warmer, the cooling always runs. You only see mistakes like this when you look at the value next to the limit.

Diagram

Three readings, five batch modes Sensor “Raum” 300 K Sensor “Raum” 310 K Sensor “Raum” 250 K lbn Average 286.67 Sum 860 Minimum 250 Maximum 310 Count 3 Sum on temperatures: 860 K – the heater thinks there is a fire.
If no device matches, Average returns NaN, Maximum −inf and Minimum, Sum and Count 0. None of these values raises an error.

Exercise

Task

The tank cooling in the starter code has three silent errors. Fix them: the wall cooler “Tankkuehlung” runs when the hottest tank (pipe analyzers “Tank”) is above 40 °C. The display “TankMax” shows the highest temperature in °C. If all analyzers are missing, the system cools to be safe, the light “Warnung” turns on and the display shows -999. The chip must keep running.

Hints

Hint 1

The limit has to be in Kelvin: 40 °C are 313.15 K.

Hint 2

j start is missing at the bottom – without the jump the chip stops after one pass.

Hint 3

sgt ok tmax 0 is 0 for NaN and −inf. Then force the cooling with select and show the fault value.

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