4 Bit Binary Calculator

 by Teslaling
100_0392.JPG
100_0391.JPG
100_0397.JPG
100_0398.JPG
100_0387.JPG

If you need to quickly add numbers from 0 to 15, and you know how to rapidly convert to binary and back to decimal, this is for you...But if your human then this is just a fun project!!  I'm going to show you how to make a 4 bit (0-15) adding calculator using 74xx series IC chips.

The chips that I used are the very basic gates like OR, AND, XOR, NOR, NAND, etc.  No actual adding chips are used so its one level up from transistors, and it's totally TLL!**

By the way, this is another addition to the unofficial "Macroelectronics" catagory for all of you who have seen my diy ram instructables!

**If you use the 74hc series or 74hct series, then its technically not TLL, but who cares about the techincal details!!

 
Remove these adsRemove these ads by Signing Up
jnowak says: May 19, 2013. 7:30 PM
oh ok. gotya.
I have one bit put together right now and i'm pretty sure the schematic matches yours, but I'm having a good deal of trouble and seem to be inducting power into it or something when i bring my hand close or something. I end up with something like:

0 + 0 = 1
0 + 1 = 10
1 + 0 = 10
1 + 1 = 11

any ideas?
jnowak says: May 19, 2013. 2:34 PM
Do you need that OR gate? ether one or the other AND gates has an output so you could just have both the AND's output go right to the carry out, right?
also, if you powered a input with Vcc, would it fry? I'm not quite understanding, but nice job!
Teslaling (author) in reply to jnowakMay 19, 2013. 6:06 PM
Yes the OR gate is necessary and no powering an input with Vcc won't fry it. Let me explain: The chips use CMOS logic. CMOS has to important properties: 1) inputs are voltage dependent not current dependent (no current flows into or out of the input); 2) outputs source current when high and sink current when low. The first property means that even if you connect an input to Vcc, no current will flow. The second property means that if you have two outputs connected together and one is high and the other is low, then a ton of current will flow from one to the other, frying them both. The solution is to put an OR gate there so that both of the outputs are connected to inputs that do not sink or source current.

I hope this clears things up!
Marat1998 says: Jan 16, 2013. 6:24 PM
Where can you actually buy 74hc chips?
Teslaling (author) in reply to Marat1998Jan 16, 2013. 6:35 PM
The 74hc chips can be found at various electronics suppliers such as Mouser, Digikey, or Jameco.
uditkotnis says: Dec 12, 2012. 5:36 AM
May I ask you which battery terminals have you connected to the vcc and gnd points on the chips?
Also I did not understand the way you connected the dip switches.
Sorrry if I sound a little dumb but this is my first electronics project with transistors.
uditkotnis says: Aug 25, 2012. 8:54 AM
Hey I tried making this project but when I switch on the dips to make inputs the current bypasses the entire circuit.
P.S.
can you please tell me what is your supply voltage,
I used two 9v batteries in series.
P.P.S.
When I dont have a input all the LEDs glow even if all the dip switch keys are open.
Teslaling (author) in reply to uditkotnisAug 27, 2012. 3:16 PM
I think your supply may be the issue. According to the datasheets, the chips have a maximum supply of 6v. two 9v batteries gives 18v which is way more than enough to fry the chips. This is probably why the LEDs are glowing, the chips are dead. The best thing you can try is replacing all of the chips and lowering your supply voltage. I have a converted computer PSU that gives stable 5v but a 2 or 4 battery pack would work. Just keep your supply below 6v.

Good Luck!
thatrandomguy80 says: May 27, 2012. 12:36 PM
hey i have all the same parts as you except my or gate is a 74LS32 and i cant get it to work when i test it so any trouble shooting or things i need to know when using gates? ps its not a bad gate because i have tried 2 of them now

Teslaling (author) in reply to thatrandomguy80May 27, 2012. 5:20 PM
I think that might be the problem. 74hc is CMOS logic levels whereas 74ls is TTL logic so there are incompatibilities when interfacing between the two. If you want, you can do a little more research on the issue, but what you need to know for this is that 74ls won't work with 74hc.

I believe that 74hct can work at both CMOS and TTL levels.
techno guy says: Jan 13, 2012. 10:35 AM
You could make this subtract by putting a signal into the carry-in of the first and unused carry-in input and then inverting your b value. e.g.: 1011=0100. That is how I made the calculator I built in minecraft to be able to also subtract. When you do the subtract thing, the carry-out of the last adder will turn on but will not mean anything, you could put a switch there to turn it off while subtracting.
Macattacku says: Oct 7, 2011. 1:47 PM
sorry its been awile but a npn transitor would work very well with a 100k resistor on its base and with that combo the data could last maybe ten seconds which is more than enough. i dont quite know quite how to show the the circuit.
Macattacku says: Sep 27, 2011. 7:21 PM
I dont mean to brag but I happen to have a very wide knowledge of the inner workings of computers, logic gates, and computer arithmatic and data flow and i was wondering I already know how to do it but i dont really have the time. could you make an instructible on making a byte of d-ram memory? if you want to make or have questions please leave a comment to talk to me.
Teslaling (author) in reply to MacattackuSep 28, 2011. 4:13 PM
Awesome! I actually started some work on that and another project after I published the results of my SRAM project. I've been working on a dram cell and a 555 timer circuit. I developed a fairly reliable long tail differential comparator for both and I'm in the process of simulating the circuits. I don't know if I can do a full byte, but I would be happy to attempt a few bits.
Macattacku in reply to TeslalingSep 28, 2011. 7:42 PM
its actually very simple for just one byte just 16 n channel mosfets, 8 small value capacitors 0.1 or 1 uf, and 8 comparators. since there is only one byte it does not need a transistor per cell because that is just for selection. how long the data will last is based on the size of the capacitors and the amount of current drawn into the comparator. so a regular comparator will work fine but a comparator with low input current draw would work the best.
Teslaling (author) in reply to MacattackuSep 29, 2011. 3:27 PM
Actually, the mosfets have reverse current body diodes in them, so any transistor that will have current going both directions will need two mosfets per gate. (32 total mosfets) I would then need 3 bjts per comparator (2 pnp and an npn). It's going to be large and I don't have the room without ripping up some other circuits I've been working on.

No offense, but why do you want me to make a full byte? Personally, I would think a few bits or a nybble would suffice.
Macattacku in reply to TeslalingSep 29, 2011. 7:38 PM
actually it just need to amplify a signal so you could just use an npn transistor with a 1 k resistor on the input no pull up resistor required. but yes a byte is sorta large so how about a nybble? also there is one thing i missed to tell you an OR gate per bit is also required but you can just used two resistors ten k would be ideal.
Teslaling (author) in reply to MacattackuSep 30, 2011. 3:10 PM
The problem with a single npn is that if 3 bits are 1 and one is 0, there is going to be leakage to that one. If the voltage is high enough to be amplified enough to be a 1 (<.5 volt is needed) With a comparator, however, the threshold could be 2.5v (5v supply) so anything less is a 0 and anything over is a 1. It's a less temperamental solution, and a bit of a personal preference. Besides, real dram uses a comparator, but using an IC just doesn't sit well with the spirit of it, for me at least.

A nybble will definitely work, but if I have the room, I will try a byte too :)
tarantado says: Aug 18, 2011. 8:56 PM
I JUST WANDERED..WHAT WOULD BE THE SUPPLY FOR THIS BINARY CALCU?lol XD
Teslaling (author) in reply to tarantadoAug 19, 2011. 7:49 AM
3V to 5V should work fine. 2 or 3 AA will do it, or if you can get power from USB that is regulated 5v.
tarantado says: Aug 18, 2011. 8:58 PM
ALSO WHAT IS THE SEQUENCE OF THE IC's FROM LEFT TO RIGHT?
I REALLY NEED HELP.. T_T
shane11 says: Feb 12, 2011. 5:14 PM
I cant seem to find a XOR GATE with the model number 74HC86 on jemeco thats an OR gate.
Teslaling (author) in reply to shane11Feb 12, 2011. 9:27 PM
Are you sure? 74HC86N - Quad 2 Input Exclusive OR Gate??
shane11 in reply to TeslalingFeb 18, 2011. 8:13 PM
oooo whoops sorry bout that!!!!!!!!!
dungeon runner says: Dec 31, 2010. 12:21 PM
Damn! After seeing your DIY RAM instructables I was going to do just this myself. Oh well, beat to the punch. Maybe I'll post a more complete version, with subtraction and such. Good job.
Teslaling (author) in reply to dungeon runnerDec 31, 2010. 10:42 PM
Thanks man! Yeah, I have the entire schematic for an 8-bit adder/subtractor (number range 127 to -128) I just need another breadboard and a few hours of free time (the hard part) and I can start. But if you beat me to it, good luck to you!!
shane11 in reply to TeslalingFeb 2, 2011. 11:51 AM
Could I possibly use your schematics for the 8 bit I would like to build that!!!!

And also correct me if i'm wrong but this requires NO programmer right????
Teslaling (author) in reply to shane11Feb 2, 2011. 12:08 PM
Yeah, just give me a day or to to draw it up on the computer. I have it all in a sketch book, so it should be only like a day's wait.

And no, it requires no programming what so ever, it's just logic chips and wires!
shane11 in reply to TeslalingFeb 2, 2011. 12:13 PM
Thats great that theres no programmer!!!!!
Im seriously excited to build this!
Teslaling (author) in reply to shane11Feb 3, 2011. 3:48 PM
These are the pics that I took of the sketchbook. I hope you can read them.

Basically, the first picture is the 2's complementor. So the Bx input (x being the bit) would go into that to be made negative (or positive if already negative).

The second picture is of the add/subtract selector. The Bx input is the normal, "un-negatized" B input, and the /Bx is the "negatized" input. When the select line is pulled high, the calculator adds, and when it's pulled low, the calculator subtracts. The ADDx outputs are connected to the Add B input. You may want to put diodes on the outputs before connecting them together and then you will want to tie the line low through a 10K ohm resistor where both outputs are connected together.

The third x inputs come from the selector's ADDx outputs. COi is the Carry In which is connected to the last bit's COo, which is the Carry Out. On the LSB, the COi is tied to ground.

The Last picture is of the gate and chip count. Yes, you will need 10 AND Chips!

Good luck and Have fun!!
100_0323.JPG100_0330.JPG100_0324.JPG100_0325.JPG
shane11 in reply to TeslalingFeb 3, 2011. 4:21 PM
Very nice design thank you so much for taking time to take the photos.
Teslaling (author) in reply to shane11Feb 3, 2011. 5:22 PM
Yeah, no problem. I would like to see it, so when you finish it, send some pix! Or better yet, make an 'ible!
shane11 in reply to TeslalingFeb 4, 2011. 4:47 PM
I would be happy to!!!!!!!
shane11 says: Feb 2, 2011. 9:03 PM
Does it matter the logic chips being in a starait line or is that just because your on a bread board?
Teslaling (author) in reply to shane11Feb 3, 2011. 12:05 PM
Yeah thats the only reason. You could have them oriented however you wanted on a PCB.
jensenr30 says: Dec 22, 2010. 6:29 PM
I have visited jameco before and I like the layout of their website, but personally, I like mouser more. It has cheaper products and they allow you to order in multiples of 1!! =D
Have you ever tried mouser.com? if not, you definitely should!!
Teslaling (author) in reply to jensenr30Dec 22, 2010. 6:45 PM
I've tried mouser and I really like them. I just went with Jameco because I had the catalog available so I didn't have to search all over the web trying to find which parts I needed!
jensenr30 says: Dec 22, 2010. 6:26 PM
Dude! I love this tutorial! you really went all out on your logic chip order! How much money was it to purchase all of those? my guess (for the 80 logic chips) around twenty to thirty dollars.

p.s.
A++Tut
=D
Teslaling (author) in reply to jensenr30Dec 22, 2010. 6:39 PM
Yeah I know I went out of my way, but it was because I'm also looking at making an extremely simple CPU to make cylon eyes! Its all for the macroelectronics movement! And yes, the total with shipping was just under $30.
jensenr30 says: Dec 22, 2010. 6:33 PM
I love that joke, and you are probably annoyed by me commenting on all of your videos!!
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!