What you learn today
- Generator by charge level
- Load shedding in stages
- Show the battery reserve
This week revolved around batteries, generators and load shedding. The project turns it into the chip every bigger base needs at some point: a power manager.
The plant
| Device | Prefab | Name |
|---|---|---|
| two station batteries | StructureBattery | “Akku” |
| solid fuel generator | StructureSolidFuelGenerator | “Notstrom” |
| wall lights | StructureWallLight | “Komfort” |
| wall heater | StructureWallHeater | “Werkstatt” |
| LED display | StructureConsoleLED5 | “Reserve” |
The charge level comes as Ratio from 0 to 1, averaged over both batteries.
The rules
| What | off | back on |
|---|---|---|
| Generator | from 90 % | below 30 % |
| Comfort (lights) | below 25 % | from 40 % |
| Workshop (heater) | below 10 % | from 25 % |
The generator is wired the other way round from the loads: it runs when the battery runs low. The loads leave the grid by priority – comfort first, the workshop last of all. All three get a hysteresis, otherwise they flutter around the threshold.
You already know the generator pattern from the heater. For a load that switches off below a threshold, you flip the comparisons:
sge tmp level C_OFF # still above the shedding limit?
and comfort comfort tmp
sge tmp level C_ON # already above the reconnect limit?
or comfort comfort tmp
When the batteries disappear
Without batteries Average returns NaN. Then: generator on, all loads off, the display shows −1. snanz ok level gives a clean 1 for that as long as there is a reading.
Milestones
- Generator with hysteresis (on below 30 %, off from 90 %)
- Shed comfort below 25 %, back on from 40 %
- Workshop last: off below 10 %, back on from 25 %
- Reserve in percent on the display
- Batteries gone: generator on, loads off, display −1
Set comfort and work to 1 before the start label. Otherwise the base starts in the dark after every chip restart even though the batteries are full.
Diagram
Project task
Task
Build the power manager following the rules above. The defines and the start are already there, the four sections are missing: generator, comfort, workshop and display.
Milestones
- Milestone 1: generator with hysteresis
- Milestone 2: shed comfort
- Milestone 3: workshop last
- Milestone 4: reserve in percent
- Milestone 5: batteries gone
Hints
Hint 1
Generator like the heater: slt/and with GEN_OFF, slt/or with GEN_ON – and also on when the battery is missing.
Hint 2
Loads with sge: first and with the shedding limit, then or with the reconnect limit, finally and with ok.
Hint 3
Display: mul, round, then select pct ok pct -1.
Quiz
3 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