# Help me teach my son (and myself) electronicsSeptember 13, 2010 6:10 PM   Subscribe

My son got a 130-in-1 electronics lab for his 8th birthday and discovered digital logic from MacCauley's How Things Work. Now he wants to build a half-adder. Help?

The instruction book gives examples of individual logic gates and combinations, but what it doesn't give is a good foundation in circuit building principles. We have built and gates, or gates, and not gates, we've wired two switches for input and LEDs for output, but we haven't been able to successfully combine them all.

Can you give a recommendation on a good foundations of electronics primer (book or online resource)? As a kid I wired things in parallel and in series, but all these transistors and dipole switches and resistors are confusing me.

Can you point me to a wiring diagram for a half adder with all the transistors/resistors/7400 IC/ whatever explicitly shown? All I've found just show gates connected to other gates assuming you can figure out how to wire them yourself.

Or is there a place I can rent a retired electrical engineer?
posted by rikschell to education (15 answers total) 13 users marked this as a favorite

A half adder can be built from an AND and one XOR, iirc. Do you have those?
posted by boo_radley at 6:34 PM on September 13, 2010

The problem is, if I recall correctly from having one of these kits when I was a kid (loved it!), you only get one of everything. One relay, one 8-segment LED display, one speaker, etc.

If you can make a logic gate and figure out which wire are which, the Wikipedia page will probably get you there in theory. (rereading, I see you're stuck there. You need to make a XOR gate, for instance, and then study it to figure out which terminals are the inputs and which is the output. Then you just combine them, treating them as a prefabricated block. You shouldn't mess with anything inside the block.)

But can you really make multiple logic gates at the same time from the kit? For a two-input half-adder you need one XOR and one AND.
posted by ctmf at 6:47 PM on September 13, 2010

I just emailed you some digital logic notes from a class I took last year that covered this (and sooo much more). Good luck, digital logic is fun!
posted by MadamM at 7:03 PM on September 13, 2010

You can't go wrong with Don Lancaster's TTL Cookbook or CMOS Cookbook. You'd think they'd be obsolete after all these years, but there's no better practical introduction to digital electronics and everyone still uses them.
posted by drdanger at 7:10 PM on September 13, 2010 [2 favorites]

All I've found just show gates connected to other gates assuming you can figure out how to wire them yourself.

They do this because (almost) nobody makes the gates themselves. Instead, you buy chips with four to eight gates on the die, and then you just wire the pins from that gate on that chip to the other gate on the other chip. So, the wiring is usually literally as simple as connecting wires where there are wires in the logic-level schematic. (Well, and giving them power. But the schematic on the blister pack will tell you where to put the 1.5V.)
posted by Netzapper at 7:19 PM on September 13, 2010

All I've found just show gates connected to other gates assuming you can figure out how to wire them yourself

The missing link, then will be diagrams showing which pins on a 7400-series package have the gate inputs and outputs you need to use:

A half-adder will need one gate from each of those packages.
posted by flabdablet at 7:32 PM on September 13, 2010

I'm not a retired EE, more of an EE manqué... but your son sounds a lot like 8-year-old me!

If you have this kit, then a half-adder is totally possible with a little chicanery. Excruciating detail to follow.
posted by haltingproblemsolved at 7:49 PM on September 13, 2010

Ooh, thank you in advance, halting! That is the kit we have. It includes a 7400 chip and three transistors. So we have 4 NAND gates and three transistors, and my son maintains that we can use two diodes as an OR gate.

Ctmf, the Wiki page does not show how to get the electronics put together into a gate, nor how to wire inputs and battery. I need something to get me the rest of the way there. It does not seem to be as simple as powering the chip, then putting in signals and getting output. WHEN you power the chip seems very important, and I keep getting my switches wired wrong. I can wire each individual thing, but by the time everything is combined, there are so many wires and I can't make out if something should go on one side of the resistor or the other, or quite how a dipole switch differs from a key switch. I'm quite humbled, because I thought it would be much easier. My brain is not as flexible as it was when I was 8.

Thanks for all the help and support so far.
posted by rikschell at 8:22 PM on September 13, 2010

Nthing TTL Cookbook. A classic.
posted by 3.2.3 at 9:27 PM on September 13, 2010

OK, here's my give-a-man-a-fish answer. (The teach-a-man-to-fish answer, to echo everyone else, is the TTL Cookbook.) I used your kit's manual (PDF) as a reference while drawing this schematic. (Apologies for the draftsmanship, it's late. Or early.) This is how it works.

------------------------

Our first input, `A`, comes from the toggle switch. We declare that `A` is 1 when the voltage at terminal 132 is +Vcc, i.e. when the switch is in position "A." The fact that this is a double-pole, double throw switch (basically two switches in the same casing) saves us an inverter: if `A` is at terminal 132, then `not A` will always be at terminal 135.

We get our second input, `B`, from the keyswitch and a 100-Ω pulldown resistor. We declare that `B` is 1 when the voltage at terminal 71 is +Vcc, i.e. when the key is held down. The first NAND gate we use serves as an inverter, and we get `not B` at terminal 58.

------------------------

Now we have four input signals: `A`, `B`, `not A`, and `not B`. A half adder has two outputs: `S` for sum and `C` for carry. From The Way Things Work, we know
`C = A and B`;
`S = A xor B = (A or B) and (not (A and B)) = (A or B) and (A nand B)`.

If `C = A and B`, then `not C = not (A and B) = A nand B`. We use our second NAND gate to produce `not C` at terminal 52.

Our third NAND gate's output, at terminal 61, we'll call `X`, where `X = (not A) nand (not B) = not ((not A) and (not B)) = A or B`.

We notice that `not S = (A or B) and (A nand B) = X nand (not C)`. Aha! Our fourth NAND gate will go to produce `not S` at terminal 55.

But what now? We wanted `C` and `S`, but all we have are `not C` and `not S`, and we're out of gates! This is where we straight-up cheat: we wire up our output LEDs so that they light up when the signal they're connected to is low, instead of when it's high. The LED on the left lights up when `C = 1`, and the LED on the right lights up when `S = 1`.

------------------------

120-134-133-137-62-72
138-71-56-57-51
136-131-34-31-49-13
132-50
135-60
58-59
61-54
52-53-33
55-36
119-14
13-14 (POWER)
posted by haltingproblemsolved at 10:50 PM on September 13, 2010 [4 favorites]

If you need to cobble together a few extra gates, you can get some circuit ideas from studying obsolete logic families like RTL, DTL, and diode logic.
It does not seem to be as simple as powering the chip, then putting in signals and getting output.
Hmm, it should be that simple, since the 74'00 doesn't have any state. In theory you can wire the power pins of the chip to +5/GND, wire the outputs to some LEDs (remember the current-limiting resistor), and then play with the inputs to see how they behave. And by "in theory" I mean "I've done this a zillion times".

Putting current into an input of a non-powered chip can make it do weird things, though for small logic like that, the input-protection diodes will probably keep everything normal.
posted by hattifattener at 11:06 PM on September 13, 2010

I don't have this book, but the Google preview for MAKE: Electronics sure looks like a friendly primer. I like the The ARRL Handbook for Radio Communications; a new edition is printed every year so an old one is always cheap at a used book store. It has a good selection of useful circuits from which to steal ideas, big lists of chip pinouts, sufficient introduction chapters, and printed circuit board layouts on the included CD. You can ignore the half of the book that deals with antenna theory and practice, but then again, maybe that will be pretty interesting to a budding engineer.

Your son sounds sharp as razors; prepare to add more advanced material like the awesomely neurotic Pease (the cover art of which might seem strikingly familiar) and classically consummate Horowitz and Hill to gift lists for his teenage years if the hobby continues. eBay a decent oscilloscope and you're off to the races.

Lastly, check out one of the "Web 2.0" electronics suppliers, such as Spark Fun. These are a lot less intimidating than DigiKey, and they do a good job making little pre-soldered break-out boards for some pretty amazing devices: microcontrollers, sensors, GPS modules, USB interfaces, XBee wireless communication modules, digital displays, etc. Browse around a store like that with the "10,000-1 electronics kit" concept in mind.
posted by fatllama at 5:21 AM on September 14, 2010 [1 favorite]

We did it! Thanks for your help, everyone. Art came home from school one day and said, "I figured out you can make a half-adder with just two gates, an AND and an XOR." I checked MadamM's notes, and sure enough, he was right. Then he drew me out a diagram of the AND output split between the carry-digit LED and the base of a transistor. The collector was connected to the output of his two-diode OR gate, and the emitter went to the sum-digit LED. I was skeptical, but we wired it up. It didn't work, but as I read a little more on transistors, I discovered we'd been misunderstanding everything based on a mixture of Macauley's explanation of a negative output signal blocking electrons and my misunderstanding of current flow (I thought it was flowing from positive to negative instead of the other way round). I still don't quite have my head around it, but I realized that Art's diagram should work perfectly if we stuck a NOT gate and a resistor between the AND gate and the transistor base. We used an extra NAND from the 7400, and sure enough, it works like a charm. Now to get my hands on the TTL Cookbook. I didn't realize how much electrical engineering is based in metaphor, because "input" and "output" and "negative" and "positive" are not as simple as I thought. This is way beyond Lego.
posted by rikschell at 6:33 AM on September 15, 2010 [2 favorites]

Man, I kinda want kids now.
posted by fatllama at 6:46 PM on September 15, 2010

Easiest way to think about transistors, in digital applications, is as current-controlled current switches.

The switched current flows from collector to emitter, and the control current flows from base to emitter. The current flow will be positive for a NPN transistor like your kit's 2SC, and negative for a PNP transistor like the 2SA's.

If you design a circuit that causes M milliamps of current to flow into a transistor's base and out its emitter, then the transistor will allow up to M * β milliamps to flow from collector to emitter. β, also frequently specified as hFE, is a (very) roughly constant number that depends on the design of the transistor. For small transistors like the ones in your kit, you won't go far wrong for digital applications by assuming that hFE is roughly 100.

The base won't draw any current at all until it's roughly 0.6V more positive (for NPN transistors) or negative (for PNP transistors) than the emitter.

If there is less current flowing from collector to emitter than the amount of base current allows, the transistor is said to be saturated. The collector of a saturated small transistor will typically be something like 0.2V more positive (NPN) or more negative (PNP) than the emitter.

Digital circuits are generally designed so that all transistors involved are either completely off (no base current at all, collector effectively disconnected from emitter) or fully saturated (more than enough base current to keep the collector within 0.2V of the emitter).

So, let's look at a really simple logic probe circuit made of one 2SC transistor, a LED and two resistors. Wire one end of a 270 ohm resistor to +4.5V, and the other end to the anode terminal of a LED. Wire the cathode of the LED to the collector of the 2SC transistor. Wire the emitter of the transistor to 0V. Wire one end of a 4.7k resistor to the base of the transistor. The other end of that resistor is your probe input.

If the transistor is off, the LED will be dark because the collector will admit no current flow.

If it's saturated, the LED will have roughly 10mA flowing through it. Why? The transistor's emitter is at 0V, so its collector and LED cathode are at +0.2V. Red LEDs have a roughly constant voltage drop of about 1.7V, so the LED anode will be at +1.9V. That means there's 4.5V - 1.9V = 2.6V across the 270 ohm resistor, so by Ohm's Law, which describes resistor behavior, there will be 2.6V / 270 ohms = about 10mA flowing though it. Since the resistor is in series with the LED, that same current will be flowing through the LED into the transistor's collector, and 10mA is enough to light a LED up nicely.

To saturate the transistor, we need at least (10mA / β) or roughly 0.1mA flowing into the base. Since the base will always be at roughly +0.6V any time there's any current flowing into it, this will happen whenever the probe end of the resistor is more than 4.7kOhms * 0.1mA = 0.47V more positive than that i.e. any time the probe is connected to a point at least 1.1V more positive than 0V.

Don't get too hung up one which way current "really" flows. "Conventional current" does indeed flow from positive to negative. The fact that this current is the physical result of a drift of electrons from negative to positive doesn't alter that fact; we have, completely arbitrarily, decided to describe electrons as "negatively charged" to make it work.

It's perfectly reasonable, when thinking about transistors, to think always of current flowing in to the base, in to the collector and out of the emitter, regardless of whether you're dealing with NPN or PNP transistors. All you need to do is get the sign of that current flow right. For an NPN transistor, the current flowing into the base will be some positive number of milliamps. For a PNP transistor, base current will be some negative number of milliamps. This is exactly the same thing as a positive number of milliamps flowing out of the base; use whichever mental model you find least confusing.

It's worth noting that the arrow parts in the circuit symbols for transistors and diodes always point in the direction of conventional current flow.

That was all a bit random, but I hope it helps.
posted by flabdablet at 5:43 AM on September 17, 2010 [1 favorite]

« Older My dental insurer made a mista...   |  I want to write an erotic stor... Newer »