# How to generate a predetermined number of pulses?

Motivation: I have a grinder that spawns spiders which are then moved to a very small space. When they accumulate in big enough numbers, I pull a lever and let a piston crush them 11 times. Then I can kill them with one hit and harvest experience.

This becomes a problem once there are a lot of spiders - the game starts to lag and it is difficult (if not impossible) to have the precise number of hits.

Question: For some n, how do I create a circuit that generates n impulses before shutting down?
Or in this case, how do I make a piston hit exactly 11 times?

-
You should be able to do this by using a lot of repeaters, something similar to youtube.com/watch?v=EfwmkHruBsw (second example) but with only one piston. It may be a bit clumsy for higher numbers though. I'm at work now so can't give you a more concrete example yet. – Hex Feb 29 '12 at 12:16

Lightweight version
It seems I overcomplicated things a bit on the first attempt, this version should be better and more compact, at least for smaller numbers (first example produces 4 pulses). It's also possible to connect the "start" for another pulse straight from the second torch).

For this setup to work with a high pulse count you will need to put repeaters every 15 blocks in the redstone line, and for each of those repeaters there will need to be extra ticks between all stone blocks. This exact setup will work for your 11 pulses (last 6 blocks of 11 shown):

Heavy version (no limit)
Basically an outer "zig-zag" circuit that will send a new pulse straight through the middle line each time it passes a stone block. I tested it with up to 11 pulses, and you can just extend it as much as needed. Obviously it gets quite clumsy with a large number of pulses.

-
Great job on the updated design. Be sure to account for the repeater(s) required when expanding to a higher pulse count. – user9983 Feb 29 '12 at 20:48
@OrigamiRobot Excellent point. It might require some tweaking to work with high pulse counts. If all else fails, the bottom one (clumsy as it is) should work for longer distances. – Hex Feb 29 '12 at 21:55
Now your heavy version is too heavy! You should get the same effect and save a lot of space/redstone if you just modify your light version by placing repeaters in the output line every 15 blocks. – user9983 Mar 1 '12 at 13:32
@OrigamiRobot That was my first thought as well, but it messed it all up by causing too much delay (all the pulses prior to the repeater ceased to work). Ran out of testing time though, maybe I'll give it another shot tonight. – Hex Mar 1 '12 at 14:09
You could probably fix that by increasing the delay on the repeaters between blocks by one tick for each repeater the output will need to go through. – user9983 Mar 1 '12 at 15:06

you could use a loop of minecart tracks and put several detectors on it connected to the pistons. A good example in use would be in this video:

shown at the time 2:18-2:38. The system that is being used is the T-FlipFlop which is explained in this video:
Using this you can test it out and calibrate it to your EXACT needs.

-
-1 Please provide more details of what you are suggesting. If possible, an example would help a lot. – user9983 Feb 29 '12 at 21:15