Read an Excerpt
Chapter 1: What is a ComputerAmicrocontroller unit (MCU) is essentially a "computer on a chip." But what is a computer? During the "electronic hobbyist's golden decade" (1955-1965), some of the most fascinating projects described in electronic hobbyist magazines and books were simple electromagnetic or electronic computers. Unlike the computer projects described in magazines in the mid-1970s and later, these early computers often consisted merely of a bank of relays or four to eight bistable flip-flops in series with an old phone dial as an input. For output, they used either no. 48 bulbs for the transistorized or relay version or NE-2 bulbs for the tube version. About the only thing this "computer" could do was translate decimal numbers to binary numbers and add them. For instance, if you dialed "3," the first from the right, and the second light would go on-all others would remain off. This indicated that "Y in decimal was "I I" in binary. If you dialed "51" lights I and 2 would go out, and light 4 would go on-this indicated "8" in binary. Of course, since a dial doesn't turn that fast, you could "see" the action taking place, with each light going on for an instant and then off as the "computer" counted upward in binary. This visible action meant that the process was slow, but it also added to the "computer's" mysterious charisma.
If you hooked up eight of these flip-flops in series (which, in those days, verged on a supercomputer), you were able to record a number as large as I I I I I I I I in binary, which is 255 in decimal. Now, doesn't something look familiar here? Eight flip-flops in seriesalong with 8 indicator lights in a row. What we have is an 8-bitregister-very similar in concept to the 8-bit registers in 8-bit microcontrollers. Quick question: What is the size of most registers in the HC I I and other 8-bit microcontrollers?
To get the concept of an 8-bit register etched in your mind, let's describe how to wire up a twenty-first-century version of the mid-twentieth-century hobbyist computer. Here we will use flip-flops in integrated chips (ICs) instead of making them from junction transistors, electron tubes, or even electromagnetic relays. Before I show the schematic and how to breadboard it, let's look at solderless breadboards and power supplies.
Solderless breadboards (also referred to as experimenter ~ breadboards) could be described as "high-tech Legos"-and are almost as easy to use. See Figs. 1-1, 1-2, and 1-3. If you use one of these, circuits can be tested quickly and easily. These breadboards come in many sizes and shapes and are produced by several companies. Radio Shack, for one, sells several sizes and types of these boards.
Solderless breadboards have plug-in points that are 0. 1 in apart and accept DIP ICs, diodes, W resistors, most capacitors, low-power transistors, light-emitting diodes (LEDs), 22-gauge wire, and many other parts that use 22- or 24-gauge leads. For more information, refer to the instructions that usually come with the boards. These boards are simple to use.
While you can power the first experiment (circa 1965 hobbyist computer) with two D-cells in series (3 V) or a 6-V battery, like most experiments and projects in this book, it is best powered by a regulated 5-V power supply capable of supplying 100 mA.
Keep in mind that this first experiment is a "get acquainted with the book's technique" project. While the circuit's operation is informative and helps ingrain the all-important concept of an 8-bit (1 -byte) number into your noggin, even more important, it enables you to gain experience with a solderless breadboard. What is most important, however, it gives me an excellent opportunity to discuss a piece of equipment you should own (not must, just should)-a regulated 0to 12-V power source capable of producing 250 mA. See Fig. 1-3. Ideally, this power supply should have the capability of monitoring the current drawn and the voltage produced. An alternative to this 0- to 12-V regulated supply is a +5-V regulated supply. If you have trouble finding either power supply at a reasonable price, you may be interested in this next section.
An Inexpensive +5-V Regulated Power Supply With Current Monitor
This simple power supply can be used to power most projects and experiments in this book. Figure 1-4 shows a schematic of a + 5-V power source capable of supplying at least 100 mA continually and more than twice this for short periods of time. You can use either a solderless breadboard or a printed circuit board for this power supply. Figure I -I provides two views of this circuit breadboard. If you breadboard the power supply, take care when inserting the LM293 1 T leads in the board-they are slightly on the large size.
If you get serious and make a printed circuit (PC) board for this power supply, follow Fig. 1-5 for the solder-side foil pattern. Figure 1-6 provides the component mounting guide so that you know which part goes where. For tips on making PC boards, see Appendix E.
If you do use a PC board, it is wise to lay down the LM293 IT and use a screw and nut to fasten it to the board. The reason for this is that the foil on the solder side aids in dissipating heat. If you are using the optional PR2 flashlight bulb in the circuit, first solder I in lengths of no. 22 wire to its two connections before inserting it in either the breadboard or the PC board.
Notice that this power supply uses an LM293 IT low-dropout regulator IC. Like the HC 11, this IC was designed originally for automotive applications and has a whole bunch of safeguards built in. According to the data sheet, this chip is almost impossible to destroy, even if you don't know what you are doing! For instance, the data sheet claims that you can connect the power supply backward or connect it to 25 V or even temporarily to 60 V and not only will blue smoke not be seen or an acrid burnt odor fill your sinuses, but the chip should still regulate nicely. This tiny piece of high-tech sand is supposed to act like nothing ever hit it! The manufacturers claim that you can even stick it in a circuit backward, and as long as you take it out before it starts smoking too much, no damage is done. Awesome! While I haven't been this rough on the chip, I have used it extensively without a problem. Did I mention that it also has short-circuit and thermal-overload protection and that its dropout voltage is typically less than 0.5 V?
Notice the optional PR2 flashlight bulb in the circuit. Its purpose is as a current monitor. If you omit the PR2, make sure you connect a jumper wire in its place. Under normal low-current operation, the PR2 should not glow. It takes about 100 mA to light the filament just a little. If you see the filament lit, shut the power down and check for trouble. There is no doubt that this bulb is quite useful-but it isn't as good as a milliammeter! Did I mention that it is cheap, though?
One caution when using the LM293 IT in your design: Make sure you connect at least a 100-iff capacitor across its output. This unusually large capacitor is required for stability...