Counting Sushi Belt

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
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2240
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Counting Sushi Belt

Post by boskid »

counting-sushi-belt.png
counting-sushi-belt.png (1.6 MiB) Viewed 6912 times
Idea is simple: sushi belt with multiple items.
Core is based on two arithmetic combinators. First one is to negate any number, second one is memory cell. Items on belt are counted. Each inserter that puts items on belt is connected by green wire to memory cell and gives pulsed hand content. This way when inserter puts new item on belt, total count of this particular item is increased. To prevent item overflow, this inserter also contains enable condition. Since green wire is connected to memory cell, circuit signal can be used to drop items only if there are not enough of them.

Every inserter that grabs from sushi belt is set to pulse hand content to red wire. This is then inverted and fed into memory cell to update total belt content.

In my example, total belt capacity is around 740 items. Because of limits set on inserters, there should be no more than 670 items. This prevents belt stopping because of item overflow.

In above example, all initial items go from infinity chests (please use editor when stamping bp). They could however go from another sushi belt with ores and intermediate items. Transfer inserters could then be connected to two different networks: by green wire to "add content" to target memory cell, and by red wire to "remove content" from source memory cell. Since it is possible to setup pulsed read content on belt, same principle can be achieved when belt goes from one "counted" network to another counted network: every pulse would increment item count in target "belt network" and decrement item count in source "belt network".

I guess this is not how you should play factorio: single belt with every assembler attached to it :) In my bp there are some shortcuts for some highly used (like green circuit - to reduce latency) or rare items (like belts only used for green science) to reduce sushi belt usage. It would however work without them. They are not counted since they do not change item count on belt. Basic ratios were obtained for blue assemblers assuming one blue assembler for each science pack (2 for chemical science packs). During experiments i changed them to AM3 with PM3 and blue belts, but this is not part of this topic. Topic is about counted sushi belt with inserters and memory cell to keep item count.
Attachments
wrong-way-of-playing-factorio.zip
(611.29 KiB) Downloaded 125 times

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

Re: Counting Sushi Belt

Post by mrvn »

I do something similar but I think easier to extend. In your case you depend on the belt capacity. What I did is similar but I'm using a time based approach.

I have a constant combinator that gives the ratio of items on the belt. E.g. 5 iron plate, 1 wood, 2 copper plate. The values are multiplied by belt_speed * 60000 and divided by the sum giving the number of items expected on the pelt per tick with 3 extra digits precision.

Next I have a memory cell. Every tick the above numbers are added to the cell. Filter inserters are programmed to "set filter" and connected to the memory cell and put items on the belt. The hand content (pulse) * -1000 is added to the memory cell. This causes the inserters to add items to the belt in the specified ratios.

Then I have two options:

1) The end of the belt is fed back into a warehouse using a loader or enough inserters to empty the belt at full speed.
2) The belt is looped. One tile just before the inserters is set to read (pulse) content, multiplied by -1000 and fed to the memory cell. Any items left on the belt reduce the amount put on it fresh. Just before that I have a yellow inserter taking items from the belt back into the warehouse. This fixes issues if the belt gets out of balance (e.g. when you change the ratio).

I also added a bit to the memory cell so if values get to large or to small they are capped.

User avatar
disentius
Filter Inserter
Filter Inserter
Posts: 694
Joined: Fri May 12, 2017 3:17 pm
Contact:

Re: Counting Sushi Belt

Post by disentius »

Nice! :D

Koub
Global Moderator
Global Moderator
Posts: 7198
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Counting Sushi Belt

Post by Koub »

Not to lessen your prowess, but to add some "related stuff" in the topic :
viewtopic.php?f=8&t=58231
viewtopic.php?f=8&t=44194
viewtopic.php?f=8&t=37857
viewtopic.php?f=193&t=63473
viewtopic.php?f=193&t=56955
viewtopic.php?f=193&t=47655
viewtopic.php?f=204&t=29560
viewtopic.php?f=8&t=14153

And for the giggles, I think this is also loosely related :
viewtopic.php?f=8&t=918
viewtopic.php?f=8&t=1101
As you can see in the screenshots, the quest for the "on demand mixed belt omni provider" is a long lasting quest indeed :mrgreen:

I find quite ... interesting the interest in these "one belt to rule them all" contraptions. Actually, I was searching for a specific one belt loop bus I have seen a few years ago, but coudln't find it :( .
Koub - Please consider English is not my native language.

User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 2420
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Counting Sushi Belt

Post by BlueTemplar »

Sometimes, the map forces sushi on you
BobDiggity (mod-scenario-pack)

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Counting Sushi Belt

Post by eradicator »

I've tried count-perfect sushi belts but i found managing them too much of a hassle. The problem is that even the slightest problem (accidentially picked/dropped up item from/on belt, biter destroyed something, maniac drives a tank through it, etcpp) means you have to completely remove all items from the belt and reset the counter. Thus i find "approximated" belt counting is much easier to handle, just select a few sample belt tiles and take the count directly from them (i guess you could also count *every* belt tile...).

If wube allowed us to get the count from a whole belt segment instead of just one belt tile the situation would greately improve. (Assuming that it would be faster to calculate than wiring up all the individual tiles.)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2240
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Counting Sushi Belt

Post by boskid »

eradicator wrote:
Mon Aug 26, 2019 4:44 pm
I've tried count-perfect sushi belts but i found managing them too much of a hassle. The problem is that even the slightest problem (accidentially picked/dropped up item from/on belt, biter destroyed something, maniac drives a tank through it, etcpp) means you have to completely remove all items from the belt and reset the counter. Thus i find "approximated" belt counting is much easier to handle, just select a few sample belt tiles and take the count directly from them (i guess you could also count *every* belt tile...).
I know, counting items by sampling all belts would be too easy, i wanted something ridiculous and unstable, for example by counting items placed and grabbed by inserters. I could also go and change all conditions to put when item-count < 0, and then by providing negative maximum items count for one tick, this would setup initial state of memory cell so that when enough items are on belt, its signal would go to 0 or above. This is more like proof-of-concept. I could also sample item counts on belts with some spacing (like every 10th belt) and then using more arithmetic combinators setup low pass filter (maybe second order with time constant similar to time for item to travel between two sampling belts) that would estimate item count. This would reduce item put/get counting but still there would be need for put condition.

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

Re: Counting Sushi Belt

Post by mrvn »

eradicator wrote:
Mon Aug 26, 2019 4:44 pm
I've tried count-perfect sushi belts but i found managing them too much of a hassle. The problem is that even the slightest problem (accidentially picked/dropped up item from/on belt, biter destroyed something, maniac drives a tank through it, etcpp) means you have to completely remove all items from the belt and reset the counter. Thus i find "approximated" belt counting is much easier to handle, just select a few sample belt tiles and take the count directly from them (i guess you could also count *every* belt tile...).

If wube allowed us to get the count from a whole belt segment instead of just one belt tile the situation would greately improve. (Assuming that it would be faster to calculate than wiring up all the individual tiles.)
In a loop I totally agree with the approximated belt counting. Or adaptive belt counting. Even if everything works perfect you often don't know the consumers behavior so items are taken of the belt randomly. If more iron plates are taken off than copper plates then you have to replace the iron plates but not so much the copper plates and so on.

If you don't loop the belt but put it back into a chest or warehouse at the end that problem goes away. You simply always put count perfect items on the belt. A disruption doesn't loop around and stay. It's gone by the time it reaches the warehouse.


The hassle with wiring up the belt is that to get a ratio of e.g. 1 centrifuge on the belt loop you have to wire up all belt tiles. And you can't have any splitters or underground belts. Because they can't be wired and you loose sight of items while they are on them. And extending the belt means your total item count changes.

So you want to wire up only a stretch and go for 1 centrifuge every N tiles. But then you have to specify items per N tiles. How many items are there in N tiles? When you add blue circuits how much do you have to lower the other items to not overfill the belt? I got sick of the math there and made factorio calculate the ratios for me. :)

I also wonder about the performance impact. Does wiring up a tile split a belt segment into 3 parts? Does wiring up a continious stretch of belt make that one segment (when possible) or each tile a separate segment? Or does the signal generation work independent of segments and each wired tile generates their own signal counts each tick?

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2240
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Counting Sushi Belt

Post by boskid »

mrvn wrote:
Thu Aug 29, 2019 9:20 am
The hassle with wiring up the belt is that to get a ratio of e.g. 1 centrifuge on the belt loop you have to wire up all belt tiles. And you can't have any splitters or underground belts. Because they can't be wired and you loose sight of items while they are on them. And extending the belt means your total item count changes.
mrvn wrote:
Thu Aug 29, 2019 9:20 am
I also wonder about the performance impact. Does wiring up a tile split a belt segment into 3 parts? Does wiring up a continious stretch of belt make that one segment (when possible) or each tile a separate segment? Or does the signal generation work independent of segments and each wired tile generates their own signal counts each tick?
Right, this is where this counting from my solution shines. In my setup there is spliter in upper right corner of belt and items here are also counted. Essentialy memory cell keeps track of items in whole belt setup because it counts each item added to or removed from it. I could use same setup with trains, cars on belts, belts with spliters, lane balancers or anything other. As long as all items going into and out of this setup are added, item counts are exact. This solution also allows using long sections of belts without inserters and they will merge into long transport lines to save some UPS-es. (well, inserters have to constantly check if item they have on belt fits assembler they point to [implicit filtering] so there may be not that much UPS gain)

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Counting Sushi Belt

Post by eradicator »

I just remembered this old thread: https://np.reddit.com/r/factorio/commen ... ish_on_it/
Pretty much the antithesis, only counts a row of belts near item insertion points.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

evopwr
Fast Inserter
Fast Inserter
Posts: 172
Joined: Fri Apr 28, 2017 1:45 am
Contact:

Re: Counting Sushi Belt

Post by evopwr »

dang, thats nuts!

Post Reply

Return to “Combinator Creations”