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.

Editing v0.34:Mechanical logic

Jump to navigation Jump to search

Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.

You are editing a page for an older version of Dwarf Fortress ("Main" is the current version, not "v0.34"). Please make sure you intend to do this. If you are here by mistake, see the current page instead.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
{{Quality|Superior|20:47, 30 April 2013 (UTC)}}
+
{{quality|Fine|21:42, 4 April 2012 (UTC)}}<!--  
{{Computing}}
 
<!--  
 
 
***************************
 
***************************
 
* WORKING IN PROGRESS !!! *
 
* WORKING IN PROGRESS !!! *
Line 10: Line 8:
 
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.
 
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. [[Gear assembly|Gear assemblies]] linked to [[lever]]s or [[pressure plate]]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.
+
The principles of mechanical logic are simple. [[Gear assembly|Gear assemblies]] linked to [[lever]]s or [[pressure plate]]swill 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.
  
== Mechanical logic compared with other logic disciplines ==
+
== Mechanical logic versus fluid logic ==
* Mechanical logic is very fast. Gears don't have a reaction delay like many components used by [[fluid logic]]. If a gear is toggled the flow of power will change immediately, there will be no added delay introduced by the movement of creatures, fluids or minecarts.
+
* 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 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.
 
* Mechanical logic is very reconfigurable. You don't have to deal with [[creature|creatures]] or fluid before changing anything.
  
  
* Mechanical logic needs a substantial amount of wood to create and transmit power.
+
* Mechanical logic needs a substantial amount of wood to create and transmit power. (So what?)
* Mechanical logic still needs converters to trigger something else than machine components, either by applying [[minecart logic]] or by using [[water|fluid]].
+
* 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 [[creature logic]].)
* Mechanical logic needs a substantial amount of mechanisms, particularly if you stick to [[mechanical logic#Load based|load based mechanical logic]].
+
* <s>Mechanical logic needs a substantial amount of mechanism.</s> (Only if you stick to [[mechanical logic#Load based|load based mechanical logic]].)
  
 
== General concepts ==
 
== General concepts ==
There are two general concepts. The older and less popular one is the so-called load-based mechanical logic. The other one is the so-called toggle-based mechanical logic. Note that the two can be integrated, however.
+
There are two general concepts. 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 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 is true, and connected while the output is false. Every circuit has to have its own power supply. Compact complex circuits are very difficult to design, because power and load need to be controlled for each circuit, and each gate in a circuit needs to be connected to others it interacts with.  However, the advantage is that load-based mechanical logic computes instantly.
+
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 receiving an on or an off signal, but toggle between connected and disengaged, independent of the type of signal. It normally uses a central power supply. It is quite easy to create very complex gates with multiple output signals such as, for example, a binary to decimal converter.  The cost of this ease of use and design, however, is that toggle based circuits need to be converted not just for output, but sometimes also for further processing.
+
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 receiving an on or an off signal, but toggle between connected and disengaged, independent of the type of signal. It normally uses a central power supply. It is quite easy to create very complex gates with multiple output signals such as, for example, a binary to decimal converter.
  
 
=== Example ===
 
=== Example ===
The first example shows a load based XOR gate. It takes input signals from two different triggers. Its 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. The power input is linked directly to the load <span style="color:#FF4444">L</span> which must be calibrated precisely so that the power provided can move the output and load and ''one'' of the input-toggled gears, but not ''both''. 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, this gate is complicated to construct. You will need four gears and four more to connect the input in addition to all the components needed for the converter and the load, and your load assembly will need to be precisely calibrated and can only be used for this circuit. When using a common load (shared with other circuits), the gate would have to be linked to it through two signal-driven gears put in line. This would increase the parts count by two installed and four link gears.
+
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. Additionally 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 signals 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 mechanisms 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;">
 
<div style="width:1px; white-space:nowrap;">
 
'''load based XOR'''
 
'''load based XOR'''
Line 53: Line 50:
 
|{{RTL|#FFF}}
 
|{{RTL|#FFF}}
 
|-
 
|-
|{{RTL|#FFF}}
 
 
|{{RTL|#FFF|&nbsp;|#FFF|L|#F44|right}}
 
|{{RTL|#FFF|&nbsp;|#FFF|L|#F44|right}}
 +
|{{RTL|#444|*|#DDD||||3|#F4F|right}}
 
|{{RTL|#444|*|#DDD||||P|#4F4|right}}
 
|{{RTL|#444|*|#DDD||||P|#4F4|right}}
 
|{{RTL|#444|*|#DDD||||2|#D4D|right}}
 
|{{RTL|#444|*|#DDD||||2|#D4D|right}}
Line 92: Line 89:
 
|}
 
|}
 
</div>
 
</div>
In stark contrast to the load-based XOR, it consists of a single gear. While it requires a power source and an output, it can accept power from an axle and serve as output gear by itself. 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 disengaged, and you link the second input trigger to it. Since gears toggle, every time your trigger changes state and sends a signal the gear will change state. Initially both triggers are off, and the gear is disengaged. When one trigger changes state, it will activate the gear. Independent of which trigger changes next, both will have the same state afterwards, and the gear will be disengaged again. So the gear will transport power when both input triggers 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 won't need many mechanisms to build this gate. 1 for the gear, 4 to connect to the input and 1 will be lost after disconnecting the temporary lever (that needs 3 temporarily). And of course you will need all the components for the converter, but no load.<br>
+
In stark contrast to the load-based XOR, 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 disengaged, and you link the second input trigger to it. Since gears toggle, every time your trigger changes state and sends a signal the gear will change state. Initially both triggers are off, and the gear is disengaged. When one trigger changes state, it will activate the gear. Independent of which trigger changes next, both will have the same state afterwards, and the gear will be disengaged again. So the gear will transport power when both input triggers 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 won't need many mechanisms to build this gate. 1 for the gear, 4 to connect to the input and 1 will be lost after disconnecting the temporary lever (that needs 3 temporarily). And of course you will need all the components for the converter, but no load.
 
 
'''toggle based XNOR'''
 
* Use a single gear as for the XOR, but omit the temporary lever step.
 
 
 
'''toggle based NOR'''
 
* Multiple gears in series, with one (and only one) input connected to each gear.  Any single ON(signal) input will produce an OFF(power) output.
 
* Can be converted to OR by adding an [[inverter]] to the output
 
* No temporary levers, so it uses fewer mechanisms.
 
 
 
'''toggle based AND'''
 
* Same as the NOR except use temporary levers to pre-toggle each input gear. For large logic arrays it is probably best to convert your Boolean equations to NOR logic, as that is the quickest simplest and least expensive (in mechanisms) to implement.  With the added benefit that all mechanisms can be recovered from gears.
 
 
 
'''toggle based NAND'''
 
* A 3x1 gear assembly for each input.  Input goes to the center (signal) gear.  Power goes to either one of the other gears (the power gear), output is the other outer gear (output gear).  Can be expanded indefinitely by adding additional 3x1 arrays in parallel (i.e. 3x2 for a 2 input, 3x5 for 5 input).  The theory is that power is transmitted across all of the power gears (which are all connected to each other in parallel.  Any single signal gear which has an OFF state (gear engaged) will allow power through to the output gears.  It requires every input gear to be disengaged (ON signal) in order to produce an OFF (unpowered) output.
 
 
 
'''toggle based OR'''
 
* Same as the NAND except pre-toggle each signal gear.
 
  
 
== 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 (or, with toggle-based mechanical logic, another gear assembly). Currently, there exists no trigger in dwarf fortress that reacts on the working state of machine components, that is, the presence or absence of power. The traditional solution to this was to use a hydromechanical power-to-signal converter, remarkably similar to hydromechanical [[Memory_(computing)|memory]].
+
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 exists no 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 173: Line 153:
 
</div>
 
</div>
 
<br />
 
<br />
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 about 100 steps. 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 about 100 steps. This gate is fluid conserving.
 
 
However, the introduction of minecarts have created alternatives that are more compact and don't require water, largely rendering the hydromechanical PTS device obsolete.  The following minecart-based PTS converter is fast, easy to build, and extraordinarily compact:
 
 
 
[[File:2x2pts.png]]
 
 
 
[http://www.bay12forums.com/smf/index.php?topic=114923.0 Bloodbeard's Minecart Dwarfputing Ideas thread] on the DF forums has other examples of minecart-based PTS.
 
  
 
==Load based Mechanical signal-input power-output gates==
 
==Load based Mechanical signal-input power-output gates==
Line 188: Line 162:
 
* 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.
 
* 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.
 
* 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 the load would shut everything down or nothing at all.
+
* 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.
 
* The gates' instructions will explain how much load and power you need to have at each P and L in the more complicated gates.
  
Line 335: Line 309:
  
 
{{Category|Computing}}
 
{{Category|Computing}}
{{Category|Logic}}
 

Please note that all contributions to Dwarf Fortress Wiki are considered to be released under the GFDL & MIT (see Dwarf Fortress Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)

Templates used on this page: