CU-Boulder PHYS 3330 - Digital Electronics II: Microcontrollers

Unformatted text preview:

Physics 3330 Experiment #10 Fall 2005 Experiment #10 10.1 Fall 2005 Digital Electronics II: Microcontrollers Purpose In this experiment we introduce microcontrollers, powerful single-chip computers that can be programmed to perform almost any digital task. Introduction Let’s suppose you want to build something more complex than the digital circuits we studied in the previous experiment. For example, you might have a Wheatstone bridge and a null detector that you want to hook up to a computer so you can automatically balance the bridge and record the null point, maybe with an adjustable excitation voltage for the bridge. Or, say you want to build a tiny battery powered data transmitter to feed to a dolphin and find out how his body temperature varies while he’s swimming around in the ocean. Since it’s hard to transmit signals through a dolphin, the transmitter should store the temperature data until it is excreted by the dolphin and floats to the surface where your receiver can detect the signal. These and many other applications require complex digital circuitry. Any digital system, including a programmable computer, can be built by combining the gates and flip-flops we discussed in the previous experiment. But it is hardly practical to build something like a computer by connecting together a bunch of TTL chips, since you could easily require thousands or even millions of gates. There are much better ways to get the job done. In fact, if you find yourself using more than a few discrete logic gates in a circuit you are probably making a mistake. As a scientist you should generally try to avoid building anything digital. The first example above could be handled by a PC with data acquisition cards and a power supply with a computer interface. For the potentiometer of the bridge you could use a digital potentiometer or a stepper motor driving an analog pot, both of which can be connected to a computer with commercial hardware. However, for the second example you would probably have to build everything from scratch. There are three general approaches to building complex digital circuits: application specific integrated circuits (ASICs), programmable logic devices (PLDs), and microcontrollers. ASIC is a general term for any complex integrated circuit that is devoted to a very specific task. Examples are chips designed for cell phones, TV sets, or controllers for liquid crystal displays. Generally, ASICs are designed to serve large commercial markets, and so you won’t find anything that will be much help for the two applications mentioned above, or for most scientificExperiment #10 10.2 Fall 2005 applications. But if there is an ASIC that does what you need to do, or that can be adapted to your task, you should certainly use it. If you have a really large project with at least a million dollars to spend you could make a custom ASIC that does just what you want. ASIC manufacturers have many ready-to-go design elements (called standard cells), including complete computer processors, digital filters, counters and timers, memories and so forth, so you can generally avoid having to do much gate-level design work. In many cases it is possible to include analog circuitry as well, such as output drivers or ADCs. ASICs (and also programmable logic) are commonly used in high energy physics experiments. Check this link www.hep.anl.gov/elec_support/ for several examples. Assuming there is no ASIC that does what you need and you can’t afford a custom ASIC, you might consider programmable logic devices. These are chips containing many logic gates, and in most cases also flip-flops, that can be programmed (usually once) to interconnect the gates and flip-flops in a way that performs a custom function (see H&H 8.15, 8.27). A single PLD can replace a large pile of TTL chips, and the smaller PLDs containing a few thousand gates are inexpensive and relatively easy to program. The largest PLDs can contain 300,000 gates or more, and the programming effort can become a major project. By far the most common approach to complex digital design is to use a microcontroller, a single chip programmable computer. Compared to programmable logic, microcontrollers process data more slowly but with much greater flexibility and power, and they are generally cheaper and more power efficient. They are available in incredible variety, from 8-pin versions costing less than a dollar to devices with processing power rivaling that of a PC. A given device may offer only digital input and outputs pins (I/O pins), or may include analog comparators or even ADCs. Modern versions usually contain their own program and data memory, and some have programmable non-volatile memory so they can remember what they were doing before the power went out. There are many specialized varieties of microcontroller, including DSP chips (digital signal processor) that can implement fast digital filters and Fourier transforms, and devices that include high-level digital interfaces, such as Ethernet or USB. To get an idea of the variety available, have a look at some of the manufacturer’s web sites (Microchip at www.microchip.com; Motorola at www.freescale.com; Rabbit Semi at www.rabbitsemiconductor.com). In this experiment, we will take a look at the 14-pin Microchip PIC16F676. It is a member of the Microchip PIC x14 processor family, with 1024 words of 14-bit wide program memory and 64 bytes of 8 bit data memory. The data and program memories are completely separate, making this a ‘Harvard architecture’ processor. Program memory uses the latest ‘flash’ technology, soExperiment #10 10.3 Fall 2005 you can program it over and over again as you debug your hardware and code, and it is non-volatile, so the chip won’t forget its programming when you turn the power off. Programming can be done without taking the chip out of your circuit via a serial digital interface that Microchip calls ICSP (In-Circuit Serial Programming). Besides program and data memory, there are 128 bytes of non-volatile data memory that can be programmed by the processor to remember the state of your system when power is off. Nearly every pin of the chip can be programmed in multiple ways for various uses, and up to 12 of the 14 pins can be used as bi-directional digital I/O. There is an internal variable frequency clock and two separate timer/counter/scalers. For dealing with analog signals there is a comparator


View Full Document

CU-Boulder PHYS 3330 - Digital Electronics II: Microcontrollers

Download Digital Electronics II: Microcontrollers
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Digital Electronics II: Microcontrollers and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Digital Electronics II: Microcontrollers 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?