Logic

From #openttdcoop wiki

Revision as of 17:47, 3 December 2012 by Mfb (Talk | contribs) (This is an edit summary)

Jump to: navigation, search

An article from scratch :)

Concept:

Introduction:

  • Presignals
  • link to signal tutorial
  • maybe link to boolean logic and red=1
  • link to prios as basic logic
  • something about timing / running conditions
  • isolation of logic via signals
  • gate bending in limited space

Logic gates

NOT

The most common logic gate you will see on coop servers is the NOT gate. It inverts the input: If the input is green, the result is red, if the input is red the result is green. This is done with two trains running on a 3x3-tile ring. If the input is green, they keep moving and at least one train keeps the output red. If the input is red, both trains stop behind an entry signal and the output is green. It is possible to use TL0.5-trains (single engine), but the gates work better with TL1-trains (two engines or double engine).

Two NOT gates, one converting red to green and the other one converting green to red.
AND "gates" with different input states

AND

AND gates are red if and only if all inputs are red. This is a feature of presignals - an entry or combo signal is red if all exit and combo signals leading to that block are red. There is no (practical) limit on the number of inputs.

OR

OR gates are red if and only if at least one input is red. There are two ways to implement this: An OR gate or a construction similar to a priority. The latter method requires less space, but it works only with trains in that signal block itself - you cannot combine arbitrary logic lines like that.

OR "gates" with different input states
OR, built like a priority

Advanced logic elements

XOR

XOR gates are red if exactly one of its two inputs is red. There is no known elementary gate for this, but it can be built as combination of multiple gates: (A XOR B) = (A OR B) AND (NOT(A AND B)) where A and B are the inputs.

Edge detector

An edge detector is sensitive to changes of its input: If the input switches from red to green (or green to red, depending on the implementation), its output becomes green (or red) for some time, and switches back to its original position afterwards. This can be used to detect trains running on a line.

Basic counter

A train, running in a loop, can be used as counter: Most of the time, all signals for this train are red. To count up, all signals get green for a short time, and the train travels to the next signal. This can be used to store data, for example in self-regulating networks.

Delay

A delay has the same output as its input, but it needs some time to change the output. This can be useful if timing is important.

Red -> absolute red

A special gate to produce absolute red: A train in a signal block instead of a red presignal.

Applications

  • SRNW stations: Many types
  • flipflop-split
  • forced ML split (PSG199)

Advanced concepts

  • 1 in 1 out (PSG239)
  • Bigger feeder SRNW station (PZ22, PSG199)
  • Self-regulating RV (PSG229)


Things to check: PSG239, 223!, 214

Powered by MediaWiki