This project idea came to me while completing a lab in my Digital Electronics class. The objective was to create a circuit that took a 4-bit binary number as input using switches and output it as the equivalent hexadecimal number on a seven-segment display. Using Quartus, we programmed logical gate circuits onto an FPGA (Field Programmable Gate Array).
It was fascinating to program a seemingly simple circuit while understanding the intricate process behind its design and the underlying binary operations.
I decided to undertake a more challenging project that would require deeper thought and careful planning. Two ideas crossed my mind:
- Instead of the output being only one 7-segment display, use two instead
- Limit the type of gates in the design to NAND gates
To reduce costs, I opted to use physical NAND gate ICs instead of an FPGA, which typically costs around $150.
I was satisfied with the additional challenges. So my goal was to create a circuit that takes in a 4-bit binary input and outputs the equivalent decimal number using only NAND gates.
Ben Eater's video on Designing a 7 Segment Decoder was another source of inspiration.
In the end, the project should be able to output something like this:
Design ProcessThe 7-segment display I planned to use was a common anode, which is active low.
Active low means that a logical low input activates the corresponding segment. If I want to turn on the 'a' segment, a low voltage (around 0V) needs to be applied to the 'a' pin.
Creating a truth table helps in understanding what combination of inputs corresponds to what is outputted.
For reference, a 1 in the table indicates a high logical level, while a 0 indicates a low logical level.
The first seven columns in the output represent the ones digit of the seven-segment display, while the last seven correspond to the tens digit.
For the inputs part, each row corresponds to an equivalent decimal number.
For example, the binary input 0111 translates to the decimal number 7, as shown in the highlighted section of the truth table. So, the seven-segment displays would look something like this.
For the binary input 0111, the first digit requires segments a, b, and c to light up, necessitating a low logical level (0) to activate those segments. This can be seen from the truth table.
So to turn these input and output combinations into circuits, k maps and boolean equations were used.
K Maps are a method to convert the input and output combinations from a truth table into a boolean equation in a simplified form.
A boolean equation can then be turned into a circuit using different logic gates.
For example, let's focus on the E1 Column.
The K Map for the E1 looks like this.
The values on the most left under 'AB' are the different combinations of the input AB. The 'A' values are the first number, while the 'B' values are the second number. The same thing occurs with the values on top to the right of 'CD'. The 'C' values are the first number and the 'D' values are the second number.
Using the truth table whenever there was a 1 in the E1 column, a '1' would be filled in the corresponding box in the K Map. For example, with the input 0001, the output is a 1, where the first row and second column box of the K map has a 1 in it.
The next step is to group these '1's into groups of 2, 4, or 8. There can be some overlap between these groups, which can look like this.
With these groups, boolean equations can be formed.
Starting with the red group, when looking at the AB column, the '1's don't move to another row. Those 1's stay in the '01' row. That means A and B stay the same value. When looking at the CD row the '1's move from the column '00' to '01'. The only thing that changes when moving columns is the last number (D) changing from 0 to 1. So that means C stays the same value but D changes.
A stays at 0. B stays at 1. And C stays at 0.
We can keep the variable 'B' in boolean form as 'B' because it has a value of 1.
But to express the variable 'A' in boolean form, it's represented as 'Ā' to show it has a value of 0. The same goes for the variable C.
The boolean term that the red group represents is ĀBC̅. Notice that the term only includes the variables that don't change. D is not part of this term.
This process is repeated for the blue and purple groups as shown below in the video.
With the final boolean equation of E1 = ĀBC̅ + D + ABC, we can simplify it a little more to make it easier to convert it to a NAND gate circuit. Using double complements and De Morgan's Theorem allows for that.
The second equation shows a double complement. This technique is used to help setup the third equation which uses De Morgan's Theorem. This theorem changes the addition to multiplication and breaks the first complement.
This equation is now in a form where it's easy to use NAND gates. So the resulting circuit would look something like this.
Then, to change the 3 input NAND gates to 2 input NAND gates, De Morgan's Theorem was used to break down the variables with 3 terms into groups of 2 terms or less. I've assigned separate variables( F, G, and H) to make it easier to understand.
Then to break down the final 3 input NAND gate at E1, the equation is transformed to this:
Then using these NAND equivalent of OR gates and NOT gates:
This is the final circuit for E1.
The process of going from truth table to circuit was repeated for each pin on the seven-segment displays. Below are the other final circuits for each pin designed on Quartus.
All the other pins (A2, D2, E2, etc...)were connected to a high logical level output because those pins stay off. They don't need any circuits with NAND gates.
With these circuits, a total of 157 NAND gates is needed.
TinkerCAD circuits were also used to build circuits on breadboards so I could easily copy them later while building. This software doesn't have individual NAND gate components, but it has these black pieces called ICs (Integrated Circuits), and these specific ones have 4 NAND gates with these pins, as shown below.
This is the circuit I built for the A1 circuit in TinkerCAD. Four switches correspond to the four bits(ABCD) and are connected to a NAND gate to the right of it. That NAND gate acts as four NOT gates to produce the opposite output (it's the ones that produce Ā B̅ C̅ and D̅)
The two breadboards on the left are rails for the outputs and their opposites. Those then connect to the NAND gates on the right however it's shown in the previous figure of the circuit for pin A1. This rail will be used by all the other circuits as well.
To verify the setup, an LED was connected to the output. Input combinations (ABCD) were tested, and the results were compared to the truth table for column A1. If all combinations matched up to when the LED turned on and off, the setup was good.
This simulation was repeated for all the other circuits.
After each circuit was simulated and confirmed to produce the proper output, I then started on the build process.
Build ProcessThe NAND gate IC I used is the TI SN74HC00N. It's an IC with 4 NAND gates, the same pins as the one in the simulation.
Each IC contains 4 NAND gates, requiring 40 ICs for the project, which cost around $25.
The project required multiple breadboards and a significant number of wires. To reduce costs, I repurposed these Cat 5 cables that my Dad had laying around, cutting and unwinding the wires, which proved to be a time-consuming task.
Each circuit was built according to the TinkderCad circuit simulation and also had an LED attached to the end to make sure to produce the right output checking with the truth table.
After each circuit was confirmed to work, I put it away safely and worked on another circuit. After each circuit was built, all of them was connected together and wired up to the proper pin to the seven-segment display.
By the end of this project, here was the final result:
Video of device working:
Final ThoughtsOne of the hardest tasks to get through was debugging when the LED output didn't match up with the truth table. It was frustrating at first but slowly taking my time and meticulously checking each wire and each pin ensured that each circuit was a success.
Another difficult part of this project was losing motivation while building. A part of me just wanted to just buy wires so that I didn't have to take additional time cutting, unwinding, and stripping Cat 5 wires, but just pushing through the process taking things one step at a time helped me reach the end.
But the most fun I had on this project was definitely during the design process. I loved being able to have a difficult problem and solve it by using different tools and methods to go from point A to point B. The problem wasn't too easy where it could be done in a day, but it also wasn't too hard where it seemed impossible to do. It was the right kind of difficulty, challenging enough that it required me to make sure everything was right.
In the end, I'm glad I worked through this project. Enduring through this project made me realize the complexity of the technology we use today, as well as an appreciation for these hardware and the people who continue to develop and improve on these things.
Throughout this project, I learned a lot through the design, build, and test phases. Also being able to document it well was a huge learning curve for me. I know there are a lot of improvements that I could have made while documenting like simplifying some explanations, proper pictures while building, writing engaging material, etc. But I hope to keep on improving, learning, and staying curious.
Now I just have to find a place to put this thing.
Comments
Please log in or sign up to comment.