Belt counter

Post pictures and videos of your factories.
If possible, please post also the blueprints/maps of your creations!
For art/design etc. you can go to Fan Art.

Lupoviridae
Fast Inserter
Fast Inserter
Posts: 155
Joined: Mon Apr 20, 2015 6:26 pm
Contact:

Belt counter

Post by Lupoviridae »

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.
Counter.PNG
Counter.PNG (592.79 KiB) Viewed 17947 times
Counter.zip
(4.13 MiB) Downloaded 319 times
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.

Neotix
Filter Inserter
Filter Inserter
Posts: 599
Joined: Sat Nov 23, 2013 9:56 pm
Contact:

Re: Belt counter

Post by Neotix »

What about jam? Items will stuck in chest and will be counted all the time?

Lupoviridae
Fast Inserter
Fast Inserter
Posts: 155
Joined: Mon Apr 20, 2015 6:26 pm
Contact:

Re: Belt counter

Post by Lupoviridae »

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)

perrydave
Manual Inserter
Manual Inserter
Posts: 1
Joined: Tue Aug 18, 2015 9:06 pm
Contact:

Re: Belt counter

Post by perrydave »

Was there any option to avoid from jamming, what could be the best option to avoid from jamming?

Lupoviridae
Fast Inserter
Fast Inserter
Posts: 155
Joined: Mon Apr 20, 2015 6:26 pm
Contact:

Re: Belt counter

Post by Lupoviridae »

perrydave wrote:Was there any option to avoid from jamming, what could be the best option to avoid from jamming?
The counter should not jam at all.

DOSorDIE
Fast Inserter
Fast Inserter
Posts: 249
Joined: Sat Oct 11, 2014 3:43 pm
Contact:

Re: Belt counter

Post by DOSorDIE »

Its work great!

I have make a plan ... because the sample is hard to read
I hope so its more clear what to do
Counter V1.png
Counter V1.png (646.67 KiB) Viewed 17811 times

User avatar
TuckJohn
Filter Inserter
Filter Inserter
Posts: 335
Joined: Sat Jul 04, 2015 4:11 pm
Contact:

Re: Belt counter

Post by TuckJohn »

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?
~1200+ hours clocked in factorio. Avid KSP and Factorio player

Lupoviridae
Fast Inserter
Fast Inserter
Posts: 155
Joined: Mon Apr 20, 2015 6:26 pm
Contact:

Re: Belt counter

Post by Lupoviridae »

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
Counter V1.png
That graphic is awesome, its always a challenge trying to show everything.

And I'm not sure how to output a blueprint string, could someone point me to a thread or something about it?

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Belt counter

Post by ratchetfreak »

Lupoviridae wrote:
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
Counter V1.png
That graphic is awesome, its always a challenge trying to show everything.

And I'm not sure how to output a blueprint string, could someone point me to a thread or something about it?
you'll need this mod: https://forums.factorio.com/forum/vie ... 92&t=13651

XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Belt counter

Post by XKnight »

Another belt counter, but more compact: 1 combinators per 2 green inserters.
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
belt_counter.png (623.39 KiB) Viewed 17688 times

Lupoviridae
Fast Inserter
Fast Inserter
Posts: 155
Joined: Mon Apr 20, 2015 6:26 pm
Contact:

Re: Belt counter

Post by Lupoviridae »

@Xknight, wouldn't that output a -2 signal each time it performed a count? Have you tested this setup?

XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Belt counter

Post by XKnight »

Lupoviridae wrote:@Xknight, wouldn't that output a -2 signal each time it performed a count? Have you tested this setup?
Do you think that I can share setup that doesn't work?
Setup was tested with one item (copper plate, 2x100 amount), two items (100 iron plates, 100 copper plates, simulatenously) and several smaller tests.

Lupoviridae
Fast Inserter
Fast Inserter
Posts: 155
Joined: Mon Apr 20, 2015 6:26 pm
Contact:

Re: Belt counter

Post by Lupoviridae »

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?

XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Belt counter

Post by XKnight »

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?
No, the same output goes to both wires.

XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Belt counter

Post by XKnight »

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
Last edited by XKnight on Thu Aug 20, 2015 8:15 pm, edited 5 times in total.

XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Belt counter

Post by XKnight »

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

XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Belt counter

Post by XKnight »

Wow, my explanation is not so simple to understand, but somehow it was very easy to create this thing.

Lupoviridae
Fast Inserter
Fast Inserter
Posts: 155
Joined: Mon Apr 20, 2015 6:26 pm
Contact:

Re: Belt counter

Post by Lupoviridae »

XKnight wrote:Wow, my explanation is not so simple to understand, but somehow it was very easy to create this thing.
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
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Belt counter

Post by XKnight »

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?
That's right.
Lupoviridae wrote: For me this is counter-intuitive to how combinators usually work (summing inputs first, then comparing), but what works, works I suppose.
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.

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?
wtf.png
wtf.png (505.08 KiB) Viewed 13665 times
answer

Lupoviridae
Fast Inserter
Fast Inserter
Posts: 155
Joined: Mon Apr 20, 2015 6:26 pm
Contact:

Re: Belt counter

Post by Lupoviridae »

XKnight wrote:
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?
That's right.
Lupoviridae wrote: For me this is counter-intuitive to how combinators usually work (summing inputs first, then comparing), but what works, works I suppose.
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.

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?
wtf.png
answer
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.

Edit: Here's the post
https://www.reddit.com/r/factorio/comme ... _comments/
Scroll down in the comments, he describes the setup in detail.

Post Reply

Return to “Show your Creations”