Redstone circuits/Piston

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

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

Unless otherwise stated, all pistons are sticky pistons.

The Principles
Redstone power can be transmitted through solid blocks, but not transparent blocks, such as glass or half slabs. Torches are considered logic components only if they change states as the gate is used. If they do change state, they are susceptible to burning out.

Power is transmitted in several ways that are useful to pistons. The first thing to note is that there are two types of solid block; transparent and solid. Transparent blocks are things such as glass or air, and solid blocks are things such as dirt and stone. 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. Power will not be transmitted by transparent blocks.

Piston-Only Gate
Piston-only gates will not use redstone torches for logic, but may use them to supply a constant signal.

The piston-only NOT gate is slightly larger than a standard redstone NOT gate. This is rarely used due to its size, but is an important concept for other piston-only gates, 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.
 * NOT Gate/Inverter

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.
 * OR Gate

Incredibly fast AND gate. The piston breaks the line if unpowered. Both inputs must be powered for the signal to pass through.
 *  AND 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".
 * IMPLIES Gate

Useful logic gate. If B followed by A then C until not B. As long as B is on and A is off, A causes C (output) to be on. Order matters, and if output is on, then A's state is irrelevant.
 * Piston Controlled Rectifier

Useful logic gate. If B followed by A then D while C until not B. As long as B is on and A is off, A causes D (output) to be on as long as C is on. Order matters, and if output is on, then A's state is irrelevant. C can be toggled to change D if A then B already met.
 * Piston Controlled Rectifier + AND

Piston-Torch Gate
The following gates use torches and Pistons to improve speed and/or size.

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.
 * XOR 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.
 * XNOR Gate

Latches
This RS NOR Latch (a simple memory cell) is easy to make and has one output. The inputs can be on the same side which can make things easier. This design is far smaller than some of the standard redstone RS NOR latches. The pistons used here are regular pistons, not sticky pistons.
 * RS NOR latch

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

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. This T-flip flop takes advantage of their quirk by using a monostable circuit.


 * 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, 5x2x2. 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


 * Design C, 4x3x2. This is a very tiny design of a Piston T-Flip Flop. This design requires a button or a lever as input and can be slow, however it may be implemented in very small spaces. The Dimensions are 3x2x2.


 * Design D, 4x3x3.This design is compact and works effectively.


 * Design E. This design 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 green block.


 * Design F, this design is a super fast design, almost instant. It combines a monostable circuit with a piston not gate. The monostable circuit output is a really fast pulse with "triggers" the piston's sticky state. Try it on your own to see the effect.

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.

Clocks
Here is a very simple piston clock. As the stone block covers a central torch, a repeater takes the signal and sends it to the corresponding regular piston. Any of the redstone wires can act as an output. The repeaters can be altered to change the period from fast (1 delay each) to slow (4 delay each). Additional repeaters can be added to extend the period even more.

Pulser
A small, stable pulser in a space of 2x3x2. The input can be a torch or a lever; the lever will give you on/off functionality.

Edge Trigger
An upward edge trigger creates a brief signal when the input turns on. Conversely, a downward edge trigger creates a brief signal when the input is turned off. Both can be created with this design simply by adjusting the delays on the repeaters.


 * For an upward edge, set both repeaters to 1 delay.
 * For a downward edge, set the left repeater to four and the right repeater to one. This will create a 2-tick signal.

Double-Edge Trigger
A double-edge trigger emits a pulse when the output turns either on OR off.

Design A: (Image Pending, excuse the text "image") _PB_r_ rB>rBr where r=redstone, B=block, >=repeater, P=piston pointing right.

Design B: This is a variant of the piston XOR gate. The right-hand repeater can be adjusted to output a longer or shorter pulse.



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