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
| Source | Result |
|---|---|
lbn … Average, no device matches | NaN |
lbn … Maximum, no device matches | −inf |
lbn … Minimum or Sum, no device matches | 0 |
define with 1e5 or with another define as its value | NaN |
div by 0 | inf, 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
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
| Quantity | Unit in the chip | typical mistake |
|---|---|---|
Temperature | Kelvin | 40 instead of 313.15 |
Pressure | kPa | 101325 instead of 101.325 |
Ratio… | 0 to 1 | 21 instead of 0.21 |
sleep | seconds | sleep 10 waits 20 ticks |
sin, cos | radians | degrees 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
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