Belt counter
-
- Fast Inserter
- Posts: 155
- Joined: Mon Apr 20, 2015 6:26 pm
- Contact:
Belt counter
I made a device that counts all items coming down a belt that is expandable for any speed belt and capable of retaining full compression. Here's a screenshot and the save file.
A blue signal in the constant combinator on the right will reset the count. This can be changed to reset every x seconds, when a dummy item passes through, or when a certain item count is reached. By adding a clocked reset signal, this can be used to measure real-time flow rate on the belt accurately.
A test is include off to the left, just provide power to the fast inserters at the head of the input belt to see the magic happen.
This will not act as a buffer, the first smart inserter only works if no items are in the chest.
Each column is separate, counting the number of items passing through that chest.
The contents of each chest is added to the total only when items are first placed in the chest. This means if the flow is stopped, an item left in the chest will not be continuously added to the total. It also means that the counter works if multiple items are placed in the chest at the same time, meaning it can measure the flow rate out of a storage chest where the inserter is grabbing multiple items with each motion.
The time needed to add each item to the total is only about 0.05 seconds (3 ticks). I believe an inserter takes about 0.5s to perform a full rotation, meaning the inserters should be able to work at full speed.
PS. Just realized one of the inserters is turned in this picture. This is going to bug the crap out of me.
The decider on the right records the count. Mouse over it to see all the items that have passed through. Each item type is counted separately, while the green signal is the total number of items.A blue signal in the constant combinator on the right will reset the count. This can be changed to reset every x seconds, when a dummy item passes through, or when a certain item count is reached. By adding a clocked reset signal, this can be used to measure real-time flow rate on the belt accurately.
A test is include off to the left, just provide power to the fast inserters at the head of the input belt to see the magic happen.
This will not act as a buffer, the first smart inserter only works if no items are in the chest.
Each column is separate, counting the number of items passing through that chest.
The contents of each chest is added to the total only when items are first placed in the chest. This means if the flow is stopped, an item left in the chest will not be continuously added to the total. It also means that the counter works if multiple items are placed in the chest at the same time, meaning it can measure the flow rate out of a storage chest where the inserter is grabbing multiple items with each motion.
The time needed to add each item to the total is only about 0.05 seconds (3 ticks). I believe an inserter takes about 0.5s to perform a full rotation, meaning the inserters should be able to work at full speed.
PS. Just realized one of the inserters is turned in this picture. This is going to bug the crap out of me.
Last edited by Lupoviridae on Tue Aug 18, 2015 5:41 pm, edited 3 times in total.
Re: Belt counter
What about jam? Items will stuck in chest and will be counted all the time?
-
- Fast Inserter
- Posts: 155
- Joined: Mon Apr 20, 2015 6:26 pm
- Contact:
Re: Belt counter
Not a problem. Each item is counted once by a pulsed signal only when it is first placed in the chest. (Edited the description to reflect this)
Re: Belt counter
Was there any option to avoid from jamming, what could be the best option to avoid from jamming?
-
- Fast Inserter
- Posts: 155
- Joined: Mon Apr 20, 2015 6:26 pm
- Contact:
Re: Belt counter
The counter should not jam at all.perrydave wrote:Was there any option to avoid from jamming, what could be the best option to avoid from jamming?
Re: Belt counter
Its work great!
I have make a plan ... because the sample is hard to read
I hope so its more clear what to do
I have make a plan ... because the sample is hard to read
I hope so its more clear what to do
Re: Belt counter
Wow. I am going to have to play with the circuit network to see if there are even cooler possibilities.
EDIT: Could you provide a blueprint string?
EDIT: Could you provide a blueprint string?
~1200+ hours clocked in factorio. Avid KSP and Factorio player
-
- Fast Inserter
- Posts: 155
- Joined: Mon Apr 20, 2015 6:26 pm
- Contact:
Re: Belt counter
That graphic is awesome, its always a challenge trying to show everything.DOSorDIE wrote:Its work great!
I have make a plan ... because the sample is hard to read
I hope so its more clear what to do
And I'm not sure how to output a blueprint string, could someone point me to a thread or something about it?
-
- Filter Inserter
- Posts: 952
- Joined: Sat May 23, 2015 12:10 pm
- Contact:
Re: Belt counter
you'll need this mod: https://forums.factorio.com/forum/vie ... 92&t=13651Lupoviridae wrote:That graphic is awesome, its always a challenge trying to show everything.DOSorDIE wrote:Its work great!
I have make a plan ... because the sample is hard to read
I hope so its more clear what to do
And I'm not sure how to output a blueprint string, could someone point me to a thread or something about it?
Re: Belt counter
Another belt counter, but more compact: 1 combinators per 2 green inserters.
It also can work with jammed belts.
It also can work with jammed belts.
Blueprint
You need to change constant combinator output if you want to support several different items on the belt (each value should be -4).- Attachments
-
- belt_counter.png (623.39 KiB) Viewed 18772 times
-
- Fast Inserter
- Posts: 155
- Joined: Mon Apr 20, 2015 6:26 pm
- Contact:
Re: Belt counter
@Xknight, wouldn't that output a -2 signal each time it performed a count? Have you tested this setup?
Re: Belt counter
Do you think that I can share setup that doesn't work?Lupoviridae wrote:@Xknight, wouldn't that output a -2 signal each time it performed a count? Have you tested this setup?
Setup was tested with one item (copper plate, 2x100 amount), two items (100 iron plates, 100 copper plates, simulatenously) and several smaller tests.
-
- Fast Inserter
- Posts: 155
- Joined: Mon Apr 20, 2015 6:26 pm
- Contact:
Re: Belt counter
That's interesting then. When output "Each" is selected, is the output specific to the wire color? E.g. does the input from the red wire get output on the red output only?
Re: Belt counter
No, the same output goes to both wires.Lupoviridae wrote:That's interesting then. When output "Each" is selected, is the output specific to the wire color? E.g. does the input from the red wire get output on the red output only?
Re: Belt counter
Perhaps, my counter requires more explanation:
Example:
(moment: chest value, green value, red value)
0: 0 plate, -4 plate (-4 from constant), 0 plate
input inserter put one item into the chest
1: 1 plate, -3 plate (-4 from constant + 1 from chest), 1 plate (1 from chest)
combinator's input: -3 from green (doesn't affect the result because value should be greater than -3), 1 from red
combinator's output: 1 plate
main counter recieve: 1 plate
output inserter value: -3 value (item still in chest)
2: 1 plate, -2 plate (-4 from constant + 1 from chest + 1 from combinator's output), 1 plate (1 from chest)
combinator's input: -2 from green, 1 from red
combinator's output: -1 plate
main counter recieve: -1 plate
output inserter value: -2 value (item still in chest)
3: 1 plate, -4 plate (-4 from constant + 1 from chest - 1 from combinator's output), 1 plate (1 from chest)
combinator's input: -4 from green (doesn't affect the result because value should be greater than -3), 1 from red
combinator's output: 1 plate
main counter recieve: 1 plate
output inserter value: -4 value, inserter take item from chest
4: 0 plate, -3 plate (-4 from constant + 1 from combinator's output), 0 plate
combinator's input: -3 from green (doesn't affect the result because value should be greater than -3), 0 from red
combinator's output: 0 plate
main counter recieve: 0 plate
output inserter value: -3 value
5: 0 plate, -4 plate (-4 from constant), 0 plate
end
Overall result in counter +1 -1 +1 + 0 = 1
Example:
(moment: chest value, green value, red value)
0: 0 plate, -4 plate (-4 from constant), 0 plate
input inserter put one item into the chest
1: 1 plate, -3 plate (-4 from constant + 1 from chest), 1 plate (1 from chest)
combinator's input: -3 from green (doesn't affect the result because value should be greater than -3), 1 from red
combinator's output: 1 plate
main counter recieve: 1 plate
output inserter value: -3 value (item still in chest)
2: 1 plate, -2 plate (-4 from constant + 1 from chest + 1 from combinator's output), 1 plate (1 from chest)
combinator's input: -2 from green, 1 from red
combinator's output: -1 plate
main counter recieve: -1 plate
output inserter value: -2 value (item still in chest)
3: 1 plate, -4 plate (-4 from constant + 1 from chest - 1 from combinator's output), 1 plate (1 from chest)
combinator's input: -4 from green (doesn't affect the result because value should be greater than -3), 1 from red
combinator's output: 1 plate
main counter recieve: 1 plate
output inserter value: -4 value, inserter take item from chest
4: 0 plate, -3 plate (-4 from constant + 1 from combinator's output), 0 plate
combinator's input: -3 from green (doesn't affect the result because value should be greater than -3), 0 from red
combinator's output: 0 plate
main counter recieve: 0 plate
output inserter value: -3 value
5: 0 plate, -4 plate (-4 from constant), 0 plate
end
Overall result in counter +1 -1 +1 + 0 = 1
Last edited by XKnight on Thu Aug 20, 2015 8:15 pm, edited 5 times in total.
Re: Belt counter
belt is jammed
0: 0 plate, -4 plate (-4 from constant), 0 plate
input inserter put one item into the chest
1: 1 plate, -3 plate (-4 from constant + 1 from chest), 1 plate (1 from chest)
combinator's input: -3 from green (doesn't affect the result because value should be greater than -3), 1 from red
combinator's output: 1 plate
main counter recieve: 1 plate
output inserter value: -3 value (item still in chest)
2: 1 plate, -2 plate (-4 from constant + 1 from chest + 1 from combinator's output), 1 plate (1 from chest)
combinator's input: -2 from green, 1 from red
combinator's output: -1 plate
main counter recieve: -1 plate
output inserter value: -2 value (item still in chest)
3: 1 plate, -4 plate (-4 from constant + 1 from chest - 1 from combinator's output), 1 plate (1 from chest)
combinator's input: -4 from green (doesn't affect the result because value should be greater than -3), 1 from red
combinator's output: 1 plate
main counter recieve: 1 plate
output inserter value: -4 value, inserter take item from chest, BUT IT CAN'T BECAUSE OF JAM
4: 1 plate, -2 plate (-4 from constant + 1 from chest + 1 from combinator's output), 1 plate (1 from chest)
...
(repeat 1,2,3,2,3,2,3,2,3,...)
Overall result in counter +1 -1 +1 -1 +1 -1 .... = 0 while belt is jammed
0: 0 plate, -4 plate (-4 from constant), 0 plate
input inserter put one item into the chest
1: 1 plate, -3 plate (-4 from constant + 1 from chest), 1 plate (1 from chest)
combinator's input: -3 from green (doesn't affect the result because value should be greater than -3), 1 from red
combinator's output: 1 plate
main counter recieve: 1 plate
output inserter value: -3 value (item still in chest)
2: 1 plate, -2 plate (-4 from constant + 1 from chest + 1 from combinator's output), 1 plate (1 from chest)
combinator's input: -2 from green, 1 from red
combinator's output: -1 plate
main counter recieve: -1 plate
output inserter value: -2 value (item still in chest)
3: 1 plate, -4 plate (-4 from constant + 1 from chest - 1 from combinator's output), 1 plate (1 from chest)
combinator's input: -4 from green (doesn't affect the result because value should be greater than -3), 1 from red
combinator's output: 1 plate
main counter recieve: 1 plate
output inserter value: -4 value, inserter take item from chest, BUT IT CAN'T BECAUSE OF JAM
4: 1 plate, -2 plate (-4 from constant + 1 from chest + 1 from combinator's output), 1 plate (1 from chest)
...
(repeat 1,2,3,2,3,2,3,2,3,...)
Overall result in counter +1 -1 +1 -1 +1 -1 .... = 0 while belt is jammed
Re: Belt counter
Wow, my explanation is not so simple to understand, but somehow it was very easy to create this thing.
-
- Fast Inserter
- Posts: 155
- Joined: Mon Apr 20, 2015 6:26 pm
- Contact:
Re: Belt counter
I see how it works. I was confused by step 1. If a combinator is receiving a -3 on green and 1 on red, I would expect these to be summed to -2 internally, then output as -2 (since -2 > -3). I am surprised to learn that it considers each value independently. So if it were to receive a -2 on green and 1 on red, the output would be -1, but with a -3 on green and a 1 on red it outputs 1? For me this is counter-intuitive to how combinators usually work (summing inputs first, then comparing), but what works, works I suppose.XKnight wrote:Wow, my explanation is not so simple to understand, but somehow it was very easy to create this thing.
Re: Belt counter
That's right.Lupoviridae wrote: So if it were to receive a -2 on green and 1 on red, the output would be -1, but with a -3 on green and a 1 on red it outputs 1?
I think this behaviour was intended to support some kind of binary logic. When the same signal type is on both wires but with different values.Lupoviridae wrote: For me this is counter-intuitive to how combinators usually work (summing inputs first, then comparing), but what works, works I suppose.
More strange thing that I am trying to understand is a zero-signal behaviour.
What output will be in the first decider combinator and in the second?
answer
-
- Fast Inserter
- Posts: 155
- Joined: Mon Apr 20, 2015 6:26 pm
- Contact:
Re: Belt counter
I encountered something like this before actually, u/orost on reddit made some ram that worked by a similar quirk in the game logic. It seems to basically amount to a shortcut in the game code, I couldn't really figure it out either. I think in some cases multiple "constant" signals connected to the same network act functionally as only a single one, and the signals being output are actually summed before it's broadcast to the wire itself. So in the second case nothing is actually being output on the red wire.XKnight wrote:That's right.Lupoviridae wrote: So if it were to receive a -2 on green and 1 on red, the output would be -1, but with a -3 on green and a 1 on red it outputs 1?
I think this behaviour was intended to support some kind of binary logic. When the same signal type is on both wires but with different values.Lupoviridae wrote: For me this is counter-intuitive to how combinators usually work (summing inputs first, then comparing), but what works, works I suppose.
More strange thing that I am trying to understand is a zero-signal behaviour.
What output will be in the first decider combinator and in the second?answer
Edit: Here's the post
https://www.reddit.com/r/factorio/comme ... _comments/
Scroll down in the comments, he describes the setup in detail.