Relay Calculator
10 Bit Adder With Subtraction Using 2's Complement
Site is under construction
Relay Calculator
10 Bit Adder With Subtraction Using 2's Complement
This is my relay calculator capable of 10 bit binary addition and subtraction. It is made of 22 buttons, 22 capacitors. 32 leds, 55 resistors, 71 relays, and 116 diodes. The PCBS were custom designed in Fusion 360 and connect together with a linking PCB in the base of the frame. It also sits inside a custom case, desgined to look like a CRT monitor.
Here is a video of the calculator solving
983 + 719 = 1702
983 + 719 can be rewritten in bianary as:
1111010111 + 1011001111 = 11010100110
The Arithmetic Logic Unit (ALU)
First and foremost, this is not a chain of full adders. It is a sequenced 1 bit Arithmetic logic unit, henceforth referred to as an ALU. This means that the calculator is only doing 1 adding sequence at a time, and it repeats down the line. The binary has to be sent into the ALU in the right order and at the right time. This is what makes this project so much more difficult than a full adder chain.
So, what is a full adder? It is a group of logic gates that take 3 inputs and output 2 results. It is made of XOR, AND, as well as OR logic. Simply composed of 2 half adders It can add 3 inputs together. A, B, and Carry in (Cin). A and B are the operands on the front display, and Carry in is the carry that results from a previous result if the result is greater than 1. In the case of the calculator If the result is 10 or 11 the Most significant bit is a carry and gets factored into the next computation cycle (The previous carry out goes into the next cycle carry in). Otherwise if the result is 01 it is just latched on to the screen to show the result. A result of 11 would save the carry and show a 1 on the display, while 10 would only latch to the carry register. Obviously 00 would latch nothing. This process repeats 9 more times with the 11th light on the bottom being the carry result from the 10th add.
Here is a truth table and logic of a full adder
The Sequencer
Now that you know how the ALU works, it is important to understand the sequencer, which acts like the heart of the computer. Typical computers have an oscillating clock signal, but for this project it is not necessary because the adding cycle only occurs 10 times. The main sequencer is made up of large capacitors giving a significant delay between each bit. The clicks that you hear as it computes are the relays in the sequencer shifting off in order. The sequencer works by cutting power to the next relay with the previous relay, so the relay can only get power from the capacitor. Once the capacitor loses its charge from powering the relay, it switches off and this cycle repeats. When a particular relay in the sequence is active, corresponding to one of the 10 groups of bits on the front, it sends a voltage to that particular set of buttons on the front display. If A and/or B is pressed on display, the ALU sees it as a logical 1 with 5v. Otherwise it is seen as a 0. The way to ensure only one bit is active at a time, is to use the currently active relay to cut power to the previous signal line. Otherwise the lines would get power in order and stay on. This system ensures that only 1 set of inputs is able to enter the ALU at a time. The signal also goes to the corresponding latches on the memory board to feed the Carry out result into the Carry in pin of the ALU. Again, in simple terms think of the sequencer as the heart of pulse of the calculator.
The Memory
The memory board is responsible for remembering the results of the calculations and displaying them on the front display. While you cannot see it, the memory board works behind the scenes, saving the carry out result, so the calculator can deal with overflow for the next calculation. The memory board also determines which relays to save the results to depending on the step that the sequencer is on. The memory board has its own delay for each add cycle to deal with flickering issues during the computation. This additional buffering is required because relays take time to switch and sometimes give inconsistent logic without a debounce delay. The delay simply waits before the outputs of the ALU (Sum and Carry Out) stabilize before latching them to prevent issues. Since the bit is saved on relays that require power to remember the state, the memory in this calculator is a form of volatile memory. The memory board is not just for storage though, it acts as part of the program of the calculator. While the ALU and sequencer feed the memory board data and signals, the memory board decides what to do with it and where data needs to go for the next cycle. For this reason the memory board is the most complicated and is what sets this apart as a specialized computer vs a chain of full adder logic gates.
The Display
Then there is the simplest board of them all: the display. The display allows for the input of the operands. The other buttons are to enable subtraction and to send a calculate pulse. The ALU reads the inputs A and B from the display when the sequencer sends a signal out to the corresponding set of inputs. The common of the switch is connected to the ALU input and the NC is connected to ground. The NO connection of the switch connects to the signal coming from the sequencer. The signal can only come into the set of inputs A and B when the sequencer is sharing power with the set of inputs. When the set is powered, if either switch is pressed 5V to go into the ALU.
This is a basic coverage of how the calculator works, I will now go into greater detail of how the signals work and how computer logic can be made of relays. I will also run through what a full cycle looks like at a signal level.
Here are the schematics and PCBs for the calculator.
This is the sequencer and ALU of the calculator. The sequencer is responsible for timing of each addition cycle and the ALU is the heart of the calculator because it is responsible for adding bits. There also exists logic to create pulse signals for the calculate button and logic to invert bits and add 1 for 2's complement.
Fun Fact: This is the only board that did not work the first try. My delays were constructed wrong and the carry never fed back into the ALU. Fixing this actually reduced the number of relays by 10!
This board contains the memory and is responsible for feeding data back into the ALU when there is a carry. This board also has its own built in delay system so flickering outputs of the ALU can stabilize before they are latched into memory. The sum result goes straight to the display on the front, while the carry is stored and fed into the next ALU cycle determined by the sequencer.
The display is responsible for programming the calculator. It takes two 10 bit binary inputs and can perform addition or subtraction (using 2's complement). The result is displayed on the bottom. The front panel also contains the calculate button and the subtraction button. DPDT latching switches are used for all inputs.
The connector board does exactly what you think it does. It simply acts as a bridge between all the main boards. It has pins on it to allow the main boards to plug in easily and correctly every time.
Here are the PCBs assembled. Left( Display) Middle( Sqenecer/ALU) Right(Memory)