In other languages: Deutsch Русский 简体中文

Tutorial:Circuit network cookbook: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (formatting)
(46 intermediate revisions by 16 users not shown)
Line 5: Line 5:


==Lamp showing chest content condition==
==Lamp showing chest content condition==
[[File:LightWiredToChest.png|right|218 × 412px]]
[[File:LightWiredToChest.png|right]]
 


This is the simplest possible use of circuit-network. A lamp is light depending on the number of goods (in this example  empty barrels) in a chest.
This is the simplest possible use of circuit-network. A lamp is light depending on the number of goods (in this example  empty barrels) in a chest.
Line 13: Line 12:
* The lamp is connected to the chest
* The lamp is connected to the chest
* the lamp is set to light if the chest contain less than 10 empty barrels.
* the lamp is set to light if the chest contain less than 10 empty barrels.
{{clear}}
[[File:LamponBarrelCondition.png|right|400x400px]]
===To set the light condition===
===To set the light condition===
# open the lamp (right click on it)
* Open the lamp (left click on it)
# Set the input to barrels
* Set the input to barrels
# Set the operator to < (las than)
* Set the operator to < (less than)
# Set the constant number:
* Set the constant number:
## Right lick on the constant number
** Left click on the constant number
## Draw the slide until 10 is shown, or edit the value box directly
** Move the slider until 10 is shown, or edit the value box directly
## Press set
** Press set


Depending on the condition you set you may light the lamp if the barrel is empty, or contain a decent number of articles.
Depending on the condition you set, the lamp may light if the chest is empty, or if it contains the required quantity of items.


The draw back with this scenario is that the lamp have a white light , and is therefore difficult to differ from ordinary lamp at night.
The drawback with this scenario is that the lamp has a white light , and is therefore difficult to differentiate from an ordinary lamp at night.
{{clear}}


== Oil Setups ==
== Oil Setups ==
Line 33: Line 30:
=== Light Oil Cracking ===
=== Light Oil Cracking ===
* This circuit provides balanced light oil and petroleum gas production by cracking excess light oil into gas.  
* This circuit provides balanced light oil and petroleum gas production by cracking excess light oil into gas.  
* The [[Small pump]] is connected to the [[Storage tank]] by a [[Red wire]].  
* The [[Pump]] is connected to the [[Storage tank]] by a [[Red wire]].  
* The [[small pump]] has an enabled condition set to '''Light Oil > 2000'''.
* The [[Pump]] has an enabled condition set to '''Light Oil > 20000''' (nb image is out of date).
{{clear}}
{{clear}}


Line 41: Line 38:
=== Heavy Oil Cracking ===
=== Heavy Oil Cracking ===
* This circuit extends on the previous circuit by adding optional heavy oil cracking to provide lubricant etc.
* This circuit extends on the previous circuit by adding optional heavy oil cracking to provide lubricant etc.
* The [[Small pump]] has an enabled condition set to '''Heavy oil > 2000'''.
* The [[Pump]] has an enabled condition set to '''Heavy oil > 20000''' (nb image is out of date).
{{clear}}
{{clear}}


Line 49: Line 46:
* This circuit buffers gas in the tank until there is at least 100, then it lets the tank drain until there is less than 50 and the cycle repeats.
* This circuit buffers gas in the tank until there is at least 100, then it lets the tank drain until there is less than 50 and the cycle repeats.
* It has a few elements that work together to do achieve this.  
* It has a few elements that work together to do achieve this.  
* Firstly the [[Small pump]] is connected to the [[Wooden chest]] by a [[Red wire]] and the enabled condition on the [[Small pump]] is set to '''Raw wood > 0'''.
* Firstly the [[Pump]] is connected to the [[Wooden chest]] by a [[Red wire]] and the enabled condition on the [[Pump]] is set to '''Raw wood > 0'''.
* Both of the [[Basic inserter]]s are connected to the [[Storage tank]] by [[Red wire]]s.  
* Both of the [[Inserter]]s are connected to the [[Storage tank]] by [[Red wire]]s.  
* The enabled condition on the left inserter is '''Petroleum gas > 100'''  
* The enabled condition on the left inserter is '''Petroleum gas > 100'''  
* The enabled condition on the right inserter is '''Petroleum gas < 50'''.  
* The enabled condition on the right inserter is '''Petroleum gas < 50'''.  
Line 61: Line 58:
[[File:ConditionalLights.png|left|400x400px]]
[[File:ConditionalLights.png|left|400x400px]]
=== Conditional Lights ===
=== Conditional Lights ===
* In this circuit we connect a series of [[lamp]]s to a [[Storage Tank]].
* In this circuit we connect a series of [[lamp]]s to a [[Storage tank]].
* By setting different conditions on each [[lamp]] we can build an indicator strip.  
* By setting different conditions on each [[lamp]] we can build an indicator strip.  
* The Enabled condition of the first [[lamp]] is '''Petroleum gas > 100'''.
* The Enabled condition of the first [[lamp]] is '''Petroleum gas > 100'''.
Line 99: Line 96:
* In this example we have generated a signal of 50 Laser turrets and 200 Piercing round magazine.  
* In this example we have generated a signal of 50 Laser turrets and 200 Piercing round magazine.  
* Constant combinators are not of much use on their own but we shall use them later.
* Constant combinators are not of much use on their own but we shall use them later.
{{clear}}
[[File:LogicGates.png|left|400x400px]]
=== Logic gates ===
* In each case the two inputs can be connected with the same color wire or different colors. The inputs are powered by two [[Constant combinator]]s each of them output an A signal with value 1 for true and nothing or false.
* You can use [[Decider combinator]]s to make all of the common logic gates.
* The output for each should be set to 1 and the signal of your choice.
* Use the following settings to create different gates:
{{clear}}
    NOT  A=0
    NOR  A=0
    NAND A<2
    XOR  A=1
    AND  A=2
    OR  A>0
{{clear}}
{{clear}}


Line 123: Line 102:
=== Constant combinator signs ===
=== Constant combinator signs ===
* You can use [[Constant combinator]]s to make signs, just set the letter signals in the combinator, each combinator can display 2 characters side by side.
* You can use [[Constant combinator]]s to make signs, just set the letter signals in the combinator, each combinator can display 2 characters side by side.
* Note that to see these letters, Alt-mode must be on and the Interface setting “Show combinator settings in “Alt-Mode”” must also be enabled.
{{clear}}
{{clear}}


Line 133: Line 113:
* If the [[Fast inserter]] hasn't picked anything up this tick the input to the Arithmetic combinator is the same as and output and hence the values are persisted.  
* If the [[Fast inserter]] hasn't picked anything up this tick the input to the Arithmetic combinator is the same as and output and hence the values are persisted.  
* When the [[Fast inserter]] does pick something up its value is added to the output from the previous tick thus incrementing that item.  
* When the [[Fast inserter]] does pick something up its value is added to the output from the previous tick thus incrementing that item.  
{{clear}}
[[File:BeltCache.png|left|400x400px]]
=== Automatic Belt-Cache ===
* Some intermediate products are huge in demand during peak-production only. To bypass the need of providing a huge amount of factories in order to cover that peaks, a cache-unit can be used. The unit stores items, while the belt has backed up (so theres obviously no current demand downstream) and releases items as soon as the belt gets too empty.
* The blue area are 3 parts of Express belts. According to the wiki, each belt can hold up to 7.11 items. This means the feeding fast belt can not provide 7.11 items for the express belts as long as the belt is moving. (And while the belt is moving, we don't want to cache items, but let regular production run, or even release items from the cache.)
* This means, once the counters on the two express belts are 7.11 each, the belt has backed up, so we can start "caching" items into our storage array.
* For this purpose, the counters are connected to the arithmetic combinator (A) which multiples the input (*100) into green signals. So, if the belt has backed up, B shows ">1422" green signals.
* This is the activation condition for the Belt (C), which will redirect the input tp the storage array.
* Since items should only be released if the belt starts to clear, the counter (D) is evaluated by the belt (E) which is only activated, if item-count on (D) is smaller than 6 (this number has to be adjusted to personal needs, when the cache should become "active" and release items)
* The layout can be extended to cache whatever amount of items is required. (Some balancing for the release-method would be required ofc.)
{{clear}}
[[File:combinatorMultiplierDetailed.png|left|400x400px]]
=== Multiplier and Dictionaries/Arrays ===
* Multiplying two signals together is simple and requires only a single combinator, however multiplying a set of signals is more complicated.
* A proof is shown below for the equation and why it works.
* A dictionary is a system that allows a value on a specific signal to be accessed. For example, A can contain many signals (either from a constant combinator or memory cell) and B can contain 1 of a specific signal (such as blue signal). What remains is the blue-signal value from A. This is because all the other signals are multiplied by 0.
* Arrays are similar to dictionaries, but instead of using a signal as a key, we use a number. Constant combinators are placed mapping each signal to a unique number (such as 1 yellow belt, 2 red belt, 3 blue belt, 4 burner inserter, etc). Then, use a combinator of "each = index OUTPUT 1 of each" and plug that in as the input to a dictionary.
[[File:combinatorMultiplierMath.png|left|400x400px]]
    ((A+B)^2 - (A-B)^2)/4 = AB
    (A+B)^2 - (A-B)^2 = 4AB
    (A^2 + 2AB + B^2) - (A^2 - 2AB + B^2) = 4AB
    4AB = 4AB
{{clear}}
{{clear}}


Line 167: Line 118:
[[File:LimitItemsPlacedIntoAChest.png|left|400x400px]]
[[File:LimitItemsPlacedIntoAChest.png|left|400x400px]]
=== Limit items placed into a chest ===
=== Limit items placed into a chest ===
*  The [[Basic inserter]] is connected to the [[Wooden chest]] using a [[Red wire]].  
*  The [[Inserter]] is connected to the [[Wooden chest]] using a [[Red wire]].  
*  The inserter's enabled condition is '''Advanced Circuit < 10'''.  
*  The inserter's enabled condition is '''Advanced Circuit < 10'''.  
*  In reality this means the inserter may place more than 10 Advanced circuits in the chest because it could pick up-to 3 at once.  
*  In reality this means the inserter may place more than 10 Advanced circuits in the chest because it could pick up to 3 at once due to stack size bonuses.
*  This effect can be even greater with Stack inserters because of their large carrying capacity.  
*  This effect can be even greater with Stack inserters because of their large carrying capacity.  
*  This technique still gives far greater control than limiting the inventory on the chest.
*  This technique still gives far greater control than limiting the inventory on the chest.
{{clear}}
=== Balanced chest insert ===
Goal: Load n chests with approximately the same number of items.
*  Place n chests and n inserters.
*  Place 1 [[Arithmetic combinator]]
*  Set the combinator to take Each (yellow star) and divide by the negative number of chests. ie &minus;n.
*  Connect all chests to each other and to the input of the combinator using red wire.
*  Connect all inserters to each other and to the output of the combinator using red wire.
*  Connect each inserter to the box it inserts into with green wire.
*  Set the enable condition on each inserter to be Everything (red star) < 0.
The combinator calculates the average number of items in the chests, and makes it negative. Each inserter gets the amount in the chest it is inserting to and adds the negative average, ie it calculates how many more than the average it has in its chest. Thus if that number is negative, it has less than the average in the chest and it enables.
Due to inserter stack bonus the count is not exact. If a precise count is needed, set the inserter stack size to 1.
{{clear}}
{{clear}}


Line 180: Line 147:
*  The [[storage chest]] is attached to the input of the [[Arithmetic combinator]] (left side in the picture) with a [[Red wire]].  
*  The [[storage chest]] is attached to the input of the [[Arithmetic combinator]] (left side in the picture) with a [[Red wire]].  
*  Another couple of [[Red wire]]s join the output of the [[Arithmetic combinator]] (right side) to the [[constant combinator]] and to the [[stack filter inserter]].  
*  Another couple of [[Red wire]]s join the output of the [[Arithmetic combinator]] (right side) to the [[constant combinator]] and to the [[stack filter inserter]].  
*  The [[Arithmetic combinator]] '''multiples''' each input value (from the storage chest) by '''-1'''.  
*  The [[Arithmetic combinator]] '''multiplies''' each input value (from the storage chest) by '''-1'''.  
*  Finally the filter stack inserter's mode of operation is set to '''Set filters'''.
*  Finally the filter stack inserter's mode of operation is set to '''Set filters'''.
<br />
*  So the input to the [[stack filter inserter]] is '''<Constant combinator> - <Storage chest contents>''' and the filter is set to filter for the first item by inventory order.  
*  So the input to the [[stack filter inserter]] is '''<Constant combinator> - <Storage chest contents>''' and the filter is set to filter the item of greatest demand.  
{{clear}}
{{clear}}


[[File:SolarAccumalatorBalancer.png|left|400x400px]]
[[File:SolarAccumalatorBalancer.png|left|400x400px]]
Line 191: Line 156:
=== Balanced Solar panel / Accumulator Production ===
=== Balanced Solar panel / Accumulator Production ===
* This circuit balances production of [[Solar panel]]s and [[Accumulator]]s to a desired ratio in my case 24:20.
* This circuit balances production of [[Solar panel]]s and [[Accumulator]]s to a desired ratio in my case 24:20.
* The first [[Arithmetic combinator]] takes the number of accumulators in the chest and '''multiples''' it by '''24'''.  
* The first [[Arithmetic combinator]] takes the number of accumulators in the chest and '''multiplies''' it by '''24'''.  
* The second [[Arithmetic combinator]] takes the output of the first combinator and '''divides''' it by '''20'''.  
* The second [[Arithmetic combinator]] takes the output of the first combinator and '''divides''' it by '''20'''.  
* This gives us the number of accumulators that we can directly compare to the number of Solar panels in both inserters.  
* This gives us the number of accumulators that we can directly compare to the number of Solar panels in both inserters.  
Line 209: Line 174:
{{clear}}
{{clear}}


[[File:SushiScience2.png|left]|400x400px]]
[[File:SushiScience2.png|left|400x400px]]
=== Memory Cell Design ===
=== Memory Cell Design ===
* This circuit counts the number of items of each type on a looping belt by counting the numbers that are added and removed from the belt by inserters.
* This circuit counts the number of items of each type on a looping belt by counting the numbers that are added and removed from the belt by inserters.
Line 218: Line 183:
* The memory cell's input is connected to the inserters that are placing items on the belt and the output of the left [[Arithmetic combinator]].  
* The memory cell's input is connected to the inserters that are placing items on the belt and the output of the left [[Arithmetic combinator]].  
* The inserters that place items onto the belt have an enabled condition that is based on the number of items on the belt.
* The inserters that place items onto the belt have an enabled condition that is based on the number of items on the belt.
{{clear}}
== Splitters ==
[[file:CondSplitter.png|left|400x400px]]
=== Conditional splitter ===
* This is the most simple circuit you can have for "controlling" a splitter.
* A signal X=1 is transmitted from off screen when the items need to be sent down the belt.
* The belt on the left is enabled when X=1.
* The belt on the right is enabled when X=0.
* The two belts are wired together and to a pole.
{{clear}}
[[File:PrioritySplitter.png|left|400x400px]]
=== Priority Splitter ===
* This circuit prioritizes items to the belt going of the screen to the left but will send items straight on if the belt to the left is backed up.
* Its not perfect and will leak some items but its good enough for most applications.
* The balancer means it will work even if the supply or demand is uneven.
<br />
* It is critical that the belts are setup as in this picture otherwise it may not work.
{{clear}}
{{clear}}


Line 251: Line 197:
Combined with the fact that creating the nuclear fuel cells are time consuming and expensive to create, it is therefore beneficial to optimize their use to match the actual consumed power.
Combined with the fact that creating the nuclear fuel cells are time consuming and expensive to create, it is therefore beneficial to optimize their use to match the actual consumed power.


[[File:NuclearSetupWithCircuits.png]]
[[File:NuclearCircuits.jpg]]


The above picture shows a setup with 4 reactors, that spend only 1 fuel cell each whenever steam backup runs low.
The above picture shows a setup with 4 reactors, that spend only 1 fuel cell each whenever steam runs low.


There are a couple of elements in this setup:
There are a few elements in this setup:


* 4 Storage tanks are connected with a wire, that is then connected to the substation. Each storage tank can contain 25.000 units of steam, for a total of 100.000 units. It is not necessary to connect more than 4 tanks, even though more tanks are added in the setup. However, connecting fewer is not recommended, since a single tank may fluctuate too much to give steady readings.
* Storage tank that provides the [[Steam]] signal.  You should only read from one storage tank, and it should have pipe connections to all your other steam storage tanks.
* 1 [[Tutorial:Circuit-network_Cookbook#SR_latch|SR-latch]], these are the 2 top-most combinators and the one on the right side. The low mark is set to 1.500 (1.5% of connected storage tank capacity) and the high mark to 5.000 (5% of connected storage tank capacity). The output can be anything except [[Used_up_uranium_fuel_cell|Empty fuel cell]]. In this example we output L. The inputs of the latch is connected to the substation, and so is the output.
* Chests containing [[Uranium_fuel_cell|Uranium fuel cells]] for the reactor.
This will trigger the response necessary during normal operation when we have enough fuel and have already started the reactors. The reason that we can have such low lower bound is that after start-up of the reactors the temperature will never drop below 500C, and thus immediately after a new fuel cell has been input the heat exchangers will start to generate more steam. The reason for the high mark to also be quite low is that we don't want it to trigger the insertion of another fuel cell until the previous one has been spent.
* Output inserters that take [[Used_up_uranium_fuel_cell|Empty fuel cells]] from the reactor. This is connected to the storage tank to listen for the steam signal, and to the chests to listen for the uranium fuel cell signal. If the steam level is low and there are uranium fuel cells available, it removes the empty fuel cells from the reactor and sends an empty fuel cell signal (since "Read hand contents" is checked).
* 1 stand-alone combinator (The one on the right), which checks if amount of steam is < 200 (0.2% of connected storage tank capacity), and outputs 1 [[Used_up_uranium_fuel_cell|Empty fuel cell]]. The inputs of the combinator is connected to the substation, and so is the output.
* Input inserters that put uranium fuel cells into the reactor. This is connected to the output inserters and listens for the empty fuel cell signal. The "Override stack size" is set to 1, so that it only inserts 1 fuel cell at a time.
This will trigger the response necessary during start up, and after running out of fuel.
* Output inserters that take [[Used_up_uranium_fuel_cell|Empty fuel cell]] from the reactor. This is connected to the substation (or any adjacent element that is then connected to the substation) and listens for the output of the SR-latch, ie. L > 0. Furthermore, it is setup to "read hand content" in "hold mode".
* Input inserters that put fuel into the reactor. This is connected to the substation (or any adjacent element that is then connected to the substation) and listens for the output of the output inserters OR the stand-alone combinator, ie. [[Used_up_uranium_fuel_cell|Empty fuel cell]] > 0. The "override input stack" is set to 1, so that it only inserts 1 fuel cell at a time.
This means that whenever the low mark is triggered, the output inserters will grab the empty fuel cell in the reactor, this then triggers the input inserters to insert a new cell. This only works if there IS an empty cell in the reactor, therefore the need for the stand-alone combinator to force always on of the input inserters, whenever the system previously ran out of the fuel, or is in start-up mode.
* 1 constant combinator to output whichever color you want the lights to be. This is not necessary at all, but looks nice.
* Lots of lamps to make it look nice, optionally setup to only turn on whenever steam level is at a given level to see storage.


 
Since this design uses empty fuel cells as a signal to fill the reactor, you need to manually insert 1 uranium fuel cell into the reactor to get it started.
{{clear}}


== Latches ==
== Latches ==
=== SR latch - single decider version ===
=== RS latch - single decider version ===
[https://forums.factorio.com/viewtopic.php?f=193&t=14556 This discussion] on the Factorio forums starts with the common 2 decider RS latch version, but the thread goes on to explain why this single decider version is better.
[https://forums.factorio.com/viewtopic.php?f=193&t=14556 This discussion] on the Factorio forums starts with the common 2 decider RS latch version, but the thread [https://forums.factorio.com/viewtopic.php?p=160896#p160896 goes on to explain] why this single decider version is better. In the thread, the latch is described as an SR latch. However, when both inputs are true, the latch will reset, so it is an RS latch.
==== Backup steam example ====
==== Backup steam example ====
This example will turn on the steam generator when the Accumulator charge drops to 20%, but will "latch" (remember) the On state until the accumulator is charged to 90%.
This example will turn on the steam generator when the Accumulator charge drops to 20%, but will "latch" (remember) the On state until the accumulator is charged to 90%.


Latching is used to introduce [[Wikipedia:hysteresis|hysteresis]] and avoid the power switch rapidly cycling on and off (as the accumulator falls to 19%, charges to 20%, falls to 19% and so on).
Latching is used to introduce [[Wikipedia:hysteresis|hysteresis]] and avoid the power switch rapidly cycling on and off (as the accumulator falls to 19%, charges to 20%, falls to 19% and so on).  
[[File:SR-01-Layout.png|left]]
[[File:SR-01-Layout.png|left]]
 
{{clear}}
<br clear=all>
{{BlueprintString|bp-string=0eNrFVk1vozAQ/SuVz1ABCaRBq5WqXntKjqsKOTBJR8IGGTtpFPHfd+w0HyU0G6pVewkxnnmemfdmzI4tSgO1QqlZumOYV7Jh6Z8da3AleWnf6W0NLGVrVNrQG49JLuyLvYU/Z63HUBbwxtKw9QZ4zs48o15P1CBObgXkWIDy80osUHJdqTOAUfviMZAaNcI+A7fYZtKIBSiK7YgjoEAjfCgh1wpzv65KoFPqqiHnStrzCdAPA49t6Rm1NrYOWjQY7QrY6FQZwcvyX1jJFajxEYrnuRGmdGW6DCe+jx1KcB9TDYl1raoyW8ArXyM5kFVldG10djObj6zdI0kKHp2Mdiy0PysFIM8pwYKldHyOKjeo3TI8y8Wup93tl7Yv3fiaOC6zjt6z9uk4VqDaR+rY7CvBO2ZGewUec1qiaobVxaE3mtseiwK7EjVXLsaU/SKPobWe7zHrLYVmpM6WqhIZSsJg6ZKXDQyiYkzF9Vhk9xUU3d3kNiaSQUwEB/l9Hw+uZg1YjGzYiPpA1+/vpKuHjk7fRNf7JrJTsZf05MLwoIFbzLvtOvlEFZNjKepqQ5poNqjz10s9jA6N+fk8Ohx/FMFXNXDqxeCC20F901vCJxN07UjVG9K4+x9YQp5M2LUZfbTpq+XDKRsNnG4cuULZcz089HZWD+D0a8Pz52bnNPgPzTj76dlJAnDfNenZp5fHSr4ACp/NZ3fPnHrkDt64qN31vwbVuFIn43GUjCdxHIVt+xcL2lBp}}
<div class="toccolours mw-collapsible mw-collapsed" style="width:50em;">
{{clear}}
Blueprint string for above backup steam example
[[File:SR-02-Accumulator.png|left]]Accumulator outputs the current charge level as % on signal [[File:Signal-A.png|21px]]
<div class="mw-collapsible-content"><pre style="white-space: pre-wrap;
{{clear}}
white-space: -moz-pre-wrap;
[[File:SR-03-RangeDeciders.png|left]]First decider outputs "Set" ([[File:Signal-S.png|21px]] = 1) if Accumulator is less than 20%.
white-space: -pre-wrap;
Second decider outputs "Reset" ([[File:Signal-R.png|21px]] = 1) once Accumulator is more than 90% full.
white-space: -o-pre-wrap;
{{clear}}
word-wrap: break-word;">
0eNrFVk1vozAQ/SuVz1ABCaRBq5WqXntKjqsKOTBJR8IGGTtpFPHfd+w0HyU0G6pVewkxnnmemfdmzI4tSgO1QqlZumOYV7Jh6Z8da3AleWnf6W0NLGVrVNrQG49JLuyLvYU/Z63HUBbwxtKw9QZ4zs48o15P1CBObgXkWIDy80osUHJdqTOAUfviMZAaNcI+A7fYZtKIBSiK7YgjoEAjfCgh1wpzv65KoFPqqiHnStrzCdAPA49t6Rm1NrYOWjQY7QrY6FQZwcvyX1jJFajxEYrnuRGmdGW6DCe+jx1KcB9TDYl1raoyW8ArXyM5kFVldG10djObj6zdI0kKHp2Mdiy0PysFIM8pwYKldHyOKjeo3TI8y8Wup93tl7Yv3fiaOC6zjt6z9uk4VqDaR+rY7CvBO2ZGewUec1qiaobVxaE3mtseiwK7EjVXLsaU/SKPobWe7zHrLYVmpM6WqhIZSsJg6ZKXDQyiYkzF9Vhk9xUU3d3kNiaSQUwEB/l9Hw+uZg1YjGzYiPpA1+/vpKuHjk7fRNf7JrJTsZf05MLwoIFbzLvtOvlEFZNjKepqQ5poNqjz10s9jA6N+fk8Ohx/FMFXNXDqxeCC20F901vCJxN07UjVG9K4+x9YQp5M2LUZfbTpq+XDKRsNnG4cuULZcz089HZWD+D0a8Pz52bnNPgPzTj76dlJAnDfNenZp5fHSr4ACp/NZ3fPnHrkDt64qN31vwbVuFIn43GUjCdxHIVt+xcL2lBp</pre></div></div>
<br clear=all>
[[File:SR-02-Accumulator.png|left]]Accumulator outputs the current charge level as % on signal [[File:Signal-A.png]]
<br clear=all>
[[File:SR-03-RangeDeciders.png|left]]First decider outputs "Set" ([[File:Signal-S.png]] = 1) if Accumulator is less than 20%.
Second decider outputs "Reset" ([[File:Signal-R.png]] = 1) once Accumulator is more than 90% full.
<br clear=all>
[[File:SR-04-SRLatch.png|left]]
[[File:SR-04-SRLatch.png|left]]
==== SR Latch configuration ====
==== RS Latch configuration ====
'''The central decider and green feedback wire is the actual SR Latch.'''
'''The central decider and green feedback wire is the actual RS Latch.'''
It latches the Set signal [[File:Signal-S.png]] until the Reset signal [[File:Signal-R.png]] is received (and vice-versa).<br />
It latches the Set signal [[File:Signal-S.png|21px]] until the Reset signal [[File:Signal-R.png|21px]] is received (and vice-versa).<br />
NB: the latch expects binary inputs ([[File:Signal-S.png]] & [[File:Signal-R.png]] must be 0 or 1) - this is why the previous two deciders are required.
NB: the latch expects binary inputs ([[File:Signal-S.png|21px]] & [[File:Signal-R.png|21px]] must be 0 or 1) - this is why the previous two deciders are required.<br />
When both inputs are true, the reset signal takes priority and the latch resets. This means it is an RS latch instead of an SR latch.
<br clear=all>
<br clear=all>
[[File:SR-05-PowerSwitch.png|left]]The Power switch isolates the generator from the rest of the factory until [[File:Signal-S.png]] = 1
[[File:SR-05-PowerSwitch.png|left]]The Power switch isolates the generator from the rest of the factory until [[File:Signal-S.png|21px]] = 1
<br clear=all>  
<br clear=all>  
----
----
=== SR latch ===
 
=== RS latch ===
[[File:SRLatch.png|left|400x400px]]
[[File:SRLatch.png|left|400x400px]]
* This should be familiar to anyone with any background in electronics.  
* This should be familiar to anyone with any background in electronics.  
Line 312: Line 245:


[[File:SRlatchinaction.png|left|400x400px]]
[[File:SRlatchinaction.png|left|400x400px]]
=== Usage of SR latch ===
 
* Here is an example of how you could use an SR latch.
=== Usage of RS latch ===
* Here is an example of how you could use an RS latch.
* The two extra [[Decider combinator]]s provide the set and reset conditions.  
* The two extra [[Decider combinator]]s provide the set and reset conditions.  
* Petroleum gas < 50 and petroleum gas > 100.  
* Petroleum gas < 50 and petroleum gas > 100.  
Line 319: Line 253:


[[File:BeltLatch.png|left|400x400px]]
[[File:BeltLatch.png|left|400x400px]]
=== Belt only latch ===
=== Belt only latch ===
* This is the most compact latch I am aware of.
* To make it work, '''3''' pieces of raw wood must be placed on the inside lane of the belt.
* To make it work you need to place '''3''' raw wood on the inside lane of the belt.
* It will have higher latency than the combinator version, but in most situations you will not notice the difference.  
* I believe it will have higher latency than the combinator version but in most situations you will not notice the difference.  
{{clear}}
{{clear}}


Line 328: Line 262:
[[File:5digitDisplay.png|left|400x400px]]
[[File:5digitDisplay.png|left|400x400px]]
=== Numerical Display ===
=== Numerical Display ===
* Each digit is driven by its own [[Green wire]], that wire holds 15 signals one for each lamp used in the digit.
* Each digit is driven by its own [[Green wire]], that wire holds 15 signals, one for each lamp used in the digit.
* [[Constant combinator]]s are used to define which lamp should light up for each value.  
* [[Constant combinator]]s are used to define which lamp should light up for each value.  
* Blueprint string including decoder [https://www.dropbox.com/s/5o13xuwthalzzfe/Brain2.txt?dl=0]
{{clear}}
{{clear}}


Line 352: Line 285:
== See Also ==
== See Also ==
* [[Arithmetic combinator]]
* [[Arithmetic combinator]]
* [[Constant Combinator]]
* [[Constant combinator]]
* [[Decider Combinator]]
* [[Decider combinator]]
* [[Circuit network]]
* [[Circuit network]]

Revision as of 19:00, 18 February 2020

Foreword

This page provides examples of simple circuit network designs and some not so simple designs that others can use, combine and modify. They are designed to be as easy to understand as possible. To see the settings of combinators without opening them, the option "Show combinator settings when detailed info is on" in the graphics options has to be checked and detailed info has to be turned on.

Lamp showing chest content condition

LightWiredToChest.png

This is the simplest possible use of circuit-network. A lamp is light depending on the number of goods (in this example empty barrels) in a chest.

Setting up circuit connection

  • The lamp is connected to the chest
  • the lamp is set to light if the chest contain less than 10 empty barrels.

To set the light condition

  • Open the lamp (left click on it)
  • Set the input to barrels
  • Set the operator to < (less than)
  • Set the constant number:
    • Left click on the constant number
    • Move the slider until 10 is shown, or edit the value box directly
    • Press set

Depending on the condition you set, the lamp may light if the chest is empty, or if it contains the required quantity of items.

The drawback with this scenario is that the lamp has a white light , and is therefore difficult to differentiate from an ordinary lamp at night.

Oil Setups

LgtOilCracking.png

Light Oil Cracking

  • This circuit provides balanced light oil and petroleum gas production by cracking excess light oil into gas.
  • The Pump is connected to the Storage tank by a Red wire.
  • The Pump has an enabled condition set to Light Oil > 20000 (nb image is out of date).
HvyOilCracking.png

Heavy Oil Cracking

  • This circuit extends on the previous circuit by adding optional heavy oil cracking to provide lubricant etc.
  • The Pump has an enabled condition set to Heavy oil > 20000 (nb image is out of date).
BalancedPlasticSulfur.png

Petroleum split evenly between plastic and sulphuric acid

  • This circuit buffers gas in the tank until there is at least 100, then it lets the tank drain until there is less than 50 and the cycle repeats.
  • It has a few elements that work together to do achieve this.
  • Firstly the Pump is connected to the Wooden chest by a Red wire and the enabled condition on the Pump is set to Raw wood > 0.
  • Both of the Inserters are connected to the Storage tank by Red wires.
  • The enabled condition on the left inserter is Petroleum gas > 100
  • The enabled condition on the right inserter is Petroleum gas < 50.
  • You will need to insert a single "Raw wood" into the chest to make it all work.


  • It is also possible to do this with decider combinators instead of the inserters, belt and the Wood chest or even just belts.

Lights

ConditionalLights.png

Conditional Lights

  • In this circuit we connect a series of lamps to a Storage tank.
  • By setting different conditions on each lamp we can build an indicator strip.
  • The Enabled condition of the first lamp is Petroleum gas > 100.
  • The others light up when gas is greater than 200, 300, 400 and 500 respectively.

In this scenario you can connect the storage tank to the lamps directly.


ColoredLights.png

Colored Lights

  • To light a lamp with a color rather than white, you need an intermediate device like an Arithmetic combinator that can send a color signal.

Instead of directly connect the the Lamp and the Storage tank you need:
1 Add the Arithmetic combinator.
2 Connect the Storage tank with the input of the Arithmetic combinator.
3 Connect the output of the Arithmetic combinator with the lamp.
4 Set up the Arithmetic combinator:
4.1 Setting the input to Petroleum Gas + 0 (the constant 0 not the signal 0)
4.2 Set the output to the Pink signal (on the bottom row of the last tab of signals.)
5 Set up the lamp:
5.1 Select the "Use colors" check box on the lamp.
5.2 Set the condition to the Pink signal, and what value you want (i.e. > 100)

Misc

MulitipleChestsAndPoles.png

Multiple Storages

  • If you connect multiple chests to a pole, the pole displays the sum of items in all the chests.
  • This also works with Storage tanks and roboports.
ConstantComb.png

Constant combinator

  • With a constant combinator you can generate any signals you may need.
  • In this example we have generated a signal of 50 Laser turrets and 200 Piercing round magazine.
  • Constant combinators are not of much use on their own but we shall use them later.
ThisASign.png

Constant combinator signs

  • You can use Constant combinators to make signs, just set the letter signals in the combinator, each combinator can display 2 characters side by side.
  • Note that to see these letters, Alt-mode must be on and the Interface setting “Show combinator settings in “Alt-Mode”” must also be enabled.
MemoryCell.png

Memory Cell / Counter

  • Basic memory cell that counts all the items moved by the inserter
  • The Fast inserter is connected to BOTH ends of the arithmetic combinator.
  • If the Fast inserter hasn't picked anything up this tick the input to the Arithmetic combinator is the same as and output and hence the values are persisted.
  • When the Fast inserter does pick something up its value is added to the output from the previous tick thus incrementing that item.

Inserters

LimitItemsPlacedIntoAChest.png

Limit items placed into a chest

  • The Inserter is connected to the Wooden chest using a Red wire.
  • The inserter's enabled condition is Advanced Circuit < 10.
  • In reality this means the inserter may place more than 10 Advanced circuits in the chest because it could pick up to 3 at once due to stack size bonuses.
  • This effect can be even greater with Stack inserters because of their large carrying capacity.
  • This technique still gives far greater control than limiting the inventory on the chest.

Balanced chest insert

Goal: Load n chests with approximately the same number of items.

  • Place n chests and n inserters.
  • Place 1 Arithmetic combinator
  • Set the combinator to take Each (yellow star) and divide by the negative number of chests. ie −n.
  • Connect all chests to each other and to the input of the combinator using red wire.
  • Connect all inserters to each other and to the output of the combinator using red wire.
  • Connect each inserter to the box it inserts into with green wire.
  • Set the enable condition on each inserter to be Everything (red star) < 0.

The combinator calculates the average number of items in the chests, and makes it negative. Each inserter gets the amount in the chest it is inserting to and adds the negative average, ie it calculates how many more than the average it has in its chest. Thus if that number is negative, it has less than the average in the chest and it enables.

Due to inserter stack bonus the count is not exact. If a precise count is needed, set the inserter stack size to 1.

SmartOutpostUnloader.png

Keeping outpost stocked with specified items

  • This circuit keeps a Storage chest at an outpost stocked with customized levels of different items.
  • For example you could keep an outpost stocked with 50 laser turrets and 200 piercing magazine rounds but not have to worry about it being over filled.
  • The storage chest is attached to the input of the Arithmetic combinator (left side in the picture) with a Red wire.
  • Another couple of Red wires join the output of the Arithmetic combinator (right side) to the constant combinator and to the stack filter inserter.
  • The Arithmetic combinator multiplies each input value (from the storage chest) by -1.
  • Finally the filter stack inserter's mode of operation is set to Set filters.
  • So the input to the stack filter inserter is <Constant combinator> - <Storage chest contents> and the filter is set to filter for the first item by inventory order.
SolarAccumalatorBalancer.png

Balanced Solar panel / Accumulator Production

  • This circuit balances production of Solar panels and Accumulators to a desired ratio in my case 24:20.
  • The first Arithmetic combinator takes the number of accumulators in the chest and multiplies it by 24.
  • The second Arithmetic combinator takes the output of the first combinator and divides it by 20.
  • This gives us the number of accumulators that we can directly compare to the number of Solar panels in both inserters.
  • If the number of accumulators is greater we enable the Solar panels inserter, if the number of Solar panels is greater we enable the accumulators inserter.
  • However, if they are equal, neither machine does anything. So we add a single accumulator to one of the inserters using a constant combinator and a wire of the other color, therefore breaking the deadlock.

Sushi Belts

SushiScience1.png

Reading Belt Design

  • Six belts in a row are connected with Red wire and set to Read belts contents and Hold
  • This Red wire is then connected to the inserters that insert onto the belt.
  • Read hand contents is unselected for all inserters.
  • Mode of operation is set to Enable/Disable on all inserters.
  • The first inserter is enabled when Science pack 1 = 0
  • The other inserters are set similarly for the other science packs.
SushiScience2.png

Memory Cell Design

  • This circuit counts the number of items of each type on a looping belt by counting the numbers that are added and removed from the belt by inserters.
  • Each inserter that takes items off the belt is connected together with Red wire and each of these inserters is set to Mode of operation none, Read hand content selected and Hand read mode pulse.
  • These inserters are connected to the input of the left arithmetic combinator.
  • The left Arithmetic combinator multiples each input by -1 and outputs it to each.
  • The right Arithmetic combinator is a memory cell as above.
  • The memory cell's input is connected to the inserters that are placing items on the belt and the output of the left Arithmetic combinator.
  • The inserters that place items onto the belt have an enabled condition that is based on the number of items on the belt.

Power

SteamBackup.png

Backup steam power

Optimal usage of fuel for nuclear power

Unlike the normal steam power that adjusts fuel usage based on power usage, the nuclear reactors spend fuel in fixed units of time. To be exact, the consumption of 1 fuel cell takes exactly 200 seconds.

Combined with the fact that creating the nuclear fuel cells are time consuming and expensive to create, it is therefore beneficial to optimize their use to match the actual consumed power.

NuclearCircuits.jpg

The above picture shows a setup with 4 reactors, that spend only 1 fuel cell each whenever steam runs low.

There are a few elements in this setup:

  • Storage tank that provides the Steam signal. You should only read from one storage tank, and it should have pipe connections to all your other steam storage tanks.
  • Chests containing Uranium fuel cells for the reactor.
  • Output inserters that take Empty fuel cells from the reactor. This is connected to the storage tank to listen for the steam signal, and to the chests to listen for the uranium fuel cell signal. If the steam level is low and there are uranium fuel cells available, it removes the empty fuel cells from the reactor and sends an empty fuel cell signal (since "Read hand contents" is checked).
  • Input inserters that put uranium fuel cells into the reactor. This is connected to the output inserters and listens for the empty fuel cell signal. The "Override stack size" is set to 1, so that it only inserts 1 fuel cell at a time.

Since this design uses empty fuel cells as a signal to fill the reactor, you need to manually insert 1 uranium fuel cell into the reactor to get it started.

Latches

RS latch - single decider version

This discussion on the Factorio forums starts with the common 2 decider RS latch version, but the thread goes on to explain why this single decider version is better. In the thread, the latch is described as an SR latch. However, when both inputs are true, the latch will reset, so it is an RS latch.

Backup steam example

This example will turn on the steam generator when the Accumulator charge drops to 20%, but will "latch" (remember) the On state until the accumulator is charged to 90%.

Latching is used to introduce hysteresis and avoid the power switch rapidly cycling on and off (as the accumulator falls to 19%, charges to 20%, falls to 19% and so on).

SR-01-Layout.png
Blueprint.png  Copy blueprint string

0eNrFVk1vozAQ/SuVz1ABCaRBq5WqXntKjqsKOTBJR8IGGTtpFPHfd+w0HyU0G6pVewkxnnmemfdmzI4tSgO1QqlZumOYV7Jh6Z8da3AleWnf6W0NLGVrVNrQG49JLuyLvYU/Z63HUBbwxtKw9QZ4zs48o15P1CBObgXkWIDy80osUHJdqTOAUfviMZAaNcI+A7fYZtKIBSiK7YgjoEAjfCgh1wpzv65KoFPqqiHnStrzCdAPA49t6Rm1NrYOWjQY7QrY6FQZwcvyX1jJFajxEYrnuRGmdGW6DCe+jx1KcB9TDYl1raoyW8ArXyM5kFVldG10djObj6zdI0kKHp2Mdiy0PysFIM8pwYKldHyOKjeo3TI8y8Wup93tl7Yv3fiaOC6zjt6z9uk4VqDaR+rY7CvBO2ZGewUec1qiaobVxaE3mtseiwK7EjVXLsaU/SKPobWe7zHrLYVmpM6WqhIZSsJg6ZKXDQyiYkzF9Vhk9xUU3d3kNiaSQUwEB/l9Hw+uZg1YjGzYiPpA1+/vpKuHjk7fRNf7JrJTsZf05MLwoIFbzLvtOvlEFZNjKepqQ5poNqjz10s9jA6N+fk8Ohx/FMFXNXDqxeCC20F901vCJxN07UjVG9K4+x9YQp5M2LUZfbTpq+XDKRsNnG4cuULZcz089HZWD+D0a8Pz52bnNPgPzTj76dlJAnDfNenZp5fHSr4ACp/NZ3fPnHrkDt64qN31vwbVuFIn43GUjCdxHIVt+xcL2lBp

SR-02-Accumulator.png

Accumulator outputs the current charge level as % on signal Signal-A.png

SR-03-RangeDeciders.png

First decider outputs "Set" (Signal-S.png = 1) if Accumulator is less than 20%.

Second decider outputs "Reset" (Signal-R.png = 1) once Accumulator is more than 90% full.

SR-04-SRLatch.png

RS Latch configuration

The central decider and green feedback wire is the actual RS Latch. It latches the Set signal Signal-S.png until the Reset signal Signal-R.png is received (and vice-versa).
NB: the latch expects binary inputs (Signal-S.png & Signal-R.png must be 0 or 1) - this is why the previous two deciders are required.
When both inputs are true, the reset signal takes priority and the latch resets. This means it is an RS latch instead of an SR latch.

SR-05-PowerSwitch.png

The Power switch isolates the generator from the rest of the factory until Signal-S.png = 1



RS latch

SRLatch.png
  • This should be familiar to anyone with any background in electronics.
  • The signal is set and reset with the constant combinators on the left by setting an A=1 signal.
  • The latch "remembers" which one was last set and the light stays on until another signal is received.
SRlatchinaction.png

Usage of RS latch

  • Here is an example of how you could use an RS latch.
  • The two extra Decider combinators provide the set and reset conditions.
  • Petroleum gas < 50 and petroleum gas > 100.
BeltLatch.png

Belt only latch

  • To make it work, 3 pieces of raw wood must be placed on the inside lane of the belt.
  • It will have higher latency than the combinator version, but in most situations you will not notice the difference.

Displays

5digitDisplay.png

Numerical Display

  • Each digit is driven by its own Green wire, that wire holds 15 signals, one for each lamp used in the digit.
  • Constant combinators are used to define which lamp should light up for each value.
BWDisplay.png

Black and White Grid Display

  • Each row has its own Red wire connection and within that row each light has a numbered signal 0-9.
  • We turn each light on by just setting or clearing the relevant signal.
MultiColoredDisplay.png

Multicolor Display by DaveMcW

  • To understand how this works, you first need to understand how color lights choose which color to light up when there are multiple colored signals.
  • The lamp will light up with the colored signal that is greater than zero and earliest in this list: Red, Green, Blue, Yellow, Pink, Cyan, White.
  • We have a Red wire per column, that wire has each of the colored signals on it at different values and a numbered signal for each row.
  • There is a Arithmetic combinator for each cell that subtracts the "row" value from each of the colored signals.
  • And this enables us to choose the color for each cell.
  • Simple!

See Also