Self Resetting Timer
Posted: Fri Jul 15, 2016 12:53 am
Hello again,
for one of my factories I needed a timer that is able to reset itself if a trigger occurs while the timer is still running. That is the result:
An Item moves over the Trigger and triggers one tick of its content. In this case red bottle x1. The Init Value combinator multiplies it by 200. That is the timer's start value. So it should count to zero in about 3 seconds (one tick = 1/60 second). For now we have 200x red bottles. At the Gate the 200x red bottles get summed up by the Remainder's output value. It contains always the negated value of the counter. So if the timer is at 150 the remainder is at -150. The Gate triggers the signal for one tick which starts the counter and makes sure that the counter doesn't get flooded by the remainders value. As this is our first run-through the remainder is at 0. So 200 gets passed to the counter. Now the counter feeds itself with its by 1 reduced output until it reaches zero. When at zero the signal gets deleted by the game rule (0 = no signal). So it cannot run negative.
But on the second run-through the timer is at.... lets say 80. So 2 seconds have passed. This time the remainder is at -80 (as the timer is at +80). Both signals get summed up at the gate (200 + (-80)). 120 is the new value that gets passed to the timer. So 80 (timer) + 120 and we are at 200 again. As already mentioned, the timer is flood save. No problems if many items trigger the timer quickly.
Probably you have some use for it. I used it for a smart stack inserter which is placed 2 belts behind the trigger in front of an underground belt which unfortunately cannot be connected to a circuit network. But that way the belt trigger can still set the filter of the inserter and be sure that the item gets picked up as the filter signal is extended by some ms.
It's really simple to build. But if you prefer the blueprint string, just tell me.
Greetings
for one of my factories I needed a timer that is able to reset itself if a trigger occurs while the timer is still running. That is the result:
An Item moves over the Trigger and triggers one tick of its content. In this case red bottle x1. The Init Value combinator multiplies it by 200. That is the timer's start value. So it should count to zero in about 3 seconds (one tick = 1/60 second). For now we have 200x red bottles. At the Gate the 200x red bottles get summed up by the Remainder's output value. It contains always the negated value of the counter. So if the timer is at 150 the remainder is at -150. The Gate triggers the signal for one tick which starts the counter and makes sure that the counter doesn't get flooded by the remainders value. As this is our first run-through the remainder is at 0. So 200 gets passed to the counter. Now the counter feeds itself with its by 1 reduced output until it reaches zero. When at zero the signal gets deleted by the game rule (0 = no signal). So it cannot run negative.
But on the second run-through the timer is at.... lets say 80. So 2 seconds have passed. This time the remainder is at -80 (as the timer is at +80). Both signals get summed up at the gate (200 + (-80)). 120 is the new value that gets passed to the timer. So 80 (timer) + 120 and we are at 200 again. As already mentioned, the timer is flood save. No problems if many items trigger the timer quickly.
Probably you have some use for it. I used it for a smart stack inserter which is placed 2 belts behind the trigger in front of an underground belt which unfortunately cannot be connected to a circuit network. But that way the belt trigger can still set the filter of the inserter and be sure that the item gets picked up as the filter signal is extended by some ms.
It's really simple to build. But if you prefer the blueprint string, just tell me.
Greetings