<< BACK | NEXT >>

4 bit Adder - Design

My first designs for this were on 5mm graph paper, but I soon found an excellent application called EagleCAD. It's both very versatile and good at what it does, allowing you to design and almost manage a project from the drawing the circuit, to the layout of the PCB, to ordering the parts. And what's really good is that it's free for private use! If you're interested you can find it here - I highly recommend it. For tutorials on how it works YouTube is your friend as well as google as lots of people use the software.

Beginning design

The objective of this project, as previously stated, was to add two set of 4 bit values together and output them. For this I needed 2 lots of 4 inputs and 5 outputs (not 4 - I'll cover the reason why in a bit). I chose some traditional DIP switches as inputs as they take little room and don't cost much. For the outputs - LEDs of course!

For the Adder chip I chose a 74HC283 Full Adder - in fact a Texas Instruments CD74HC283E. To be fair, this was a bit random - I could have just gone with basic TTL or the latest ACT - it didn't matter as speed wasn't an issue and everything was +5V. LEDs are standard 1.9V red and one 2.1V yellow, transistors (later I got rid of these) BC547 - again, standard NPN stuff.

Here's an early prototype design:

AssemblerUIpic
(click to enlarge)

As you can see it has at least one major problem: the lines going between the 2 sets of DIP switches and the adder chip (IC3) do not have a pull up or pull down resistors. As a layman you might ask: what are they and why do we need those? I certainly did!

Pull up/pull down resistors explained (I hope!)

In digital circuits pull up/down resistors sit between a digital line and either the power rail (+5V normally) or ground and provide a way for power to flow if no easier path can be found. You need this because digital ICs (apart from some tri-stated microprocessor type devices) require either a logic 0 (ground) or a logic 1 (+5V typically) on input pins. If this isn't provided and the voltage level fluctuates or is arbitrary due to not being driven by anything then you get a state called high impedance. When this happens the IC may give erratic and unpredictable output on other pins. To avoid this, pull up or pull down resistors give a path to +5V or ground and so power still flows and a value is set on the IC pin in question. The reason why the resistors don't affect values driven on the line to the IC is that they offer a greater resistance than the IC to the current flowing and current will always take the easiest path.

In the above design you can see that I attached the two 4-switch DIP switch blocks (SW1 and SW2) to the two sets of four inputs on the Adder chip (IC3). When in the ON position these switches allow power to flow between +5V through them to the input on the Adder and so that input becomes logic 1 (+5V). So what happens if the switch is in the OFF position? It would disconnect that line from the power rail and so should go to 0V? Nope. It'll go high impedance - it's not connected to either the power rail or ground at this point and so the value on it might be read as anything.

Implementing pull up resistors

To resolve it I added some pull-up resistors which means that if any of the switches are off then the line it's managing will go to +5V. I also changed the input to SW1 and SW2 from +5V rail to the ground rail. I did this so that if the switch are on then line will go to 0V. If I'd left it as it was then the lines would be +5V no matter the switch position. In retrospect I really should have fitted pull down resistors and left SW1 & 2 tied to +5V - as it stands, when a switch is in the ON position, it's actually off! Not that it really mattered for this project.

Here's the updated design:

AssemblerUIpic
(click to enlarge)

The pull up resistors are R1 to R8 and the 10K means that current is limited to 0.5mA (5V divided by 10000 Ohms) so as to protect the inputs on the Adder.

The Adder

The Adder IC takes two sets of 4 inputs (pins marked A0-3 and B0-3) and does a binary addition between each set. It then adds on another input called the Carry (pin 7 marked CIN). If you cast your mind back to your school days and math class you might remember all of this :D). If you don't and you're interested then this might be helpful.

Because this is a full Adder it can take a Carry-in from the Carry output of another Adder. I've set this to logic 0 by connecting it to ground (otherwise our output would get an extra 1 added to the additional of A0 and B0).

A0 to A3 are connected to SW1 and B0 to B3 are connected to SW2. The outputs S0 to 3 and also the Carry output are connected to the LEDs via transistors.

Outputs

I initially had the outputs from the Adder going through some transistors. The reason for this is all ICs have a maximum amount of current that they can output. However, LEDs will take as much as possible - until they burn out. It's a bit like a balloon being filled with water. You put more and more in, the balloon keeps stretching and getting bigger until it bursts.

So, if I connected an LED directly to the output pin of the Adder the following would happen: The LED would draw tons of current, exceeding the among that the IC can offer. the IC output would then fail or the LED would burn out.

To stop this happening and because I initially believed that the Adder output wouldn't be able to provide enough current to even light an LED, I thought of using an NPN transistor with the Adder output switching on the power to light the LED for that line. The current would then come directly from the +5V rail.

As it turns out, the CD74HC283E can output up to 25mA per output pin - more than enough to light an LED. So all I needed to do was to limit the current that the LEDs could draw by putting in a series resistor on each output:

AssemblerUIpic
(click to enlarge)

As you can see, I put in 220 Ohm resistors. This limits the current to:
Red LED: 5V - 1.9V (used by red LEDs) = 3.1V. 3.1V / 220 Ohms = 0.014A = 14mA Yellow LED: 5V - 2.1V (used by yellow LED for output Carry) = 2.9V. 2.9V / 200 Ohms = 0.013A) 13mA. This really didn't need to be this high. I could have gotten away with limiting it to between 5 and 10mA each - the LEDs would have still have been visible.

As a side note; You normally work out the resistance and not the current (amps). For example:
With the red LEDs we would say that we know the maximum they can take is 25mA, but know that 5mA is more than bright enough. The calculation for the resistors would be:
5V - 1.9V (used by the each LED) = 3.1V. We convert the 5mA value to amps by dividing it by 1000 giving us 0.005.
3.1V / 0.005A = 620. This is the value of the resistor needed in Ohms.

Power

The power for the circuit is something that's now a standard for me: an LM7805 with two 100nF smoothing capacitors. The LM7805 provides 5V @1.5A max out generated from an input of between 7V and 25V. This allows me to easily use a standard 9V battery when testing.

<< BACK | NEXT >>



Site Map | CSS Hover Menus by Css3Menu.com