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. There are a number of approaches here:
 * Factorial stacking of clocks: Precise clocks with different periods may be connected to an AND gate in order to generate larger periods with the least resources possible. One way to make a 60-second (600 ticks) would be to use 150 repeaters. 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.
 * Devices can make use of item entities: items flowing on a stream, falling through cobwebs, or just waiting to despawn. Dispensers and hoppers can be quite useful here, but there's still an issue with supplying the dispensers.  Boats can be used similarly.
 * minecarts can be shuttled around a track, with surprisingly good precision. (Stray mobs and players notwithstanding....)
 * 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.

Even 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. (Forcing the loop high will generally stop the clock; whether the output will be stopped high or low depends on the clock.) 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.

Hopper Toggle-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" 4 only 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.

Minecart Clocks
Minecart clocks are simple, easy to build and modify, but are somewhat unreliable. A minecart clock are 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.

Comparator clocks

 * Subtraction Pulser


 * 2&times;3&times;2, flat, silent
 * clock output: 1 tick on, 1 tick off
 * A subtraction pulser is a 1-clock (it 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).

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.

红石电路/时钟