2-tick delay between inserter signal output and enable/disable

Bugs that are actually features.
ChickenBones
Burner Inserter
Burner Inserter
Posts: 6
Joined: Mon Feb 01, 2021 10:56 am
Contact:

2-tick delay between inserter signal output and enable/disable

Post by ChickenBones »

The enable/disable condition of an inserter cannot react to the signal emitted by the inserter as the result of picking up an item in the previous tick. This makes some otherwise clean and simple circuit network builds impossible.

This is more a feature request than a bug report, and somewhat overlaps with the following other issues:
- viewtopic.php?f=23&t=92636
- viewtopic.php?f=71&t=99519


The easiest way to see the issue is with an inserter picking up from the far lane of a blue belt set to enable when not holding anything.
Image

An inserter will only ever pick up one item off a belt each tick, but depending on item position, belt speed and inserter rotation, there are times when an inserter will pickup items in consecutive ticks and not have time to react to the signal from the previous pickup.

The main practical consequence of this is that attempts to 'count and limit number of items picked up by an inserter' can't work perfectly. In the screenshot below, the inserter has stack-size 3, and a 'limit' of 7, but picks up 2 items on the 3rd swing, with the combinator counting up to 8.
Image

Editor consecutive ticks. Note that it picks up the second item in the same tick it becomes disabled. With the disable condition being satisfied in the previous tick.
ImageImage

Note that the stack-size limit here is not important, and a consecutive tick pickup can happen under any circumstance when the inserter swings back to find multiple items on the belt in its pickup window.

A graph of the circuit network signal for the red wire in this setup is below. A single lane of a yellow belt has an 8 tick spacing between items.
Image

I have been unable to find a viable workaround to allow for perfect counting off a belt, other than setting stack size to 1 and ruining throughput.

The stack-size related issue indicates that the enable/disable status is 'snapshot' and propagated to the following tick, but the stack-size is not. Presumably there are reasons for this, so it won't get changed, but I can't think of any builds which are made possible by the current behaviour.

Blueprint string for experimentation:
Tertius
Smart Inserter
Smart Inserter
Posts: 1115
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: 2-tick delay between inserter signal output and enable/disable

Post by Tertius »

Why don't you use the "set stack size" functionality? I solved this challenge by computing the amount of remaining items to pick up as S, and set stack size to S. Enable/disable with condition S>0. You can set stack sizes higher than 12 fine, the inserter will just stop at 12. While the inserter swings, the new S is being computed, 1 or 2 ticks due to the latency of the counter, but if it swings back, the new S is correct. Always picks exactly the desired amount without having to hardcode stack size 1.
Locked

Return to “Not a bug”