Redstone circuits/Clock

Introduction
Clock generators are devices where the output is toggling on/off constantly. The customary name x-clock is derived from half of the period length, which is also usually the pulse width. For example, a classic 5-clock will produce the sequence  on the output.

Using only redstone torches and wire, it is possible to create clocks as short as a 4-clock, sometimes by exploiting glitches. Using repeaters or pistons allows easy construction of any clock down to 1-clocks, and other devices can also be pressed into service. There are also special circuits called "rapid pulsers", which produce rapid pulses like a 1 tick clock, but inconsistently due to torches burning out. Indeed, torch based rapid pulsers can be too fast for repeaters. Even with repeaters in use, 1-clock signals are difficult to handle in other circuits, as many components and circuits will not respond in timely fashion.

Creating long clocks (more than a few ticks) can be more difficult, as adding repeaters will eventually get unwieldy. However, there are a number of approaches here, which are discussed in a separate section.

Clocks without an explicit toggle can often have one retrofitted, by wiring a lever or other switch to the controlling block of an inverter, or even to a redstone loop. In general, forcing the delay loop high will eventually stop the clock, but the output may not respond until the current pulse has made its way through the loop. Whether the output will be stopped high or low depends on the clock and where in the loop you force it. Another option is to use a lever-controlled piston to open or close one of those loops, using either a solid block to transmit power, or (as of 1.5) a redstone block to supply it.

Torch Loops
The basic torch pulser is the oldest clock circuit in Minecraft, simply an odd number of inverters (NOT gates) joined in a loop. The design has been mostly replaced by repeaters, but still works. Design A shows a 5-clock, which is the shortest clock that can easily be made this way. Its pulse length can be extended by adding pairs of torches and/or repeaters. Repeaters can be added into the loop, or can replace any pair of inverters Adding repeaters also allows even-numbered clocks such as a 10-clock. The total interval will be "NOT gate count"+"repeater total delay".

Even torch based 5-clocks can be made more compact, as with designs B and C. However, these have fewer places where repeaters can be inserted without using more space. Using this method, 1-clocks and 3-clocks are possible, but these will be unstable and erratic as the torches will regularly "burn out". As with the basic clock, the compact clocks can be extended by making the chain of inverters longer, or with repeaters. A 5-clock can also be made vertical, as in G

Design D uses a different method to produce a 4-clock. (A 4-clock is the fastest clock of this sort which will not overload the torches.)

By making use of the North/South Quirk, it is possible to produce a more compact 4-clock with a regular on/off pulse width, as seen in design E. This design uses five torches, but if the stacked torches are pointed north-south, it has a pulse width of 4 ticks.

Rapid Pulsers
Redundancy can be used to maintain a 1-clock, even as the torches burn out; the result is the so-called "Rapid Pulser" (designs X, Y and (vertical) Z). However, the signal may not be consistent.

Device R creates energy in an irregular sequence. It is a variant of the "Rapid Pulser" design shown above, except that each torch pulses in an irregular pseudo-random pattern as each torch coming on turns the other three (and itself) off. Occasionally torches will burn out for a few seconds (until reset by a block update), during which time other torches blink. As of version 1.5.1, this is likely to favor one pair of torches, such as the east and west torches, which will blink while the others stay dark. Output can be taken anywhere on the circuit.

Repeater Loops
With the addition of Redstone Repeaters in the Beta 1.3 update, A complete clock generator can be simplified to a single block, one Redstone torch and from one to any number of repeaters chained together, as shown in design A. The repeater delay must be at least two ticks, or the torch will burn out.

Clocks also can be made with repeaters only, as in design B. There are no torches to burn out, so they can run at very high speed, such as the 1-clock design C. However, unlike torch-based clocks, these do not start running on their own and must be triggered by hand or with a pulse generator. One way to hand-start a torchless clock is to place a temporary torch which will immediately be turned off by a (previously-placed) power source. The torch will flash on for 1 tick before it realizes it's powered, which is enough to start most fast clocks.

This clock is built from 2 modified pulse limiters (as shown) in series, and allows for not only an off-switch, but adjustment of how much of the cycle is spent "on". A rising edge on the toggle line will turn the clock on or off. Caveats:
 * The first pulse limiter needs a minimum total of 5 ticks delay between the repeaters, to reliably start the clock.
 * For the second limiter, altering the delays will affect both the output's delay, and how much of the cycle it spends "on". You generally need a total of 10 ticks delay among the 3 repeaters, or the clock will stop.
 * A signal received on the output line can also toggle the state of the clock, so the output should be "isolated" (repeater or inverter) from any circuits it connects to.

Vertical Loops


Design D is a tiny vertical clock that can output a 3, 4, or 5-tick cycle.

Earliest Known Publication: June 30, 2011, in video "Cobblestone Factory", YouTube video, 5:50, posted by "ZirumsHeroTWR"

The period will be the repeater's delay plus 1, but the repeater must be set to at least 2 ticks or the torch will burn out. This circuit is formally 1&times;3&times;3, but is most commonly built as a "V" on the ground, and can easily be buried entirely.
 * A lever on, or redstone signal to, any of the four solid blocks can stop the clock. The torch will be forced "off", while the dust will be lit.
 * Output can be taken almost anywhere, with a few exceptions:
 * The blocks "crosswise" from the redstone dust (pistons work, but dust or a repeater is likely to jam the clock).
 * The block under the repeater (a repeater or piston next to it will be out-of-phase, and dust won't light).
 * Output from the dust side will be reverse phase.

Design E is a more general vertical clock. It can be extended indefinitely to add 2 repeaters (up to 8 ticks of delay) for each block of extension. As shown, it has a minimum delay of 5 ticks, but this can be shortened by replacing some of the repeaters with redstone dust. A lever or redstone signal behind the torch will stop the clock with output OFF, once any current ON-phase passes the output. A signal at the other end (e.g., into the output) will also stop the clock, but with the output immediately going high. (A dust-cut piston will also work.)

Piston Clocks
Pistons can be used to create new types of clocks with a modifiable pulse delay without the use of pulse generators. Pistons can be clocked in a fashion that only leaves the arm extended for the time required to push an adjacent block. However, note that if sticky pistons are regularly used this way (that is, as a 1-clock), they can occasionally "drop" (fail to retract) their block, which will usually stop the clock. (Specifically, if the setup allows for a pulse less than 1 tick long, that will make a sticky piston drop its block. This can be useful, notably for toggles.)  Piston clocks in general can be easily turned off or on by a "toggle" input T.

Design A requires only a sticky piston and redstone wire, and is controllable. It runs as long as the toggle line (its power source) is on, and turns off when the toggle line is off. Repeaters can be added to increase its delay. If the repeater is replaced with wire, it can be used as a 1-tick clock, but it is prone to "dropping" its block.

Design B shows how to counter block dropping with an optional, non-sticky, piston. The non sticky piston (the bottom one) is needed for the 1 tick clock as a self repair mechanism. It prevents detaching of the moving block from the sticky piston. If using it only for a 1-tick cycle, the repeater (under the extended piston) can be replaced with redstone wire. The toggle line stops the clock on a high signal.

Design C requires two sticky pistons, and can be easily stopped by just setting one side of the redstone high. The repeaters can be indefinitely extended to make a very long delay clock.

Design D only needs one sticky piston, but at the repeater must be set to 2 or more ticks. If it is set to one tick, the torch will burn out. The output signal can be taken from any part of the circuit. This design can also be controlled; a high input on the toggle line will stop the clock.

The symmetrical design E shows how non-sticky pistons can also "pass around" a block. Output can be taken from any of the outer redstone loops.

Design F is an unusual, stable, 1-tick piston clock. Unlike most repeater-based 1-clocks, its signal is fast enough to make a sticky piston reliably toggle its block, dropping and picking it up on alternate pulses. For The clock to work, the block the piston moves must be placed last. The piston will extend and retract very quickly. The output wire appears to stay off, because it's changing state faster than the game visually updates. However, attaching a piston or other device to the output will show that it is working. The clock can be turned off by a redstone signal (e.g. the lever shown on the block below it) to the piston.

Design G is the simplest design and can be used to create rapid clocks. However, it is not controllable, so the only way to stop such a circuit, without adding additional parts, is to break one component (one redstone wire is recommended). Place a block of Redstone on a sticky piston, then lay down Redstone so that the block powers the piston. Then, once the piston is powered and moves the block, the redstone current will stop, pulling the block back to the original position, which will make the block power the wire again, and so on.

Basic Hopper Clock
To create a switchable 4-clock (more or less), you can set up 2 hoppers facing each, drop an item in one hopper, and use a redstone comparator as the output. Four hoppers in a circular pattern will give a period of 16, but this is not properly an 8-clock, because the output will be "on" only 4 ticks out of 16. A switch can power the side of the comparator, to cut off output, or one of the hoppers, to stop the transfer itself. Note that in the schematic, the switch as positioned will power the hopper only; it would need redstone dust to power the comparator. Note that since it uses a comparator, building this in survival mode requires access to Nether Quartz.

Long period hopper clock
The basic principle of the basic hopper clock can be extended to create adjustable hopper clocks with periods of up to several minutes.

If the comparator output from a hopper in the loop is fed into the next hopper along, it prevents the items in the second hopper from passing into the third hopper until the first hopper has completely emptied into the second. This allows the period to be controlled by the number of items in the hoppers, whereas ordinarily, only one item will travel around the loop regardless of how many are stored.

The size of the design shown is 7&times;8&times;2, including a falling edge detector. With this design, a short pulse is output every 1.6N seconds, where N is the total number of items in the hoppers. Since a single hopper able to store five stacks totalling 320 items, the maximum period is 520 seconds, or 8 minutes 32 seconds.

Switching the lever on halts the output and, eventually, the hoppers. The switch is also capable of forcing a pulse (triggered on the lever's falling edge), but this is not an entirely reliable feature, as it only works if the hopper nearest the lever is empty.

Variations:
 * If the circuit is not required to output short pulses, the edge detector can be removed (reducing the footprint to 6&times;6). The period of the clock will be unaffected, but the output pulses will have a duration of 0.4N seconds (a quarter of the clock period).
 * It is also possible to remove two of the four comparator/repeater circuits, if the user wishes to save on resources, but the clock still requires all four hoppers, and the comparators removed must be on opposite sides of the hopper loop. This alteration also roughly halves the period, changing it to 0.8(N+1) seconds, with a maximum of 256.8 seconds (4m 16.8s).

Earliest known publication: 22 January 2013

Comparator clocks
Comparators can be used to make fast clocks and slow pulsers.

Subtraction clock

 * Subtraction 1-Clock


 * 2&times;2&times;2 (8 block volume), flat, silent
 * clock output: 1 tick on, 1 tick off


 * A subtraction 1-clock toggles on and off every tick. It uses a redstone comparator in subtraction mode, with the output feeding to the comparator's side input.


 * When the comparator first receives full power, it outputs strength 15 to the block in front of it, which passes the same signal strength to the dust next to it. The signal strength then declines by 1 (to 14) as it moves to the dust next to the comparator. In the next tick, the comparator subtracts 14 from its it 15 input to output only signal strength 1. This is enough to barely power the block and the dust next to the block, but isn't strong enough to reach back to the dust next to the comparator, so on the next tick the comparator subtracts 0 from its input and the cycle starts again.


 * Only the redstone dust next to the comparator will actually toggle between on and off -- the comparator, the block in front of it, and the dust next to the block only toggle between signal strength 15 and 1. Add additional dust lines to these points to take output from them and allow the signal strength to decline to at least 14 and 0.


 * A subtraction clock doesn't require full power for input -- it will work even with an input strength as small as 2.


 * Variations: You can use any full container as the "input" if a power source would be inconvenient in that location (such as right next to the output).


 * Earliest Known Publication: 9 February 2013.


 * Subtraction N-Clock


 * 2×3×2 (12 block volume), flat, silent
 * clock output: 2-5 ticks on, 2-5 ticks off


 * With the repeater set to a 1-tick delay, this is a 2-clock (2 ticks on, 2 ticks off). Increase the repeater delay to slow the clock down, or even add additional repeaters. If the input strength is higher than 1, the block behind the repeater can be replaced with redstone dust; if higher than 2, the block in front of the comparator can also be replaced with redstone dust. Output can be taken from anywhere.

Fader pulsers
Fader pulsers are useful for making small clocks with periods of 1-15 seconds (for longer periods, hopper clocks can be smaller), but they are difficult to adjust to a precise period. They use a fader circuit (aka "fader loop"&mdash;a comparator loop where the signal strength declines with every pass through the loop because it travels through at least one length of two or more redstone dust), renewed by a redstone torch every time it fades out.


 * Fader 9-Pulser


 * 1&times;4&times;4, 1-wide, silent
 * clock output: 1 tick on, 8 ticks off


 * When the input turns off, the redstone torch initially "charges" the fader loop at signal strength 15. There's only one comparator in the loop so each cycle through the loop takes only 1 tick, and the signal strength declines by 2 each time through the loop, so the fader loop will stay charged for 8 ticks. The redstone torch then turns on for only one tick because it short-circuits itself (the torch won't burn-out because it's held off most of the time by the fader circuit).


 * Fader 29-Pulser


 * 2&times;4&times;2, flat, silent
 * clock output: 2 ticks on, 27 ticks off


 * When the input turns off, the redstone torch initially "charges" the fader loop at signal strength 14 at the dust next to the block (the signal strength declined by 1 getting there from the torch). There are two comparators in the loop so each cycle takes 2 ticks, and the signal strength declines by 1 each time through the loop, so the fader loop will stay charged for 28 ticks. One tick later, the redstone torch turns back on, re-powering the fader loop (it stays on for 2 ticks so it overlaps the fader loop's on time by one tick).


 * Variations: Add more comparators to increase the clock's period, or run one side of the fader loop above the other to reduce the clock's footprint.

Minecart Clocks


Minecart clocks are simple, easy to build and modify, but are somewhat unreliable. A minecart clock is made by creating a small track rails with one or more powered and detector rails, arranged so that a minecart can run forever either around the track (A), or back and forth from end to end (B, C). (These need not be sloped -- properly placed powered rails will let a minecart "bounce" off solid blocks -- but you get some extra time as the cart slows down.) A larger vertical track (design C), taken from this video is claimed to produce an exceptionally stable clock. Note that the minecart never quite hits the top of the track.

When running an empty minecart on the loop or back-and-forth, the cart generates redstone signals as it passes over the detector rail(s). Minecart Clocks can be extended or shortened easily by adding and removing track, to adjust the delay between signals. On the flip side, the they are easily disrupted by wandering players or mobs, and a long clock can take a fair bit of space. Also, the exact period is generally not apparent from the design. The need for gold in the booster rails can also be a problem for some players.

Cactus Clock
These clocks utilize growth of a cactus to generate pulses, generating a five-minute long pulse roughly every 25 minutes (i.e. it turns on every half hour or so). Though the pulses are irregular, making it unsuitable for clocks or computers, the long span makes this clock type highly suitable for sugar cane farms, melon farms, and pumpkin farms.

Cactus clocks are built by building a small automatic cactus farm (basically a cactus with a block poised next to it at the second or third level), with the drop going to a wooden pressure plate. The signal will stay on until the item despawns, which takes 5 mins.

To approximately halve the time-span, hook up two of these clocks to an OR gate. To multiply the time-span, hook the output of this clock to a suitable counter. Hooking two of these clocks to an AND gate gets a much longer, but rather unpredictable, clock.

Boat Clock
Boat clocks use a boat and a pressure plate, with something regularly lifting the boat off the plate. This forum post shows the boat used as the trigger for a water clock, being lifted by a flood of water which it then cuts off.

Another boat clock uses a piston to lift the boat, and a cobweb to slow its fall. This produced a clock which toggles on and off in about 9 seconds with minimal lag. A boat is placed in between a piston and pressure plate below and a cobweb above. Note that a boat is long enough to be "over" both plate and piston.... When the boat falls onto the pressure plate, it activates the adjacent piston, pushing the boat upwards back into the cobweb it fell from.

Long Period Clocks
Creating very long repeater loops can be very expensive. There are several sorts of clocks that are naturally quite long, or can easily be made so:
 * Devices can send item entities through the world: Items flowing on a stream, falling through cobwebs, or just waiting to despawn (that's a 5 minute timer provided by the game).  (Dispensers and hoppers can be quite useful here.)
 * Boats and minecarts can be used similarly, though they don't despawn.
 * Pseudoclocks can even be based on plant growth. For these, timing will not be exact, but they can still be useful for getting occasional signals over long periods.
 * "Factorial stacking" of clocks: Precise clocks (that is, repeater loops) with different periods may be connected to an AND gate in order to generate larger periods with much less expense. One way to make a 60-second (600 ticks) would be to use 150 repeaters set on 4-ticks of delay. Or you could connect two clocks with the periods of 24 and 25 ticks (that's 13 repeaters) to an AND gate.  Note that if the input clocks' ON state is longer than 1 tick, you'll need to filter them with an Edge Detector or Long Pulse Detector, to prevent overlapping on imperfect syncs.  The disadvantages here are that the circuitry can be fairly finicky, and the lengths of the sub-clocks need to be chosen to avoid common factors in their periods.
 * Using comparators with hoppers and such, allows triggering a pulse after a whole lot of items have been taken up or passed along. The advanced hopper clock above demonstrates this.
 * Then there's the obvious: the Daylight Sensor acts as a clock with a period of one in-game day. The duty cycle can be adjusted by using comparators at different threshold values. Keep in mind that weather may interfere with this.

There are also a couple of methods that apply to any clock whatsoever, including irregular pseudoclocks:
 * A T flip-flop can be used to double the period of any clock. This will also convert the pulse to have the same length ON and OFF, if it didn't before.  (Pseudoclocks won't be completely regularized, but they will be smoothed out.)
 * Most powerfully of all, latched repeaters allow production of a general clock multiplier, detailed below. This can be used to multiply the period of any clock, and they can be used in series.

Clock Multiplier
This nearly-flat circuit takes a clock input of period  and any pulse length, and outputs as a clock of period , where   is the number of latches used; the output is on for a pulse length of  , and off for the remaining. is limited to 12 or so by redstone signal attenuation; however, the design can simply be repeated to multiply the period again, e.g. a 21-multiplier can be made by chaining a 7-multiplier and a 3-multiplier. This can be continued indefinitely, and unlike factorial stacking there is no restriction on the multipliers.

The build is somewhat tricky: The multiplier loop is in fact a torchless repeater-loop clock. This needs to be started separately, before the latches are engaged. The easiest way to start it is probably to add a temporary "startup circuit" starting 4 blocks from the dust part of the loop: Place a power source, then dust and a block for it to power. Finally place a redstone torch on the block, positioned to power the redstone loop. The torch will flash on for one tick before "realizing" it's powered, and this will start the loop as a clock, which will cycle until the latches are powered. This startup rig can then be removed.

The latches are driven by an edge detector which takes a rising edge and produces an OFF pulse; the pulse length must match the delays of the latched repeaters, so that the multiplier's pulse advances one repeater per edge. The delay/pulse length must also be no longer than the input clock, so it's probably best to keep them both at 1. Note that the delays of the latched repeaters are not actually part of the output period; the latches only count off input edges. The circuit's output is ON while the last repeater is lit and lighting the dust loop.

This circuit need not be fed with a regular clock. With any varying input, it will count N rising edges and output HIGH between the (N-1)th and Nth rising edge.

Variations:
 * A T flip-flop can be used to "normalize" the pulse to half on/half-off, while doubling the output period. Designs L5 from that page is suitable and compact.
 * By separating the latched repeaters with redstone dust (to read their signals individually), this circuit could be generalized into a "state cycler", which can activate a series of other circuits or devices in order, as triggered by input pulses.

Efficiency: An efficient approach to making very long period clocks is to start with a repeater loop of 9 to 16 repeaters (up to 64 ticks), then add multiplier banks with N of 7, 5, and 3 (bigger is more efficient). Doublings should done with T flipflops, as 2 of those are cheaper and perhaps shorter than a 4-multiplier. A couple of notes for the picky:
 * Using two 7-multipliers (&times;49) is slightly more expensive, but shorter, than getting &times;50 with 5&times;5&times;2, or getting &times;48 with 3&times;4&times;4 or 6&times;8;.
 * An 8-multiplier is slightly more expensive, but shorter, than separate 2- and 4-multipliers. However, two of them are both longer and more expensive than three 4-multipliers.

Earliest Known Publication: 22 October 2012.