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

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

Start-up after a restart

Start-up after a restart: what holds after inserting a chip, checking stored values and switching loads on one after another instead of all at once.

Lesson 18 min Week 46

What you learn today

  • What applies after insertion
  • Check memory
  • Soft start

You pull the workshop chip, change one line and plug it back in. At that very moment light, pump and heater switch on together, the grid collapses and the life support in the neighbouring module goes off. The start-up is the place where an otherwise good script slips up most often.

What holds after inserting

WhatState
program counterline 0
registers r0 to r15, sp, ra0
deviceskeep their state – a heater that was on stays on
Logic Memorykeeps its value

So the chip starts with an empty head in a world that keeps running. Whatever it remembered in registers – hysteresis state, counters, sequence step – is gone. You had also better not rely on old contents of the stack. Anything that should survive a restart belongs in a Logic Memory.

Once before the loop

Everything that should only happen at start sits before the label of the main loop:

  1. Defined beginning: set the outputs deliberately instead of inheriting the old state of the devices.
  2. Check memory: read stored values and check them. A Logic Memory can contain anything, including nonsense from an earlier script.
lbn soll SPEICHER HASH("Sollwert") Setting Average
sge ok soll SOLL_MIN          # NaN gives 0 here
sle tmp soll SOLL_MAX
and ok ok tmp
select soll ok soll SOLL_STD
sbn SPEICHER HASH("Sollwert") Setting soll   # write the repaired value back

The repaired value is written back. That way the memory holds something valid again, also for other chips that read it.

Gentle start

In the power grid every tick counts: if demand exceeds supply, all normal loads on the grid go off. Switching many loads on in the same tick is therefore the riskiest thing a chip can do. A staggered start is better: one more stage every few ticks. Light first, then the pump, finally the heater.

Tip

A staggered start costs a few seconds, but makes every restart harmless – including the one after a power failure, when all chips of the base start up at the same time.

Exercise

Task

Build the start-up of the workshop: before the main loop the chip switches “Licht”, “Pumpe” and “Heizung” off, reads the setpoint from the Logic Memory “Sollwert” (valid 16 to 28 °C, otherwise 21 °C – also with a missing memory), writes the checked value back and shows it on the display “Soll”. In the loop one more stage switches on every 3 passes: first the light, then the pump, then the heater.

Hints

Hint 1

The start part belongs before start: – it only runs once.

Hint 2

Check: sge ok soll SOLL_MIN, sle tmp soll SOLL_MAX, and, then select. NaN fails on its own.

Hint 3

Stage: div tmp tick ABSTAND, floor, add stage tmp 1, min stage stage 3.

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