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

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

Redundancy

Redundancy: compare two sensors, decide by majority with three sensors and report a failed sensor without stopping the system.

Lesson 20 min Week 46

What you learn today

  • Compare two sensors
  • Majority vote
  • Report failure

A sensor is an opinion. If it hangs too close to the heater in the greenhouse, it reports 25 °C while the tomatoes at the other end freeze. If it fails, you know nothing at all. With several sensors the opinion turns into a decision.

Comparing two sensors

With two sensors you can tell that something is wrong:

sub diff ta tb
abs diff diff
sgt disagree diff TOLERANZ    # more than 2 K apart

You still do not know which of the two is right. So two sensors are enough for a warning (“sensors disagree, please check”), but not for a safe decision.

Majority vote with three sensors

Three sensors vote. Each casts a vote “too cold”, and the heater follows the majority:

slt cold ta EIN
slt tmp tb EIN
add cold cold tmp
slt tmp tc EIN
add cold cold tmp
sge tmp cold 2           # at least two votes

A single sensor next to the heater is outvoted. And because a comparison with NaN is always 0, a failed sensor simply casts no vote – the other two decide on their own.

With the same idea the heater gets a hysteresis: votes for “too cold” switch on, votes for “too warm” switch off. If the temperature is in between, everything stays as it is.

Tip

For a display you can take the median instead of voting, the middle one of the three values: max(min(a, b), min(max(a, b), c)). It ignores one outlier. But careful: with a NaN in it the median becomes NaN as well.

Reporting failure

Redundancy has a trap: if one sensor fails, nobody notices, because everything keeps running. Until the second one fails. That is why the chip counts the valid sensors and reports every failure immediately. Below two valid sensors there is no majority any more – then the heater goes into the safe state.

Exercise

Task

Three sensors “Temp_A”, “Temp_B” and “Temp_C” vote on the heater “Gewaechshaus”. At least two votes “below 19 °C” switch on, at least two votes “above 21 °C” switch off. The display “Sensoren” shows the number of valid sensors, the light “Sensorfehler” is lit as soon as one is missing. Below two valid sensors the heater is off.

Hints

Hint 1

Valid sensors: snanz three times and add up.

Hint 2

Votes: three times slt … EIN for cold, three times sgt … AUS for warm, each added up.

Hint 3

On: sge tmp cold 2 with or. Off: slt tmp warm 2 with and. Finally and with “at least two valid”.

Quiz

4 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