This article is about an older version of DF.
|
Template:Elven
Mechanical logic is one discipline of Template:L using mechanical Template:L to perform logical operations. In this case powered or unpowered Template:L represent the binary information.
The principles of mechanical logic are simple. Template:L linked to Template:L will be toggled between disengaged and engaged when they receive an on/off signal. In this manner, you can conditionally attach power supply from Template:L or Template:L to specially arranged gears to build logic gates. You can also connect additional gears or other machine components as load - consuming power - to a linked gear in various configurations.
An alternative to using the gates listed here that require an extra load of gears is to use Pre-Toggled Mechanical Logic. This logic discipline has the benefit of being far easier to power, since it does not rely on extra gears to force a gear to disable in certain circumstances.
Pros and cons
- needs a substantial amount of wood to construct power supply
- needs a substantial amount of Template:L and therefore Template:L especially when you base your gates on load
- needs Template:L to build converter to trigger something else than machine components
- is very fast because gears don't have a reaction delay of 100 steps
- is very flexible because gears can be toggled and therefore inverting input signals is very easy
- is easy to reconfigure because you don't have to deal with fluid or Template:L as you have to when you stick to other computing disciplines
Power to signal converter
When you are dealing with mechanical logic, you'll finally want or have to trigger something else than machine components like doors or bridges. Currently, there doesn't exist any Template:L in dwarf fortress that reacts on the working state of machine components, thus power on/off. So, you'll have to convert power via pressure plates, screw pumps and fluid into an on/off signal.
Z 0
█
|
█
|
█
|
█
|
█
|
█
|
█
|
·
|
÷
|
|
·
|
█
|
█
|
█
|
█
|
█
|
█
|
█
|
|
Z-1
█
|
█
|
█
|
█
|
█
|
█
|
█
|
|
|
|
|
█
|
█
|
█
|
█
|
█
|
█
|
█
|
|
When the pump is connected to power, it will suck water from the pressure plate and pump it to the right. The water level on the pressure plate will fall to 0. The plate can be constructed to react on 0…3 water. You can invert it to get an off signal instead setting it to 4…7. In both cases the off signal will have a delay of 100 steps.[Verify] This gate is fluid conserving.
Mechanical signal-input power-output gates
- These gates can be used either by adding a power -> link signal converter (also known as a "rotation sensor"), or directly used to control pumps, such as in other logic gates (the unsourced fluid logic gates use these, for instance). The conventional "rotation sensor" consists of a pump powered by the gate's OUTPUT gear, pumping an infinite supply of water onto a water-sensing pressure plate with an infinite drain.
- There are certain things important to all the gates:
- Each gate has an OUTPUT gear, which will be placed next to a pump which the gate will control.
- In diagrams, the OUTPUT gear is below the 'O' gear, connected to it by gears or vertical axles. The P indicates where you should hook power up, and L indicates where load (gears or pumps that don't have a water source) should be connected, and ¦ and - are horizontal axles. The Is are gears linked to INPUTs (some gates have one input, but most have two).
- Gates which incorporate a NOT will have the power network branch off from the 'O' gear, and have a train of power-draining stuff connected to the input gears, whereas gates which do not incorporate a NOT will have the power connected to the input gears instead. The principle behind normal gates is that when the INPUTs are ON, power is connected. The principle behind the NOT gates is that power is always connected, but when the INPUTs are ON, a large enough power requirement is connected to send the power requirements above the power supply, shutting down the system.
- If your windmills produce no power, you'll have to come up with some way to use water wheels for power instead.
- You should build only enough windmills (or water wheels) to power the system, and should not connect the network for one gate to another gate's network, since that would both gates up.
- The gates' instructions will explain how much load and power you need to have at each P and L in the more complicated gates.
Legend
Symbol
|
Meaning
|
|
A gear which connects to your OUTPUT gear, which outputs power when the gate is producing an ON output.
|
|
A gear connected to an INPUT. In most gates you will have two Is, with each one connected to a different input.
|
and
|
Horizontal axles
|
|
Power goes here
|
|
Two more gears, each connected to the two different inputs.
|
|
a chain of gears or pumps which serve to add load to the system, generally shutting it off when connected.
|
|
A gear which isn't linked to any inputs or outputs and just serves to connect the power or whatever.
|
Mechanical identity gate
- This takes an linked input signal and converts it to power without changing it.
- Connected to the input gear, such that they will only be connected to the system if the input gear is receiving an ON signal, are gears with windmills on top of them. Build only enough windmills to power the devices that the gate's OUTPUT gear are connected to (and the gears/axles).
- When the INPUT is ON, the INPUT gear will be active, and the network will provide power to the OUTPUT. When the INPUT is OFF, it will not provide power to the OUTPUT.
Mechanical NOT gate
- When the INPUT is ON, the INPUT gear will be active, and the network should need more power than is available. The devices connected to OUTPUT should shut down. When INPUT is OFF, the devices should have power since the INPUT gear will be disconnected.
Mechanical NAND gate
- This works just like the NOT gate, except that there are two inputs and both have to be active to shut down the system instead of one. Make sure you have enough power to run the system when one of the input gears is active.
Mechanical AND gate
- This works like the identity gate, except that there are two inputs and both have to be active for the system to get power.
Mechanical OR gate
- This works like the identity gate, except that there are two inputs, and if either is active, the system receives power. Note that the entire power network is connected to both inputs, such that if either input is active the entire power network is powering the system.
Mechanical NOR gate
- This works like the NOT gate, except that there are two inputs, and if either is active, the gear train or pump stack signified by the 'L' will be connected to the system. You need to have enough load to push power requirements above the amount of power produced by the power supply, shutting the system down.
Mechanical XOR gate
O
|
I
|
I
|
*
|
-
|
-
|
*
|
P
|
.
|
i
|
.
|
.
|
i
|
.
|
L
|
.
|
.
|
L
|
- Except for the 'i's and 'L's, this gate is identical to the OR gate. The additional components add the 'exclusive' part of the 'XOR' to the gate.
- This gate may be a bit difficult to construct. First, the 'i's are additional gears connected to each of your inputs, and the Ls are additional load, however, neither load by itself should be enough to shut down the system. However, you need to make the two sets of load large enough that if both inputs are active at the same time, their power requirements become large enough to shut down the system, without making them large enough to shut it down when only one of them is active. It'll just require a little math on your part.
Mechanical XNOR gate
.
|
.
|
I
|
*
|
L
|
.
|
.
|
O
|
I
|
.
|
.
|
¦
|
P
|
-
|
*
|
i
|
-
|
P
|
.
|
.
|
i
|
.
|
.
|
¦
|
.
|
.
|
P
|
A
|
B
|
Drain
|
Power
|
Extra Power
|
Result
|
0
|
0
|
No
|
Yes
|
No
|
1
|
0
|
1
|
Yes
|
Yes
|
Half
|
0
|
1
|
0
|
Yes
|
Yes
|
Half
|
0
|
1
|
1
|
Yes
|
Yes
|
Full
|
1
|
- The XNOR gate is an equality gate: The output is ON when both inputs are equal, and OFF when they are not equal.
- This gate may be even more complicated to build than the XOR gate!
- First, your 'i's are again gears connected to your two inputs. The two extra Ps to the right and below them are additional power sources, ideally only one windmill each.
- Here's where it gets complicated. The load has to be sufficient to shut down the system even when ONE of the inputs' additional power supplies are connected. However, when BOTH inputs are on, there needs to be enough power from both additional Ps to bring the system back online.
- Thus our gate does what it is supposed to: Produce enough power to have the OUTPUT gear be ON when both A and B are either 0 or 1, but not when they are not equal.