v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Difference between revisions of "v0.31:Mechanical logic"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
 
(6 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{quality|Exceptional|16:06, 11 August 2010 (UTC)}}<!--  
+
{{quality|Exceptional|16:06, 11 August 2010 (UTC)}}
 +
<!--  
 
***************************
 
***************************
 
* WORKING IN PROGRESS !!! *
 
* WORKING IN PROGRESS !!! *
Line 6: Line 7:
 
{{av}}
 
{{av}}
  
Mechanical logic is one discipline of {{l|computing}} using mechanical {{l|power}} to perform logical operations. In this case powered or unpowered {{l|machine component|machine components}} represent the binary information.
+
Mechanical logic is one discipline of [[computing]] using mechanical [[power]] to perform logical operations. In this case powered or unpowered [[machine component|machine components]] represent the binary information.
  
The principles of mechanical logic are simple. {{l|Gear assembly|Gear assemblies}} linked to {{l|trigger}}s will be toggled between disengaged and engaged when they receive an on/off signal. In this manner, you can conditionally attach power supply from {{l|windmill}}s or {{l|water wheel}}s 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.
+
The principles of mechanical logic are simple. [[Gear assembly|Gear assemblies]] linked to [[trigger]]s will be toggled between disengaged and engaged when they receive an on/off signal. In this manner, you can conditionally attach power supply from [[windmill]]s or [[water wheel]]s to specially arranged gears to build logic gates.
  
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. At present, it does not work with pressure plates, however, but probably only needs a bit of redesigning.
+
== Mechanical logic versus fluid logic ==
 +
* Mechanical logic is very fast. Gears don't have a reaction delay of 100 steps like most other components used by [[fluid logic]]. So if a gear is toggled the flow of power will change immediately.
 +
* Mechanical logic is very flexible. Gears can toggle, so inverting signals is easy and you don't have to deal with different machine components.
 +
* Mechanical logic is very reconfigurable. You don't have to deal with [[creature|creatures]] or fluid before changing anything.
  
== Pros and cons ==
 
  
* needs a substantial amount of wood to construct power supply
+
* Mechanical logic needs a substantial amount of wood to create and transmit power. (So what?)
* needs a substantial amount of {{l|mechanism}}s and therefore {{l|mechanic}}s especially when you base your gates on load
+
* Mechanical logic still needs [[water|fluid]] to build converter to trigger something else than machine components. (If you really want to be fluid free you'll have to stick to [[animal logic]].)
* needs {{l|water|fluid}} to build converter to trigger something else than machine components
+
* <s>Mechanical logic needs a substantial amount of mechanism.</s> (Only if you stick to [[mechanical logic#Load based|load based mechanical logic]].)
  
* 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 {{l|creature}}s as you have to when you stick to other computing disciplines
 
 
<!-- ToDo -->
 
<!--
 
 
== General concepts ==
 
== General concepts ==
 +
There are two general conceps. The older and inadvisable one is the so called load based mechanical logic. The other one is the so called toggle based mechanical logic.
 
=== Load based ===
 
=== Load based ===
 +
Load based mechanical logic uses single logic gates with a defined amount of power. They have an additional amount of load in terms of mechanism or other machine components, consuming all of the power if connected. The gates are designed in a way that the load is disconnected while the output shall be true, and connected when the output shall be false. Every logic gate has to have its own power supply. Compact complex logic gates are very hard to design, utterly impossible.
 +
 
=== Toggle based ===
 
=== Toggle based ===
-->
+
Toggle based mechanical logic works more like [[fluid logic]], not controlling the flow of fluid but the flow of power. It uses the fact that gears don't have a defined state when recieving an on or an off signal, but toggle between connected and dismanteled, independent of the type of signal. It normaly uses a central power supply. It is quite easy to create very complex gates with multiple output signals like for example a binary to decimal converter.
 +
 
 +
=== Example ===
 +
The first example shows a load based XOR gate. It takes input signals from two different triggers. It's output gear (<span style="color:#FFFF44">O</span>) is powered when exactly one of the two input triggers is on and the other one is off. This is done as follows:<br />The power will be connected to the gear with the <span style="color:#44FF44">P</span> (from the bottom of the diagram or another z-level). One input is linked to gear <span style="color:#FF44FF">1</span> the other to gear <span style="color:#FF44FF">2</span>. This way power will flow from <span style="color:#44FF44">P</span> to <span style="color:#FFFF44">O</span> if either one of the input signals is off. Aditionally both inputs are linked to gear <span style="color:#FF44FF">3</span>, that is connected to the load <span style="color:#FF4444">L</span>. Since gears toggle the gear will be active if both singals where off (or on), and the load will stop any flow of power then. You can build this on top of a [[Mechanical logic#Power to signal converter|power to signal converter]] as shown on this page.<br />As you can see you will need many mechanism to build this gate. 5 for the gears, 8 to connect to the input in addition to all the components needed for the converter and the load.
 +
<div style="width:1px; white-space:nowrap;">
 +
'''load based XOR'''
 +
{| cellpadding="0" cellspacing="0" style="border-spacing:0; border-style:solid; border-width:thin; border-color:#000000;"
 +
|
 +
{| cellpadding="0" cellspacing="0" style="border-spacing:0; padding:0; margin:0; vertical-align:middle;"
 +
|-
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|-
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#444|*|#DDD||||1|#F4F|right}}
 +
|{{RTL|#222|*|#BBB||||O|#FF4|right}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|-
 +
|{{RTL|#FFF|&nbsp;|#FFF|L|#F44|right}}
 +
|{{RTL|#444|*|#DDD||||3|#F4F|right}}
 +
|{{RTL|#444|*|#DDD||||P|#4F4|right}}
 +
|{{RTL|#444|*|#DDD||||2|#D4D|right}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|}
 +
|}
 +
</div>
 +
<br />A toggle based XOR gate looks much simpler:
 +
<div style="width:1px; white-space:nowrap;">
 +
'''toggle based XOR'''
 +
{| cellpadding="0" cellspacing="0" style="border-spacing:0; border-style:solid; border-width:thin; border-color:#000000;"
 +
|
 +
{| cellpadding="0" cellspacing="0" style="border-spacing:0; padding:0; margin:0; vertical-align:middle;"
 +
|-
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|-
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#222|*|#BBB}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|-
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|{{RTL|#FFF}}
 +
|}
 +
|}
 +
</div>
 +
Yes, that's right. You'll need only one gear. This is how it works:<br />Connect it to your source of power, and link it to one of your input triggers. Build a temporary lever anywhere and connect it, too. Pull the lever once. You can deconstruct the temporary lever now. Now the gear is dismanteled, and you link the second input trigger to it. Since gears toggle, everytime your trigger changes state and sends a signal the gear will change state. Initially both triggers are off, and the gear is dismanteled. When one trigger changes state, it will activate gear. Independent of whitch trigger changes next, both will have the same state afterwards, and the gear will be dismanteled again. So the gear will transport power when both input troggers are at different state: XOR. You can build this on top of a [[Mechanical logic#Power to signal converter|power to signal converter]] as shown on this page.<br />As you can see you will need little mechanism to build this gate. 1 for the gear, 4 to connect to the input and 1 will be lost after disconnecting the temporarry lever (that needs 3 temporarry). And of course you will need all the components for the converter, but no load.
  
 
== Power to signal converter ==
 
== 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 {{l|trigger|trigger}} 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.
+
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 [[trigger]] 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.
 
<div style="width:1px; white-space:nowrap;">
 
<div style="width:1px; white-space:nowrap;">
 
'''Z 0'''
 
'''Z 0'''
Line 45: Line 108:
 
|-
 
|-
 
|{{RTL|#DDD}}
 
|{{RTL|#DDD}}
|{{RTL|#222|*|#BBB}}
+
|{{RTL|#222|·|#BBB}}
 
|{{RTL|#444|÷|#DDD}}
 
|{{RTL|#444|÷|#DDD}}
 
|{{RTL|#444|÷|#DDD|►|#00A|center|►|#00A|center}}
 
|{{RTL|#444|÷|#DDD|►|#00A|center|►|#00A|center}}
|{{RTL|#222|*|#BBB}}
+
|{{RTL|#222|·|#BBB}}
 
|{{RTL|#222}}
 
|{{RTL|#222}}
 
|-
 
|-
Line 93: Line 156:
 
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&hellip;3 water. You can invert it to get an off signal instead setting it to 4&hellip;7. In both cases the ''off signal'' will have a delay of 100 steps.{{Verify}} This gate is fluid conserving.
 
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&hellip;3 water. You can invert it to get an off signal instead setting it to 4&hellip;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==
+
==Load based 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.
 
* 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:
 
* There are certain things important to all the gates:
Line 197: Line 260:
 
[#000].[#000].[#ff0]O[#aaf]I
 
[#000].[#000].[#ff0]O[#aaf]I
 
[#000].[#000].¦
 
[#000].[#000].¦
[#0f0]P[#aaf]-*[#aaf]i-[#0f0]P
+
[#0f0]P[#aaf]-*
 +
[#000].[#000].[#aaf]i
 
[#000].[#000].[#aaf]i
 
[#000].[#000].[#aaf]i
[#000].[#000].¦
 
 
[#000].[#000].[#0f0]P}}
 
[#000].[#000].[#0f0]P}}
  
Line 222: Line 285:
 
| Yes
 
| Yes
 
| Yes
 
| Yes
| Half
+
| No
 
| 0
 
| 0
 
|-
 
|-
Line 229: Line 292:
 
| Yes
 
| Yes
 
| Yes
 
| Yes
| Half
+
| No
 
| 0
 
| 0
 
|-
 
|-
Line 236: Line 299:
 
| Yes
 
| Yes
 
| Yes
 
| Yes
| Full
+
| Yes
 
| 1
 
| 1
 
|}  
 
|}  
Line 242: Line 305:
 
* The XNOR gate is an equality gate: The output is ON when both inputs are equal, and OFF when they are not equal.
 
* 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!
 
* 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.
+
* First, your 'i's are again gears connected to your two inputs. The extra P below them is additional power source, ideally only one windmill.
* 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.
+
* Here's where it gets complicated. The load has to be sufficient to shut down the system when additional power supply is disconnected. However, when BOTH inputs are on, there needs to be enough power from additional P 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.
 
* 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.
  
 
{{Category|Computing}}
 
{{Category|Computing}}

Latest revision as of 05:47, 21 February 2012

This article is about an older version of DF.

Mechanical logic is one discipline of computing using mechanical power to perform logical operations. In this case powered or unpowered machine components represent the binary information.

The principles of mechanical logic are simple. Gear assemblies linked to triggers will be toggled between disengaged and engaged when they receive an on/off signal. In this manner, you can conditionally attach power supply from windmills or water wheels to specially arranged gears to build logic gates.

Mechanical logic versus fluid logic[edit]

  • Mechanical logic is very fast. Gears don't have a reaction delay of 100 steps like most other components used by fluid logic. So if a gear is toggled the flow of power will change immediately.
  • Mechanical logic is very flexible. Gears can toggle, so inverting signals is easy and you don't have to deal with different machine components.
  • Mechanical logic is very reconfigurable. You don't have to deal with creatures or fluid before changing anything.


  • Mechanical logic needs a substantial amount of wood to create and transmit power. (So what?)
  • Mechanical logic still needs fluid to build converter to trigger something else than machine components. (If you really want to be fluid free you'll have to stick to animal logic.)
  • Mechanical logic needs a substantial amount of mechanism. (Only if you stick to load based mechanical logic.)

General concepts[edit]

There are two general conceps. The older and inadvisable one is the so called load based mechanical logic. The other one is the so called toggle based mechanical logic.

Load based[edit]

Load based mechanical logic uses single logic gates with a defined amount of power. They have an additional amount of load in terms of mechanism or other machine components, consuming all of the power if connected. The gates are designed in a way that the load is disconnected while the output shall be true, and connected when the output shall be false. Every logic gate has to have its own power supply. Compact complex logic gates are very hard to design, utterly impossible.

Toggle based[edit]

Toggle based mechanical logic works more like fluid logic, not controlling the flow of fluid but the flow of power. It uses the fact that gears don't have a defined state when recieving an on or an off signal, but toggle between connected and dismanteled, independent of the type of signal. It normaly uses a central power supply. It is quite easy to create very complex gates with multiple output signals like for example a binary to decimal converter.

Example[edit]

The first example shows a load based XOR gate. It takes input signals from two different triggers. It's output gear (O) is powered when exactly one of the two input triggers is on and the other one is off. This is done as follows:
The power will be connected to the gear with the P (from the bottom of the diagram or another z-level). One input is linked to gear 1 the other to gear 2. This way power will flow from P to O if either one of the input signals is off. Aditionally both inputs are linked to gear 3, that is connected to the load L. Since gears toggle the gear will be active if both singals where off (or on), and the load will stop any flow of power then. You can build this on top of a power to signal converter as shown on this page.
As you can see you will need many mechanism to build this gate. 5 for the gears, 8 to connect to the input in addition to all the components needed for the converter and the load.

load based XOR

*
1
*
O
 
L
*
3
*
P
*
2


A toggle based XOR gate looks much simpler:

toggle based XOR

*

Yes, that's right. You'll need only one gear. This is how it works:
Connect it to your source of power, and link it to one of your input triggers. Build a temporary lever anywhere and connect it, too. Pull the lever once. You can deconstruct the temporary lever now. Now the gear is dismanteled, and you link the second input trigger to it. Since gears toggle, everytime your trigger changes state and sends a signal the gear will change state. Initially both triggers are off, and the gear is dismanteled. When one trigger changes state, it will activate gear. Independent of whitch trigger changes next, both will have the same state afterwards, and the gear will be dismanteled again. So the gear will transport power when both input troggers are at different state: XOR. You can build this on top of a power to signal converter as shown on this page.
As you can see you will need little mechanism to build this gate. 1 for the gear, 4 to connect to the input and 1 will be lost after disconnecting the temporarry lever (that needs 3 temporarry). And of course you will need all the components for the converter, but no load.

Power to signal converter[edit]

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 trigger 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

^
7
7
7
7


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.

Load based Mechanical signal-input power-output gates[edit]

  • 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[edit]

Symbol Meaning
O
A gear which connects to your OUTPUT gear, which outputs power when the gate is producing an ON output.
I
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
P
Power goes here
i
Two more gears, each connected to the two different inputs.
L
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[edit]

O I - - P
  • 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[edit]

O I L
¦
¦
P
  • 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[edit]

O I I L
¦
¦
P
  • 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[edit]

O I I P
  • 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[edit]

O I
I * P
  • 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[edit]

I * L
O I
¦
¦
P
  • 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[edit]

O I
I * - P
. i
. i
. L


  • Except for the 'i's and 'L', this gate is identical to the OR gate. The additional components add the 'exclusive' part of the 'XOR' to the gate.
  • The 'i's are additional gears connected to each of your inputs, and the L is additional load (large enough to stop the system, of course).

Mechanical XNOR gate[edit]

. . I * L
. . O I
. . ¦
P - *
. . i
. . i
. . P
A B Drain Power Extra Power Result
0 0 No Yes No 1
0 1 Yes Yes No 0
1 0 Yes Yes No 0
1 1 Yes Yes Yes 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 extra P below them is additional power source, ideally only one windmill.
  • Here's where it gets complicated. The load has to be sufficient to shut down the system when additional power supply is disconnected. However, when BOTH inputs are on, there needs to be enough power from additional P 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.