## Repeating Counter help

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
unknownzzzz
Burner Inserter
Posts: 7
Joined: Fri Nov 20, 2020 10:51 pm
Contact:

### Repeating Counter help

I am trying to launch a rocket while there is still science in silo, but less than 1000 to prevent waste.

I found that filling a silo up to 2000 science, then launching a rocket every time 1000 science is removed keeps it fluctuating between 700 and 1700 science internally.

I do this my counting the science removed by inserters. What I need help with is making this counter more efficient/smaller - while keeping the counter from going to infinity.

I ran into the major issue that an Arithmetic Combinator's "Pulse" is actually "2-4 Pulses" by default. So I had to add an extra pulse generator section.

https://imgur.com/a/aisM0Oc

DaveMcW
Smart Inserter
Posts: 3263
Joined: Tue May 13, 2014 11:06 am
Contact:

### Re: Repeating Counter help

unknownzzzz wrote:
Fri Nov 20, 2020 11:04 pm
an Arithmetic Combinator's "Pulse" is actually "2-4 Pulses" by default. So I had to add an extra pulse generator section.
This only happens if the arithmetic combinator has low power. Try putting it on an isolated electric network with a solar panel and an accumulator to make sure it is always fully powered.

unknownzzzz
Burner Inserter
Posts: 7
Joined: Fri Nov 20, 2020 10:51 pm
Contact:

### Re: Repeating Counter help

DaveMcW wrote:
Sat Nov 21, 2020 12:10 am
unknownzzzz wrote:
Fri Nov 20, 2020 11:04 pm
an Arithmetic Combinator's "Pulse" is actually "2-4 Pulses" by default. So I had to add an extra pulse generator section.
This only happens if the arithmetic combinator has low power. Try putting it on an isolated electric network with a solar panel and an accumulator to make sure it is always fully powered.
The main topic is to receive help with making a more compact and efficient design for the current looping/repeating counter.
https://imgur.com/a/aisM0Oc

I was not planning on discussing the multiple pulse issue, but here is my research showing the multiple pulses. If you find a solution it might help with the main topic's solution.
Example was running on infinite power. I also tried it with plenty of normal power (solar/accumulators) to rule out an infinite power issue.
Here is blueprint to showing that each loop is sending 2 or 3 pulses (see image as well).

https://imgur.com/a/SO51Ikw

DaveMcW
Smart Inserter
Posts: 3263
Joined: Tue May 13, 2014 11:06 am
Contact:

### Re: Repeating Counter help

I see. You have a memory cell that outputs a signal every tick (not a 1-tick pulse). Then when you calculate it is time to reset it, the reset signal lasts for several ticks until a new calculation is finished.

The solution is to make a self-resetting memory cell. Instead of "science + 0 → science", use "science % 1000 → science".

Then the condition to launch the rocket is "science >= 1000". This condition will only last for 1 tick before it resets. Note that you must read the memory cell input and output on the same wire, since the memory cell itself will never output more than 999.

unknownzzzz
Burner Inserter
Posts: 7
Joined: Fri Nov 20, 2020 10:51 pm
Contact:

### Re: Repeating Counter help

DaveMcW wrote:
Sat Nov 21, 2020 1:22 am
I see. You have a memory cell that outputs a signal every tick (not a 1-tick pulse). Then when you calculate it is time to reset it, the reset signal lasts for several ticks until a new calculation is finished.

The solution is to make a self-resetting memory cell. Instead of "science + 0 → science", use "science % 1000 → science".

Then the condition to launch the rocket is "science >= 1000". This condition will only last for 1 tick before it resets. Note that you must read the memory cell input and output on the same wire, since the memory cell itself will never output more than 999.
After testing:

Memory cell won't work:
If the output got stuck on 999 the rocket would keep on firing - wasting lots of resources.
If the rocket is not ready to fire and the 999 comes the inserter will not inset the satellite and the memory cell will continue to the 1000 marker reset. Then the rocket won't ever fire.

My counter that pulses and resets every 1000 science will not work either:
If the rocket is not ready to fire and the 1000 science pulse comes the inserter will not inset the satellite and the rocket won't ever fire.

I found a solution!!!!:
> Satellite Inserter when Science >= 1000
> Satellite Inserter pulse causes Science Counter to -1000.

> Extra: Shift "Satellite Inserter when Science >= 1000" 2000 to the left so it inserts 2 satellites by default.
Now: "> Satellite Inserter when Science >= -1000"

Works great.
2 Arithmetic combinator and 1 Decider combinator

https://imgur.com/a/UoXG7nr

unknownzzzz
Burner Inserter
Posts: 7
Joined: Fri Nov 20, 2020 10:51 pm
Contact:

### Re: Repeating Counter help

Found issue.

Minor Blueprint issue.
If satellite inserter is set to insert "Science >= -1000" it will keep insert satellites by default.
If the rocket is ready to fire and the circuit is not 100% built bad things happen. Rockets can continuously launch - wasting science.

Safest method is to place the rocket silo(s) last or have all the circuit materials close-by.

-------------

If there was a way to set the counter value to an initial 2000 in a blueprint that would work, but I don't think it's possible without Constant combinators (Which make bad things happen if left on, and are an extra unnecessary component).

Zavian
Smart Inserter
Posts: 1564
Joined: Thu Mar 02, 2017 2:57 am
Contact:

### Re: Repeating Counter help

unknownzzzz wrote:
Sat Nov 21, 2020 2:59 am
Safest method is to place the rocket silo(s) last or have all the circuit materials close-by.
If you want safety, why use a complicated circuit? Just use a stack inserter to unload the silo into a chest, than wire the chest to the satellite inserter with a condition like, "space science flask < 500". With max stack inserter research the stack inserter removing the science is faster than a max beaconed silo, so science won't overflow. (Also I don't turn on the auto-launch with satellite setting until after I have limited satellite insertion. That way even if something is delayed during building, nothing will overflow).

unknownzzzz
Burner Inserter
Posts: 7
Joined: Fri Nov 20, 2020 10:51 pm
Contact:

### Re: Repeating Counter help

Zavian wrote:
Sat Nov 21, 2020 3:14 am
unknownzzzz wrote:
Sat Nov 21, 2020 2:59 am
Safest method is to place the rocket silo(s) last or have all the circuit materials close-by.
If you want safety, why use a complicated circuit? Just use a stack inserter to unload the silo into a chest, than wire the chest to the satellite inserter with a condition like, "space science flask < 500". With max stack inserter research the stack inserter removing the science is faster than a max beaconed silo, so science won't overflow. (Also I don't turn on the auto-launch with satellite setting until after I have limited satellite insertion. That way even if something is delayed during building, nothing will overflow).
Safety for building is a factor, but not a critical factor. I want to "have my cake and eat it too".
• Inserting satellites when Rocket Silo is Empty (unloaders are not holding sciences) brings my Factory production at ~490 Science per second.
• Using Counter to keep rocket silo internal buffer from going empty brings production to ~540 Science per second. An 8% increase with no need for increasing factory footprint.
• Using chests as a buffer would be nice - but by adding chests, the factory footprint increases by over 22%. Adding more factory blocks with an 8% loss is more efficient than the 22% footprint loss. But on the other hand, there is 0% science wastage from unexpected launches during the build process (unless the chest(s) overfill.).
For UPS.
• For buffer chests, "inserter -> chest -> inserter" is still 2 actions per unloading.
I would prefer a way to add safety to the circuit network without adding overhead. In code I would set the initial counter value = 2000, but here it's always 0.
Last edited by unknownzzzz on Sat Nov 21, 2020 4:18 am, edited 1 time in total.

DaveMcW
Smart Inserter
Posts: 3263
Joined: Tue May 13, 2014 11:06 am
Contact:

### Re: Repeating Counter help

In your latest blueprint, you are effectively multiplying the satellite pulse by -1000. You can do that more directly by using an arithmetic combinator.

unknownzzzz
Burner Inserter
Posts: 7
Joined: Fri Nov 20, 2020 10:51 pm
Contact:

### Re: Repeating Counter help

DaveMcW wrote:
Sat Nov 21, 2020 4:17 am
In your latest blueprint, you are effectively multiplying the satellite pulse by -1000. You can do that more directly by using an arithmetic combinator.
WOW, WOW, WOW!!! Thank you!!! Thank you!!! Thank you!!!
Why didn't I think of that!
Removing 1/3 of the circuit logic with that one step! No more Decider combinator needed.

Updated image and print.

https://imgur.com/a/VOH9KyY

### Who is online

Users browsing this forum: No registered users