What you learn today
- Monitor three rooms at once
- Show the worst value
- Report sensor failure
Lab, storage, living area – when the pressure drops in one room, you want to know right away. The average does not help: if one room sinks to 40 kPa, the mean of the three is still 80. What matters is the worst value.
The setup
| Device | Name | Job |
|---|---|---|
| 3 gas sensors | “Labor”, “Lager”, “Wohnen” | pressure per room |
| LED display | “Mindestdruck” | lowest pressure of the three |
| LED display | “Ausfall” | number of failed sensors |
| flashing light | “Druckalarm” | on below 80 kPa |
| flashing light | “Sensorfehler” | on when a sensor is missing |
The problem with NaN and min
If you read the three pressures separately and take min, one failed sensor ruins everything: min with NaN gives NaN. The fix: replace every NaN with plus infinity first. Infinity is never the minimum, so the room simply drops out of the calculation.
snan failed p1
select p1 failed pinf p1 # missing: pinf instead of NaN
snan tmp p2
add failed failed tmp # count failures
select p2 tmp pinf p2
If all three fail, the minimum itself is pinf. Then the display shows 0 – and 0 is below 80 kPa, so the pressure alarm goes on. That is the safe direction: whoever knows nothing warns.
seq tmp low pinf
select low tmp 0 low
Milestones
- The display “Mindestdruck” shows the lowest pressure of the three rooms.
- Below 80 kPa the pressure alarm goes on.
- A failed sensor is reported: “Ausfall” counts it, “Sensorfehler” flashes.
- A failed sensor does not distort the minimum.
- If all sensors fail, “Mindestdruck” shows 0 and the pressure alarm is on.
pinf and ninf are the natural starting values for minimum and maximum searches. Starting with 0 always gives 0 as the minimum.
Why not just lbn with Minimum over all three? Because the sensors have different names – and because Minimum returns 0 instead of NaN without a match. A failure would then look like a vacuum.
Diagram
Project task
Task
Build the room monitor from the lesson:
- Read the pressures of the sensors “Labor”, “Lager”, “Wohnen” separately.
- “Mindestdruck” shows the lowest pressure; failed sensors do not count; if all are missing, it shows 0.
- “Druckalarm” on below 80 kPa.
- “Ausfall” shows the number of missing sensors, “Sensorfehler” flashes as soon as one is missing.
Milestones
- Milestone 1: lowest pressure on the display
- Milestone 2: pressure alarm below 80 kPa
- Milestone 3: failed sensor is reported
- Milestone 4: failure does not distort the minimum
- Milestone 5: all sensors gone – 0 and alarm
Hints
Hint 1
Three lbn with Average, one per room.
Hint 2
Per pressure: snan, count the failure, select … pinf ….
Hint 3
At the end min twice, then replace pinf with 0.
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