American library books ยป Other ยป Make: Electronics by Charles Platt (read me a book .TXT) ๐Ÿ“•

Read book online ยซMake: Electronics by Charles Platt (read me a book .TXT) ๐Ÿ“•ยป.   Author   -   Charles Platt



1 ... 108 109 110 111 112 113 114 115 116 ... 122
Go to page:
values of variables on a temporary basis, and ROM, which tells it how to perform tasks such as sensing a varying voltage input and converting it into digital form for internal use. It also contains an accurate oscillator, so that it can keep track of time. Put it all together, and itโ€™s a tiny computer that you can buy for under $5.

Letโ€™s suppose that you have a greenhouse where the temperature must never fall below freezing. You set up a temperature sensor, and you have two different heaters. You want to switch on the first heater if the temperature falls below 38ยฐ Fahrenheit. But if, for some reason, that heater is broken, you want to switch on the second, backup heater when the temperature goes below 36ยฐ Fahrenheit.

Programming a MCU to take care of this can be very simple indeed. You could even add extra features, such as a second temperature sensor, just in case the first one fails, and you could tell the chip to use whichever sensor gives a lower reading.

Another application for a MCU would be in a fairly elaborate security system. The chip could monitor the status of various intrusion sensors, and can take various preprogrammed steps, depending on the sensorsโ€™ status. You could include delay intervals, too.

Many MCUs have additional useful features built in, such as the ability to control servo motors that turn to a specific angle in response to a stream of pulses. Servos are widely used in radio-controlled model boats, airplanes, and hobby robotics.

Perhaps you are now wondering why, if MCUs can do all this, havenโ€™t we been using them all along? Why did I spend so much time describing the development of an alarm system using discrete components, if one chip could have done everything?

There are three answers:

1. MCUs cannot do everything. They need other components to help them interact with the world, such as transistors, relays, sensors, and amplifiers. You need to know how those things work, so that you can make intelligent use of them.

2. MCUs can introduce their own kinds of problems and errors, associated with using software in addition to hardware. Iโ€™ll have more to say about this later.

3. MCUs have limits and restrictions, most obviously their requirement for a 5-volt regulated power supply, and their inability to source or sink much current from each pin. They also demand that you learn a programming language (which differs from one brand of MCU to the next). And to get the program into the chip, you have to be able to plug it into a computer and do a download, which is not always convenient.

In this experiment, youโ€™ll learn how to write a program for a small and simple MCU, and youโ€™ll transfer the program into it and see how it works.

Background

Origins of programmable chips

In factories and laboratories, many procedures are repetitive. A flow sensor may have to control a heating element. A motion sensor may have to adjust the speed of a motor. Microcontrollers are perfect for this kind of routine task.

A company named General Instrument introduced an early line of MCUs in 1976, and called them PICs, meaning Programmable Intelligent Computerโ€”or Programmable Interface Controller, depending which source you believe. General Instrument sold the brand to another company named Microchip Technology, which owns it today.

โ€œPICโ€ is trademarked, but is sometimes used as if itโ€™s a generic term, like Scotch tape. In this book, Iโ€™ve chosen a range of controllers based on the PIC architecture. They are licensed by a British company named Revolution Education Ltd., which calls its range of chips the PICAXE, for no apparent logical reason other than that it sounds cool.

I like these microcontrollers because they were developed originally as an educational tool and because they are very easy to use. Theyโ€™re cheap, and some of them are quite powerful. Despite their odd name, I think theyโ€™re the best way to get acquainted with the core concepts of MCUs.

After you play with the PICAXE, if you want to go farther into MCUs, I suggest the BASIC Stamp (which uses a very similar language, but with additional powerful commands) and the very popular Arduino (which is a more recent design, packed with powerful features, but requires you to learn a variant of C language to program it). Iโ€™ll say more about these chips later.

If you search for โ€œpicaxeโ€ on Wikipedia, youโ€™ll find an excellent introduction to all the various features. In fact, I think itโ€™s a clearer overview than youโ€™ll get from the PICAXE website.

Supplies

Figure 5-122 shows some of the chips in the PICAXE range. Iโ€™ll be telling you how to use the smallestโ€”the 08Mโ€”which costs less than $5 and is cheaper than any other MCU that Iโ€™ve found. It has only 256 bytes of memory to store a program (not gigabytes, megabytes, or kilobytes, just 256 bytes!), but youโ€™ll be surprised how many possibilities this amount allows for. Figure 5-123 shows a closeup of the 08M with its legs safely embedded in a piece of conductive foam.

Figure 5-122. A page from the PICAXE catalog lists only some of the chips that are available. What began as an educational aid has become a useful prototyping tool.

In the United States, there are three distributors of this chip:

http://www.advancedmicrocircuits.com

http://www.phanderson.com/picaxe

http://www.sparkfun.com

I like P. H. Anderson for its grass-roots hobbyist approach, and they have good prices if you want to buy multiple chips. But SparkFun Electronics offers other associated products that you may find interesting.

All the distributors will want to sell you โ€œstarter kits,โ€ such as the one in Figure 5-124, perhaps because the PICAXE itself is so cheap that it doesnโ€™t offer much of a profit margin. Still, for our purposes, you should buy the chip as a standalone item. And buy two of them, just in case you damage one (for example, by connecting voltage to it incorrectly).

Figure 5-123. When supplied by one of its American distributors, a PICAXE 08M arrives embedded in a little square of conductive foam. The chip is the same size as

1 ... 108 109 110 111 112 113 114 115 116 ... 122
Go to page:

Free e-book: ยซMake: Electronics by Charles Platt (read me a book .TXT) ๐Ÿ“•ยป   -   read online now on website american library books (americanlibrarybooks.com)

Comments (0)

There are no comments yet. You can be the first!
Add a comment