Page 1 of 4

LED counter

Posted: 08 Jun 2008 19:08
by Igloo
While playing this game, messing around with train signals, I wondered whether it was possible to create electronic circuitry with the help of signals, trains and tracks. After several days of trial and error, the attached save game is the result.
In short: I have made a ´LED´ display that counts the amount of times a train passes a certain track (see image, showing the number 3). At this moment the display will only count to 7, and then reset.

In terms of efficiency, we're doing not so well: the display takes a couple of days to update, which gives it a clock speed of approximately 0.000002 Hertz (consider that regular computers are into the gigaherz range).
LED.png
LED.png (27.19 KiB) Viewed 20548 times
This savegame runs on the latest stable build of OpenTTD (0.6.1.0).

Check it out :)

Re: LED counter

Posted: 08 Jun 2008 19:23
by Core Xii
That's wicked, but how about a little closer zoom screenie?

Re: LED counter

Posted: 08 Jun 2008 19:34
by broodje
You sir.... you've got way to much time on your hands! Incredible fun to watch. It took me some time to find out where the clock was though, I hadn't noticed the passenger line was such an important part of the design. Show's quite well that conditional orders aren't needed to make a nice switch board, or should I regard your design as 'too low level' to be usable? ;).

Re: LED counter

Posted: 08 Jun 2008 20:01
by moki
I guess, the "computer" could be made slightly faster by using maglev trains in the switches as well as in the "display", though I still don't know how exactly this thing works after staring at it for ten minutes... :shock: quite impressive, to say the least...

Re: LED counter

Posted: 08 Jun 2008 20:39
by Tom0004
This is some what mad.

Well done !! 8)

Re: LED counter

Posted: 08 Jun 2008 22:40
by zypa
This is sick ;)
How much time did you "waste" on this savegame?

Re: LED counter

Posted: 08 Jun 2008 23:53
by AntBUK
Sounds like somebody needs to discover a copy of WireWorld...

Re: LED counter

Posted: 09 Jun 2008 02:43
by Roujin
Interesting.. I've started to make some comments on it with signs, but I've given up on the magic that's happening in the east oO It's too late right now for such things :shock: here's my commented save file for those who are interested in it.

Unfortunately I've done it with trunk, not 0.6.1, so you'll need trunk/nightly too to load it...

Here's also a screenshot.

Re: LED counter

Posted: 09 Jun 2008 07:48
by Draakon
So what this does is count how many trains pass on a certain line?

Re: LED counter

Posted: 09 Jun 2008 09:51
by Igloo
Thanks for all the replies, and yes I am slightly mad ;-). This project took several days of slow and steady improvement.

The savegame contains a network that counts the trains that pass from east to west along the maglev line. However, it does take quite some time to update because the network is quite slow. Updating the system to maglev is possible, however, when I did that not all gates worked correctly so I stuck with railroad.

Roujin: you deciphered it correctly =]. Tonight after work and soccer I'll post a version including more details.

Re: LED counter

Posted: 09 Jun 2008 10:38
by Roujin
Igloo wrote:Thanks for all the replies, and yes I am slightly mad ;-). This project took several days of slow and steady improvement.

The savegame contains a network that counts the trains that pass from east to west along the maglev line. However, it does take quite some time to update because the network is quite slow. Updating the system to maglev is possible, however, when I did that not all gates worked correctly so I stuck with railroad.

Roujin: you deciphered it correctly =]. Tonight after work and soccer I'll post a version including more details.
Looking forward to it. I didn't really get the rest (where I didn't place signs) yesterday, e.g. why there's two 3-bit numbers, of which one is increased as soon as the passenger train reaches the point I've labelled "start of mechanism", and the other is adapted to what the first one holds as soon as the passenger train reaches the point "checkpoint 1".
Also the eastern part which probably counts up by one and then handles overflows and such was too confusing for me to be understood in each detail :? I also failed to understand what your structures there using trains with ~3 wagons exactly do.

Re: LED counter

Posted: 09 Jun 2008 17:54
by CommanderZ
That's awesome. I had to laugh when I was looking at the refreshing display.

Btw, couldn't "tunnels can cross each other" cheat make your work easier?

Re: LED counter

Posted: 09 Jun 2008 20:42
by Frostregen
Impressive :)
Reminds me of the old NAND-Signals Patch ;)

Re: LED counter

Posted: 09 Jun 2008 22:31
by Igloo
After playing this game for a while it became clear that the signals are very powerful. Which led me to wonder whether it is possible to build all logical gates in openTTD using only trains and signals. From there on it went downhill. The attached save game is the same save game I posted previously, but now with lots of comments.

Overview of the logic gates
In the system a green sign represents a value of 1 and a red sign represents a value of 0.

The OR gate is trivial:
OR.PNG
OR.PNG (19.74 KiB) Viewed 19214 times
The AND gate is not quite so simple. When the first train stops before the sign near Bit I or Bit 2 the presignals send the second train through the checkpoint. This turns the output to red. If both Bit I and II are green the trains will never go through the checkpoint.
NOT.PNG
NOT.PNG (23.1 KiB) Viewed 19228 times
The NOT gate was the hardest. By using a combination of presignals and standard signals it was possible to keep one piece of track occupied continuously if the input is green.
The attachment NOT.PNG is no longer available
The memory is simple in itself. However because the system does not use a clock-pulse it became more complex. To work around this problem the memory stores it's state internally before the output is updated. Hence two trains for each bit.

The other parts of the system are large combinations of ORs to convert binary numbers to decimal and to update the LED display on basis of the decimal value.

Re: LED counter

Posted: 09 Jun 2008 22:34
by Igloo
Apparently only three files can be included in a post :?

Re: LED counter

Posted: 09 Jun 2008 23:03
by XeryusTC
I've tried to do the logic gates too one day, OR is not so hard as it is the default of presignals. AND becauses a bit harder but isn't that hard to get as you can simply add an extra signal IIRC, it has been a while though.
I think I never got the NOT gate to work although I fiddled quite a bit with it.
I also remember having completed another logic gate but I don't know which one.

Kudos on the LED counter though, I haven't looked at it but it sure seems like it took you A LOT of time and thinking to make it work.

Re: LED counter

Posted: 10 Jun 2008 07:38
by Ammler
OMG, that is crazy! ;-)

Nice to see, someone reached to make a NOT and AND (NAND) without patching: http://www.tt-forums.net/viewtopic.php?f=33&t=26364


Greets
Ammler

Re: LED counter

Posted: 11 Jun 2008 21:43
by flake
crazy :o

thank you for amazing me.

Re: LED counter

Posted: 11 Jun 2008 21:48
by Roujin
Thank you for posting the commented version. Now I also understand the eastern part. Who would have thought that these wacky constructions with the waypoints are nothing else than AND-gates? 8) Great job on managing to build them! :)

edit: now, how long will you take to build a turing machine out of rails, and emulate OpenTTD on it? :lol:

Re: LED counter

Posted: 12 Jun 2008 08:00
by hertogjan
This is really nice :)
It reminds me of a similar program I once programmed in QBasic, which basically was a binary adder (the thing that adds two numbers, not the snake) using a train and a lot of switches. If one figures how to make the switches work reliably in OpenTTD, then one could make a binary adder in OpenTTD as well, although it will be quite large, I guess.