Redstone circuits/Piston

Pistons have allowed players to design circuits that are smaller and/or faster than the standard, redstone-only counterparts. An understanding of standard Redstone Circuits is helpful, as this tutorial is focused on the circuit design rather than the function.

There are three benefits of Piston circuitry:
 * Neither repeaters nor pistons 'burn out', unlike redstone torches.
 * Piston circuits tend to be smaller than their redstone counterpart
 * The resources used are much easier to find and mine.

The main components of piston circuits are Sticky Pistons, Redstone Wire, Redstone Repeaters, and Redstone Torches.

Unless otherwise stated, all pistons are sticky pistons.

The Principles
Power is transmitted in several ways that are useful to pistons. The first thing to note is that there are two types of blocks; transparent and solid. Transparent blocks are things such as glass, half slabs, or air, while solid blocks are more common materials such as dirt, stone, or wool.

The key is that redstone power can be transmitted through solid blocks, but not transparent blocks. However, power can pass through only one solid block at a go, it cannot be passed from one solid block to another. A solid block can power wire leading from it only if it was "strongly powered" (by a torch, repeater, or comparator, but not by redstone wire). Redstone dust can be placed on some transparent blocks, but this will transmit power only upwards, not downwards (that is, not through the transparent block).

Redstone torches are considered logic components only if they change states as the gate is used. (Otherwise they're just power supplies.) If they change state too often, they are susceptible to burning out. If a solid block is on top of a redstone torch, any wire connected to the block will be powered. If, however, the block is transparent, the torch will not power the wires.

When a repeater is directed at a solid block, it will pass power into that block in the same way redstone torches do. A repeater can also take power from a solid block which is powered, even weakly powered (that is, it turns a weakly powered signal into a strong one). Power will not be transmitted by transparent blocks.

Pistons will extend if powered, but it's notable that they can take power from the block above them -- that is, even if the block is air, if that block would have been powered, the piston will be too. They can also be powered through their extended piston, which produces several useful quirks that are commonly used in circuits. A piston can push up to 12 blocks when it extends; however, a sticky piston can only pull back one block when it retracts. Some blocks are immune to being pushed or pulled, notably obsidian and any block with a GUI or inventory. Other blocks will "pop" and drop as items if a piston tries to push them -- this includes most "attached" blocks such as either sort of torch, or doors, but also a few others such as jack-o-lanterns.

Piston Gate Designs
Pistons can produce alternate designs for many of the classic logic gates. Piston gates may also use redstone torches to supply a constant signal, or for other purposes.

NOT Gate/Inverter
The piston-only NOT gate is slightly larger than a standard redstone NOT gate, so it is rarely used alone. However, it demonstrates an important concept used in many piston mechanisms, namely that torches below solid blocks create a current in any surrounding wire. When an input is triggered, the piston extends, uncovering the torch hole removing the signal from the output line. The input can power the piston from almost any direction.

OR Gate
This design is slightly faster than the standard redstone OR gate, with a comparable size. It uses one piston which covers a torch when extended by any of the inputs.

AND Gate
Incredibly fast AND gate. When unpowered, the sticky piston pulls the block over the hole, breaking the circuit. When powered, it extends and lets the current flow in and out of the hole. One input feeds the piston, the other feeds the circuit it interrupts; both must be ON to release a signal.

IMPLIES Gate
Comparable size and speed to some of the basic redstone IMPLIES gate. This gate represents material implication. Returns false only if the implication A → B is false. That is, if the conditional A is true, but the consequent B is false. It is often read "if A then B." It is the logical equivalent of "B or NOT A". The torch under the mobile block is in a hole.

XOR Gate
A device which activates when only one of the inputs is on. Pronounced "ex-or", and is a shortening of "exclusive or". Adding a NOT gate to the end will produce an XNOR gate, which activates when the inputs are equal to each other. A useful attribute is that a XOR or XNOR gate will always change its output when one of its inputs changes, allowing for 2 switches to be combined to open or close a door, or activate another device.This design is significantly smaller than the redstone-only equivalent and slightly faster.

XNOR Gate
A device which activates when both inputs are equal, thus useful for doors, such that if either is changed the output always changes. This design, like the XOR gate, is smaller and faster than the redstone-only equivalent.

Latches
Latches are memory circuits. Naturally, pistons' ability to physically move blocks to new locations make them a natural tool for these.

RS Latches
The basic piston RS Latch is small and easy to make, but only has one output. The inputs can be on the same side. The pistons used here are regular pistons, not sticky pistons. Using a Block of Redstone lets the circuit become even smaller, and adds the inverse output.

T-Flip Flops
These T-flip flops use one input to switch between two states.

Sticky pistons behave strangely when they receive a 1-tick signal. If a block is directly next to the piston, the piston will push the block but will not pull it back when the signal ends. If the piston receives another 1-tick signal, the piston will extend and retract the block. This can be used to toggle the position of blocks.

Design A, 4x2x4. Uses regular pistons. Both of the pistons are regular pistons. This flip flop is quite fast and quite small. When the input goes from a 1 to a 0 it will toggle. Note that you can invert the input to increase the speed of the circuit.

Design B (5x3x2) is actually an RST latch, combining the functionality of both the Set/Reset (RS) and toggle (T) latches. Uses regular pistons. This flip flop doesn't use torches for logic so it can work with signals of any length, although if the signal is mainly on, it will need it to be off for ~4 ticks for it to work. The dust on level 1 is there to redirect the redstone wire -- you could also use wire, if you avoid powering stray components. However, this circuit does not have an inverse output.

Design E is a combination pulse limiter and downward edge detector. When the signal turns off, the first sticky piston retracts the second, which receives a 1-tick signal. The 1-tick signal toggles the mobile block. It is very sensitive to timing.

Designs C, D, and G (G was from this video) appear to be broken, and have been removed.

Ring Memory
This is a ring of blocks attached to regular pistons at the corners so it can rotate. The blocks are usually a combination of solid and non-solid blocks. The pistons are often connected to a clock so that they will rotate the ring. Most (if not all) rings have a reading head which consists of a repeater pointing at the ring and a redstone torch powering the repeater. By using redstone on the other side of a ring, one can see which type of block is in front of the reading head (1 = Solid; 0 = Non-solid). This information now can be passed to a circuit.

Bands
When you add several rings together in a row, you create a band. A band stores even more information and works similar to punched tape. Examples include music machines, combination locks, and memory.

Rapidfire Piston Clock
This rapidfire clock is fairly simple to build. It is demonstrated in this video from May 18, 2012. You will need 2 non-sticky pistons, 2 repeaters, and 6 redstone. You will also use 5 solid blocks, but will probably be digging two out of the ground. The repeaters must be set to at least 2 ticks, and they must match. Place the mobile block last to start the clock, and take output from either end or any wire. Note that this clock is not switchable, and if it does stop for any reason, it's difficult to restart by a redstone signal. The player can restart it by breaking and replacing the mobile block, or by changing the repeater delays (both of them, the clock will restart when they match and are set to at least 2 ticks).

Pulser
A small, stable pulser in a space of 2x3x2. The period can be adjusted with the repeater, and the clock can be turned off or on with the lever. (Turning the lever ON stops the clock, and vice versa.) The lever can be placed on any of the solid blocks.

Edge Detector
A rising edge detector creates a brief signal when the input turns on. Conversely, a falling edge detector creates a brief signal when the input is turned off, and a dual-edge (aka "zero-crossing") detector responds to both.

Design A can be a rising- or falling-edge detector depending on the delays of the repeaters.
 * For a rising edge, set both repeaters to 1 delay.
 * For a falling edge, set the left repeater to four and the right repeater to one. This will create a 2-tick signal.

Design B is a variant of the piston XOR gate, and a dual-edge detector. The right-hand repeater can be adjusted to output a longer or shorter pulse.

Designs D, E, and F are straight-line versions, 1x2x2. Design D is a rising edge detector; design F, a falling edge detector; both with an output pulse of 2 ticks. Design E is a zero crossing detector, activating on both rising and falling edges. However, it only produces a single-tick pulse output. This can be moderated by adding a 2-tick repeater to the output, producing a 2-tick pulse, same as the other two.

Double Extender
The following design will push and pull a block two spaces instead of one:



The repeaters must all be at delay 3 of 4. The pistons are sticky and the device will correctly push and retract the block. The main trick is properly sequencing the retraction since the back piston will not pull back the forward piston when it is extended. Additionally, the back piston will only retract the forward piston, not the block. To handle these issues the forward piston must be retracted, pulled back, then extended and retracted again.

Further extenders (3-block, 4-block, etc.) should be possible, but will likely require much more advanced circuitry. Putting together multiple types of these extenders would allow fully retractable staircases.

This can be changed so that pistons can be pushed, without extending them and stopping the system:

This can be powered from below to hide all the wiring, by using torches. Input over the blue wool, so the signal reaches all the way round without the need for extra repeaters. This design does take up a lot more space, so is only really used for pushing pistons.

The design to the right can push and retract a block two spaces instead of one, vertically:



The two repeaters closest to the pistons must be at delay 2 of 4. Vertical double extenders are more difficult to make than horizontal extenders; the bottom piston will not retract unless the wire that extends the forward piston after it has been pulled back is not powered.

Longer vertical extenders require very complex circuitry, and are often used as elevators. To slightly simplify the required circuits, a gravity-affected block like gravel or sand can be used as the elevator platform. This avoids the need for the top piston to be sticky and for it to execute multiple extensions to pull down the top block at each stage of descent. If more than two pistons are used in total, multiple extensions of lower sticky pistons will still be required to pull down the pistons higher in the stack, which are not gravity-affected.

Further Resources
Grizdale's Piston Logic Compendium