Time for your masterpiece. An airlock is the classic: program it wrong and you notice at the latest when your base vents into space.
The in-game setup
| Device | Prefab | Name |
|---|---|---|
| Lever | StructureLogicSwitch | “Richtung” (Setting 1 = going out, 0 = going in) |
| Gas sensor inside the airlock | StructureGasSensor | “Schleuse” |
| Active vent inside the airlock | StructureActiveVent | “Schleuse” |
| Inner door | StructureAirlock | “Innentuer” |
| Outer door | StructureAirlock | “Aussentuer” |
The vent has two directions via Mode: Vent.Outward (0) blows from the pipe into the airlock, Vent.Inward (1) sucks the airlock empty.
The rules
Going out (lever = 1):
- Inner door closed.
- Vent sucks (
Mode1) until the pressure is below 1 kPa, then off. - Outer door opens only when the pressure is below 1 kPa.
Going in (lever = 0):
- Outer door closed.
- Vent blows (
Mode0) until the pressure reaches at least 100 kPa, then off. - Inner door opens only when the pressure is at least 100 kPa.
Sensor gone (NaN): vent off, both doors closed.
Think in states, not sequences
You do not have to work through steps one after another. Every tick the chip reads lever and pressure and computes how each device should be right now:
slt empty press EMPTY # 1 = airlock empty
sge full press FULL # 1 = airlock full
seqz tmp out # going in?
and tmp tmp full # ... and full?
sbn DOOR HASH("Innentuer") Open tmp
With seqz, and, or and select from the earlier lessons you build the remaining rules the same way.
In the IC10 coder you can bring the airlock to life with couplings in the simulator: vent “On” lowers or raises the pressure every tick. Then you watch the airlock work in the trend view.
Diagram
Exercise
Task
Program the airlock following the rules above. All devices are on the data network, the names are in the table. The test plays a complete cycle out and back in – plus a sensor failure.
Hints
Hint 1
First three helper values: snanz ok press (1 = sensor present), slt empty press EMPTY, sge full press FULL.
Hint 2
Inner door: open exactly when not going out (seqz tmp out) and full. Outer door: going out and empty.
Hint 3
The vent direction is simply the lever value: sbn VENT HASH("Schleuse") Mode out.
Hint 4
Vent on: going out “not empty yet”, going in “not full yet” – select tmp out notEmpty notFull picks it. Finally “and” it with ok.