Analog And Digital Circuits For Electronic Control System .

Transcription

TEAM LRN

Analog and Digital Circuits forElectronic Control System ApplicationsTEAM LRN

This page intentionally left blankTEAM LRN

Analog and Digital Circuits forElectronic Control System ApplicationsUsing the TI MSP430 MicrocontrollerbyJerry LueckeAMSTERDAM BOSTON HEIDELBERG LONDONNEW YORK OXFORD PARIS SAN DIEGOSAN FRANCISCO SINGAPORE SYDNEY TOKYONewnes is an imprint of ElsevierTEAM LRN

Newnes is an imprint of Elsevier200 Wheeler Road, Burlington, MA 01803, USALinacre House, Jordan Hill, Oxford OX2 8DP, UKCopyright 2005, Elsevier Inc. All rights reserved.No part of this publication may be reproduced, stored in a retrieval system, ortransmitted 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 RightsDepartment in Oxford, UK: phone: ( 44) 1865 843830, fax: ( 44) 1865 853333,e-mail: permissions@elsevier.com.uk. You may also complete your request on-linevia the Elsevier homepage (http://elsevier.com), by selecting “Customer Support”and then “Obtaining Permissions.”Recognizing the importance of preserving what has been written, Elsevier printsits books on acid-free paper whenever possible.Library of Congress Cataloging-in-Publication DataLuecke, Gerald.Analog and digital circuits for electronic control system applications : using the TIMSP430 microcontroller / by Gerald Luecke.p. cm.ISBN 0-7506-7810-01. Electronic circuit design. 2. Electronic control. 3. Programmable controllers. I. Title.TK7867.L84 2004629.8'9--dc222004054669British Library Cataloguing-in-Publication DataA catalogue record for this book is available from the British Library.For information on all Newnes publicationsvisit our Web site at www.books.elsevier.com04 05 06 07 08 09 10 9 8 7 6 5 4 3 2 1Printed 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 blankTEAM LRN

ContentsForeword . xiPreface .xiiAcknowledgments .xiiiWhat’s on the CD-ROM? . xivChapter 1: Signal Paths from Analog to Digital . 1Introduction .1A Refresher .1Accuracy vs. Speed—Analog and Digital .5Interface Electronics .6The Basic Functions for Analog-to-Digital Conversion .6Summary .8Chapter 1 Quiz .9Chapter 2: Signal Paths from Digital to Analog . 11Introduction .11The Digital-to-Analog Portion .11Filtering .13Conditioning the Signal .13Transducing the Signal.13Summary .15Chapter 2 Quiz .16Chapter 3: Sensors . 18Introduction .18Temperature Sensors .18Angular and Linear Position .21Rotation .24Magnetoresistor Sensor.24Pressure .25Light Sensors .27Other Sensors .32Summary .32Chapter 3 Quiz .32Chapter 4: Signal Conditioning. 35Introduction .35Amplification .35Bipolar NPN Amplifier .36Amplifier Frequency Response .39Coupling.40Small-Signal vs. Large Signal.41Classes of Amplifiers .42Field-Effect Transistor Amplifiers .42A N-Channel JFET Amplifier Design .43An NPN MOSFET Amplifier .45TEAM LRNvii

ContentsOperational Amplifiers .47Conditioning the Output of a Pressure Sensor .50A More Sophisticated Pressure Sensor Amplifier.51Current Mirror.52Applications of Op Amps.53Oscillators .53Power Amplifiers .54Class B Audio Power Amplifier .56Special Signals .56RC Time Constants .58Frequency Selection .59Typical Application of Filters .61Summary .62Chapter 4 Quiz .62Chapter 5: Analog-to-Digital and Digital-to-Analog Conversions . 66Introduction .66Decimal Equivalent of a Binary Number .67Digital Codes of ADC .67A Resistor Network DAC .68A Simple Resistor-String DAC .71A Simple Current-Steering DAC .72Analog-to-Digital Converters (ADC) .73Successive Approximation Register (SAR) ADC .74Capacitor Charge-Redistribution ADC .75Highest Speed Conversions.78Sample and Hold and Filters .78Summary .79Chapter 5 Quiz .80Chapter 6: Digital System Processing . 82Introduction .82Digital Processor or Digital Computer .82What is a Microprocessor?.86What is a Microcomputer? .86System Clarifications .86Digital Signal Representations.90Clock, Timing and Control Signals.90Interrupts .92Status Bits .92More About Software .93Sophisticated Programming Languages.95How Parts of a Processor Perform Their Functions .95Memory and Input/Output .97Addressing Modes .97Summary .99Chapter 6 Quiz .100Chapter 7: Examples of Assembly-Language Programming . 103Introduction .103A Processor for the Examples .103About the MSP430 Family .103The CPU.104TEAM LRNviii

ContentsProgram Memory and Data Memory .105Peripherals.106Operation Control and Operating Modes .106Watchdog Timer .106System Reset .107Interrupts .107Oscillators and Clock Generators .107Timers .109Addressing Modes .109More on MSP430 Control.110Further Thoughts .114Labels .117Instructions.117Operands .117Hexadecimal Numbers .117Comments .118Programming Examples .118Subprogram No. 1 .118Subprogram No. 2 .127Subprogram No. 3 .131Variation of Threshold .137Summary .137Chapter 7 Quiz .138Chapter 8: Data Communications . 142Introduction .142The Data Transmission System.142Parallel and Serial Transmission .142Protocols .144High-Speed Data Transmissions .145Serial Data Communications Advances .145A Return to the Format .145Shift Registers .147USART Serial Communications .148The UART Function with Software. .150Technology Advances .150I2C Protocol .150USB .152Summary .156Chapter 8 Quiz .157Chapter 9: System Power and Control . 160Introduction .160Voltage Regulators .161Load Variations .162Actual Linear Voltage Regulator Circuit .163Voltage Regulation .163Power Dissipation .164Switching Voltage Regulators .165Summary of Regulators .167Power Supply Distribution .168Power System Supervisors .170TEAM LRNix

ContentsSummary .171Chapter 9 Quiz .171Chapter 10: A Microcontroller Application . 174Introduction .174Application Block Diagram .174System Schematic .177The Display .177The Microcontroller .179The Analog Circuitry .180JTAG .181Summary of Schematic .182System Development .182Breadboard Construction—Powered by the PC .185The Display Board .189The Analog Board .190The Application Program .191Creating a Project in IAR Workbench .192Compiling the Program .193Loading the Program.194Troubleshooting .194The Stand-Alone Breadboard .194The PCB Circuit.195Summary .197Chapter 10 Quiz .197Appendix A: The MSP430 Instruction Set . 200Appendix B: Standard Register and Bit Definitions for the MSP430 Microcontrollers. 260Appendix C: Application Program for Use in Chapter 10. 273Appendix D: A Refres

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 desig