A question about filtering the first thing coming on the belt

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
ming.yuan
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Sep 04, 2020 7:54 am
Contact:

A question about filtering the first thing coming on the belt

Post by ming.yuan »

Short description: How can i read the first thing coming to the belt, then set this item to the filter of one inserter following it, and then cut off to avoid reading new contents from the belt, and only reset following other conditions to read the content of the belt again and to set the filter of the inserter again?
Long context:
I am using py's ore mods and i find out that the raw ore processing processes can be quite similar across all type of ores, requiring a limited range of machines, with some common outputs. So the idea bumped to me that instead building a processing line for each type of ore, I may set up generic factories per type of machine, which handle one or more steps in the processing for all ores which require this type of machine. For example, ore crushers can handle the first step of 5 types of ores. So my plan is to place, say 100, crusher together, and feed all types of materials which need to be crushed into the belts, and let the crushers do their job and collect all the finished products, to send them to next step accordingly.
Now this set up would require some special setups.
1. The machine needs to identify what is coming
2. The machine should select the recipe depending on what is coming
3. The machine should finish the work and then loop.
I have attempted some stages of this process. So my process is like this.
1. The belt sends one signal to announce what is coming (there can be many things mixed on the belt),
2. The filter inserter picks up the signal and filter that ingredient goes into a buffer chest
3. The machine sets recipe according to what is in the buffer chest and do the job.
4. The output is put in another buffer chest
5. The belt reads another signal when the output buffer chest is completely emptied.
I achieved some step 3 4 but cannot figure out others.
The following paragraph is about how I use the crafting combinator mod to do step 3. I use the crafting combinator mod to help with recipe selection. One recipe combinator reads the contents of the input buffer chest, which is an type of ore. Another constant combinator output all possible recipes for the crusher machine. Since each recipe would only deal with one type of ore, the combination of the two is able to identify one recipe, which is sent to crafting combinator. This is tested.
Now the question comes in. I cannot control the timing of the signals for the rest of the steps. Specifically, I connect belt reading contents to an inserter, the belt would constantly read the contents passing through and constantly change the filter and the filter cannot work. I wonder how to get the belt to read only one pulse of signal and then stops to wait for next activation order.
If I can do this, then i need to manage to activate the belt reading content again after the output buffer chest is cleared, which means the current recipe is all finished, at least for some time (I intend to use a slightly slower inserter to take contents out of output buffer chest so that whenever the output is empty, the input must be completely empty as well). However I can imagine another problem being that the empty signal is constantly sent to the belt, which means the belt try to read something constantly until the output buffer chest has something in it again. Similarly I may need this activation signal to be sent only one pulse. How can i do that?
To make it crystal clear let me explain it again. I want the belt to read only the first item coming to it, then set this item to the filter of an inserter. Then the belt does not read anymore, the inserter starts to fill a buffer chest. Later, the inserter has picked up all this ingredients in the belt, and the machine has processed all those buffered, and all outputs removed. Now I need to send another signal to let the belt read a new item coming to it, to allow the machine to work on another cycle again. Can i possibly do that?

starlinvf
Long Handed Inserter
Long Handed Inserter
Posts: 70
Joined: Sat Dec 14, 2019 6:28 pm
Contact:

Re: A question about filtering the first thing coming on the belt

Post by starlinvf »

Ugh...... this might be a little bit too big brain for me..... But it sounds like you need to make a Latched Memory Cell. I don't know what the mods you use allow for, so there might be a better way with your mod resources.


The easiest way to set up one up for experimentation is to use a single belt segment as a memory cell. Once you get the control system design down, you can redo it as a combinator memory cell; though I don't know the design for "remember item type" (or how its possible).

Moving forward, you want to isolate circuit networks at each step, to avoid crosstalk messing with the logic. IE: Just alternate wire colors between IN/Out so they don't accidentally feed back into each other.

Have an Input inserter with enable/disable to Anything (green asterix) to =0, and have it attached to memory belt. This will turn it on when the cell is empty, and disable it when the belt is occupied. You then setup an Output inserter thats enabled only by a "clear" signal that gets sent to it (this is the Latch for the system). Have the Belt segment itself set to Read/Hold.

This will grab One item off the main belt, and sets the item type for the Cell to feed to the rest of the decider logic. Aside from holding one item that you'll have to empty somehow, this is way easier to prototype test logic with; since Read/Pulse is Momentary, and harder to troubleshoot.


I've searched for a Signal-only Combinator version of this, but have had no luck.

mmmPI
Filter Inserter
Filter Inserter
Posts: 503
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: A question about filtering the first thing coming on the belt

Post by mmmPI »

I am no expert, to me this seems like a "main design" that require several "unit" to make it work.

I had time to try a little and come up with protoype that i will try to explain in the second part and i uploaded the test map. I mostly focus on part 1 2 5 because i think it doesn't require any mods.

I know Py's mod have many many receipe and i didn't want to spend too much time finding the one you plan to use because maybe i would make mistake so i used a furnace as a replacement for the machine. If you can list the receipe and if i find more time maybe i will try implementing the system with the correct machine.

I made 3 very similar module with slight differences to allow for testing and showing different behavior.

there you can see the "northern" and the "middle" module:
attempt 1.png
attempt 1.png (1.3 MiB) Viewed 570 times
1) IF buffer chest is empty => output 1 green
2) "memory cell" that read item on belt and set filter to inserter. IF no filter => output 1 green
3) IF output chest is empty AND when inserter hold something => output 1 green ( this is so that if 1 input material gives more than 1 ouput material only the last one will count)
4) IF belt c and b are empty => output 1 green

belt (a) : Enable IF green = 4

My idea was to control activation of belt (a)when signals at other places says it is ok. In this example, condition is green = 4 because there are 4 different places that are checked.

The northen module has trouble, the check (4) is too slow, sometimes more than 1 item goes on the belt.


The middle module works better because i downgrade the belt pointed by the arrow from blue belt to red belt.
also i skip 1 check and so i used condition green =3 on the belt (a) for the middle module.
I did that to show that some checks are redundant and the system would function similarly without them.


Maybe it's not the best way to do, i may try other things if i have time. Maybe you can use the crafting combinator to add additionnal check that could allow to remove some of those i used. Or maybe you can add additional checks to make a better version.

I think the main feature is the "memory cell" , the way i did it though will probably require having 1 per machine. I don't know if you can scale it nicely.

Also, those setups with memory cell require initialization, if you copy paste one setup it will not function right away. you need to drop manually 1 ore on belt (c) or (b) to start the setup. this may be problematic if input runs dry.

if you have any question on what i did please ask; hopefully it helps :).


here is the map :
crafting combinator setup 3.zip
(4.32 MiB) Downloaded 5 times

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

Re: A question about filtering the first thing coming on the belt

Post by mrvn »

If you want to take things from a belt then you are thinking way to complex.

Simply have an inserter feeding the furnace from the belt. It will pick up the first item and fgeed it into the furnace. This sets the recipe for the furnace. It will then only pick up the same items till the furnace is empty again.

Now the problem you will run into is that the belt might start with an iron ore. The furnace will switch to the iron recipe. But then only copper ore follows on the belt, it backs up and everything stops moving. So you need 2 other things:

1) the belt should be a loop. Connect the end to the front and feed the loop with a splitter with input priority from the loop. That way it always keeps moving.

2) add one furnace per ore type with a filter inserter taking only that ore. That way if e.g. all furnaces are set to iron and the belt only has copper ore on it the special furance will still remove some copper. At some point more iron ore will enter the loop, one of the furnaces will finish the iron recipe and switch to copper and things will pick up again.

ming.yuan
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Sep 04, 2020 7:54 am
Contact:

Re: A question about filtering the first thing coming on the belt

Post by ming.yuan »

mmmPI wrote:
Fri Sep 04, 2020 5:43 pm

if you have any question on what i did please ask; hopefully it helps :).


here is the map :
crafting combinator setup 3.zip

Big thanks! I make it work with some tweaks of your design and I think it is pretty neat. I made a video about it and please have a look here.
Time stamp
0-5min explanation of how crafting combinator works to determine recipe
5-15 min, explanation of how the machine initiate and finish one cycle.
16-20 Demonstration and discussion
https://www.youtube.com/watch?v=LXxQ9rEuOS4

These days youtube video quality deteriorates.
I also include a few screenshots here.
Image
In this image you can see that only small rocks are picked up (white rocks at bottom side)
Image
Capture1.JPG
Capture1.JPG (161.99 KiB) Viewed 510 times
In this image you can see that first machine is collecting all iron, while second machine collects all rocks, white small rocks still left in the belt.
Attachments
Capture.JPG
Capture.JPG (108.8 KiB) Viewed 510 times

mmmPI
Filter Inserter
Filter Inserter
Posts: 503
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: A question about filtering the first thing coming on the belt

Post by mmmPI »

ming.yuan wrote:
Sat Sep 05, 2020 4:42 am

https://www.youtube.com/watch?v=LXxQ9rEuOS4
These days youtube video quality deteriorates.
I think google is having a cookie indigestion from all those personnal information they need to steal in order to promote even more dubious unwanted ads because it doesn't want to load THIS particular video past the 30 sec mark, even though i can easily get 1 min of HD ads on a 15 sec video that's just someone yelling fuck you google.

Also your other videos are loading. It's just this one and it's a bit sad because i'm unable to understand what you did from the screenshot.

But i'm glad it helps :)

Maybe you can post a blueprint string of one module ?

ming.yuan
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Sep 04, 2020 7:54 am
Contact:

Re: A question about filtering the first thing coming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zaTn1YdpjPWAAbYmBB/RsBwg394TY0hPSte390IkZt91Eire8pcCz7iG49W7FXeW5EdVSNXh4y4uDlXskwOjq9vjk9G/k9lcv8BykOajuFS/CXujFYRDqSsgP2vYP61x20g==

I removed all mod based components from this bp. I think you can use vanila furnace to mimic the process. At least it is able to screen one type of ore out in the main belt while the rest of the ores still running.

Some key points
1. input inserter takes a sample if (1) input chest empty, (2) output chest empty (3) sampling area empty
2. releasing inserter removes the sample if (1) input chest empty, (2) output chest empty.
3. Use timing to prevent releasing inserter from activating when the system initiates for the first time.

If you visit the video later there is a showcase of two machines processing 4 types of mixed inputs one by one

ming.yuan
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Sep 04, 2020 7:54 am
Contact:

Re: A question about filtering the first thing coming on the belt

Post by ming.yuan »

If i get it running I will try to upload another video showing a full scale factory processing random inputs later.

mmmPI
Filter Inserter
Filter Inserter
Posts: 503
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: A question about filtering the first thing coming on the belt

Post by mmmPI »

thanks , i'll try to have a look before the end of the week end !

mmmPI
Filter Inserter
Filter Inserter
Posts: 503
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: A question about filtering the first thing coming on the belt

Post by mmmPI »

I had a bit more time to look at the blueprint and the video that finally loaded.

I tried something to remove the buffer belts it look like this :
autodetect.jpg
autodetect.jpg (203.21 KiB) Viewed 390 times


You can set item you accept in the constant combinator.

When inserter see one of the accepted item it will put it into the buffer chest and forget about other item until the chest is empty, then it will accept all item set in the constant combinator again.

It works by setting filter on the inserter based on the constant combinator. (1iron)(1copper) (Q)

Then multiply amount in the constant *-1;(-1iron)(-1copper) (-Q)

add result to chest content + item inserter are holding;

this means if an item has not been sampled it has negative quantity (-1iron) or (-1copper); (N)
if an item has been sampled it has positive quantity let say (5iron) or (12copper); (S)


use a decider with "each" < 0 output each "1" on (N) this allow to deselect the sampled ore and you get (N2) (1iron) or (1copper)
use a decider combinator on (S) If anything > 0 output (1 Red signal).

(Red signal *-10) => (-10Red signal)

(-10Red signal) * (N2) will then give a negative amount of the ore that has not been sampled (N3) (-10copper) or (-10iron );

Feed (N3) to the inserter on a wire with different color than the link with the constant. (Q+N3), the negative amount will disable the filter for the "wrong" item leaving the inserter picking up only the sampled item.

In case no sample, signals from the constant combinator are the only signal received by the inserter so it can pick everything.

It's far from perfect, because even if you can add as many different item as you want on the constant combinator, the inserter is limited to only 5 but maybe it can give inspiration, it was fun trying :).

ming.yuan
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Sep 04, 2020 7:54 am
Contact:

Re: A question about filtering the first thing coming on the belt

Post by ming.yuan »

The five filter slot limit would really hurt here since each machine is supposed to handle dozens of possible recipes.
On a first look it is possible to spread to multiple inserters and each gets five when in sleep mode, since one machine would utilise multiple input inserters anyway.
Looks neat

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

Re: A question about filtering the first thing coming on the belt

Post by mrvn »

It also gets stuck when you need multiples of an item for the recipe and no more items are coming. E.g. you load up 3 out of 8 copper ore and then all the belt has is iron ore. The furnace will be stuck forever.

Only way I can think of to make this sort of thing reliable is to first fill a chest with up to 8 ore of any kind (normal inserter set to stop when 8 of a kind are present using a latch). When 8 ore of a kind are present the latch needs to trigger and output the ore that has 8 items. With that program a filter inserter to fill the furnace. When all 8 items are removed from the chest reset the latch and start collecting ores again.

Note: The inserter loading the chest should have a stack size override = 1. Otherwise you might end up with 9 ore in the chest.
Note2: If you want to process items with varying counts (e.g. 8 copper ore make a copper plate but 4 iron plate make a steel plate) then programming the latch becomes harder.

mmmPI
Filter Inserter
Filter Inserter
Posts: 503
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: A question about filtering the first thing coming on the belt

Post by mmmPI »

mrvn wrote:
Wed Sep 16, 2020 11:14 am
It also gets stuck when you need multiples of an item for the recipe and no more items are coming. E.g. you load up 3 out of 8 copper ore and then all the belt has is iron ore. The furnace will be stuck forever.
Yes in this case you can''t add stone or iron plate to the constant that holds iron ore and copper ore.

BUT !

The furnace here is a placeholder for a PY's crusher, supposedly connected to a crafting combinator. In this case you have a way to expell the material that would stuck the machine.
The crafting combinator when changing a receipe output the remaining trapped material in a chest.

Edit:
ming.yuan wrote:
Sat Sep 12, 2020 6:32 am
The five filter slot limit would really hurt here since each machine is supposed to handle dozens of possible recipes.
On a first look it is possible to spread to multiple inserters and each gets five when in sleep mode, since one machine would utilise multiple input inserters anyway.
Looks neat
To remove the five filter slot maybe trying to read what's on the belt and store it in a combinator to replace the constant will result in something.

Other solution with higher probability of success would be putting 3 inserters, 3 chest and 3 cells per crusher, so that makes it up to 15 ores. that's lazy but it could allow for nice design :)

Do you crush PY's ore 1 by 1 or do you need several ore to complete 1 receipe ?

ming.yuan
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Sep 04, 2020 7:54 am
Contact:

Re: A question about filtering the first thing coming on the belt

Post by ming.yuan »

mmmPI wrote:
Wed Sep 16, 2020 1:14 pm

Do you crush PY's ore 1 by 1 or do you need several ore to complete 1 receipe ?
Currently one input recipe uses this setup. Multiple inputs and liquid inputs would be too difficult to manage.

I got this slightly successful set up to work for now.
auto.png
auto.png (2.78 MiB) Viewed 201 times
In this screenshot you can see three different recipes running.
I put assemlies in 3 groups to save some computing needed.
Basically the idea is working fine. But the there can be many contraints.
Most notably the throughput of the input and output belt.
The model requires a very fast input traffic for the machines to pick up the needed material from a flow of mixed materials.
Once the input belt got stuck, the whole setup falls into very slow mode as the machine cannot get what it needs, less materials are processed, and the input belt get more crowded, and the speed gets even slower.
And eventually the buffer at the train station get stuck, and all is halted.
But yeah, it can be solved by speedy belt and less machines sharing the same belt. So it is promising.

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

Re: A question about filtering the first thing coming on the belt

Post by mrvn »

It looks like you feed each row a separate input belt but then merge the letfovers all into a single belt and, I assume, feed it back to the input. You say that when things aren't consumed the belt backs up and becomes slow. Sure, you are feeding N belts into a single belt. It can't move that many items.

Try making a single belt serpentine (S shape) left to right to left to right ... past all the assembler. You can refill the belt with a priority splitter for every row. Priority set to favor the serpentines. That way all assemblers will always have items going past them at full belt speed and each row can still get a full belt even if the row before that consumes a lot.

ming.yuan
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Sep 04, 2020 7:54 am
Contact:

Re: A question about filtering the first thing coming on the belt

Post by ming.yuan »

mrvn wrote:
Fri Sep 25, 2020 2:51 pm
It looks like you feed each row a separate input belt but then merge the letfovers all into a single belt and, I assume, feed it back to the input. You say that when things aren't consumed the belt backs up and becomes slow. Sure, you are feeding N belts into a single belt. It can't move that many items.

Try making a single belt serpentine (S shape) left to right to left to right ... past all the assembler. You can refill the belt with a priority splitter for every row. Priority set to favor the serpentines. That way all assemblers will always have items going past them at full belt speed and each row can still get a full belt even if the row before that consumes a lot.
Exactly. The idea is that the machine should consume most of the materials, leaving a little bit of leftover. However with multiple inputs, different processing time for different recipes, many other factors, always difficult to fully resolve the issue. Serpent + refill sounds good. Let me try that set up and get some more screenshots and videos. When the factory start to process 10+ materials things get really interesting

Post Reply

Return to “Gameplay Help”

Who is online

Users browsing this forum: Google [Bot]