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

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

Light cycles

Plants need light and darkness: light and dark phase with a tick counter, counting cycles across days and switching the grow light off in sunshine.

Lesson 16 min Week 38

What you learn today

  • Light and dark phases
  • Counters across days
  • Save power

A grow light that burns around the clock costs 70 W without a break – and even harms some plants. The game objectives say it clearly: plants need light to grow and darkness to rest.

Light and darkness

The game data lists a light and a darkness requirement per day for every plant (LightPerDay, DarknessPerDay, in seconds). The potato is listed with 300 s of light and 200 s of darkness, corn with 500 and 200. Mushrooms are the exception: no light, but lots of darkness – according to the Stationpedia, lasting light even kills them.

A cycle of light and dark phase can be built with a single counter. Each tick (0.5 s) the register counts up by one, at the end of the cycle it starts again at 0:

add tick tick 1
blt tick CYCLE next
move tick 0
add days days 1          # one cycle over
next:

It is light as long as the counter is below the light limit: slt light tick BRIGHT. The values in the exercise are kept short so you can watch them in the simulator. In the game you use minutes, for example define BRIGHT 1200 for 10 minutes.

Counting across days

Every time the counter jumps back, a cycle is over. A second register counts the cycles – that is your day counter for the greenhouse.

Warning

Registers do not survive a restart. If you take the chip out or load new code, the tick and day counters start at 0 again. For a plant that is harmless, for statistics it is not. How to rescue values across a restart comes in the expert level.

Saving power

If your greenhouse has windows, the sun provides the light during the day. A daylight sensor measures the irradiation as SolarIrradiance. If it is above a threshold, the grow light stays off:

lbn sun SENSOR HASH("Sonne") SolarIrradiance Average
sgt sun sun SUN    # 1 = sun is enough
seqz sun sun
and light light sun

The threshold is an example value. Read SolarIrradiance at a bright noon and at dusk and put the limit in between.

Tip

If the sensor fails, it returns NaN, and sgt gives 0 – “no sun”. The grow light then simply keeps working by cycle. For the plants that is the safe direction.

Diagram

Ticks and yield on a timeline tick 0 · 0.0 s tick 1 · 0.5 s tick 2 · 1.0 s tick 3 · 1.5 s 5 instr. yield 5 instr. yield 5 instr. yield 128 instr. no yield: limit hit Device values only change between two ticks.
A register counts the ticks of a cycle. Below the light limit it is bright, above it dark.

Exercise

Task

Control the grow light “Pflanzenlicht” in a cycle:

  • one cycle has CYCLE = 180 ticks, the first BRIGHT = 120 ticks are light
  • the display “Zyklen” counts completed cycles
  • if the daylight sensor “Sonne” reports a SolarIrradiance above SUN, the light stays off
  • without the sensor the cycle carries on normally

Hints

Hint 1

A register counts up every tick. When it reaches CYCLE, set it to 0 and count the cycles up by one.

Hint 2

Light: slt light tick BRIGHT.

Hint 3

Sun: sgt, then seqz and fold it into the light with and.

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