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
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Combinator Contraptions

Post by Optera »

How would you build a toggle light switch with combinators?
- N constant combinators outputing the same signal (lamp = 1)
- combinators and lamps are connected on one circuit
- changing on/off of any constant combinator should toggle the connected lamps
- no more than 2 signals should be on that network: one is the sum of currently active combinators and the second as lamp control signal


Edit:
nevermind.... i was thinking way too complicated.
Simplistic solution was using every odd number. :oops:
Attachments
2016-07-25-17-28-41-7780692.jpg
2016-07-25-17-28-41-7780692.jpg (92.53 KiB) Viewed 9712 times
User avatar
Dr. Walrus
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Fri Nov 20, 2015 6:30 am
Contact:

Re: Combinator Contraptions

Post by Dr. Walrus »

Optera wrote:Edit:
nevermind.... i was thinking way too complicated.
Simplistic solution was using every odd number. :oops:
You can take it one step further. With 4 combinators setup like this, you can have an unlimited number of light-switches without having to add a new combinator for every 2 switches you add.

Picture:
Image

This setup works by taking the input of "Lamp" and outputting 1 signal "white" if the count of "Lamp" is odd and outputting nothing if the count of "lamp" is even. As you discovered, every time you turn on or off a switch, the count of "Lamp" changes from odd to even or even to odd. That means every time you flip a switch the lamps will turn on/off.

Schematic: The oval input in the schematic is attached to all of your light-switches.
Image

If you aren't worried about the lamps turning on or off in the first few game ticks (1/60 sec) after a switch has been flipped then you can remove 2 combinators and just use this:
Image
User avatar
komrade_toast
Inserter
Inserter
Posts: 44
Joined: Sat Apr 16, 2016 3:28 am
Contact:

Re: Combinator Contraptions

Post by komrade_toast »

I haven't read through the entire thread yet, so I'm not sure if someone already posted this.

I created a small contraption that will read the percentages from your accumulators, convert that to MJ then spit it out for things to use. It also includes an S-R Latch for turning a switch on / off and controlling power networks. I use it to see the amount of power in my accus and to control my steam generation at night. The constant combinators by the Nixie tubes are just for controlling the colors of them, they are not part of the actual device. Combinator "A" sums the output of my four accumulators and multiples it by the total amount of MJ capable of being stored in my accus (this value is set by the Constant Combinator "E"). It then outputs that value to Combinator "B" to be divided by 400 (400 comes from my number of accus times 100). Combinator C is what sets the condition for when to activate Combinator "D", in this case, if my power drops below 2MJ. The output of Combinator "D" is what you would hook up to a power switch to control your network. The output of Combinator "B" is what is sent to my nixie tubes for displaying the Megajoules stored in my accumulators, If i used the output of Combinator "D" for this it would only display when my power drops below 2MJ. It probably isn't the most efficient setup, as I found that when transitioning from accu power to steam power my whole network flickers on and off very quickly (I'm lucky I'm not epileptic, because my lights flash very fast during this transition). If anyone knows how to fix that, I would greatly appreciate it.

Personally I like the method that someone posted here on the forums that uses water tanks and a small pump hooked to a power switch to control steam power (I forget who it was and where they posted it, or I'd link for credit). I just thought I would give this a shot to see if I could make a decent combinator-only setup.
Setup Image
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinator Contraptions

Post by siggboy »

komrade_toast wrote:I found that when transitioning from accu power to steam power my whole network flickers on and off very quickly (I'm lucky I'm not epileptic, because my lights flash very fast during this transition). If anyone knows how to fix that, I would greatly appreciate it.
You need to put a Schmitt Trigger between your accumulators and your power switch.

Here's a description: viewtopic.php?f=6&t=28899&start=50#p189046

(I will make a post about the three best possible ways to create them in this thread, I meant to do that for a while now).
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
User avatar
komrade_toast
Inserter
Inserter
Posts: 44
Joined: Sat Apr 16, 2016 3:28 am
Contact:

Re: Combinator Contraptions

Post by komrade_toast »

Isn't what combinators C & D are doing similar to a Schmitt Trigger? I'm essentially setting an upper with the constant combinator output of C and a lower with the value of 2 in combinator C. The feedback between the two combinators causes the switch to happen. I've added the schmitt trigger to my design, but haven't been able to drain enough power at night yet to test it out (i'm on my main game map, and have a rather large amount of accus). The Schmitt trigger looks like the S-R Latch i'm using (C & D) but just wired differently.

Edit: Nevermind, I responded too quickly. By replacing combinators C & D with the two shown in your design, It works just fine. Thank you for your help, you never cease to amaze me with your combinator knowledge!
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinator Contraptions

Post by siggboy »

komrade_toast wrote:Isn't what combinators C & D are doing similar to a Schmitt Trigger? I'm essentially setting an upper with the constant combinator output of C and a lower with the value of 2 in combinator C.
You need to apply positive feedback when your input ("J") goes over the threshold. In your case, your doing it when it goes under the threshold; that cannot work.

J goes over a certain value U, the feedback applied then pushes J to J+D, where D is the difference between U and L. So, in order to put J back below U, the input first has to make up for this difference "D" that was introduced by the feedback. Therefore, J has to become smaller than L for the switch to turn off again.

J > U -> J is now J+D due to feedback from the arithmetic combinator: switch is on
Now, in this state, in order for the switch to turn off, J+D <= U has to be true, which is equivalent to J <= U-D, which is equivalent to J <= L: switch is off

In the middle, when L < J < U, the switch stays in the present state.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinator Contraptions

Post by siggboy »

komrade_toast wrote:you never cease to amaze me with your combinator knowledge!
That's what I said to XKnight the other night after we had... nevermind :mrgreen:
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
User avatar
komrade_toast
Inserter
Inserter
Posts: 44
Joined: Sat Apr 16, 2016 3:28 am
Contact:

Re: Combinator Contraptions

Post by komrade_toast »

Thanks for the in-depth explanation, until just now I only half got how it worked, the other half was just "black magic". I could see TONS of uses for this, not just power related. Hook it up to assemblers, oil processing, you name it. This is awesome! You would think I would have no problem understanding combinators, as I am a programmer, but something about them just gets my brain all tangled up.

On a side note: I agree with what other users were saying in the linked thread, we DO need a dedicated sub-forum for combinator related posts. Searching through "Show your Creations" is a bit too convoluted for finding combinator logic.
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinator Contraptions

Post by siggboy »

komrade_toast wrote:On a side note: I agree with what other users were saying in the linked thread, we DO need a dedicated sub-forum for combinator related posts. Searching through "Show your Creations" is a bit too convoluted for finding combinator logic.
Make a post there, or message Klonan about it, I'm sure he's willing go to forward with this if there's enough interest. I personally feel strongly that such a sub-forum would be good to have.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
cid0rz
Long Handed Inserter
Long Handed Inserter
Posts: 89
Joined: Sun Jul 31, 2016 5:52 pm
Contact:

Re: Combinator Contraptions

Post by cid0rz »

Hello fellow factorians! Regarding the encoder posted here, as the blueprint is broken :cry: I'd like to know if it is possible to encode multiple signals in another signal with a dictionary. So I want to encode words, which I order with power of two slots, so signal "T=2, R=4, A=8, I=(16+128+256), N=32" will display "TRAIN II" on my nixie-tubes setup. Problem is in my memory cells I use signal letters for commands so the letters cannot travel as they are. Of course another solution is change the instructions for the memory so they use colors for example instead of letters but I'd like to know if somebody came to an encoder capable of this since I tried but ddin't came with a solution. As well I can think on a way of sending the letters sequentially or in a separate wire but then it will make the display more complicated. So the task would be:

Encoder capable of transforming a sequence of letter signals with their values to a (unique for example blue) "coded" signal (this can be done in a separate contraption and then the value of the word stored as the coded signal)
A decoder capable of reading this coded signal, output the sequence of letters with their values (statically preferred) if it is necessary they can be stored in a memory cell resetted when new coded word is incoming.

I dont know if the encoder-decoder posted on the first post was capable of this since also it lacks a detailed description or diagram. The display I actually have is 14 so largest value for letter signal is 32 762

Ill continue spending wires meanwhile ^^
piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

Re: Combinator Contraptions

Post by piriform »

cid0rz wrote:Encoder capable of transforming a sequence of letter signals with their values to a (unique for example blue) "coded" signal (this can be done in a separate contraption and then the value of the word stored as the coded signal)


If I understand your "problem" correctly, you are trying to pack a number of (14?) signals each of which may have up to 36 values, into another signal, send that signal down the line and then unpack it.
If so, I can't see how that is possible (in 1 signal). 14 signals each requires 6 bits for a total of 84 bits , Factorio signals are limited to 32, so no joy there.
XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Combinator Contraptions

Post by XKnight »

piriform wrote:
cid0rz wrote:Encoder capable of transforming a sequence of letter signals with their values to a (unique for example blue) "coded" signal (this can be done in a separate contraption and then the value of the word stored as the coded signal)


If I understand your "problem" correctly, you are trying to pack a number of (14?) signals each of which may have up to 36 values, into another signal, send that signal down the line and then unpack it.
If so, I can't see how that is possible (in 1 signal). 14 signals each requires 6 bits for a total of 84 bits , Factorio signals are limited to 32, so no joy there.
I think we are not limited with a single signal, aren't we? so we can use red+green+blue (96 bits) simultaneously for this purpose.
User avatar
brunzenstein
Smart Inserter
Smart Inserter
Posts: 1117
Joined: Tue Mar 01, 2016 2:27 pm
Contact:

Re: Combinator Contraptions

Post by brunzenstein »

piriform wrote:
cid0rz wrote:Encoder capable of transforming a sequence of letter signals with their values to a (unique for example blue) "coded" signal (this can be done in a separate contraption and then the value of the word stored as the coded signal)


If I understand your "problem" correctly, you are trying to pack a number of (14?) signals each of which may have up to 36 values, into another signal, send that signal down the line and then unpack it.
If so, I can't see how that is possible (in 1 signal). 14 signals each requires 6 bits for a total of 84 bits , Factorio signals are limited to 32, so no joy there.
Probably this holds the answer:
viewtopic.php?f=8&t=32684
piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

Re: Combinator Contraptions

Post by piriform »

brunzenstein wrote:Probably this holds the answer:
viewtopic.php?f=8&t=32684
Yes, but
XKnight wrote:I think we are not limited with a single signal, aren't we? so we can use red+green+blue (96 bits) simultaneously for this purpose.
Then again, if not limited to a single signal, why not go to N signals. In which case, the solution not only addresses the original issue, but is far more intriguing in general. ( provided that #combinators * ticks << N)
cid0rz
Long Handed Inserter
Long Handed Inserter
Posts: 89
Joined: Sun Jul 31, 2016 5:52 pm
Contact:

Re: Combinator Contraptions

Post by cid0rz »

The multiplexing/demultiplexing would be quite a mess since you odn't know which letters you expect to get and their values are arbitrary, they can be limited though. I use for exampel in this sistem powers of 2 to order the letters in a word, so I can store a word with the letters ordered. Now the thing would be to convert these signals, for example S(2), I(4), G(8), N(16), A(32), L(64). So you can think ok I multiplex it with powers of 10 but the numbers you get for 26 characters is over the maximum we can handle and also the original value is not small so you need more than one power of 10 to store the info. Additionally the order won't be always the same so S won't be the first letter always and letters can be repeated, then take as value the sum of its repetitions. I think there is no "easy" way of doing this with one signal, neither I can think on a "difficult" way. With manysignals I find it difficult as well that's whi I got interested wen i saw the encoder here. But thanks for teh replies and interest
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinator Contraptions

Post by siggboy »

cid0rz wrote: So you can think ok I multiplex it with powers of 10
You would shift each letter by "x" bits, where "x" is the number of bits needed to encode a single letter. That way you can combine several letters in one 32-bit value, they'll just sit next to eachother in the "bit space".

Multiplexing with powers of 10 wastes too many bits, and it's not necessary because bit shifting is easily done by multiplying/dividing with powers of two (e.g. multiply by 8 for a 3-bit shift to the left, etc.).
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
Cobaltur
Long Handed Inserter
Long Handed Inserter
Posts: 52
Joined: Sat Sep 24, 2016 1:33 pm
Contact:

Re: Combinator Contraptions

Post by Cobaltur »

The Largest Item Finder
I'm really interested how this build might work.
But I cannot build the blueprint.
I see it correctly in the blue print and the correct setup in ghost mode, but not all entities get placed by the robots.

Failed with import by "BlueString" and "Foreman" in 14.9 (and one of them in 13.0 why I upgraded to 14.9)

I'm looking for "station unload balancing" and this combinator might fit. May be it is already too complex.
I'm really missing a Math.min/max :) or has anyone a link or desciption to a solution.


update:
spend the whole day to create a Math.max.
see viewtopic.php?f=193&t=33376
Now I need the Math.min ...
Xeteth
Fast Inserter
Fast Inserter
Posts: 158
Joined: Tue Feb 17, 2015 6:06 am
Contact:

Re: Combinator Contraptions

Post by Xeteth »

Alright, I've been at it for hours and cannot come up with something that I am happy with. Time to ask the experts;

I am trying to build an odd-even sorting system and I am having trouble coming up with a comparitor that is appropriate for the task.

The comparitor needs to take two inputs and compare these inputs, outputting the highest value north and the lower value south, in doing so I can run values through the comparitor multiple times and have a working odd-even sorting system.

BUT - the comparitor needs to work as such:

There are two inputs, each input has a 0 signal and a 1 signal of different values.
The highest 0 signal needs to go north (with it's associated 1 signal)
The lowest 0 signal needs to go south (with it's associated 1 signal)

If both 0 signals are equal then the 1 signal is compared.
So if 0 = 0;
The highest 1 signal goes north (with it's associated 0 signal)
The lowest 1 signal goes south (with it's associated 0 signal)

A couple of examples to explain:
Examples
This is what I have come up with so far, but it's a disastrous mess and I am sure there's a much simpler way of making such a comparitor.

Image
Blueprint String
Note that I have no background in computer science or anything similar, hence why this is such a horrid design. Anyone able to come up with something better?

Bonus points if you can make it such that I can pulse the inputs in (for a single tick) and the output comes out on a single tick also.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3724
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Combinator Contraptions

Post by DaveMcW »

sort3.jpg
sort3.jpg (122.09 KiB) Viewed 9002 times
3 tick sort
If both signals are in the range 0 to 46000, you can combine steps:
sort2.jpg
sort2.jpg (102.04 KiB) Viewed 9006 times
2 tick sort
Xeteth
Fast Inserter
Fast Inserter
Posts: 158
Joined: Tue Feb 17, 2015 6:06 am
Contact:

Re: Combinator Contraptions

Post by Xeteth »

Damn Dave that was incredibly quick! Unfortunately the range will likely be above 46000 so I will have to use the 3-tick version but that's incredibly efficient and I can now see where I totally over-engineered my comparitor. Thanks for your help! :)
Post Reply

Return to “Combinator Creations”