TEAM LRN Analog and Digital Circuits for Electronic Control System Applications TEAM LRN This page intentionally left blank TEAM LRN Analog and Digital Circuits for Electronic Control System Applications Using the TI MSP430 Microcontroller by Jerry Luecke AMSTERDAM • BOSTON • HEIDELBERG • LONDON NEW YORK • OXFORD • PARIS • SAN DIEGO SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO Newnes is an imprint of Elsevier TEAM LRN Newnes is an imprint of Elsevier 200 Wheeler Road, Burlington, MA 01803, USA Linacre House, Jordan Hill, Oxford OX2 8DP, UK Copyright © 2005, Elsevier Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, e-mail: permissions@elsevier.
You may also complete your request on-line via the Elsevier homepage (http://elsevier.com), by selecting “Customer Support” and then “Obtaining Permissions.” Recognizing the importance of preserving what has been written, Elsevier prints its books on acid-free paper whenever possible. Library of Congress Cataloging-in-Publication Data Luecke, Gerald. Analog and digital circuits for electronic control system applications : using the TI MSP430 microcontroller / by Gerald Luecke. Electronic circuit design.8'9--dc22 2004054669 British Library Cataloguing-in-Publication Data A catalogue record for this book is available from the British Library.
For information on all Newnes publications visit our Web site at www.com 04 05 06 07 08 09 10 9 8 7 6 5 4 3 2 1 Printed in the United States of America. TEAM LRN The book is dedicated to my wife Velma and our grandchildren: From the Luecke side: Cameron, Graham, Andy, Alex, Alyssa, Brent, Jacob, Harper, Arielle, Emery. From the Hubbard side: Jared, Garrett, Matthew, Ashton, Audrey. TEAM LRN This page intentionally left blank TEAM LRN Contents Foreword .xiii What’s on the CD-ROM?.
xiv Chapter 1: Signal Paths from Analog to Digital. Speed—Analog and Digital .6 The Basic Functions for Analog-to-Digital Conversion .9 Chapter 2: Signal Paths from Digital to Analog .11 The Digital-to-Analog Portion .13 Conditioning the Signal .13 Transducing the Signal.18 Angular and Linear Position .32 Chapter 4: Signal Conditioning.35 Bipolar NPN Amplifier .36 Amplifier Frequency Response .40 Small-Signal vs.41 Classes of Amplifiers .42 Field-Effect Transistor Amplifiers .42 A N-Channel JFET Amplifier Design .43 An NPN MOSFET Amplifier .45 TEAM LRN vii Contents Operational Amplifiers .47 Conditioning the Output of a Pressure Sensor .50 A More Sophisticated Pressure Sensor Amplifier.52 Applications of Op Amps.53 Power Amplifiers .54 Class B Audio Power Amplifier .56 RC Time Constants .59 Typical Application of Filters .62 Chapter 5: Analog-to-Digital and Digital-to-Analog Conversions .66 Decimal Equivalent of a Binary Number .67 Digital Codes of ADC .67 A Resistor Network DAC .68 A Simple Resistor-String DAC .71 A Simple Current-Steering DAC .72 Analog-to-Digital Converters (ADC) .73 Successive Approximation Register (SAR) ADC .74 Capacitor Charge-Redistribution ADC .75 Highest Speed Conversions.78 Sample and Hold and Filters .80 Chapter 6: Digital System Processing .82 Digital Processor or Digital Computer .82 What is a Microprocessor?.86 What is a Microcomputer? .86 System Clarifications .86 Digital Signal Representations.90 Clock, Timing and Control Signals.92 More About Software .93 Sophisticated Programming Languages.95 How Parts of a Processor Perform Their Functions .95 Memory and Input/Output .100 Chapter 7: Examples of Assembly-Language Programming .103 A Processor for the Examples .103 About the MSP430 Family .104 TEAM LRN viii Contents Program Memory and Data Memory .106 Operation Control and Operating Modes .107 Oscillators and Clock Generators .109 More on MSP430 Control.131 Variation of Threshold .138 Chapter 8: Data Communications .142 The Data Transmission System.142 Parallel and Serial Transmission .144 High-Speed Data Transmissions .145 Serial Data Communications Advances .145 A Return to the Format .147 USART Serial Communications .148 The UART Function with Software.157 Chapter 9: System Power and Control .162 Actual Linear Voltage Regulator Circuit .164 Switching Voltage Regulators .165 Summary of Regulators .167 Power Supply Distribution .168 Power System Supervisors .170 TEAM LRN ix Contents Summary .171 Chapter 10: A Microcontroller Application .174 Application Block Diagram .179 The Analog Circuitry .181 Summary of Schematic .182 Breadboard Construction—Powered by the PC .185 The Display Board .189 The Analog Board .190 The Application Program .191 Creating a Project in IAR Workbench© .192 Compiling the Program .193 Loading the Program.194 The Stand-Alone Breadboard .194 The PCB Circuit.197 Appendix A: The MSP430 Instruction Set. 200 Appendix B: Standard Register and Bit Definitions for the MSP430 Microcontrollers. 260 Appendix C: Application Program for Use in Chapter 10.290 Decibel—A Quantity to Describe Gain .292 The Diode—A One-Way Valve for Current .294 Four Common Types .297 About the Author.
300 TEAM LRN x Foreword February 2004 The concept of a programmable system-on-chip (SoC) started in 1972 with the advent of the unassuming 4-bit TMS1000 microcomputer—the perfect fit for applications such as calculators and microwave ovens that required a device with everything needed to embed electronic intelligence. Microcomputers changed the way engineers approached equipment design; for the first time they could reuse proven electronics hardware, needing only to create software specific to the application. The result of microcomputer-based designs has been a reduction in both system cost and time-to-market. More than thirty years later many things have changed, but many things remain the same.
The term microcomputer has been replaced with microcontroller unit (MCU)—a name more descriptive of a typi- cal application. Today’s MCU, just like yesterday’s microcomputer, remains the heart and soul of many systems. But over time the MCU has placed more emphasis on providing a higher level of integration and control processing and less on sheer computing power. The race for embedded computing power has been won by the dedicated digital signal processor (DSP), a widely used invention of the ‘80s that now domi- nates high-volume, computing-intensive embedded applications such as the cellular telephone.
But the design engineer’s most used tool, when it comes to implementing cost effective system integration, remains the MCU. The MCU allows just the right amount of intelligent control for a wide variety of applications. Today there are hundreds of MCUs readily available, from low-end 4-bit devices like those found in a simple wristwatch, to high-end 64-bit devices. But the workhorses of the industry are still the versatile 8/16-bit architectures.
Choices are available with 8 to 100+ pins and program memory ranging from <1 KB to >64 KB. The MCU’s adoption of mixed-signal peripherals is an area that has greatly expanded, recently enabling many new SoC solutions. It is common today to find MCUs with 12-bit analog-to-digital and digi- tal-to-analog converters combined with amplifiers and power management, all on the same chip in the same device. This class of device offers a complete signal-chain on a chip for applications ranging from energy meters to personal medical devices.
Modern MCUs combine mixed-signal integration with instantly programmable Flash memory and embed- ded emulation. In the hands of a savvy engineer, a unique MCU solution can be developed in just days or weeks compared to what used to take months or years. You can find MCUs everywhere you look from the watch on your wrist to the cooking appliances in your home to the car you drive. An estimated 20 million MCUs ship every day, with growth forecast for at least a decade to come.
The march of increasing silicon integration will continue offering an even greater variety of available solutions—but it is the engineer’s creativity that will continue to set apart particular system solutions. Buccini Director of Marketing MSP430 Texas Instruments Incorporated TEAM LRN xi Preface Analog system designers many times in the past avoided the use of electronics for their system functions because electronic circuits could not provide the dynamic range of the signal without severe nonlinearity, or because the circuits drifted or became unstable with temperature, or because the computations using analog signals were quite inaccurate. As a result, the design shifted to other disciplines, for example, mechanical. Today, young engineers requested by their superiors to design an analog control system, have an entirely new technique available to them to help them design the system and overcome the “old” problems.
The de- sign technique is this: sense the analog signals and convert them to electrical signals; condition the signals so they are in a range of inputs to assure accurate processing; convert the analog signals to digital; make the necessary computations using the very high-speed IC digital processors available with their high accuracy; convert the digital signals back to analog signals; and output the analog signals to perform the task at hand. Analog and Digital Circuits for Control System Applications: Using the TI MSP430 Microcontroller explains the functions that are in the signal chain, and explains how to design electronic circuits to perform the func- tions. Included in this book is a chapter on the different types of sensors and their outputs. There is a chapter on the different techniques of conditioning the sensor signals, especially amplifiers and op amps.
There are techniques and circuits for analog-to-digital and digital-to-analog conversions, and an explanation of what a digital processor is and how it works. There is a chapter on data transmissions and one on power control. And to solidify the learning and applications, there is a chapter that explains assembly-language program- ming, and also a chapter where the reader actually builds a working project. These two chapters required choosing a digital processor.
The TI MSP430 microcontroller was chosen because of its design, and because it is readily available, it is well supported with design and applications documentation, and it has relatively inexpensive evaluation tools. The goal of the book is to provide understanding and learning of the new design technique available to analog system designers and the tools available to provide system solutions. TEAM LRN xii Acknowledgments Mark Buccini, Product Line Marketing Manager for the MSP430 in the Semiconductor Group for Texas Instruments Incorporated and his staff deserve much credit for the project in Chapter 10, and for the thoroughness and accuracy of the MSP430 information. Special thanks go to Neal Frager, an applications expert, for writing the program for the Chapter 10 project, for designing the PCB breadboard, arranging meetings and for researching many inquiries as the book developed.
Others that deserve mention for their assistance: Cornelia Huellstrunk, Byron Alsberg who helped develop the initial schematic, Dale Wellborn, Dan Harmon, Rajen Shah, Zack Albus, Modupe Ajibola, Mike Mitchell for his excellent reviews, and Neal Brenner and for helping clean up the last details. A hearty “Thank You” to all! TEAM LRN xiii What’s on the CD-ROM? ■ A fully searchable eBook version of the text in Adobe PDF format. It includes: Full text of ten chapters. Appendix A — The MSP430 Instruction Set.
Appendix B — Standard Register and Bit Definitions for the MSP430 Microcontrollers. Appendix C — Application Program for Use in Chapter 10. ■ A user’s guide to the MSP430x1xx family of microcontrollers. ■ Layout wiring of PCB interconnection layers.
TEAM LRN xiv CHAPTER 1 Signal Paths from Analog to Digital Introduction Designers of analog electronic control systems have continually faced the following obstacles in arriving at a satisfactory design: 1. Instability and drift due to temperature variations. Dynamic range of signals and nonlinearity when pressing the limits of the range. Inaccuracies of computation when using analog quantities.
Adequate signal frequency range. Today’s designers, however, have a significant alternative offered to them by the advances in integrated circuit technology, especially low-power analog and digital circuits. The alternative new design technique for analog systems is to sense the analog signal, convert it to digital signals, use the speed and accuracy of digital circuits to do the computations, and convert the resultant digital output back to analog signals. The new design technique requires that the electronic system designer interface between two distinct design worlds.
First, between analog and digital systems, and second, between the external human world and the internal electronics world.