Blue Flower

In essence a relay is an electric switch. It uses power and an electromagnet to close a switch.

Relay Computer

This relay has five connections as shown in the picture below.

This can be simplified by letting out the ground pin, so a simple four pin scheme is obtained. There are four basic switching possibilities for a relay, depending which contacts are powered. Green is power that switches the relay, red is power that is switched and black is no power. This relay is a Single Pole Double Throw relay, as shown in the figure below right.

Source: Wikipedia

Since computers use binary data, signals are very simple: 0 (no voltage) or 1 (voltage). In MERCIA’s case 12V relays are used because this voltage is not too low to have large amperage's and not too high to have problems with dissipating the the power for the used LED’s.

A combination of several relays can realize almost every function that can be found in a relay computer. However, in a number of cases it is more efficient to use one or more diodes. Since (flyback) diodes are also necessary to protect the LED’s that connected parallel to the relay and diodes play an important role in the memory implementation, I choose to incorporate diodes into the designs.

There are a number of functions that are used on one or more places in a relay computer. I’ve called these functions ‘elements’. In the following paragraphs I’ll describe these elements.

 

Relay logic


The relay logic of a bare relay is given in the truth table below.

In

Out

   

In

 

Out

Coil

CO

NC

NO

 

Coil

NC

NO

CO

0

0

0

0

 

0

0

x

0

0

1

1

0

 

0

1

x

1

1

0

0

0

 

1

x

0

0

1

1

0

1

 

1

x

1

1

 

The relay can be used in two way’s, depending if the CO or NC/NO are used as input (figure left).

For the connections between the relay pins an uniform color code will be used (above figure right) in all my relay circuit diagrams. This makes it possible to determine the function of a line by its color.

 

Basic binary logic


Three basic logical functions are known: AND, OR and XOR. If there is an N in the function name, the output will be inverted (NOT). That means 1 becomes 0 and 0 becomes 1. This is shown in the table below.

In

 

Out

a

b

 

AND

NAND

OR

NOR

XOR

XNOR

0

0

L1

0

1

0

1

0

1

0

1

L2

0

1

1

0

1

0

1

0

L3

0

1

1

0

1

0

1

1

L4

1

0

1

0

0

1

 

This logic table can be implemented using three relays as shown in the following (left) relay circuit diagram.

Relay Universal port

The required function is coded with the lines L1 to L4. For instance when an AND is needed L4 must be set to 1 and when a XNOR is needed L1 and L4 must be set to 1.

The right diagram shows how this principle can be used to make an universal logic port. The lines top left are used to select the required function.

However there are more economical implementations possible for the logic functions with two inputs, using two relays or even less. In the following paragraphs the economical circuit diagrams for these logical functions will be given.

 

AND and NAND


The output of an AND gate will only give 1 when both inputs are 1. For a two input port, only one relay is needed. For every extra input one extra relay is needed. Another relay is used to invert the signal.

Relay logic AND, Relais AND, Relay circuit AND

 

OR and NOR


Just connecting the lines together, can create an OR gate. However if an input becomes 1, all the other inputs – even if they are 0 - will also become 1. This can create unwanted feedback to relay’s earlier in the switching chain. This problem is eliminated by adding diodes, as shown with the red lines in the picture below. Then the signal cannot be fed back to the other inputs. For a NOR port, an inverting relay is added.

Relay logic OR, Relais OR, Relay circuit OR

For the purists among us, the OR an NOR gates can also be realized with the use of relays only as shown in the following circuit diagram.

Relay logic OR, Relais OR, Relay circuit OR Relaiscomputer,

 

XOR and XNOR


The most elegant way to create a two input XOR gate, is the use of two relays with crossed connections as shown below. Only when one of the inputs is 1, the output will be 1. An inverter will make the XOR a XNOR gate.

Relay logic XOR, Relais XOR, Relay circuit XOR Relaiscomputer,

A XNOR can also be created using only two relays, as shown in the circuit diagram below.

Relay logic XNOR, Relais XNOR, Relay circuit XNOR, ,

An entirely different approach is needed for a XOR gate with more than two inputs, as shown in the next circuit diagram.

The first two relays to the left form a triple AND-gate. The diodes will feed one or more 1-es to the output. The third relay forces the output to 0 when the AND-gate is true. The last relay (to the right) is used to invert the signal.

 Relay logic XNOR, Relais XNOR, Relay circuit XNOR,

Another solution for the XNOR gate uses two more diodes but only three relays.

 Relay logic XNOR, Relais XNOR, Relay circuit XNOR

 

One bit only


In some cases it is required to have only one of four signals different. This is given in the truth table below. Besides the already presented AND/NAND and OR/NOR there are two specials: Special 1 and Special 2.

 

 

 

Only one 1

 

Only one 0

In 1

In 2

 

NOR

Sp1

AND

 

OR

Sp2

NAND

0

0

 

1

0

0

 

0

1

1

1

0

 

0

1

0

 

1

0

1

0

1

 

0

0

0

 

1

1

1

1

1

 

0

0

1

 

1

1

0

 

These functions can all be implemented with the use of only one relay, except the OR (no relays) and the NAND (two relays). The circuit diagrams for the first 5 functions are given below.

On-off switch


The purpose of an on-off switch is to connect or disconnect lines. The truth table is very simple and resembles that of an AND-gate. The switch works both ways, so the output can also be the input.

Enable

In

Out

0

0

0

0

1

0

1

0

0

1

1

1


Relay Logic Switch

 

Amplifier


Relays are often put behind each other. This can be called a relay switching chain. It is important to know the switching chain. Below a switching chain, with a switching depth of two and a switching width of three.

Relay Computer Relaiscomputer

The switching depth is defined as the number of relays that are placed behind each other. This is an important factor to determine the clock-speed of the relay computer. The larger the switching depth, the lower the allowed clock speed. The switching width is defined as the number of relays that are switched by a certain relay. The switching width of relay 1 is three. This is important for the maximum allowed currant that may be switched by a relay. It is essential that the switching width stays well below the allowed switching amperage. This will significantly increase the lifetime of the relays.  In the next circuit diagram an amplifier is drawn. Note that the amplifier will only work in one direction.

Relay Amplifier

An amplifier can be used to reset the switching width to 0, however it will increase the switching depth with one.

 

Switch and amplifier combined


In a number of occasions it can be very useful to combine the on-off switch and the amplifier. This can easily been done by adding just one relay, as shown below.

Switch and amplifier

Also this circuit will only work in one direction.

 

Decoder


The purpose of this decoder is to convert a binary word of n bits to the 2n separate signal lines. Herefore 2n – 1 relays are needed. The decoder will only have output, when the enable signal is set to 1. This is drawn in the next circuit diagram.

Relay logic decoder, Relais decoder, Relay decoder

A decoder is an important part of memory addressing.

 

Coder


The coder does the opposite of the decoder. It converts a number of disjunct lines (XOR function, only one of the lines contains a 1) to a binary word. A special form of the decoder is the universal coder. In that case the coding is done with the use of DIP-switches. An universal coder can also be used as ROM (Read Only Memory).

Relay coder, Relais coder

 

Coder and decoder combined


A combination of a decoder followed by a coder can be used to do bit transformations from input to output. This is for example used to convert a 4 bit integer (4 bit in) to a 7-segment display code (7 lines out). The principle is shown below, with a (useless) example were the output is identical to the input.

Relay Decoder Coder, Relay logic decoder coder, Relais coder, Relay circuit coder,

 

Also the combination of a coder followed by a decoder can be useful. For instance to reduce the number of cores in a cable needed for disjunctive (only one signal at the time is active) signals. This is shown in the schematic below. Relay Coder and Decoder

 

Multiplexer


The purpose of a multiplexer is to select one out of a number of inputs. A multiplexer is in principle a combination of a decoder and a switch. There are two implementations possible: one that uses a decoder for every input and one that uses a decoder and a switch for every input. Both circuit diagrams are given. The given situation: number of inputs and number of bits determine which of both possibilities consumes the least number of relays. When the first input (Data 1) is not connected and both decode bits are set to 0, there will be no connection between in- and output. In the following circuit diagram, ‘Data in 1’ is (default) connected to the output when both decode bits are set to 0.

Relay multiplexer, Relais multiplexer, Relay circuit multiplexer

Relay logic multiplexer, Relais multiplexer, Relay multiplexer

T flip-flop


The T flip-flop will divide an input pulse train by two. E.g. every even pulse will bring the output to 1, every odd pulse will return the output to 0. The relay circuit diagram for this flip-flop is given below. The wire coding is given in the table to the right. An explanation of the wire coding conventions can be found in the last paragraph. To make the construction more visible, several colors for the connection wires where used.

Relay flip-flop, Relais  flip-flop, Relay circuit flip-flop

 

D flip-flop


The D flip-flop is the base for a register. It can be constructed using three relays. ‘Set’ will set the flip-flop to 1, ‘Reset’ to 0. ‘Enable’ will give the flip-flop the value the ‘Signal’ line has.

 Relay D flip-flop, Relais  D flip-flop, Relay circuit flip-flop

The truth table of the D flip-flop is the following.

 

Input

     

Input

 

Output

Signal

Enable

Set

Reset

Output’

 

Output

Signal

Enable

Set

Reset

Output’

0

0

0

0

0

0

 

1

0

0

0

0

1

0

0

0

0

1

0

 

1

0

0

0

1

0

0

0

0

1

0

1

 

1

0

0

1

0

1

0

0

0

1

1

1

 

1

0

0

1

1

1

0

0

1

0

0

0

 

1

0

1

0

0

1

0

0

1

0

1

0

 

1

0

1

0

1

0

0

0

1

1

0

1

 

1

0

1

1

0

1

0

0

1

1

1

1

 

1

0

1

1

1

1

0

1

0

0

0

0

 

1

1

0

0

0

1

0

1

0

0

1

0

 

1

1

0

0

1

0

0

1

0

1

0

1

 

1

1

0

1

0

1

0

1

0

1

1

1

 

1

1

0

1

1

1

0

1

1

0

0

1

 

1

1

1

0

0

1

0

1

1

0

1

1

 

1

1

1

0

1

1

0

1

1

1

0

1

 

1

1

1

1

0

1

0

1

1

1

1

1

 

1

1

1

1

1

1

 

Latch


A latch is a circuit that will hold (remember) the logical 1’s of the input until it is cleared. The circuit diagram for a three bit latch is shown below.

Relay latch

The truth table of a latch is given in the next table.

Register

Input

Register

before

Clear

In

after

0

0

0

0

0

0

1

1

0

1

0

0

0

1

1

0

1

0

0

1

1

0

1

1

1

1

0

0

1

1

1

0

 

Register


When a latch and switches are combined, a register emerges. Registers do play an important role in computers. They store bytes in a more accessible way than memory does. In the three bit circuit diagram below, the latch is combined with two switches. This is often done to be able to connect the register to a data- as well address-bus.

Relay Register, Relay logic register, Relais  register, Relay circuit register

In a number of occasions, for copying values, in a relay computer two registers are connected together. It is important to understand that registers cannot be copied, in that sense that there is a source and a destination, and the destination register will get the source values regardless of what the current values are. Both registers will connect and take each other’s values through an OR-function.

This is given in the following truth table. Left of ‘Enable’, the values of a bit in the registers before connecting them, right the values after connecting them.

Reg 1

Reg 2

Enable

Reg 1'

Reg 2'

0

0

Ò

0

0

0

1

Ò

1

1

1

0

Ò

1

1

1

1

Ò

1

1

 

Radio button


A so called radio button is a set of buttons, only one of which can be selected at any time. This can be implemented using n*2 relays and n*(n-1) diodes. Beneath an example for three radio buttons is given. In essence it uses a latch with corresponding clear relay for every button. When a button is pressed, a signal is given to the corresponding latch to activate and to all other clear relays to clear the other latches.

Relay Radio Button

 

Pulse generators


A relay in combination with a capacitor can also be used to generate pulses. The circuit diagram to the left shows a single pulse generator. A trigger signal causes a pulse to be given, the duration depends on the capacity of the capacitor. F=A*V/s or the required capacity in Farad is determined by the relay its current in Amperes multiplied by the Voltage of the relay divided by the required pulse length in seconds.

The circuit diagram to the right shows the generation of a (asymmetric) pulse train. Here the frequency is determined by capacitor capacity. Bear in mind that the capacitor must activate both relays, so the current is twice the current of a single relay. When a symmetric pulse train is needed, a T flip-flop must be connected to pulse output.

 

 

Delay line


Delayed switching is very useful when registers are used. A register is often put at the end of a relay switching chain. Unless the last relay switched, the value of the chain is undefined. This is shown in the next two examples. The top circuit will put a 1 in the register, while the bottom circuit will not.

Relay Delay line

In order to avoid these kind of problems, the register must only be enabled when all the switching has been done. For a switching chain with length n and a relay switching time of t, this is after a delay of n*t. Therefore a delay-line with a delay-time of n*t.

This can be solved by n relays put in a switching chain (top circuit diagram). A more elegant solution can be found in the circuit diagram at the bottom. There a capacitor is used to realize the required delay. As usual, the mass connection of the capacitor is not drawn (but is needed). The capacity of this capacitor must be chosen precisely, so that the required delay is achieved.

It is important to realize that after each usage of this delay-line, the capacitor must be given some time to recharge. An delayed off can be realized with the following circuit.

Relay delayed off

Both circuits, delayed on and delayed off, can also be combined by placing the delayed off circuit behind the delayed on circuit.

 

 

Adder


An adder ads two binary numbers. The addition of two binary values is defined by the following truth table. The output of an adder, called the result, can be obtained by the logical function a XOR b. 

Half adder (incrementer)

In

Out

a

b

result

carry

0

0

0

0

0

1

1

0

1

0

1

0

1

1

0

1

  

The carry is the value that has to be taken to the next bit to the left, which is the more significant bit. So every bit has an incoming carry from the right (less significant bit) and an outgoing carry to the left (more significant bit). The carry can be obtained by the logical function a AND b. An adder that is calculating the sum from only two inputs, is called a half adder. Half adders are also known as incrementers, since they can add 1 to a binary number. The circuit diagram is given below. 

When the carry bit of the less significant bit is taken into account, there are three inputs: a, b and the carry. An adder that can handle these three inputs is called a full adder. The following truth table is applicable to a full adder.

Full adder

In

Out

Carry

a

b

c

Carry

0

0

0

0

0

0

0

1

1

0

0

1

0

1

0

0

1

1

0

1

1

0

0

1

0

1

0

1

0

1

1

1

0

0

1

1

1

1

1

1

 

A full adder can be realized by the combination of two half adders. One that adds a and b and one that adds this result with the carry. The circuit diagram is given below.

The term ripple carry is used when the value of the carry out is calculated by use of a relay that is switched on by the carry in. In that case the carry ripples through the entire word and causes a significant delay. With Mercia’s ten bit word, this means that in a worst case 10 relays must be consecutive switched on, before the carry of the most significant bit (MSB or bit 9) is calculated correctly.

It is evident that a ripple free adder is needed in order to eliminate the carry delay.

 

Relay wire coding


In order to convert the circuit diagrams to working PCB's, relay wire coding can be very helpful. It is used to implement relay circuit diagrams and check the implemented wiring.

The pins of a relay can be coded as follows:

A – Activate relay
F – Feed
C – commonly Closed
O – commonly Open
G – Ground

Consider the following circuit diagram that is called ‘fake function’


The connections can be coded in the following two ways:

Fake circuit:
1A – 1C
1O – 2C – 2A or 1O – 2C, 2C – 2A or 1O – 2A, 2A – 2C
1F – plus
2O > out

or

Fake circuit:
Red: 1A – 1C
Yellow: 1O – 2C – 2A or 1O – 2C, 2C – 2A or 1O – 2A, 2A – 2C
Green: 1F
plus
Blue: 2O > out

Use the following conventions:

  • The coding starts with the function name of the circuit diagram.
  • Every relay has a number.
  • Every line starts with the color name or the line is printed in the applicable color.
  • Every line is a continuous connection, e.g. all the pins mentioned on the line are connected to each other.
  • A connection is indicated by “-“
  • A diode is indicated by “>”, marking the direction the diode is conducting.
  • Relay pins in upper case and other signals in lower case.
  • Black: G1 – G2 – minus, is considered trivial and therefore left out.

 


May 2016, Naarden The Netherlands, Jeroen Brinkman