Relay Computing

Recently, [Manuel] did a post on making logic gates out of anything. He mentioned a site about relay logic. While it is true that you can build logic gates using switch logic (that is, two switches in series are an AND gate and two in parallel are an OR gate), it isn’t the only way. If you are wiring a large circuit, there’s some benefit to having regular modules. A lot of computers based on discrete switching elements worked this way: you had a PCB that contained some number of a basic gate (say, a two input NAND gate) and then the logic was all in how you wired them together. And in this context, the SPDT relay was used as a two input multiplexer (or mux).

In case you think the relay should be relegated to the historical curiosity bin, you should know there are still applications where they are the best tool for the job. If you’re not convinced by normal macroscopic relays, there is some work going on to make microscopic relays in ICs. And even if they don’t use relays to do it, some FPGAs use mux-based logic inside.  So it’s worth your time to dig into the past and see how simply switching between two connections can make a computer.

Mux Mania

How do you go from a two input mux to an arbitrary logic gate? Simple, if you paid attention to the banner image. (Or try it interactive). The mux symbols show the inputs to the left, the output to the right and the select input at the bottom. If the select is zero, the “0” input becomes the output. If the select is one, the “1” input routes to the output.

Obviously, a relay with two poles can act like two gates (the input at the bottom has to be the same for both gates). You can also work out a buffer (swap the inputs of the NOT gate), or A OR NOT B and A AND NOT B.

It is also possible to do things like “wired OR” with relays. For example, suppose you had ten AND gates made like the one above. If you want to OR the outputs together, you just connect the output wires. Any one (or more) AND gates triggering will drive the output high. Or, you could let ground be a 1 and float highs. This has the advantage of working better with ICs and other circuits that can sink more current than they can source. Then the relay coils are always hooked up to the positive supply and you need the ground to complete the circuit.

There are other tricks you can use. Diodes can handle some simple logic functions, although this may be considered cheating if you are trying to make a true relay computer. Resistors can convert normal relays into latching relays, as can extra contacts. If you do make both logic levels actual voltages, you can play tricks with feeding both sides of the coil.  This makes a great XOR circuit–think about it. It is even more straightforward to create XOR if you don’t mind using two relays. Many modern demonstration relay computers bite the bullet and use semiconductors for memory and control circuits.


This isn’t just in the realm of theory. Many relay computing devices were built in the last century. There are several modern examples, too, although they are mostly for show, not practical devices. There is a good looking 8-bit computer, for example, that only uses 83 relays. Watch it go in the attached video. In all fairness, though, it does use semiconductors for memory and the front panel. However, the architecture write up is quite illuminating, even if you don’t want to build the computer yourself. You can see a video of it in action below.

[Paul] has a project over on that refuses to use diodes for logic and has a whopping 32-bits of memory. To save relays, he uses a 1-bit ALU. There are quite a few others out there including [Simon Winder’s] impressive build to compute square roots with a telephone dial (see video below).

We’ve covered some other cool  relay builds in the past, including this 8-bit marvel that uses 152 relays and reads its programming from paper using optical sensing. There’s also this much larger computer that even has its own online simulator.

Go For It!

If you’ve ever thought about building a computer with relays, this should give you plenty of inspiration. Just keep in mind that relays are deceptively simple: they are non-ideal devices made of coils and strips of spring steel. For example, arcing across contacts is bad, right? Depends. Some contact material depends on arcing to clean corrosion. Others just pit and fail. There’s a lot of subtlety to relays and a lot of their perceived unreliability is really just misapplication. Not that they are as reliable as modern semiconductor devices, of course, but well-made relays with the proper construction for their intended application can be pretty reliable.

24 thoughts on “Relay Computing

    1. Thank you !
      I should really finish YGREC (whygee’s relay electric computer)
      For this project I created a “new” (?) kind of logic : CC-PBRL
      Capacitively Coupled Pre-Biased Relay Logic (using hysteresis, like the memory single-relay cells)

      but I got lured into the transistor novelty realm because of Ted Yapo…

      How many hackers does it take to change a bulb ?
      Wait a minute, we reinvent the bulb.

      1. Many times it’s transistor outputs, but relays are used a lot too. There are things you need to run with more current, than the transistor outputs can provide, or different voltages etc.

  1. Seems like a more modern take would be to use analog SPDT switches such as SN74LVC1G3157 which is a single solid-state SPDT in a SOT-23-6 package. Cheaper than relays ($0.34 in single quantity), take less power to operate and are smaller than relays but large enough to be easily handled by the average person.

    1. As an electrical engineer, I deal with relay logic all the time at work. While most of the relays in my designs are used as electrically-actuated switches, the electrical isolation and fail-safe operation of electromechanical relays are necessary components for safety systems. I can’t risk a solid-state relay failing conductively and starting up equipment that’s supposed to be deenergized.

    1. Actel’s A1020 was my first exposure to FPGA and MUX-based logic.
      I still marvel at its design…

      But these days I play with larger, more inefficient, slower, communist-era, clicking and vibration-sensitive MUX2 :-D
      Thanks to eBay and Alex (a Ukrainian surplus seller),
      I now have enough electromechanical parts to build my own 16-bits relay computer using CC-PBRL (invented with and for those relays)

  2. I found this article really fascinating, so I did some analysis to find how efficiently each possible 2-input logic gate could be constructed:

    a AND b => a?b:a
    a NAND b => (a?b:a)?0:1
    a XOR b => a?(b?0:a):b
    a XNOR b => a?b:(b?a:1)
    a OR b => a?a:b
    a NOR b => a?0:(b?a:1)
    a AND !b => b?0:a
    !a AND b => a?0:b
    a OR !b => b?a:1
    !a OR b => a?b:1
    !a => a?0:1

    There are obviously many solutions to this, but the above shows an example with the fewest muxes needed for each. So you can do anything with a single mux except NAND, NOR, XOR, and XNOR, which each need two.

  3. In the mid 1980’s my dad owned a general store with a shoplifting problem. He installed cctv cameras but soon had more cameras than monitors. He designed and built a switcher controlled by telephone keypads operating relays switching video. He could control which one of ten cameras was being recorded on a VCR. He had six monitors; one showed the feed going to the VCR. The other five showed one of a pair of images. If he chose to record camera 1 then the monitor for cameras 1&2 would flip to show camera 2 because camera 1 was visible on the recording monitor. As a suspect customer moved around the store he could follow them, keeping them recorded, while keeping an eye on the rest of the store.

    The switcher used a bank of old telephone relays on a board, hard wired together and worked flawlessly for many years. I guess he just used the technology he was used to, having worked in the telephone industry after leaving university.

  4. Given that the electric relay was known by the mid 1800s (it was apparently invented independently by several people) and that Babbage had conceived the idea of a general-purpose computer around the same time, it is too bad that these ideas didn’t cross. Had Babbage considered a relay based design he might have gotten further if for no other reason than the mechanical tolerances are far lower with these components, and thus the costs would have been far lower.

    1. I have often thought that fluidic logic was within the capabilities of many ancient civilizations. The Egyptians, for example, could have built it using the flow of the Nile as power. Imagine Pharoh with a giant stone mainframe to do data processing. You have to wonder where computing would be today.

      1. The difference here being that for relay computing, both the concept and the hardware coexisted at the same time and in the same place. I should have also added that George Boole had written “The Laws of Thought” in the same period, so indeed all the necessary elements were at hand. The Egyptians, while decent mathematicians had not developed a comparable understanding of logic.

  5. I’ve worked on some elevator controls that were completely relay logic with approximately 200 relays.
    Also there are companies that sell elevators with the option of plc or relay logic the selling point of the relay logic being that it is cheaper to repair and maintain.

  6. When I was a kid one of the science museums had n exhibit that let you play tick tack toe against a computer that was made out of relays. It was very cool. I think one of the phone companies AT&T or Bell Labs) was behind it.

  7. glad I accidentally left this tab open, there’s some interesting comments in here. Pharoh with super computers, tick-tac-toe, prebiased relays, video-switching, the fact that relays and the idea of computing were near but not combined…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s