Combinator Contraptions

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.
User avatar
hansinator
Fast Inserter
Fast Inserter
Posts: 160
Joined: Sat Sep 10, 2016 10:42 pm
Contact:

Re: Combinator Contraptions

Post by hansinator »

siggboy wrote:Here's a special purpose register that will accept any signal (or set of signal during the same tick), and then block any further writes until the "erase" signal is applied.

The erase signal is "Red" in the diagram, but could of course be changed if you actually need to store "Red" signals in your application.

The only other caveat is that you cannot store the value "-2^31", it's possible to change this if necessary; left as an exercise for the reader.

This register can handle 1-tick inputs, but it will also accept "hold" signals. It does not matter since all writes are blocked after the first tick of input. Just throw a signal at it and it will store it (forever/until reset).

I'm using this setup in my train scheduler, where I poll the outposts and need to accept one value (the first one that appears on the wire) and then process it -- so I want to block further writes to the register until the processing is finished. Other applications are surely possible.

You can put a 2-combinator circuit in front of it that generates an "erase" signal, and then you have a normal general purpose register that will accept any input, much like what piriform posted on the previous page on this thread, but without the caveats...
factorio-write-once-register.png
When I wire the register like in the picture it does not work. Are you sure that this is the working circuit?
There must be a difference, as we can't setup a decier combinator to "each" when the input is not "each" like in your picture.
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinator Contraptions

Post by siggboy »

hansinator wrote:When I wire the register like in the picture it does not work. Are you sure that this is the working circuit?
There must be a difference, as we can't setup a decier combinator to "each" when the input is not "each" like in your picture.
The output is "Everything (input count)" which I abbreviated to "EACH" in the diagram. Maybe not the best way to document it, but it's the only thing that makes sense if you understand what the circuit does :).
factorio-write-once-register.png
factorio-write-once-register.png (8.7 KiB) Viewed 11206 times
The input goes into the top two combinators at the same time (that is, during the same tick). As a result, the right combinator will output the input one tick later, unchanged (that's the "-> EACH", it's actually "Output everything (input count)"). The left combinator will input "Red = 1" into the right combinator in that tick.

So if the input appears in tick #1, then in tick #2 the following happens:
  1. Top-right combinators passes through the input. It goes into the bottom combinator, which is the actual value store (register).
  2. Top-left combinator inputs a "Red = 1" to the top-right combinator; that is the "lock" signal.
As a result, in tick #3 the register will hold the input, and also the top-right combinator will not output anything any longer (due to the "Red = 1" signal).
Also, the top-left combinator will continue to output "Red = 1", because it now receives an input from the register (bottom combinator).

Therefore, any further inputs can not get through to the register, because of the "Red = 1" signal being present and blocking any inputs.

The register then needs to be force-cleared in order to reset the contraption. The "clear signal" does not have to be "Red", it could be anything. That is, you could set up the bottom combinator to do "E = 0; Output everything" and it would work all the same (in that case you'd erase it by applying any "E" signal).
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Combinator Contraptions

Post by Optera »

I would abbreviate "Everything (input count)" to EIC to avoid confusing it with EACH.
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinator Contraptions

Post by siggboy »

Optera wrote:I would abbreviate "Everything (input count)" to EIC to avoid confusing it with EACH.
I did something like that in my other post (train stuff documentation, not in this thread), and it did confuse people as well.

Probably the best thing would be to use the symbols as they are in the game (e.g. a star on red background for "Everything", and so on).

However, no matter if you write "EACH" or "ALL" or "*" in the output, in this context it should be obvious what it means. The combinator condition is "Red = 0", so the output cannot contain that as a signal, in that case "EACH" obviously means "output everything from the input". "ALL" would have been better, because that's not yet taken.

In fact, it's not necessary to distinguish "Each" and "Everything", because they're mutually incompatible (like hansinator has pointed out). So it's always clear what you mean if you write "EACH" as the output: if there's "EACH" at the input, it will be just that, and otherwise it will be "Everything". Also, usually you output the input count, and not "1", or at least one should assume that "output 1" would be mentioned (maybe as "EACH 1" or "EACH = 1").

So I guess as long as you don't assume that the diagram is nonsense it's not that important that you strictly define what "EACH" means at the output side.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
User avatar
hansinator
Fast Inserter
Fast Inserter
Posts: 160
Joined: Sat Sep 10, 2016 10:42 pm
Contact:

Re: Combinator Contraptions

Post by hansinator »

siggboy wrote:The input goes into the top two combinators at the same time (that is, during the same tick). As a result, the right combinator will output the input one tick later, unchanged (that's the "-> EACH", it's actually "Output everything (input count)"). The left combinator will input "Red = 1" into the right combinator in that tick.

So if the input appears in tick #1, then in tick #2 the following happens:
  1. Top-right combinators passes through the input. It goes into the bottom combinator, which is the actual value store (register).
  2. Top-left combinator inputs a "Red = 1" to the top-right combinator; that is the "lock" signal.
As a result, in tick #3 the register will hold the input, and also the top-right combinator will not output anything any longer (due to the "Red = 1" signal).
Also, the top-left combinator will continue to output "Red = 1", because it now receives an input from the register (bottom combinator).

Therefore, any further inputs can not get through to the register, because of the "Red = 1" signal being present and blocking any inputs.

The register then needs to be force-cleared in order to reset the contraption. The "clear signal" does not have to be "Red", it could be anything. That is, you could set up the bottom combinator to do "E = 0; Output everything" and it would work all the same (in that case you'd erase it by applying any "E" signal).
I assumed that each should be everything and set it up accordingly. However, it does not work. So when I saw the "each" I assumed that you didn't even test exactly what you've drawn.
However, it turns out that I got confused by the drawing and misplaced one wire at first..

The green wire from the bottom combinator to the top right one is extremely misleading. For all wires but that one it is true that the top of a combinator is the input and the bottom of a combinator is the output (or left is output and right is input).

So it looks like the output from the lower combinator should be wired to the output of the upper left combinator. It is not clear that the direction arrow represents an output->input connection. It could also represent an output->output connection.

Nonetheless, I still can't see how the lower combinator would reset. There is no way signal red can get through to it.
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinator Contraptions

Post by siggboy »

hansinator wrote:The green wire from the bottom combinator to the top right one is extremely misleading. For all wires but that one it is true that the top of a combinator is the input and the bottom of a combinator is the output (or left is output and right is input).
Yes, but for all wires it's also true that the arrow always points from output towards input... so, without the arrows it would indeed need to be drawn in a different way.

Layouting the diagrams is more difficult if arrows are not used and/or the wires are always drawn at the "correct" end of the boxes (like in the game). So I tried to clean up the layout and put the wires in arbitrary positions, since the arrows make it unambiguous.
Nonetheless, I still can't see how the lower combinator would reset. There is no way signal red can get through to it.
The reset wire is not shown in the diagram. The "Red" signal in the top combinators is unrelated to the "Red" signal in the register. Like I've said, you can use any condition in the register (bottom) combinator.

In order to reset the register you need to apply the reset signal directly to the bottom combinator.

If you want to see how this register is used in a complex circuit you can check the link in my signature.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
User avatar
hansinator
Fast Inserter
Fast Inserter
Posts: 160
Joined: Sat Sep 10, 2016 10:42 pm
Contact:

Re: Combinator Contraptions

Post by hansinator »

siggboy wrote:..since the arrows make it unambiguous.
The point I was making is that it is not unambiguous..

Now with an additional reset wire it suddenly all makes sense.
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinator Contraptions

Post by siggboy »

hansinator wrote:
siggboy wrote:..since the arrows make it unambiguous.
The point I was making is that it is not unambiguous..
The arrow side goes to the input. The other side goes to the output. (Information flows in the arrow direction, from output to input.)

It is completely unambiguous, and it's what common sense dictates, you don't have to know anything about combinators.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
nubjub
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat May 13, 2017 1:57 pm
Contact:

Re: Combinator Contraptions

Post by nubjub »

Your Variable Signal Delayer 2.0 is terrific. I'm wondering if you could provide a flowchart of how you would change it such that the timer restarts with each new input signal, only releasing the delayed signal(s) if it can reach the set time delay without receiving any new signals.
nubjub
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat May 13, 2017 1:57 pm
Contact:

Re: Combinator Contraptions

Post by nubjub »

nubjub wrote:Your Variable Signal Delayer 2.0 is terrific. I'm wondering if you could provide a flowchart of how you would change it such that the timer restarts with each new input signal, only releasing the delayed signal(s) if it can reach the set time delay without receiving any new signals.
I've come up with a solution, very much based on Dr. Walrus's Variable Signal Delayer 2.0. The behavior of this is to accumulate incoming pulse signals, resetting the timer with each new signal. Only when no new signals are received for the duration the timer is set to does it pulse the accumulated values and reset the memory cell.
factorio-signal-delayer.jpg
factorio-signal-delayer.jpg (84.27 KiB) Viewed 10679 times
blueprint exported with foreman 1.1.6
blueprint exported from 0.15.x
My intended purpose was to smooth transferring virtual inventory on belts to real inventory in chests, but I've also bastardized this contraption to cross contents of train's with filters for a station.
Shown here: The rail signal resets the contraption on a yellow signal. The lone express inserter takes one handful of the cargo wagon's contents to set the memory cell, the value in the memory cell is crossed with materials the factory associated with this station has a deficit in. The filtered inserters reset the timer every time they take more items from the cargo wagon (without updating the memory cell). When the timer reaches the set duration (1 second) without being reset train is sent the signal to leave.
factorio-signal-delayer-as-station-cross.jpg
factorio-signal-delayer-as-station-cross.jpg (120.61 KiB) Viewed 10679 times
Claudius1729
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Mon Apr 03, 2017 5:47 pm
Contact:

Re: Combinator Contraptions

Post by Claudius1729 »

I want to iterate through a collection of signals, but I can't find an elegant way to iterate if many signals have all the same value. Sadly the special signal "Anything" isn't an output.

Example: Input=10 of all signals
Output= any single one of those
I could even do if the output isn't consistent in time (so for instance if the output flickers between any of the nonnull signal)

The trivial but totally impractical way I see is just filtering the input by every signal possible and select the first one that's not null through the signal. But that requires an insane amount of combinators and space.

Any ideas?
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3717
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Combinator Contraptions

Post by DaveMcW »

nubjub
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat May 13, 2017 1:57 pm
Contact:

Re: Combinator Contraptions

Post by nubjub »

Claudius1729 wrote:I want to iterate through a collection of signals, but I can't find an elegant way to iterate if many signals have all the same value. Sadly the special signal "Anything" isn't an output.

Example: Input=10 of all signals
Output= any single one of those
I could even do if the output isn't consistent in time (so for instance if the output flickers between any of the nonnull signal)

The trivial but totally impractical way I see is just filtering the input by every signal possible and select the first one that's not null through the signal. But that requires an insane amount of combinators and space.
This topic is a recent discussion of this challenge: viewtopic.php?t=42902
Do you have a way of predicting the possible signals you'll see, so it's not the set of all possible signals?
How many is an insane amount of combinators or space?

Here's an implementation that may be an insane amount of combinators, some basic instructions: The constant combinators designated as Filter Set in the image should include every signal type you could encounter on the input. Each signal type included in the Filter Set should have a unique value assigned to it, as the value is being used as an index for iteration. (I set up more than one constant combinator so hopefully it's clear how to add more signal types to the Filter Set). The combinator designated as Mod in the image should be configured with a value 1 greater than the highest value assigned to the signal types in the Filter Set.
Factorio-signal-iterator.jpg
Factorio-signal-iterator.jpg (101.63 KiB) Viewed 10526 times
signal iterator
Last edited by nubjub on Sun Jun 04, 2017 2:14 pm, edited 3 times in total.
Claudius1729
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Mon Apr 03, 2017 5:47 pm
Contact:

Re: Combinator Contraptions

Post by Claudius1729 »

I will take a look later but I do not think it's going to work.

I was trying to build a balanced logistic train station.

- Hence it could be any number of items.
- I have no way to guarantee that values of the signal would be unique in anyway.
nubjub
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat May 13, 2017 1:57 pm
Contact:

Re: Combinator Contraptions

Post by nubjub »

I have no way to guarantee that values of the signal would be unique in anyway
My instructions were obviously unclear, I'll retry in the original post, have a re-read please.
balanced logistic train station
I can imagine quite a few different things one might describe as a balanced logistic train station, so I'm still very much in the dark as to what you're working on. However, if I were trying to implement a round robin type mechanic I might well start by toying around with something that iterates through signal types.
Claudius1729
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Mon Apr 03, 2017 5:47 pm
Contact:

Re: Combinator Contraptions

Post by Claudius1729 »

Thank you that seems this is actually going to work. The size isn't too big.

As for my balanced logistic train station,

I built a contraption that takes in input a signal of item and then load a train with exactly that quantity using logistic chests, at a fairly decent speed with stack inserters. I use intermediary buffer chests to make sure not to load anything extra (and have a situation where an inserter is jammed because it's filled with something it can't unload for instance).

Here is my a test station of my first version (I've switched to a v2 that manages the buffer better, effectively removing extra items as my v1 doesn't need it and risk filling over the request). Requires the creative mod.
Test Station
Just turn the A signal to start the loading. Once loading is complete, turn off A and it will start to load the train.

However the way I divide the signal between wagons is simple division (one wagon contains the reminder, the others the result of the division) lead to situations like a request of 50 blue tunnel belt getting scattered across 8 wagons, which takes a lot of space.
So now I want to divide the signal more properly between the wagons, assigning stacks. I need to iterate over the signal to do that.
Now that I have an iterator, I just need to get down to it. The algorithm is fairly simple and wouldn't be too hard to translate to combinators.
fhoulbr
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Dec 16, 2017 1:10 pm
Contact:

Re: Combinator Contraptions

Post by fhoulbr »

Hi there,

I'm new to factorio and looked at the signal delayer 2.0...

I tried to reproduce the thing but the screen wiring to not match the diagram and if I do exactly what the flow chart shows, I can't get it to work. Do you have any example/blueprint I could use of this one? Or maybe something different?

I want to delay the stop/activation of factories for a few second to avoid shutting it and starting it every tic, have you a way to do that elegantly? I want some kind of memory that can keep the value for 10 seconds then update with the latest reading and so on.

Thanks.
golfmiketango
Filter Inserter
Filter Inserter
Posts: 549
Joined: Fri Jan 29, 2016 2:48 am
Contact:

Re: Combinator Contraptions

Post by golfmiketango »

fhoulbr wrote:Hi there,

I'm new to factorio and looked at the signal delayer 2.0...

I tried to reproduce the thing but the screen wiring to not match the diagram and if I do exactly what the flow chart shows, I can't get it to work. Do you have any example/blueprint I could use of this one? Or maybe something different?

I want to delay the stop/activation of factories for a few second to avoid shutting it and starting it every tic, have you a way to do that elegantly? I want some kind of memory that can keep the value for 10 seconds then update with the latest reading and so on.

Thanks.
To do that you can do something like this:
SayCheese.png
SayCheese.png (733.93 KiB) Viewed 9647 times
blueprint
If you provide a 1-tick "P=1" pulse to the right-most combinator, it will take a "snapshot" of everything else on the input side on the right. The "picture" will emerge from the left-most combinator three ticks later (on the green wire. On the red wire, it is available two ticks later; this discrepancy is unfortunate, perhaps, but exploitable, if you are interested only in tracking changes between the pictures). It's completely stutter free, and the "P=1" will not appear on the output side. It's kinda-sorta a stolen design from the multiplexing circuit in another thread. I use this all over the place; it's reliable enough that you can just plop it down and use it without giving much thought to the inner workings.

So, if you wanted to snapshot what's on the wire every 10 seconds, you would just make a 600-tick clock that pulses "P=1" into it, every ten seconds, and hook up your signal to it. It's OK (but perhaps not very UPS-efficient, if you could have shared your clock between builds) to let your clock spew, for example, the numbers P=599, P=598, ..., P=0 onto the wire. This is roughly how it's used in the multiplexer circuit; your snapshot will only occur when P is exactly one on the input side.

I'm not sure what it will do if you hold down the P=1 for more than one tick. Probably nothing good. Also there may be a lower bound on how fast it can gobble up pulses before it freaks out (I generally keep at least three non-pulse ticks between each pulse tick; perhaps the actual minimum is lower? Now that I think about it, I wouldn't be surprised if it can effectively take one snapshot every other tick without glitching out... furthermore I'd bet that if you "hold the shutter open" by emitting a continuous P=1 into it, it would do the exact same thing an analog camera would: accumulate until you take your finger off the button, and then preserve the resulting "composite time-lapse" image).

[Edit. Now that I think about it more, maybe I am wrong about the accumulate -- instead, I think it will effectively take a new snapshot every tick, but only on the red wire. But... I still have not tested this, just dry-running. Amazing how long I can try to reason it out but still not be sure... combinators are hard!]
SuicideJunkie
Fast Inserter
Fast Inserter
Posts: 124
Joined: Wed Aug 23, 2017 10:17 pm
Contact:

Re: Combinator Contraptions

Post by SuicideJunkie »

fhoulbr wrote:Hi there,

I'm new to factorio and looked at the signal delayer 2.0...

I tried to reproduce the thing but the screen wiring to not match the diagram and if I do exactly what the flow chart shows, I can't get it to work. Do you have any example/blueprint I could use of this one? Or maybe something different?

I want to delay the stop/activation of factories for a few second to avoid shutting it and starting it every tic, have you a way to do that elegantly? I want some kind of memory that can keep the value for 10 seconds then update with the latest reading and so on.

Thanks.
Rather than switching on and off with a timer, it is much simpler (2-3 combinators total) to switch on and off with a delay based on numbers.
IE: switch on if Accumulators are >50 and off if <40, or switch on if widget storage < 1000 and off if >1500

I've been doing those for a while with basic latches, but today learned that the package is called a Schmitt Trigger: viewtopic.php?f=6&t=28899&start=50#p189046



Also, while the wiki has a digital display, it isn't explained well and the blueprint string is broken.
I figured out the key to it last night in bed, and made this:
Blueprint String
extendable 7-seg display
extendable 7-seg display
7seg_display.png (476.54 KiB) Viewed 9490 times
The input value (black signal in this case) is divided by 10, then multiplied by -10 and combined. This gives the ones place digit at the same time as passing the 1/10th value to the next segment.
I then do 1 << digit to get a one bit value between 0b1 (0) and 0b1000000000 (9)
The constant combinator outputs signals for each element of the display. Signal (0) is for the top bar, signal (1) is for the top left bar, etc. The value of the signal maps to when the bar should be on. EG: Topleft (sig 1) should be on for digits 9,8,,6,5,4,,,,0 so it gets a value in binary of 0b1101110001 AKA 881 in decimal, as seen in the combinator window.
Finally the (EACH) AND (shifted bit value) will thus pass only the relevant signals to the lights and turn on the appropriate elements.
The lights are simply set to Signal > 0, with the specific signal they look for depending on where in the array the light is.

I was a bit disappointed that you can't put a constant number in the left side of an arithmetic combinator so I used 1 wooden box in the constant combinator. I ran out of wires but there is probably a way to run the whole thing off of one constant combinator as well.
If you want to see a number, such as your accumulator % or steam levels from the map view, this will work.

Should be useful for a map-view power meter.
Post Reply

Return to “Combinator Creations”