Introduction: 4-bit Binary Calculator
I developed an interest in the way computers work on a fundamental level. I wanted to understand the use of discrete components and the circuits necessary to accomplish more complex tasks. One important fundamental component in a CPU is the arithmetic logic unit or the ALU which performs operations on integer numbers. To accomplish this task, computers utilize binary numbers and logic gates. One of the simplest operations performed is adding two numbers together, in an adder circuit. This video by numberphile does an excellent job of explaining this concept via Domino Addition. Matt Parker extends this basic concept and builds a Domino Computer circuit using 10,000 dominos. Building an entire personal computer out of dominos is absurd but I still wanted to understand the use of discrete components to accomplish this adding task. In the videos, logic gates were created out of dominos but they can also be made out of basic components, namely transistors and resistors. The purpose of this project was to utilize these discrete components to learn and create my own 4-bit adder calculator.
My goals for this project included:
1) Learn how to create and fabricate a custom PCB
2) Make the design easy to conceptualize adding binary numbers
3) Demonstrate the difference in scale between discrete components and an integrated circuit performing the same task
Much of the inspiration and understanding of this project came from Simon Inns.
Attachments
Supplies
I used Fritzing to make schematics, create and fabricate the PCBs
Step 1: Theory
Counting in base 10 is simple because there is a different integer to represent the sum of two integers.
The simplest example:
1 + 1 = 2
Counting in base 2 or binary only uses 1's and 0's. A combination of 1's and 0's are used to represent different integers and their sums.
An example of counting in base 2:
1+1 = 0 and you carry the 1 to the next bit
When adding two bits (A and B) together, 4 different results are possible with the outputs of Sum and Carry (Cout). This is what is shown in the table.
Logic gates take inputs and generate an output. Some of the most basic logic gates consist of the NOT, AND, and OR gates which are all utilized in this project. They are made up of different combinations and wiring of transistors and resistors. Schematics of each gate are provided.
Referring back to the table, A combination of these gates can be used to produce the Sum results in the table. This combination of logic is also known as an exclusive OR (XOR) gate. The input has to be exactly 1 to result in an output of 1. If both inputs are 1 the resulting output is 0. The carry bit results can be represented by a simple AND gate. Thus, using both an XOR with an AND gate can represent the whole table. This is known as a Half Adder and the schematic is shown above.
In order to add larger binary numbers, the carry bit must be incorporated as an input. This is accomplished by combining 2 Half Adder circuits to generate a Full Adder. Full Adders can then be cascaded together to add larger binary numbers. In my project I cascaded 4 Full Adders which enabled me to have 4 bit inputs. The schematic for the Full Adder is above.
Simon Inns has a great and more in-depth write up about the theory. There are also a few PDFs that I found helpful.
Step 2: Testing the Circuit
The first step after understanding how logic gates work and the theory behind a Full Adder is to build the circuit. I started by gathering all of the components I needed: 10K and 1K resistors, NPN Transistors, Breadboard, Jumperwires. I followed along with a printout of the full adder. The process was tedious but I was able to get a working circuit for the full adder. I would tie the inputs high or low and used a multimeter to test the outputs. Now I was ready to translate the breadboard and schematic into to a PCB.
Step 3: Designing the Full Adder PCB
To design the PCB I used Fritzing exclusively. This was my first time designing a PCB and this program seemed like the most user friendly and intuitive with the smallest learning curve. There are other great programs like EasyEDA and Eagle available to help design a PCB. With Fritzing, you can start designing on a virtual breadboard or a schematic, then move to the PCB. I utilized both of these methods for this project. When you are ready to fabricate the PCB, its as simple as the click of a button to export your files and upload them directly to Aisler, the partnered fabricator for Fritzing.
Draw the Schematic
I started with the schematic tab to begin the process. First, I found and inserted all of the components into the workspace. Next, I drew all of the traces between the components. I made sure to add 5V input and ground to the appropriate places.
Design the PCB
I clicked on the PCB tab. When you move directly from a schematic you get a mess with all of the components connected by ratsnest lines based on the traces you made in the schematic. The first thing I did was resize the gray PCB to the size that I wanted and added mounting holes. I also added 16 pins for the input and outputs.
Next, I started to arrange the components in a logical fashion. I tried to group components with connections that were close to each other so that I would minimize trace distance. I went an extra step and grouped the components together by logic gate. One of my goals was to be able to visualize how the circuit works and be able to follow the "bit" through the circuit.
After that, I used the autorouting function which goes through automatically and draws the optimized tracings between the components. I was skeptical that this process completed all of the right tracings so I went through to double check and redraw tracings where they were supposed to be. Fortunately, the autorouting feature did a pretty good job and I only had to fix a few of the tracings. The autorouter did also make some weird angles with the traces that is not the "best practice" but I was okay with that and everything still worked fine.
The last thing I did was add text that would be printed as the silkscreen. I made sure all of the components were labeled. I also imported custom logic gate pictures to emphasize the grouping of the components. The last picture above shows the silkscreen.
Fabricate the PCB
I clicked on the fabricate button at the bottom of the screen. It directly routed me to the Aisler website where I was able to make an account and upload all my Fritzing files. I left all of the default settings and placed the order.
Step 4: Designing the Other PCBs
The remaining PCBs that I needed were the input/output interface board and the board for the IC. I followed a the process as Step 3 for these boards. The pdf of the schematics are posted below.
For the IC, I made all of the connections using the virtual breadboard feature. I included the schematic for completeness but was able to go directly from the breadboard to the PCB tab which was pretty cool.
I also added a base 10 to base 2 conversion chart on the silkscreen on the I/O interface board before uploading and ordering in Aisler.
Step 5: Soldering Components to PCB
All of the PCBs arrived and I was really impressed with the quality. I have not had any experience with other manufactures but would not hesitate to use Aisler again.
The next task was to solder all of the components which was an arduous process but my soldering skills improved greatly. I started with the full adder boards and soldered the components starting with transistors, then 1K resistors, then 10K resistors. I followed a similar method to solder the rest of the components onto the I/O and IC board. After each Full Adder board was complete I tested them with the same method as the breadboard Full Adder. Surprisingly, all of the boards worked correctly without an issue. This meant that the boards were routed correctly and that they were soldered correctly. On to the next step!
Step 6: Finishing the PCBs for Stacking
The next task was to solder all of the header pins to each board. I also needed to add jumper wires between the correct header pin and the inputs/outputs of the Full Adder boards (A, B, Cin, V+, GND, Sum, Cout). This step could be avoided if you designed different PCBs for each level of the adder circuit but I wanted to minimize design and cost by creating only one Full Adder PCB. As a result, connections to these inputs/outputs required jumper wires. The schematic provided is how I accomplished this task and which pins were used for each level of the Full Adder boards. Images show how I soldered the jumper wires for each board.
I started by soldering free wires to the correct pins on the header. I then soldered the header to the PCB. After I had the header pins with jumper wires soldered in place, I soldered the free ends of jumper wires to the correct leads on the PCB. The picture above shows a close up of the header pins with the jumper wires soldered to them.
Step 7: Powering the Circuits
I planned on using a 12V DC barrel jack power supply for this project so I designed the I/O interface board to have a DC barrel jack/connector for the power input. Because I was using the same I/O board and wanted to use a sole power supply I needed to regulate the voltage to 5V as this is the max input for the SN7483A IC. To accomplish this I needed a 5V regulator and a switch that could toggle between the 12V and 5V. The schematic above shows how I wired the power circuit together.
Step 8: 3D Printing the Base
Now that all of the wiring and soldering is complete, I needed to figure out how it was all going to be held together. I opted for CADing and 3D printing a design that would accommodate and display all of the parts of this project.
Design Considerations
I needed places to mount the PCBs with bolts and standoffs. The stacked Adders are the most visually appealing and I wanted to have those on display when not in use so I wanted a place to store the IC PCB. I needed to accommodate the power circuit with cutouts for the switch and DC barrel jack/connector. Lastly, I wanted some sort of enclosure display case to prevent dust from collecting in the open PCBs so I needed a place for the enclosure to sit.
3D Modeling
I used Fusion360 to design the base. I started with the dimensions of the PCB and the spacing of the mounting holes. After that I used a series of sketches and extrusions to set the height and size of the base with the PCB mounting points. Next I made the cutouts for the enclosure, and the power circuit. Then, I made an area to store the IC PCB when not in use. Lastly I added some finishing edge details and sent it to Cura, my slicing software.
Printing
I chose black PLA filament. The print took a little over 6 hours and turned out great. Surprisingly, all of the dimensions were correct and everything appeared like it would fit together properly. The picture above shows the print after I added the standoffs into the mounting holes. They were a perfect fit!
Attachments
Step 9: Assembly
Insert the standoffs. I placed all of the standoffs into the mounting holes of the base.
Position the power circuit into the base. I had wired everything together and pulled all of the components through the hole for the switch. Next, I inserted the power jack/adapter into the back of the base. I pushed the 5V regulator into its slot and finally the switch was able to be push fitted into position.
Mount the I/O PCB. I placed the IC PCB into its storage space and placed the I/O interface PCB on top. I screwed down the PCB using 4x M3 bolts and a hex driver. Finally I plugged the DC barrel jack into the PCB.
Stack the Adder PCB's. I stacked the first Adder into place. I screwed down the back of the PCB into the back mounting holes with 2 standoffs. I repeated this process until the last Adder was in place and secured it with the 2 more M3 bolts.
Make the enclosure. I used 1/4" acrylic for the enclosure. I measured the final height of the project and, with the CAD dimensions, cut out 5 pieces for the sides and top to make a simple box with an open bottom. I used epoxy to glue the pieces together. Finally I sanded a small half circle cutout on the right side to accommodate the switch.
Ready to Calculate!
Step 10: Calculating and Comparison
Plug in your new calculator and start adding! The base 10 to base 2 chart can be used to quickly convert between binary and integers. I prefer to set the inputs then hit "equals" by flipping the power switch and observing the binary output from the LEDs.
Comparing discrete components to an Integrated circuit.
Now, you can unstack the full Adders and plug in the SN7483A IC into the I/O board. (Don't forget to flip the switch to the opposite direction to power the IC with 5V instead of 12V). You can perform the same calculations and you will get the same results. Its pretty impressive to think that both the discrete component Adder and the IC function in same way just on a very different size scale. The pictures show the same inputs and outputs for circuits.
Step 11: Conclusion
I hope you enjoyed this project and learned as much as I did. It is pretty satisfying to learn something new and turn it into a unique project that also takes learning a new skill like PCB design/fabrication. All of the schematics are listed below. For anyone interested I can also link my PCB Gerber files so that you can make your own 4-bit Binary Calculator. Happy making!