Distributed Bitwise R/S-Latch for a Recycling Train

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.
Post Reply
Premu
Fast Inserter
Fast Inserter
Posts: 100
Joined: Wed Nov 13, 2019 4:40 pm
Contact:

Distributed Bitwise R/S-Latch for a Recycling Train

Post by Premu »

For my new, large base consisting out of lots of seperate logistic networks I wanted to make sure that any "junk" is recycled properly by sending it to a part where it is either produced (and therefor distributed again) or consumed. As I have connected all my different subfactories with red and green wires I can send signals to activate or deactivate stations everywhere. But for that purpose I wanted to use as few signals as possible.

Everytime I dismantle something with bots and it ends up in storage chests, it will be ferried back to my main mall and weapons proudction which is directly besides my original main base. Here I load it in my recylcing train:

Image

Currently a few products are already prepared to be shipped out again to specific unload stations:

Image

In general my strategy is to use an S/R latch. I'll activate the appropriate receiving stations based on the train content in my main base. For example, if this train contains either sulfur or batteries, it will go to my sulfur production where these will be unloaded and "recycled". The train car itself has no limitations or reserved storage places. It could be filled with lots of different stuff, or completely filled with e.g. only red circuits.

To activate each of the differet receiving stations, I set a signal "S" which I send out via my global data network to the receiving stations. Each station receives a specific bit in S. The station using the iron and copper ore is the bit 0, all the uranium stuff is unloaded at the station marked with the bit 1, etc. At the receiving stations I set a signal R once a train arrives to the same value as its value for S, which is also sent via my network back to the main base. So if the train stops at my Uranium processing, R will have the value 2.

So how does it work in detail?

To set S I use the (local) signal "W" in the first picture. I set W to 1 if there's copper or iron ore in the train, 2 if some of the uranium stuff is in there, 4 if it contains either coal or plastic, etc. All these Ws are send to a memory cell (1 in the picture), so they are added up implicitely. So if both coal and iron ore is in the car, W will have the value 5.

This memory cell calculates S OR W and puts it out to S. It's connected to the resetter 2 which calculates S XOR R. So as long R is 0, S remains the same. If R takes a value, the same bit in S will be reset. There is a slight problem with this approach, though - if S is 0 and R is not, the output will take over the value of R, and the signal jitters. This is obviously not wanted. So for that purpose it is important to set R back to 0 after two ticks which is just enough to reset the appropriate bit. For that purpose I use a timer T which is started as soon as R is larger than 0. (combinators 3+4) The value R which is sent from the receiver station is passed through anouther combinator 5 only if T has the value 1. This is given for exactly the two ticks I need to reset the value without the jitter.

The circuit logic at the receiver stations is a lot simpler. For once, it reads the value S and uses a bitwise AND with the value of its bit. For example for the sulfur station it's S AND 16, and the result is used as activation condition for the train station. So only if sulfur or batteries are loaded up to the train, this station will get active, and it will remain so until the train arrives, where filtered inserters will remove those items only. Another combinator checks if the train ID is not equal to 0, and if that's the case it sets R to the appropriate value, in this case 16, to reset S at the main base.

As a result any "junk" is sent to places where I have use for it, and the train will only drive if there is actually something to transport. It is also possible to handle all different kind of combinations and travel through all relevant recyling stations in one go. So it's quite handy and useful, and uses only two signals S and R on my global data network.

Post Reply

Return to “Combinator Creations”