Keep exact # of items in remote chest with circuit network

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Krinkovic
Burner Inserter
Burner Inserter
Posts: 15
Joined: Sat May 28, 2016 11:55 am
Contact:

Keep exact # of items in remote chest with circuit network

Post by Krinkovic »

Without boring you with to much detail of what exactly I want to use it for, I want a chest in a remote location to keep a specified amount of a certain item, without having a belt full of the stuff all the way there.
In other words I want an inserter at my iron plate production to send 20, and only 20, iron plates to the remote chest. and if I then take those 20 plates from the chest, it sends 20 new ones down the belt. Or if I only take 10, it only sends 10 etc.

This is what I've got so far:
20170502184045_1.jpg
20170502184045_1.jpg (411.92 KiB) Viewed 8299 times
And here is (I hope) an easy-to-read diagram of the setup I tried to make with my amazing paint skillz:
Diagram.jpg
Diagram.jpg (282.45 KiB) Viewed 8299 times
Now this basically works. I set the amount of plates I want in the right chest, by inputting the amount into the constant combinator. Only, when putting in amount n I always end up with n+1. I think I have figured out why it happens, but can't figure out how to solve it. Whatever I try just breaks everything :(

I am going to assume that anyone here who can help me can also figure that out so I won't bother with a lengthy (and most likely just a confusing) ramble about it (unless you really want it).

So if anyone knows how to eliminate that +1, or just knows a better/simpler way of doing it, please let me know.
Also let me know if something is unclear and I'll try to explain better.
Thanks :)
Selvek
Fast Inserter
Fast Inserter
Posts: 238
Joined: Fri May 06, 2016 4:04 am
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Selvek »

I'm not 100% sure this is where your +1 comes from, but you may want to enable "set stack size" on the left inserter. Assuming you have a stack bonus, it will always pick up 2 (or 3) items even if the circuit says it only wants 1.

To make that work you will need to invert all your signals (so that the left inserter is active on *>0 instead of *<0)

Actually, now that I think about it, I'm not sure whether the pulse gets issued to the circuit network immediately when the item gets picked up, or while the arm is turning, or when the item is dropped... I may have some experimenting to do!
Krinkovic
Burner Inserter
Burner Inserter
Posts: 15
Joined: Sat May 28, 2016 11:55 am
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Krinkovic »

Selvek wrote:I'm not 100% sure this is where your +1 comes from, but you may want to enable "set stack size" on the left inserter. Assuming you have a stack bonus, it will always pick up 2 (or 3) items even if the circuit says it only wants 1.

To make that work you will need to invert all your signals (so that the left inserter is active on *>0 instead of *<0)

Actually, now that I think about it, I'm not sure whether the pulse gets issued to the circuit network immediately when the item gets picked up, or while the arm is turning, or when the item is dropped... I may have some experimenting to do!
I do not have any stack bonuses, and doesn't that only affect stack inserter now anyway?

The pulse is indeed the problem. when the last item is picked up by the right inserter a pulse gets sent reducing the counter by one, making the system think I only have 19 plates, until the inserter places it in the chest where it adds back to 20. But during that time the left inserter goes "Oh missing 1 plate!" and sends that last +1.
So it's the part between when the inserter pulses and when it places it in the chest that creates the problem.

There's probably a super simple solution that I am not seeing though :P
Selvek
Fast Inserter
Fast Inserter
Posts: 238
Joined: Fri May 06, 2016 4:04 am
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Selvek »

Krinkovic wrote:I do not have any stack bonuses, and doesn't that only affect stack inserter now anyway?
Regular inserters get a stack size of 2 at maybe level 3 stack bonus research, and a stack size of 3 at max stack bonus research.
Krinkovic wrote: The pulse is indeed the problem. when the last item is picked up by the right inserter a pulse gets sent reducing the counter by one, making the system think I only have 19 plates, until the inserter places it in the chest where it adds back to 20. But during that time the left inserter goes "Oh missing 1 plate!" and sends that last +1.
So it's the part between when the inserter pulses and when it places it in the chest that creates the problem.
Hmm yeah I see the issue. Too bad you can't read "pulse" and "hold" simultaneously on different wire colors!

I have an untested theory - basically, the idea is to generate the "pulse" for decrementing the "number of items on belt" counter just from the chest reading. Basically, you would send "items in chest" through a "*-1" combinator and then add it to itself. The combinator introduces a 1-tick delay on the subtracted value, which should generate a value of 1 for 1 tick right when an item is added to the chest. That "pulse" signal would then be used in place of the pulse read from the right inserter. And that pulse would be generated at the same time as the chest count increments. I will test this tonight if I have time!
Krinkovic wrote:There's probably a super simple solution that I am not seeing though :P
EASY solution? Subtract 1 from the "desired amount" ;)
Selvek
Fast Inserter
Fast Inserter
Posts: 238
Joined: Fri May 06, 2016 4:04 am
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Selvek »

Ok, got it!

Again, basic idea is using a subtraction to fake the "read pulse" behavior of an inserter, with the contents of a chest.

A: Constant combinator, used to set desired items in chest.
B: Each*-1, used to subtract current chest contents from desired quantity to get the quantity we still need.
C: Differentiator. Each*-1. By adding the input and output of this combinator, we create a pulse signal corresponding to items added or removed from the chest.
D: Each < 0. Basically this gates the pulse signal so that only pulses corresponding to items being ADDED to the chest are passed through. Items REMOVED from the chest are ignored. Otherwise, pulling things out of the chest by hand would mess up the counter.
E: Belt counter. Each >= 0. The output of this combinator is the number of items currently on the belt. The condition Each >= 0 prevents that number from ever going negative, which makes the setup a bit more robust.
F: Each*-1. Used to correct the sign on the output of E. Also serves as a buffer to prevent signals from crossing.

Inserters: Enable on [Coal] > 0, set stack size on [Coal]. Or whichever item is in the chest. Note that you can share the single belt between multiple items using this setup. Just make sure to connect both red and green wires to each of the new inserters, you can't see the red one in this screenshot.

Note: You can ignore the green inserter and yellow belt to the left of the chests, I was just using that for corner case testing.

Known issues:
The system will get confused if you pick up any items from the belt (it has no way of knowing whether an item was removed from the belt, or if the belt is just really, really long).

Blueprint
Attachments
Capture.PNG
Capture.PNG (250.29 KiB) Viewed 8260 times
Krinkovic
Burner Inserter
Burner Inserter
Posts: 15
Joined: Sat May 28, 2016 11:55 am
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Krinkovic »

Test
Krinkovic
Burner Inserter
Burner Inserter
Posts: 15
Joined: Sat May 28, 2016 11:55 am
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Krinkovic »

Don't know what I am doing wrong, but when I try to quote you I get an SQL error...
Krinkovic
Burner Inserter
Burner Inserter
Posts: 15
Joined: Sat May 28, 2016 11:55 am
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Krinkovic »

General Error
SQL ERROR [ mysql4 ]

Incorrect string value: '\xF0\x9F\x98\x9C w...' for column 'post_text' at row 1 [1366]

An SQL error occurred while fetching this page. Please contact the Board Administrator if this problem persists.
Krinkovic
Burner Inserter
Burner Inserter
Posts: 15
Joined: Sat May 28, 2016 11:55 am
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Krinkovic »

Let's Try Again
Selvek wrote:Ok, got it!
Thanks so much for the help. Don't fully understand by your description but I'll play around with it and figure it out :D
Selvek wrote:Regular inserters get a stack size of 2 at maybe level 3 stack bonus research, and a stack size of 3 at max stack bonus research.
Oh yeah, you're right. I forgot.
Selvek wrote:EASY solution? Subtract 1 from the "desired amount"
Hah yeah thanks :P was kinda hoping for a less "cheaty" solution XD
Krinkovic
Burner Inserter
Burner Inserter
Posts: 15
Joined: Sat May 28, 2016 11:55 am
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Krinkovic »

Yay it worked...for some reason :P
Selvek
Fast Inserter
Fast Inserter
Posts: 238
Joined: Fri May 06, 2016 4:04 am
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Selvek »

Krinkovic wrote:Yay it worked...for some reason :P
Haha the reason is "circuit magic" :) Glad it's working for you!

Out of curiosity - what are you using it for?
Krinkovic
Burner Inserter
Burner Inserter
Posts: 15
Joined: Sat May 28, 2016 11:55 am
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Krinkovic »

Selvek wrote:
Krinkovic wrote:Yay it worked...for some reason :P
Haha the reason is "circuit magic" :) Glad it's working for you!

Out of curiosity - what are you using it for?
I meant that quoting you worked this time, for some reason. Have not actually tried your blueprint yet, but am going to do that now. Kinda forgot, sorry :P
Well I wanted a centraliced area for storage of things like belts and assembly machines, before I got robots. And also without having long belts from the actual factories filled with the stuff :)
Krinkovic
Burner Inserter
Burner Inserter
Posts: 15
Joined: Sat May 28, 2016 11:55 am
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Krinkovic »

But yes, tested the blueprint now and that worked too :D Thank you!
Will need some more time to figure out how it works though :P
Skjolbir
Inserter
Inserter
Posts: 20
Joined: Thu Apr 23, 2020 2:04 pm
Contact:

Re: Keep exact # of items in remote chest with circuit network

Post by Skjolbir »

Code: Select all

0eNrlWuuOqzYQfhf/rMIqXMIlavsi1QoRmGysAka2iU664t1rh4QQghMPR+pZdf8kAsxcvplvZuzkk+zKFhpOa0m2n4TmrBZk+9cnEfSjzkp9T54aIFtCJVRkReqs0lfwo+EghCN5VouGcensoJSkWxFaF/CDbN3ufUWgllRS6CWeL05p3VY74GrBIGtHPxwoIZec5k7DSlBqGibUm6zWBihpjrtZkRPZem6iVCgja7Wcnm39JK7+4FCMtVB15XWru2vX0zZ9cID61dJAKaE8b6m8PH7vutGSqw8exocI74E7Mcs3OjBdubl3wDU44A8OVFDQtnrlg+u9XQMRv21+IhTJg30Gx5JpJF4KmnU0GBzNOJWHCqTyMWfVjtaZZHw2466uem7vqOSsTHdwyI5UvaGW3USl6nFBBxj2lAuZPlDoSLls1Z3Bln6FA1l+0NQRoMVoWUJmmpCOIglrgGe9YeQ39SprZdOihXeGWM1iHj1m/4p4xuUmzDdYzMM7xAvKe2t7Ov4K/H8N/K/wTuyKU4iFP/m2Ce+ucRlvGYFoMK2AnBbArSuObwjARc5Pon8EfpIHWn+QXs0FfA0Cq5qMn+3bkj+XgD+R3ZyUrW0t0z1nVUprJYxsJW+hQ3RBc992fVzgArtuEQ9uNa047FopVZQeAhbcwnXuhaOC5c2Hb09LCdwwYJkg1YicwWovJWk8YVGRan37rBRgj6hl00xQ+Rv+N9k7wGFK2z++SNrG9jMNqto8DoVPR7/pxBTa1S5dEhHBT75W6fr9q5SuyFy6YlwWhHacdW/7qpyD6qNHcCpWpEdGCyc/gJBznScawqd60KzY21ZHSIDSLGpzJ2rxViey3SBMW4ARGB+/BfBvvny3iehVOkaWqAfz6ahPExzBWp7P7DKnKTRqrIoF4yZ6bYWDEspZ7TRlJoFoay7Pvdnn73P23jYtk6ONJ/3uwUpvTnI4YlCW/+3QWgBXnsycFDzxf05yZMfNeCEz19ZUjC2TIsZS0V1/XyZGr7bfa0vUEzTq3h3q/48NecGkOQIz6W8+c/NvgZl5LwhNh4brV6eoT7tqZFMSPHeBjgCpw7MuaGP7wze7XLqmtOoWkLJ9Oor7qOOrnlKkh6xPEqksFJcZTSWGmue4GjnTs3UqQf4BTZY5T/wFaPlItIIFOjykjs0CHS5SR7hAxxqpI8LrSJAqYryKGKkiwauIcCr8BaUkRKpYUEmQxcr38CqQtcpfwHAkwf0FBEfy21/Cb6SKBfRGstvHsxurAU9uLEx4biNjHeCpjUzYAM9sJOsCPLGRpSPA8xpZ/wI8rZFFPMCzGtmJAvutZzyZ055NZsOIv2DCP0/h4xO8zeMRHuacbe4XGfMIqA/O9d8ZtqN/P6yIWiz67XvsBlHiRZvEj9R31/0LrRk5tA==


Here is a blueprint that will ensure the chest on the left is always going to have 50. When it drops below 50 items, the chest from the right will send 10 downstream, but will only send another 10 downstream when the left chest again drops to below 50.
I'm not sure how I will use this, but seems kind of neat.
Sorry for mega necro, I literally could not find another example of this system with hours and hours of googling, except for here. It could be improved for usability I'm sure, with the setting of the X item count (50 in this case) to a constcomb somewhere. Maybe even filter out the longrange signal on an inserter by inserter basis, so you can ensure different levels of different items across one long distance circuit poles. Feel cute might update later.
Post Reply

Return to “Gameplay Help”