Power source priorities

This board is to show, discuss and archive useful combinator- and logic-creations.
Smart triggering, counters and sensors, useful circuitry, switching as an art :), computers.
Please provide if possible always a blueprint of your creation.
Post Reply
SafwatHalaby
Burner Inserter
Burner Inserter
Posts: 5
Joined: Thu May 10, 2018 8:42 am
Contact:

Power source priorities

Post by SafwatHalaby »

Summary
This guide explains an easy method for power source priorities. The explanation is detailed. If you are experienced and just want to see the blueprints, skip to "the solution in practice". Only 3 combinators and a switch are required for each power source. It's likely not a novel solution, but I thought it would be nice to write it in a clear guide.
The problem
By default, factorio priorotizes power as follows:
  • Solar panel power is utilized.
  • If that's not enough, then both steam engines and turbines are utilized. There is no priority between them, and the load is shared by both.
  • If that's not enough, accumulators are discharged.
  • If there aren't enough accumulators to discharge fast enough, the electricity supply starts to fail, even if there's still excess accumulator energy. Side note: Always make sure you have enough accumulators for a fast enough discharge.Formula: Accumulators needed to prevent flicker = peak consumption / 300Kw.
  • If there's no accumulator energy left, power dies completely.
In short, the default priority is Solar -> Steam (engines + turbines) -> Accumulator.

Sometimes, one would like to change this priority.
Examples of desired priorities
  1. In a factory where solar panels charge accumulators in daylight and discharge them at night, we may want the steam engines and turbines to only work if the accumulators are depleted. We want Solar -> Accumulator -> Steam (engines + turbines)
  2. In a factory where a nuclear reactor energy is used, we want to shut down steam engines unless the reactor's steam turbines cannot keep up. We want Steam turbines -> Steam engines -> accumulators
  3. In a factory where uranium is low, we want to use nuclear only when absolutely needed (e.g. on heavy biter attacks or base pushes where power is peaking). We want Steam engines -> Steam turbines -> accumulators. Side note: In this scenario is advised that you use steam storage to utilize your uranium as much as possible.
  4. Finally, one might want Solar -> Accumulators -> Steam turbines -> Steam engines or Solar -> Accumulators -> Steam engines -> Steam turbines.
The system should be simple, and reconfiguring priorities should be easy.
The solution - theory
The power system needs to be segregated with power switches. Each power supply is connected to the factory using a power switch, and not directly, except for accumulators.
manualPriorities.png
manualPriorities.png (687.47 KiB) Viewed 15197 times
Now we can manually toggle power sources on and off, but Factorio is about automation! So, for every power switch, we need to somehow add the following automatic logic:
  • A. If the accumulator charge is less or equal to X percent, turn on the switch.
  • B. If the charge has been over X for a while, turn off the switch. Side note: the switch waits for a while to prevent rapid on/off flickering. This can also be resolved with SR-latches but this setup is simpler and requires only one variable (X) per switch.
X determines the power source priority. For priority #1, we set X to 100. For priority #2, we set X to something lower, e.g. 95. For priotiy #3, we set X to e.g. 90.

Let's see how this works with an example: Suppose the accumulators are at 100% percent. Now aliens attack and the lasers are engaged, or perhaps a lab research has started and the factory is now demanding a lot of power. power demand peaks, the accumulators start discharging. At 95%, our priority #2 source is enabled because of logic condition A. If that is enough, energy goes back to 100%, and at some point priority #2 is disabled because of logic condition B. If that is NOT enough, the accumulator charge keeps going down until 90%, and priority #3 is enabled, etc. etc.

But what if we want to also prioritize the accumulators themselves? e.g. for using up electricity collecting using solar as priority #1 at night. Well, we simply set X low! For instance, x=8 for priority #2, x=4 for priority #3. This means that the other power sources are utilized only when the accumulators are nearly empty.
The solution in practice
For every power switch, we add 3 combinators that do the above logic. We connect the logic circuitry to an accumulator to read its charge, and to the power switch to control it. Below are the images and the blueprint. In summary, setting priorities is a matter of modifying our X values. X=100 is the highest priority power source, X=1 is the lowest. Use a low X (<20) for anything that is prioritized less than accumulators, and a high X (>90) for anything that should be used before the accumulators are utilized.

Images:
autoPriorities.png
autoPriorities.png (1.1 MiB) Viewed 15197 times
Detailed view of the combinator tabs
Detailed view of the combinator tabs
combinatorDetails.png (370.73 KiB) Viewed 15252 times
Zoom in on the combinators
Zoom in on the combinators
combinatorZoomIn.png (148.81 KiB) Viewed 15252 times

Blueprint:
blueprint
Final notes
  • It is possible to modify the 5k value and to set it less. This value controls how many ticks it takes to turn off the switch after the power condition has been met.
  • This 3 combinator device can be used in other scenarios. It's actually a device that sends a 0 if and only if a certain condition has been true for T time or more, and otherwise sends a 1.
Thank you for reading!

Post Reply

Return to “Combinator Creations”