Download EPE Online Magazine
Transcript
EPE Tutorial Series TEACH-IN 2006 Part Ten – PICs and Operational Amplifiers. MIKE TOOLEY BA Our Teach-In 2006 series provides a broad-based introduction to electronics for the complete newcomer. The series also provides the more experienced reader with an opportunity to “brush up” on topics which may be less familiar. This month we shall be looking at two very different integrated circuit devices that have both had a huge impact on the world of electronics, the PIC microcontroller and the operational amplifier (op amp). These deceptively simple devices have found their way into a wide variety of electronic applications and both deserve a special mention in our Teach-In series. PIC Microcontrollers Last month, we introduced the notion of the microcontroller as a device that can form the basis of a stand-alone (or embedded) electronic application that can perform a variety of programmed functions. A PIC is just such a microcontroller device and it provides a flexible low-cost solution to bridge the gap between single-chip computers and the use of large numbers of discrete logic and other chips. PIC microcontrollers are being increasingly used in “self-contained” applications involving logic, timing and simple analogue-to-digital and digital-to-analogue conversion. PIC microcontrollers first became popular more than a decade ago. Since then the range and power of these devices has increased dramatically. Nowadays, a PIC device exists for almost any embedded application, from small 6-pin devices ideal for simple control applications, through to powerful high-speed devices packed with diverse I/O (input/output) features and large amounts of program memory. PICs are based on RISC (Reduced Instruction Set Computer) architecture and, as a consequence, they use a relatively small number of instructions. In fact, some PIC chips have as few as 33 instructions compared with some general-purpose microprocessors (such as the Z80 that we met last month) that may have several hundred. Because it is only necessary to remember a small number of commands, it is relatively easy to learn to program a PIC using its own assembly language (note, however, that it may take several instructions to achieve on a PIC what can be done in a single instruction using a fully-fledged microprocessor). And, if you don’t like the idea of having to learn assembly code programming you can make use of high-level languages such as C, BASIC or Flowcode (a language based almost entirely on flowcharts). Program memory can be ROM, 42 PROM or Flash memory. Data memory, on the other hand, must be read/write memory (commonly known as RAM – see last month). As mentioned last month, mainstream microprocessors (like the Z80) are often classified by the number of data bits that they can manipulate (i.e. the “width” of the data bus). This can be either 8-, 16-, 32-, 64- or 128-bits. PIC microcontrollers, by contrast, are all based on an 8-bit data bus and, because of this, they can only operate on 8-bits of data at a time (despite this, you will sometimes encounter program instructions that reference data in 12-, 14-, and 16-bit units). The program memory of a PIC usually varies in width from 12-bits to 16-bits. PIC Families In the early 1990s, PIC microcontrollers were grouped in three families, often referred to as “Base-Line”, “Mid-Range”, and “High-End”. Unfortunately, many of these devices are incompatible with the latest PIC development platforms and software tools. Despite this, it is usually possible to locate a modern device that is compatible with (and will generally outperform) one of these early devices. Another important feature of modern PIC devices is the use of electrically erasable and programmable Flash memory for program storage. These Flash memory devices are often denoted by the use of the letter “F” as part of the device coding (e.g. PIC16F877A). Note, as we shall see later, Flash devices are much easier to work with for one-off prototyping because erasure and reprogramming is greatly simplified. Choosing a PIC Device When choosing a PIC device for a particular project it is important to select a device that is well supported, both in terms of being a member of one of the current PIC families but also in relation to the programming environment that you intend to use for software development. It is also important to ensure that the device incorporates all of the peripheral I/O facilities that you will need. These features might include: Communication interfaces (such as RS232/RS485, USB, etc) Display peripheral interfaces (such as LED or LCD drivers) Capture/compare facilities Pulse Width Modulators (PWM) Counters/timers Watchdog facilities Analogue-to-digital (A/D) converters Analogue comparators and operational amplifiers Brown-out detectors Low-voltage detectors Temperature sensors Oscillators Voltage references Digital-to-analogue (D/A) converters. The PIC16F84 The PIC16F84 is an excellent example of a simple PIC device for use with a wide variety of simple microcontroller projects. The chip offers the following features: 35 single-word instructions 1K × 14-bit EEPROM (Flash) program memory 68 × 8-bit general purpose static RAM registers 15 × 8-bit special function hardware registers 64 × 8-bit EEPROM data memory 1,000,000 data memory erase/write cycles (typical) Data retention > 40 years 5 data input/output pins (Port A) 8 data input/output pins (Port B) 25mA current sink maximum per pin 20mA current source per pin 8-bit timer/counter with pre-scaler Power-on reset (POR) Everyday Practical Electronics, August 2006