Combinators 101

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.
afk2minute
Fast Inserter
Fast Inserter
Posts: 120
Joined: Wed Aug 10, 2016 2:53 pm
Contact:

Re: Combinators 101

Post by afk2minute »

steinio wrote:Yes
Ok so the simpliest thing you can do is to multiply (using arithmetic combinator) contents of one of the warehouses by -1. Then if you connect wires from that combinator and from other non-multipied chest condition into inserters for 3 inserters is that item <0, and for other 3 is >0. Needs one arithmetic combinator per 2 warehouses...
I hope you get the idea, im pretty bad at explaining, feel free to ask.

If you want to plug more of warehouses you just make it other sign to the one you balance it with. So 3 warehouses is like (positive sign wh) (negative sign wh) (positive sign wh). You can expand it as much as you wish.

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2631
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Combinators 101

Post by steinio »

Nice, thank you.
I hooked something up and the warehouses are nearly equal at everytime but the inserters are always active.


Edit: Added third warehouse but had to use green wire. Don't know why.
Last edited by steinio on Fri Sep 09, 2016 6:25 pm, edited 1 time in total.
Image

Transport Belt Repair Man

View unread Posts

afk2minute
Fast Inserter
Fast Inserter
Posts: 120
Joined: Wed Aug 10, 2016 2:53 pm
Contact:

Re: Combinators 101

Post by afk2minute »

steinio wrote:Nice, thank you.
I hooked something up and the warehouses are nearly equal at everytime but the inserters are always active.
That is because of stack inserter bonus + they work together.
Just set them work if its >100 / <-100, it will be a little less equal, but they should stop work all the time.


You had to use green wire to prevent singnal from the third\second balancing inserters going to the first\second inserters, that will mess things up, didnt thought about that and didnt mentioned that you need more wire colours than 1.

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2631
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Combinators 101

Post by steinio »

Fantastic.
A differenz of 10 was enough for this moment, don't know if stack bonus gets this high.

Would make a video if needed.

Thank you very much.
Image

Transport Belt Repair Man

View unread Posts

User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinators 101

Post by siggboy »

You can use a balancer on the loading side and also at the unloading side, as explained in the sticky thread "Balanced Buffer" (23125).

Such a balancer will only load the warehouses with fewer than the average item count, and it will only unload the warehouses with more than the average item count (if they're already balanced it will load/unload all of them).

I don't think that re-balancing the warehouses the way you're doing it has any advantages, and it's more difficult.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2631
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Combinators 101

Post by steinio »

Well looks interesting but seems to need more combinators.

This will not work because i only insert remove from the first (left) warehouse and the others are only expansions.
Maybe i will use it for train stations as suggested.

Greetings steinio
Image

Transport Belt Repair Man

View unread Posts

afk2minute
Fast Inserter
Fast Inserter
Posts: 120
Joined: Wed Aug 10, 2016 2:53 pm
Contact:

Re: Combinators 101

Post by afk2minute »

steinio wrote:Well looks interesting but seems to need more combinators.

This will not work because i only insert remove from the first (left) warehouse and the others are only expansions.
Maybe i will use it for train stations as suggested.

Greetings steinio
If you unload\load only from the first chest, isnt it better to load into the second chest once the first is full and the third when the second is full?
Not "better" but more "logical" or something like that. And it does now need any combinators.

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2631
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Combinators 101

Post by steinio »

Yes thats an alternative way to do it but it don't sounds like it make fun :)

I guess i'm in love with the eqalizing function so i will play with it a while and maybe change it later.

Greetings steinio
Image

Transport Belt Repair Man

View unread Posts

User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinators 101

Post by siggboy »

You can average all the warehouses with a single combinator, and then you can enable the inserters to equalize. This still works even if you only load one of the warehouses. It doesn't really matter how many warehouses you use for loading and/or unloading, the inserters will always try to keep them even.

The combinator takes all the contents from the warehouses (input) and divides by (number_of_warehouses * -1), i.e. you divide by the negative count of warehouses. The output of this combinator goes to all the inserters. Use green wire.
The inserters are connected to the warehouse in front of them (= destination, i.e. unload location) with red wire. The inserters are enabled when "Everything < -3", assuming they're Fast Inserters and you have maximum stack bonus. This needs to be modified for stack inserters because they can move 12 items at a time.

If you use more than 1 inserter to move from warehouse to warehouse you set the number higher, otherwise you will have perpetually moving inserters (the average will still be kept but the inserters will do their monkey business until you shutdown the game :). You set the threshold to (-1 * num_inserters_per_direction * stack_size), e.g. "Everything < -9" if you have 3 inserters in each direction. But it appears to be finicky, sometimes it doesn't reach equilibrium. So I guess higher thresholds are required (double?), I'm not sure what the theoretical best value is.
You figure it out :). I think it depends on the total item count, what the modulus is and also timing. With high a high enough value it should always stop, only the balance does have some margin of error, not really an issue with warehouses I guess...

Here's a blueprint:

Code: Select all

H4sIAAAAAAAA/9VXwW7jIBD9lYgz7gY7Tht1uexP9FCtLGpPEyQHLMBpI8v/vthJ1RDjTdjTklMShpl5bx7PuJKLWpasXhS0A2G44aBp1wm2B4o+mIKdbDUk
2kjFtoBwI7WNkYJ2nzR5fMjxkSbLh7zHpRQCymHJ7n9FBP2mnYLK5hrTHgte0ae+x1sFIJx/V/3wweea70ybhAsNyoC6qrcaqmU9rrg6laLroa5Rsi7eYMcO
XCralVyVLTeFXanOe9+50qbQfCtYTTtzbGyhA1emZTXCp7qnxQQOoI5mx8UWjZi0YcLQZGO/7xummOWBop+ovw9w5gWchQFOIwJse734tfHCn8RckHFLcctA
xW2cWmTpbYg4QY/uFkv4md4x8s7JZbEpde1lZh2ENyah5u6UiRf+NOh+qa4DlTrTQpg5Li8nkP7fE3BPHfFb5WYSFOKcJCJBrhykfjaermL+os4bZzUmobjM
kNzv4eQ6at7F0yBXi0lE7rPL7+mTRyL+F8MfD1gakYpmDCbQUkhEiF23IOkdlkKCjkZU45+xjTwEcEzTvzrYZOXHP426oIMpbnZ7MLxMbA9vXAw9uLSQ8ZqT
3SLmO9M3NzqIHFbuHFoyLBuwpAwV0Q+EZWuaNiTXDI/+Kxh+Ral/dXinGDnj5ZimczvgBvZf5ac3RrtLVPA5vFecY36xmokSqsXLV7BG/bMC0yqxKJ5BVH8A
cuGYybIPAAA=
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

aeros1
Long Handed Inserter
Long Handed Inserter
Posts: 87
Joined: Wed Aug 03, 2016 3:44 am
Contact:

Re: Combinators 101

Post by aeros1 »

I would tackle memory cell problem a bit.
Now first is pulse memory or counter it is simple short circuited "+" decider input "A+B" output "A" "B" is setter. Important not to screw with memory the out wire should be different color. It is in first post.

Now for memory cell is harder.
Top constant combinator is setter (It sets to memory), The bottom one is Eraser(writes 0 to memory when >0). both don't care about signals and can be pulse. Both combinators output test "A=1" value when on.
The attachment Memory cell.jpg is no longer available
The right "*" combinator is memory cell and stores value as long as nullifier doesn't sends signal. Input "A*B" output "A" Important not to screw with memory the out wire should be different color.
The left "*" combinator is anologue "AND" to limit addition to one cycle, when we write cell. Input "A*B" "A" output.
Top "=" decider is simple if. Input "A=0" output "A" It protects memory cell from continous inputs.
Bottom "<" decider is "NOT" operator. Input "A<1" output "B"

Now this memory cell is not perfect. Though it is possible to make auto reset with pulse generator, once value changes.
First it only can store value if it is empty (Stored value is 0), Second it stores double value instead. It is important to use Red wire for cell, and please don't connect any part of cell network(except ones used to connect constant combinators), with red wire use green instead or memory cell would freak out. "Colors can be switched, aka Green for Cell, red for external connection from cell output.
Though it is trival task if new value and stored value not matched to use pulse generator to reset memory.(Not putting solution not to complicate already complicated design).
Attachments
Memory Cell.jpg
Memory Cell.jpg (67.91 KiB) Viewed 11192 times
Last edited by aeros1 on Tue Sep 13, 2016 10:48 pm, edited 1 time in total.

aeros1
Long Handed Inserter
Long Handed Inserter
Posts: 87
Joined: Wed Aug 03, 2016 3:44 am
Contact:

Re: Combinators 101

Post by aeros1 »

Another one for people curious how to limit inserters to 1 item even with research.
inserter limiter.png
inserter limiter.png (268.54 KiB) Viewed 11355 times
The top tower and constant combinator is amount setter. Top + combinator connected to belt is "A+B" output "A"
First connected control belt(left one) It is on when "A>0", second belt set on pulse detect belt.
Bottom "*" combinator set to "Belt"*-1 output "Belt" (takes value from right belt sensor, and outputs to counter "+" combinator.
It is even possible take out from stopped belt and feed back to main stream. As well as put directly on control belt.(Left one)

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Combinators 101

Post by ssilk »

After some thinking (I was really unsure) I moved the combinator 101 to the new subboard Combinator Creations.
Happy working on this great thread. :)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3699
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Combinators 101

Post by DaveMcW »

GopherAtl wrote: Output Modes
They have two output modes - "1" or "input count." Setting them to "output 1" makes them output a count of 1 of the selected type if the condition is true, and output nothing otherwise. In general, values of 0 are not usually sent as signals, so you won't see a signal count of '0' in the info box on the right when selecting them; no signal is treated as a count of 0, though, so it's not usually a problem. There is an exception I'll get to later, though, so keep it in mind.

Setting the output to "input count" means that, if the condition is true, the number output on the signal is the same as the input on the signal selected on the left in the condition. So, if you had a combinator test "iron plates > copper plates" and output signal "coal" as "input count", when the condition is true, the combinator will output the number of iron plates, as a signal on coal. The coal value in the input, if present, is not a factor. If the output type doesn't match the left type in the condition, then when true, it basically converts the signal to the specified output type.
This is wrong in Factorio 0.13 and higher. Decider combinators can't rename signals anymore.

User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinators 101

Post by siggboy »

DaveMcW wrote:This is wrong in Factorio 0.13 and higher. Decider combinators can't rename signals anymore.
They still can, but only if you use the "Each" virtual signal in the input condition. In my opinion that is a bug/oversight, but I guess it should be mentioned.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

kann_
Inserter
Inserter
Posts: 44
Joined: Fri Apr 15, 2016 4:36 pm
Contact:

Re: Combinators 101

Post by kann_ »

Abstract Data types in Factorio

I was building a bigger automation project and was running into a reappearing problem.
Multiple signals on one wire are tricky to separate.

Just to clarify, I am talking of arbitrary signals with unknown type, value, and number.
There is the way to use a “database” with all possible signals and iterate through all of them, but that is tedious to set up and takes one tick per possible signal.
So I started thinking about alternatives. One neat solution would be to store the value of the signals on one wire and the order of the signals on a second wire. This way it is easy to separate the mixed signal later.

And what is a neat way to store the order of signals: a Stack.
Sorry for the low quality, but the file got too big.
Sorry for the low quality, but the file got too big.
Push & pop.gif (3.72 MiB) Viewed 10702 times
Operation Details
Blueprint

User avatar
moon69
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Sep 18, 2016 6:53 pm
Contact:

Re: Combinators 101

Post by moon69 »

siggboy wrote:
BlaatMekker wrote:A simpler S-R latch design: two binary (0/1) signals (A and B) being fed into one signal decider combinator which feeds back into itself.
...
This is in every aspect the better latch design than the one shown in the OP
...
Thanks to BlaatMekker, siggboy and others on this thread - the 2 decider SR latch examples floating about were doing my head in!
I've added this section to the wiki:
Tutorial:Circuit-network_Cookbook#SR latch - single decider version

mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Combinators 101

Post by mrvn »

steinio wrote:Hello,

i tried some stuff with combinators and tested the latch from this thread which worked at the end.

Now i have the following 'opportunity':

2 warehouses which should always stay equalized (as the inserter speed allows).
So i thought about 3 inserters pointing in each direction and connect some deciders.

The warehouses are only big chests and circuit network connectable.

There should only the inserter be active which points to the warehouse with the lower value.
What happens if i add a third warehouse which should be synched with the second and so on?

Here i have no clue how this can work because the decider always get two signals with the same item only with different numbers.
Should also not to take much space.

I would be thankfull for help.

Greetings steinio
I solved the same problem yesterday and it is really simple.

For single item warehouses: Add an arithmetic combinator "each * -1 = each" connectred to one warehouse. Connect the output and the other warehouse to the inserters. Set one inserter to enable when "anything > 12" and the other on "anything < -12".

For multi item warehouses it is more complex. You need to program each direction separately. Again use an arithmetic combinator to negate one warehouse. Then add a constant combinator to subtract a few for each item the warehouse might contain (or set the arithmetic combinator to "each * -1.1 = each"). Connect all three to a filter inserter and use it to set the filter. For the other direction use the same setup but negate the other warehouse.
Note: you can use a single constant combinator for both direction by using different wire colors.

The reason for the "> 12" or the constant combinator is to stop balancing when the warehouses are nearly equal. Say one warehouse has 6 more item than the other. Then a stack inserter would take 12 items from one warehouse to the other. No the other warehouse has 6 more items than the first. So the other stack inserter would move 12 items the other way. Ad eternitatem. So some inbalance has to remain.
Note: If you have multiple inserters in each direction then you need to increase the value. E.g. 2 stack inserter can move 24 items at a time. If you only have fast inserters than you can lower it, their stack size is smaller.


For 3 or more warehouses I would simply put them in a row and balance between each two.

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2631
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Combinators 101

Post by steinio »

Multi item equalizer warehouses:
viewtopic.php?f=193&t=48302&p=285050#p285050
Image

Transport Belt Repair Man

View unread Posts

SuicideJunkie
Fast Inserter
Fast Inserter
Posts: 123
Joined: Wed Aug 23, 2017 10:17 pm
Contact:

Re: Combinators 101

Post by SuicideJunkie »

siggboy wrote:The "B" signal is not even necessary. An even simpler way to make it is: "A > 0; Output A = 1" (and feed it back to itself). This one is toggled on with any positive "A" (of any length), and toggled off with any negative "A".
A great use for this is to have a persistent Charging/Discharging indicator using only two combinators.

1) Accumulator -> MonoLatch
2) Accumulator -> {*-1} op -> MonoLatch

Since the multiplication op's result is delayed by a tick, whenever the accumulator charge increases, you'll get a 1 tick Set signal, and when the charge decreases, you'll get a 1 tick Reset signal.

User avatar
Baile nam Fonn
Inserter
Inserter
Posts: 22
Joined: Sun Sep 17, 2017 4:48 am
Contact:

Re: Combinators 101

Post by Baile nam Fonn »

GopherAtl wrote:Now, timers are related to clocks, and can be based on them. This one is probably not optimal, but it will hopefully be easy to understand as it simply combines the clock I just showed you with an r-s latch and pulse generator like I showed you earlier. As always the pulse generator may or may not be necessary; in the test setup, the input signal stays on until I remove the iron from the chest, so I'm using one. If your input signal is itself a pulse, or will always turn off by the time the timer is finished, then you can skip it.

Image
H4sIAAAAAAAA/9WWbW+bMBDHv0rkl5OpAoUsVetK+xzVhDzbaU8yNjJHtQjlu89O2BbIQ4EWbeVV0Jn73/3ufBdpF9oKrhc5a5RBQFAVaxrDC8VIVXCHkXhR
FRJa2spbrWHNTxalNxndsii+yXZUWGOUCCb/5ROJyXfWOCW9l73DbQ6SJVSAEzVgeIl34aGtiFQCpHKRsMUPMByt62klf5QkuINQ8DdANQjRJ5Kcs6W9iOiz
U8p0jtyeBB1UJbSibeCs2YCrMK/g2XDNGtyWPitAVRB6yBCcNVGpOSqy91AhN8iW/mdRchcyZoQRamss676fV3BYc/3b1cEYfds7Kre5sLXBfONskYPxXzOy
4bryOmP5LofwPUXUqWtyhPv06Nd30LxGocUZz4MTXT2KZjy5WXso6SV0yZWmvpuXcbdlH/8V43Qy46wH8sylj5dDYWdd2McFW89bh1W32R/mKoSf/1pHmhdl
twCrkdP/lGmXR2v8sL48SoE7wJdCIYjrA3Di/Lsd2iz9ddMj8DfMyRCimNpSeQYhfvJlbE+MnHGDeL11/a5si27LfPwVytbzzLLR6zedCjO9vC+Gz7C5Mf8v
f3IC5WQK5bu3N8Z64nY+rtjqrOfscxdnR0HsA23ASBXmxsVi+cP3TmHtzCK/V0b+AsUB0N2XDAAA
On the left you should recognize the normalized pulse generator I talked about for using with r-s latches. It is exactly as before, except the condition - in the top decider - has been changed to "iron = 0" instead of "iron > 0."

To the right of that, next to the lamp, is the clock, like the first I showed; it's set to "A<60" and outputs A, as before.

The two below the clock are the r-s latch, exactly as before.

The extra one, to the left of the r-s latch, is set to "A > 57." That number is deliberate, set to the clock's upper limit minus 3. Any higher and it won't output true long enough to properly reset the latch, and the whole thing will become undetermined.

The result: when the chest becomes empty, a pulse is sent and the latch turns on. This turns on the clock, which begins counting up.

When the clock approaches 60, a reset signal is sent to the latch, which turns off just as the clock reaches 0. If you work through exactly what happens, cycle by cycle, you'll see this is why the new decider is at 60 - 3 or 57 rather than 60 - 2, which would be 58.

And so, we took an input condition - chest out of iron - and generated a timed output signal for 1 second. You could use another pulse generator on the output, triggered on the falling edge like I mentioned in that section, to turn this into a pulse, generated 1 second after the condition became true. By changing the values 60 and 57, you can adjust the timing to anything you want - though the minimum is 3 cycles for this particular design. (for shorter times than that, using a series of deciders to delay a signal, one per cycle, will be easier and far simpler). The rule is just 60 * the number of seconds you want for the clock, and that minus three for the decider that connects the clock to reset, so for a minute, it would be 60*60 = 3600 and 2597.[/spoiler]
Could someone help me out with a reconstructed, clearly labelled, up-to-date version of this tutorialized timer?
I want to learn and apply this (specifically the falling edge generated pulse variant he mentions), but the blueprint string isn't working for me and I can't figure out how to reproduce it based on these instructions.

Post Reply

Return to “Combinator Creations”