Request random number of items from a inserter

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
cmnielsen
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Jan 09, 2021 7:06 am
Contact:

Request random number of items from a inserter

Post by cmnielsen »

Hello.

I'm trying to make my own koarex setup. I know thewre are many to be found, but I want to learn more about circuts, so I guess this is a way.

Can any make a fool proof guide how to get started?

I want to take 40 U235 from a belt, and then the inserter should not insert more, untill the centrifuge has made 41 U235. When 41 U235 are unloaded, a "start" signal should activate the first inserter again, untill another 40 is loaded.

I know this is maybe not the best way to use the kovarex, but it will give me some valuable understanding of circuts, as of wich I only understand the basics.

I have looked at https://wiki.factorio.com/Tutorial:Circ ... _/_Counter but the wiki is not too clear.

Tertius
Filter Inserter
Filter Inserter
Posts: 675
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Request random number of items from a inserter

Post by Tertius »

I tried to make an example how you might get into circuit network counters.
In the wiki circuit network cookbook, the explanation is a bit short.
You probably want to increase a counter when an item is inserted and decrease the counter, when an item is extracted.

If you use this counter for counting U-235, you can check if the counter reached 40, so this is the signal 40 U-235 have been inserted and the corresponding inserter should not insert any more.
If the counter reached -1 or some other negative value, this is the signal surplus items have been extracted, because you extracted more than you inserted.

The counter is a decider combinator with its output looped back to the input. This way the combinator memorizes the current value.
To make the counter increase when an item is inserted, wire the inserter and set it to read value in pulse mode and connect it to the combinator. Whenever a pulse comes in, it gets added to the combinator value, and it memorizes the new value.

To make the counter decrease when an item is extracted, wire the inserter and set it to read value in pulse mode. Then wire it to an arithmetic combinator and multiply it with -1. Then connect it to the decider combinator. So whenever a pulse comes in, it subtracts one from the counter value instead of adding one.

To reach 0 from negative values, you can use another inserter that additionally pulls items away, and read+add its hand value like the regular inserting inserter. Just that it removes the generated item from the system instead of feeding it back into the centrifuge. As soon as one item has been removed from the system, its pulse is added to the counter, it reaches 0, and you again have only 40 items to count.

This is an example how you can investigate how to increase/decrease the counter. Don't forget to set the stack size of inserters to avoid taking them more than 1 item if you don't want them to.
It counts the items on the center belt. The counter increases if the right inserter adds items to the center belt, and it decreases if the left inserter removes items.
You can activate the "R" constant combinator to reset the counter.
You can start/stop the belt on the right with the constant combinator with the "check" signal.
You can add conditions to the two inserters by switching their mode of operation from none to enable/disable. They can read their hand content as well as operate on conditions at the same time. For example, to make sure you only add items if there are less than 4 items on the center belt, set the condition in the right inserter to "U-235 < 4".
Screenshot 2023-12-10 154639.png
Screenshot 2023-12-10 154639.png (143.78 KiB) Viewed 748 times

You can run it yourself by starting a sandbox game, then switch to map editor mode with /editor. In map editor, the game is frozen. The map editor widget appears on the top left corner. Go to the "time" tab where you start/stop the game and even single step through the ticks. Single stepping through the ticks is the best way to get an understanding how more complex circuit things like loops will work. It's somewhat like debugging a computer program.

cmnielsen
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Jan 09, 2021 7:06 am
Contact:

Re: Request random number of items from a inserter

Post by cmnielsen »

@Tertius you are my hero, thank you for your reply and blueprint :D

astroshak
Filter Inserter
Filter Inserter
Posts: 597
Joined: Thu May 10, 2018 9:59 am
Contact:

Re: Request random number of items from a inserter

Post by astroshak »

Maybe someone else has a more elegant solution, but this is what I came up with. For this, you will need 5 Combinators : one Decider Combinator, and four Arithmetic Combinators.

On the Input side, you want two Filter Inserters : one set for U235, the other set for U238. On the 235 Inserter, connect it to one of the Arithmetic Combinators, using the Green Wire, on both the Input and Output sides. Set the Inserter to Stack Size 1, and to Read Hand Contents : Pulse. Set this Arithmetic Combinator to Each + 0, output Each. Set a second Arithmetic Combinator down as well, hooking the output of it to the Inserter.

On the Output side, you will want a similar setup : two Filter Inserters, one set for U235 and the other for U238. Again, set the stack size for the 235 Inserter to 1, and set it to Read Hand Contents : Pulse. Put down an Arithmetic Combinator, and again, using the Green Wire connect the 235 inserter to both the input and output sides and set the Combinator to Each + 0, output Each. And also, set down the final Arithmetic Combinator, connecting its output to the Inserter.

Set the Decider Combinator down. Connect its Input side to the Output 235 Inserter with a Red Wire. Set the Combinator to “U235 > 40, Output U235 = 1”. Wire the output of this to the Input side of the two Arithmetic Combinators that have not had anything set yet. The Input side of the machine’s Arithmetic Combinator now gets set to “U235 * -40, output U235”. The Output side of the machine’s Arithmetic Combinator gets set to “U235 * -41, output U235”.

On either side, the first Arithmetic Combinator is a Memory Cell. It keeps track of the U235 that each hand has picked up. This Memory Cell tells the Input Inserter when to stop working. The other just tells the Decider Combinator when to send the reset signal. When the Output Inserter hits 41 U235 removed from the machine, the Decider Combinator sends 1 to the two Arithmetic Combinators, which then send a -40 or -41 (depending on which Memory Cell it is aimed at through the Inserters) to reset the Memory Cells to 0. Note too that as soon as the Memory Cells reset to 0, the Decider is not getting the 41 U235 signal anymore, so the reset Arithmetic Combinators stop trying to reset the signals.

Note that this is NOT “tick perfect” so it may mess up at some point. I have not tested this setup, as I usually set Kovarex up long before I set up nuclear power plants and thus can afford to wait for the first machine to have 80 U235 before allowing the first one through to the second machine, and so on.

Loewchen
Global Moderator
Global Moderator
Posts: 8321
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: Request random number of items from a inserter

Post by Loewchen »

You can make a kovarex setup with only one combinator, but it might not be the best example for someone just trying to learn circuits

Tertius
Filter Inserter
Filter Inserter
Posts: 675
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Request random number of items from a inserter

Post by Tertius »

astroshak wrote:
Sun Dec 10, 2023 4:19 pm
I have not tested this setup, as I usually set Kovarex up long before I set up nuclear power plants and thus can afford to wait for the first machine to have 80 U235 before allowing the first one through to the second machine, and so on.
That's my strategy as well, since the limitation to 40 U-235 is only relevant when you just started. Later, it isn't relevant any more, so why bother in the first place? I found it extremely tedious and not worth the time to create such a circuit in the first place. It's not a good idea to start with th circuit network to control inserters for Kovarex, because the whole uranium processing facility is much much more complex than you might think in the first place. You get bogged down with it before you get a successful result.

As soon as I unlock uranium processing, I set up one uranium mine and as many centrifuges as I'm able to build at the time. I let the centrifuges create U-235 and U-238 and prepare a bunch of chests where this is stored. Totally simple, just putting down everything manually. Don't consume it, just pile up the stuff in chests.

As soon as there are at least 40 U-235, and Kovarex enrichment unlocked, I set up a very primitive Kovarex loop that's just feeding everything back to itself. I manually feed the 40 U-235 as starter into the centrifuge, add a belt loop running around the centrifuge so what's extracted can be fed right back into the centrifuge. Small filtering splitter setup needs to be added to supply the ring with U-238 and to separate U-235 and U-238 in two belt lanes. The U-238 can be provided by the chests or by newly processed uranium ore.
This runs unattended until the loop overflows with U-235. And this is the point where I set up my regular sophisticated blueprinted Kovarex setup that can be started with 40+80=120 U-235 that overflows on its own immediately, without the need of any counting circuits.

If I want to use nuclear reactors prematurely before at least 40+80=120 U-235 has been produced, I manually grab 5 U-235 as soon as 45 were produced in the primitive loop and create 50 uranium fuel cells for the reactor. If I use 4 reactors (480 MW) as start, this lasts at least 200 * 50 / 4 = 2500 seconds, usually much longer if I employ a wasteless reactor setup that uses steam buffers and inserts fuel only, if steam is low.

Additionally, I insert every speed module I was able to create at the time into the Kovarex centrifuge and into any beacons around it. This speeds up accumulating U-235 in the starting phase. This should be enough to get automatic uranium fuel cell production up and running before the manually created first 50 cells are running out.

One unmodified Kovarex centrifuge is able to produce 1 U-235 per minute or 60 per hour.
This can be doubled with 8 speed modules 1 (2 in the centrifuge and 6 more in 3 beacons around it) or 5-6 speed modules 2 (2 in the centrifuge and 3-4 in 2 beacons around it) or 2 speed modules 3 in the centrifuge and no beacons around it.

cmnielsen
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Jan 09, 2021 7:06 am
Contact:

Re: Request random number of items from a inserter

Post by cmnielsen »

astroshak wrote:
Sun Dec 10, 2023 4:19 pm
Maybe someone else has a more elegant solution, but this is what I came up with. For this, you will need 5 Combinators : one Decider Combinator, and four Arithmetic Combinators...................


Note that this is NOT “tick perfect” so it may mess up at some point. I have not tested this setup, as I usually set Kovarex up long before I set up nuclear power plants and thus can afford to wait for the first machine to have 80 U235 before allowing the first one through to the second machine, and so on.
Thank you for a good quality reply. I also make the Kovarex way before I need the powerplants, but it was a way to learn about circuts, and having a problem to solve, often gives better understanding of some complex situations.
Have a nice sunday.

cmnielsen
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Jan 09, 2021 7:06 am
Contact:

Re: Request random number of items from a inserter

Post by cmnielsen »

Loewchen wrote:
Sun Dec 10, 2023 4:52 pm
You can make a kovarex setup with only one combinator, but it might not be the best example for someone just trying to learn circuits
Thank you, i will look at it.

Post Reply

Return to “Gameplay Help”