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

Day 265 of 365 · Pro · Month 9: Logistics and greenhouse

Project: farm control

Two greenhouses, one chip: one subroutine per house with heater and alarm, a collective alarm that shows which house has trouble, and the harvest status of the whole farm.

Project 45 min Week 38

What you learn today

  • Several greenhouses
  • Collective alarm
  • Harvest status

The farm is growing: next to “GH1” there is now “GH2”. A second chip with almost the same code would be twice the upkeep. Better is a subroutine that handles one greenhouse and is called twice – with the name in a register.

The setup

DevicePrefabNames
Gas sensorsStructureGasSensor“GH1”, “GH2”
Wall heatersStructureWallHeater“GH1”, “GH2”
Hydroponics devicesStructureHydroponicsTrayData3 × “GH1”, 2 × “GH2”
Wall lightStructureWallLight“Sammelalarm”
LED displaysStructureConsoleLED5“Alarm”, “Reif”

The subroutine

Before each jal house the main program sets three registers: name (hash of the house name), num (trays in the house) and bit (1 for GH1, 2 for GH2). The subroutine then does this for that house:

  1. Heater with hysteresis, 20 to 24 °C. It simply reads the previous state back from the heater (lbn heat HEATER name On Average) – that way no house needs a register of its own.
  2. Alarm below 15 °C, above 35 °C or with a missing sensor. An alarm adds bit to the sum: GH1 alone gives 1, GH2 alone 2, both 3.
  3. Count ripe plants. Empty trays return Mature −1. With Sum therefore: ripe = sum of Mature + trays − sum of Occupied.

Milestones

  1. Each house has its own heater with hysteresis.
  2. The display “Alarm” shows 0, 1, 2 or 3, the light “Sammelalarm” is on for any alarm.
  3. The display “Reif” shows the ripe plants of both houses together.
  4. If a sensor fails, there is an alarm for that house and its heater goes off.
Tip

The calculation for ripe plants is not obvious. Work it out once by hand for GH1: ripe 1, growing 0, empty −1 gives a sum of 0, 2 of 3 trays are planted, so 0 + 3 − 2 = 1 ripe plant.

Warning

A third house only needs three more move and one more jal – and a new alarm value of 4, not 3. Otherwise you cannot tell “GH3” from “GH1 and GH2”.

Diagram

Calling and returning from a subroutine Main loop 2 l r0 d0 Temperature 3 jal celsius 4 s d2 Setting r1 5 l r0 d1 Temperature 6 jal celsius 7 s d3 Setting r1 8 j start celsius: sub r1 r0 273.15 j ra ra = 4 back to line ra
The main program sets name, number of trays and alarm value and calls the same subroutine twice.

Project task

Task

Build the farm control with a subroutine house that handles heater, alarm and ripe plants for the house in name. GH1 has 3 trays and alarm value 1, GH2 has 2 trays and alarm value 2.

Milestones

  1. Milestone 1: heater per house
  2. Milestone 2: collective alarm
  3. Milestone 3: harvest status
  4. Milestone 4: sensor fails

Hints

Hint 1

Main program: alarm and ripe to 0, then twice move name …, move num …, move bit …, jal house.

Hint 2

In the subroutine lbn temp SENSOR name Temperature Average – the name comes from the register.

Hint 3

Ripe: add lbns … Mature Sum, add num, subtract lbns … Occupied Sum. At the end j ra.

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

Esc
↑ ↓ selectEnter open/ opens search anywhere