Redstone circuits/Piston

Why Pistons?
Simply, pistons do not fizzle out like redstone torches. It is therefore possible to create circuits with only pistons, redstone wire, and repeaters, as these can run at a third of the speed as traditional circuits.

The Principle
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.

There is another related detail:

These two above will work. However,

will not work

= Simple logic gates =

If you don't understand these, look at Redstone circuits.

NOT Gate
FYI the piston is sticky. 2x2x1

Red = Input Green = Mechanism Blue = Output.

OR Gate
The piston is sticky. If any of the inputs are on, the output will be on. 3x2x1

Red = Input Green = Mechanism Blue = Output.

AND Gate
Note that the piston is sticky. When both inputs are on, the output is on, too. 2x2x1

Red = Input Green = Mechanism Blue = Output.

IMPLIES Gate
A device which 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". 4x2x2

Red = Input Green = Mechanism Blue = Output

XOR Gate
A device which activates when only one input is on. Pronounced "exor", 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.

The Piston XOR gate is much more efficient compared to an XOR gate without pistons.

3x2x1

Red = Input Green = Mechanism Blue = Output

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,

The Piston XNOR is much more efficient compared to an XNOR gate without pistons

3x2x1

Red = Input Green = Mechanism Blue = Output

= More Complex Machines = These are very useful and very compact. In some cases, far smaller than standard redstone circuits.

Clocks
Here is a very simple gate. Each line leading out of a repeater is an output. It can also be switched on and off.

Red = Input. Green = Mechanism. Blue = Output.

RS NOR latch
This RS NOR Latch (aka. memory cell)is easy to make and has two outputs just like a normal RS NOR Latch, but on the same side. The outputs can also be on the same side which can make things easier. 4x2x2

Red = Input. Green = Mechanism. Blue = Output.

Pulser
A small, stable pulser in a space of 2x3x2. Worked on a (small) multiplayer server. Input can be a torch and a lever, lever will give you on/off functionality.

Pulse limiter
Here is simple piston based pulse limiter size of 3x2x2. Works great and can easily be used. 2x2x1

Red = Input. Green = Mechanism. Blue = Output.

T-Flip Flops
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.

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



This is a very tiny design of a Piston T-Flip Flop that works good. This design can be implemented into small spaces, but can be slow. The Dimensions are 3x2x2.

Red = Input. Green = Mechanism. Blue = Output.

[[Image:Small Piston T-Flop Flop.png|thumb|none|A small Piston T-Flip Flop. The Dimentions are 4x3x3.

Red = Input. Green = Mechanism. Blue = Output. ]]

This design is compact and works effectively.

Red = Input. Green = Mechanism. Blue = Output.

Rings
This is a ring of blocks attached to 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.

By using a ring, you can create things like item sorting machines and other complex mechanisms.

Bands
When you add several rings together in a row, you create a band. A band is useful for even more complex things, as it can be used in a similar manner to punched tape. Examples include music machines, combination locks, and memory.

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, extended, retracted (pulling back the block), then pulled back.

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.

= Math =

This section denotes "IF THEN ELSE" statements as follows:

(some_value) ? (if the value is true, return this) : (otherwise, return this)

TRUE and FALSE constants are written as true and false, respectively.

Much like how redstone circuits can be denoted using boolean algebra, Piston Circuits can be denoted using conditional expressions. Consider the following equation.

o = a ? false : true

Where o is the output, and a is the input. If a is true, THEN false is returned, ELSE, true is returned.

In piston circuits, the THEN part is inputted when a sticky piston is pushed forward (its on state), and the ELSE part is inputted if the block is pulled back to the piston (its off state).

In this sense, every piston in a piston circuit represents an if statement. If there's more than one piston, the if statement is nested. For instance:

o = a ? (b ? false : true) : b

That's an equation for an XOR gate, and in the outer if statement, there's another if statement inside the THEN part. In pistons, this is equivalent to outputting one piston's value to the input of another piston's THEN or ELSE inputs.

NOT Gate
Outputs the inverted input

o = a ? false : true

OR Gate
Outputs true if either of the inputs are true

o = a ? true : b

AND Gate
Outputs true if both inputs are true

o = a ? b : false

XOR Gate
Outputs true if inputs are not equal to each other

o = a ? (b ? false : true) : b

XNOR Gate
Outputs true if inputs are equal to each other

o = a ? b : (b ? false : true)