# Relay Calculating Engine

The relay calculating engine is a huge project that I started in 2009 and finished in 2014. The photo here shows a partially complete version, but the whole thing is now finished and fully functioning.

I decided to build a machine that could carry out calculations using just electromechanical relays. I was inspired by the first computers from the 1930s, in particular, the work of German scientist Konrad Zuse who built the first process controlled computer, making use of relays.

Part of the reason that I am interested in this kind of thing is because I like the art style of re-working obsolete technology. Especially I enjoy these retro devices that often do modern things, but use technology that according to our time-line is from a bygone era.

This project was shown as an exhibit at the Maker Faire in San Mateo in 2014. It was also part of a one-month solo show at Microsoft Research, in Redmond, WA, in the fall of 2014.

I have always been interested in relays and the way that they can do computation, especially after viewing a number of giant relay computers in museums such as the amazing Munich Museum of Science and Technology. Inspired by this kind of thing, I built a simple two relay latching circuit when I was a child. I imagined that if I had a very large number of these electromechanical switches, I could build a computer. Essentially that is what I am working on at the moment. However, quite a few people have built computers, and actually its not all that hard with so many designs on the internet. I decided instead to do something a little more crazy, which was to build a machine that is dedicated to floating point mathematical operations, more akin to the work of the early computer pioneers.

Initially I was intending to build a “pocket calculator” but using relays and with a Nixie tube display. However doing the math, this would require too many relays for a full precision calculator with addition, subtraction, multiplication, division, and square roots – around 800 of them. Therefore I decided to build a machine that just is dedicated to square roots. The reason I like square roots is that it is a non-obvious calculation, and also when I was working at GEC Sensors in the 1990s, I designed some ASIC circuitry to compute square roots in hardware, and so I was familiar with the logical operation, as it were, broken down into binary operations.

One of the things that I like about relays is that they are slow and noisy, and if you add lights to each one, as I have done, then you can easily see how these devices are being used, at least in terms of a pattern of operation over time. This is in contrast to modern computers where the operations happen in microscopic circuits in a manner which is far removed from human senses. Watching a slow relay computer figure out square roots seems to bring this digital world back into human consciousness.

Relays are electromechanical switches where a magnetic solenoid can be activated in order to switch over one or more sets of contacts, to reconfigure a circuit. I have made a few videos describing how relays can be used to carry out logic operations. In the one below I describe a simple latching relay circuit, of the type I made when I was a child. This tells you haw you can make a circuit that can have one button to turn on a light, and another one to turn it off.

One of the reasons I decided to go ahead with this calculator project was because after a few days of head scratching, I managed to come up with a circuit that could transfer information from one set of relays to another based on a single “clock pulse”. This allows you to make a synchronous counter, and therefore to construct state machines using relays. Unlike regular digital logic, its quite difficult to avoid race conditions and drop-outs with relays because their contacts go through an intermediate non-connected period when switching over from one set to another. This innovation that I made allowed me to get over this and build counters and memory circuits where storing and transferring information was fairly easy. You can see a video below where I walk through the development of this “flip-flop” circuit.

Using the circuit idea above, I was able to make a four bit counter and latch circuit to count pulses from a telephone dial and transfer them into a relay memory store. The output of this store was decoded using relay contacts in order to drive a nixie tube display. You can see the circuit operating in the video below.

Once I had these concepts sorted out, I wrote a simulation of the square root operation in C-sharp on a PC. This was not a detailed digital simulation, but just a program that made sure that I had the necessary registers and operations in place conceptually to carry out a square root operation using 8 digit floating point precision. It was a proof of concept that allowed me to approximately calculate the number of relays that I would need and evaluate how realistic the project was going to be.

I built a frame for the relay computer which could hold up to 30 identical relay modules, built using printed circuit boards. Each was designed to hold 16 relays for a total of 480 relays maximum. They can each be added or removed as necessary for servicing. My construction method was to build printed circuit boards which could hold the relays, but provided a prototyping area on the back so that they could all be manually wired up. I decided to go this route because I thought that I would make lots of mistakes and need to re-work parts of the machine, and I did not want to design a whole bunch of different custom PCBs for cost reasons. However the wiring and debugging of all these boards is very laborious – but also meditative.

The display unit makes use of eight Russian IN-16 nixie tubes. The anodes connect via a resistor to a high voltage supply. The cathodes get shorted to ground via relay contacts, depending on which of the ten digits is required to illuminate. In addition, there is also a decimal point that can be illuminated by a different circuit.

Also shown here is the mechanical clock pulse generator. This makes use of a motor driving a cam which presses alternately on two microswitches. Using this device I can generate regularly spaced pulses to sequence the machine through its various internal states during operation. The speed of the clock can be varied by the user so that they can watch carefully the sequence of lights corresponding to relays energizing when the machine is in operation.

Here you can see a picture of part of the inside of the system with all of the modules fully installed and wired up.

The numbers that the user wants to enter are dialed in via a telephone dial. The pulses from the dial are counted using a binary decade counter and the result when the dial returns to rest is shifted into an 8 digit binary coded decimal shift register where three relays are used to store every bit of information and the digit can shift in a synchronous way on the edges of clock pulses that come from various sources.

Relay contacts convert the binary stored values into 1 of 10 decoded outputs to drive the display cathodes and also there is circuitry to implement decimal point dependent leading zero blanking.

The case for this project was commissioned from Matthew Richter who is a very skilled local woodworking artist here. I felt it was important for such an involved project that could be around for a long time to have a very nice case to make it presentable.

Here you can see a block diagram of the whole system. It is fairly involved. There are two main registers – an 8 digit (32 bit) store for the answer and entry system, and a 17 digit store for the working accumulator and shift register.

In addition, there is a 10 digit subtraction unit that recirculates its results with the accumulator register.

Other registers store the decimal point position and floating point exponent, and count digits during the generation of the answer. The whole system is controlled by a state machine which has 11 different states. Each state commands different parts of the system to carry out various transformation operations.

Detailed documentation for this project, including schematics, can be readÂ here.