What you learn today
- Tracking and load shedding as building blocks
- Target quantities and collective alarm as building blocks
- Combine blocks
Once you have built many plants you notice: they are the same shapes again and again. A pro does not write them anew every time but recognises them as building blocks and puts them together.
Four building blocks of the pro level
| Block | Shape | Example |
|---|---|---|
| Tracking | read a setpoint, convert, write to all | solar panels follow the sun |
| Load shedding | hysteresis, output “on” above | comfort off with little reserve |
| Target quantity | hysteresis, output “on” below | furnace up to 200 ingots |
| Collective alarm | many conditions, one signal | one light for everything |
Tracking always has the same form, whether panels, lights or valves follow:
lbn target SENSOR HASH("Sonne") Horizontal Average
jal convert # to suit the build
select target night PARK target # park at night
sb PANEL Horizontal target
The conversion depends on how you built it – for solar panels you know it from day 186. At night a select sends the devices into a parking position.
One block for three controls
Generator, load shedding and target quantity look different but are the same hysteresis: “on below the lower limit, off from the upper one”. With load shedding only the output is inverted – shedding happens below the limit, the light is the opposite of that.
So you write the hysteresis once as a subroutine. Before each call you set four registers:
| Register | Content |
|---|---|
value | the reading |
low | below this it turns on |
high | from here it turns off |
state | the previous state, afterwards the new one |
move value level
move low GEN_ON
move high GEN_OFF
move state gen
jal hyst
move gen state
The previous state of each control stays in a register of its own (gen, shed, furn). The subroutine only works on state.
Combining blocks
A collective alarm connects blocks that know nothing about each other: batteries missing, store missing. Each condition becomes 0 or 1, or combines them. In addition each control gets its own safe direction: without a battery value the generator runs, without a store the furnace stands still.
A subroutine must not overwrite registers the caller still needs. That is why the hysteresis has its own helper register h and does not touch tmp.
Diagram
Exercise
Task
Write the subroutine hyst (on below low, off from high, state in state) and use it three times:
- generator “Notstrom”: battery ratio, 30 % / 90 %, on without a battery
- load shedding: battery ratio, 25 % / 40 %, light “Komfort” is the opposite, off without a battery
- target quantity: ingots in slot 0 of the locker “Barren”, 50 / 200, arc furnace “Huette” (
Onas release, another chip starts the stacks), off without the locker - light “Sammel” on when battery or locker are missing
Hints
Hint 1
The subroutine has four lines plus j ra: slt h value high, and state state h, slt h value low, or state state h.
Hint 2
Before each jal hyst: set value, low, high and state. Afterwards put the state back into gen, shed or furn.
Hint 3
The comfort light is seqz tmp shed.
Quiz
3 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