Microcomputer Control of Thermal and Mechanical Systems

11
Microcomputer Control of Thermal and Mechanical Systems W. F. Stoecker University of Illinois at Urbana-Champaign P. A. Stoecker Hewlett-Packard Company ШЕ VAN NOSTRAND REINHOLD New York

Transcript of Microcomputer Control of Thermal and Mechanical Systems

Microcomputer Control of Thermal and Mechanical

Systems

W. F. Stoecker University of Illinois at Urbana-Champaign

P. A. Stoecker Hewlett-Packard Company

ШЕ VAN NOSTRAND REINHOLD New York

Contents 1 Microcomputer Control 1

1-1 The Penetration of Microprocessors into Engineering Fields 1 1-2 The Path by which Microcomputer Control Has Grown . . . 2 1-3 Chemical and Process Industries 3 1-4 Environmental Control of Buildings 4 1-5 Automobiles о 1-6 Home Appliances 6 1-7 Computer Control in Manufacturing 7 1-8 Electric Power Generation and Regulation 7 1-9 Agricultural Applications of Computer Control 8 1-10 What the Engineer Who Applies Computers Needs to Know 8 References 9

2 DC Circuits and Power Supplies 11 2-1 Understanding Circuits 11 2-2 Kirchhoff's Laws 11 2-3 Thevenin Equivalent 12 2-4 Norton Equivalent 14 2-5 RC Circuits 16 2-6 Resistors 18 2-7 Diodes 20 2-8 Rectifying Circuit 22 2-9 Voltage Ripple 23 2-10 Commercial Power Supplies 24 2-11 Voltage Regulators 24 Problems 25

3 Operational Amplifiers 29 3-1 Application of Operational Amplifiers 29 3-2 Basic Characteristic of the Op Amp 30 3-3 Comparator 30 3-4 Inverting Amplifier 30 3-5 Choice of Resistances 32 3-6 Non-inverting Op Amp 32 3-7 Buffer or Follower Amp 33 3-8 Signal Conditioning 33

ix

x Contents

3-9 Summing and Multiplying Amplifier 34 3-10 Generalized Circuit for an Op Amp 36 3-11 Integrator 37 3-12 Pin Diagram of 741 Op Amp 39 3-13 Limitations and Ratings of the Op Amp 40 General References 41 Problems 41

4 Transistors 45 4-1 Impact of the Transistor 45 4-2 Symbols and Terminology 45 4-3 Current Characteristics 47 4-4 Bipolar-Junction and Field-Effect Transistors 49 4-5 Voltages at the Transistor Terminals 49 4-6 Voltage Amplifier 49 4-7 Transistor as a Switch, and Saturating the Transistor . . . . 51 4-8 Common Emitter and Common Collector Circuits 52 4-9 Zener Diode 53 4-10 Constant-Current Source 54 4-11 Designing a Constant-Current Source 55 4-12 Operating Limits of a Transistor 56 4-13 Transistor Packages 57 References 58 Problems 58

5 Transducers 61 5-1 Importance of Good Instrumentation 61 5-2 Thermocouples 62 5-3 Thermocouple Reference Junction 63 5-4 Metal and Thermistor Resistance-Temperature Devices . . . 63 5-5 Series Circuit 64 5-6 Bridge Circuits 67 5-7 Amplification of a Bridge Output 69 5-8 RTD Circuits Supplied with Constant Current 70 5-9 Temperature-Dependent Integrated Circuits 71 5-10 Application of Sensors—Liquid Temperature 71 5-11 Application of Sensors—Temperature of Air and Other Gases 75 5-12 An Overview of Temperature Sensors and Transducers . . . 77 5-13 Flow Rate and Velocity Measurement 78 5-14 Venturi Tubes Liquid Flow Measurement 79 5-15 Orifice Liquid Flow Measurement 81

Contents xi

5-16 Flow Measurement of a Compressible Fluid in a Venturi or Orifice 83

5-17 Pitot Tubes 85 5-18 Hot-Wire Anemometer 85 5-19 Turbine Flow Meter 86 5-20 Ultrasonic Flow Meters 86 5-21 Vortex-Shedding Flow Meters 87 5-22 Evaluation of Flow-Measuring Devices 89 5-23 Pressure Transducers 90 5-24 Evaluation of Types of Pressure Transducers 90 5-25 Force 91 5-26 Torque 91 5-27 Electric Current 91 5-28 Humidity Sensors 92 5-29 Chemical Composition 92 5-30 Liquid Level 93 5-31 Position and Motion Sensors 94 5-32 Rotative Speed 97 5-33 How to Choose Transducers 97 References 98 General References 99 Problems 99

6 Actuators 105 6-1 Actuators for Computer Control Systems 105 6-2 Two-Position DC Electric Switch 106 6-3 Silicon-Controlled Rectifier (SCR) for DC Switching 107 6-4 Triac Alternating Current Switching 108 6-5 Optically Isolated Switch 110 6-6 Solid-State Relays 110 6-7 Electric-Motor Actuators 112 6-8 Magnetic Operator 113 6-9 Hydraulic Actuator 114 6-10 Pneumatic Valve and Damper Operators 114 6-11 Electric-to-Pneumatic Transducer 115 6-12 Stepping Motors 115 6-13 Performance of Stepping Motors 118 References 121 Problems 121

xii Contents

7 Binary Numbers and Digital Electronics 123 7-1 Transition to Digital Electronics 123 7-2 Binary Numbers 124 7-3 Conversion between Binary and Decimal Numbers 125 7-4 Addition of Binary Numbers 126 7-5 Basic Logic Operations 126 7-6 OR Gate 127 7-7 AND Gate 127 7-8 Inverter 128 7-9 NOT-OR (NOR) Gate 128 7-10 NOT-AND (NAND) Gate 129 7-11 Exclusive-OR (XOR) Gate 129 7-12 Combining and Cascading Gates 129 7-13 De Morgan's Laws 130 7-14 Gate Chips 131 7-15 Ladder Diagrams for Conditional and Sequential Control . . 131 7-16 Ladder Diagram Using Gates 135 7-17 Sequential Logic Circuits 137 7-18 Binary Addition with Gates 137 7-19 Pull-Up Resistor 138 7-20 Three Classes of Outputs Found on Inverters and Buffer

Gates 139 7-21 Debounced Switch 141 7-22 Clocks and Oscillators 142 7-23 Flip-Flops 143 7-24 Divide-By Counters 144 7-25 Schmitt Trigger 145 7-26 Monostable Multivibrator 148 7-27 Low-Frequency Pulses 148 7-28 Latches 149 7-29 Comparators 150 7-30 Analog Switches Field-Effect Transistors 150 7-31 Binary-Coded Decimal (BCD) 151 7-32 Seven-Segment LEDs 151 7-33 Summary 153 General References 153 Problems 154

8 Conversion Between Digital and Analog 159 8-1 Elements of a Microcomputer Controller 159 8-2 A Simple DAC 160 8-3 DAC Using R-2R Ladder Circuit 162

Contents xiii

8-4 The 1408 DAC 163 8-5 Applying the 1408 DAC 165 8-6 Multiplexers 167 8-7 Fidelity of Voltage Transmission Through a MUX 169 8-8 Sample-and-Hold Circuits 170 8-9 Operating Sequence with Multichannel Control 172 8-10 Where Analog-to-Digital Conversion Is Needed 173 8-11 Internal Functions of One Class of ADCs 174 8-12 More Complete Description of the Internal Functions of an

ADC 175 8-13 Staircase and Successive Approximation Search Routines

and Dual-Slope Integration 176 8-14 Pin Diagram of an 8-Bit ADC 177 8-15 Characteristics of the ADC 0800 178 8-16 Analog-to-Digital Conversion Using a DAC in Combination

with Software 180 8-17 Choosing the ADC 180 Problems 182

9 Memories 185 9-1 Function and Types of Memories 185 9-2 ROMs 186 9-3 EPROMs 187 9-4 RAMs 187 9-5 The MCM6810 RAM 189 9-6 Four-Bit RAMs the MCM2114 190 9-7 Dynamic RAMs 192 9-8 EEPROMs 192 9-9 Memories on the Microcomputer 192 General References 193 Problems 193

10 Binary Arithmetic 195 10-1 The Eight-Bit Microcomputer 195 10-2 Two's Complement Arithmetic—Subtraction 195 10-3 Multiplication 196 10-4 Hexadecimal System 197 10-5 Labeling Conventions 197 10-6 Signed and Unsigned Numbers 198 10-7 Unsigned Numbers The Carry Flag 200 10-8 Signed Numbers—Two's Complement Overflow 204 10-9 Status Registers on Microprocessors 206

xiv Contents

References 207 Problems 208

11 Programming a Microprocessor 209 11-1 A Generic Microprocessor 209 11-2 Data and Address Buses in a Generic Microcomputer . . . . 209 11-3 The Accumulator with its Arithmetic, Logic, and Transfer

Operations 210 11-4 The Fetch-Decode-Execute Sequence 211 11-5 Preliminary Instruction Set 212 11-6 Program Counter 214 11-7 Status Register and Jumps 214 11-8 Another Accumulator Incrementing and Decrementing . . 217 11-9 Additional Addressing Modes 218 11-10 The Index Register and the Use of Register Addressing . . . 219 11-11 Subroutines and the Stack 221 11-12 The Intel 8080/8085 Microprocessor 222 11-13 Loading Into and Storing From the Accumulator 228 11-14 Forms of Addressing on the 8080/8085 228 11-15 Flag Register 229 11-16 Subroutines 231 11-17 The 8080/8085 Programming Guide 232 11-18 The Motorola 6800 Family 232 11-19 Registers in the 6800 Microprocessor 232 11-20 The Instruction Set of the 6800 234 11-21 Condition Codes 237 11-22 Forms of Addressing 238 11-23 Branches—Relative Addressing 238 11-24 Index Register—Indexed Addressing 240 11-25 Loops 240 11-26 Stack Pointer 242 11-27 Subroutines 243 11-28 The 6800 Microprocessor Programming Guide 243 11-29 Summary 244 References 246 Problems 246

12 Assembly Language Programming 249 12-1 Machine Language; and Assembly Language 249 12-2 An Overview of the Assembly Process 249 12-3 Major Components of the Program 250 12-4 Assembly Language Statements 251

Contents xv

12-5 Assembler Directives 253 12-6 The Location Counter 254 12-7 Using Assembler Labels and Symbols 255 12-8 Relocating Assemblers and Loaders 257 12-9 The Operation of an Assembler 258 References 259 Problems 259

13 The Structure of an Elementary Microcomputer 261 13-1 Definition of an Elementary Microcomputer 261 13-2 The Bus Structure 262 13-3 Flow of Information on the Buses During Execution of a

Program 263 13-4 The Intel 8080 Microprocessor 264 13-5 Structure of the SDK-85 System Design Kit 266 13-6 Memory Map of the SDK-85 266 13-7 The Motorola 6802 Microprocessor 268 13-8 Structure of the MEK6802D5 Evaluation Kit 269 13-9 Memory Map of the D5 Evaluation Kit 270 13-10 Common Features of an Elementary Microcomputer 271 References 272 Problems 272

14 Parallel Input/Output and Interrupts 273 14-1 Parallel Input/Output 273 14-2 A Generic Parallel I/O Chip 274 14-3 Processing Interrupts 275 14-4 The Motorola Peripheral Interface Adapter (PIA) 276 14-5 Registers in the PIA 277 14-6 Preparing the PIA to Send and Receive Data 278 14-7 Interrupt from a Peripheral—An Overview 279 14-8 The Control Register and the Control Lines 281 14-9 Setting the Microprocessor to Receive an Interrupt 283 14-10 Structure of an Interruptible Program 283 14-11 User I/O Socket 285 14-12 Intel 8155/8156 RAM with I/O 286 14-13 Intel 8212 I/O Chip 286 14-14 Rudimentary Control Capability Now Available 287 Problems 288

xvi Contents

15 Serial Input/Output and Modems 289 15-1 Serial Data Transmission 289 15-2 Mark, Space, and Baud Rate 290 15-3 Synchronous and Asynchronous Communication 291 15-4 Parity 292 15-5 Shift Register 292 15-6 A Generic Universal Asynchronous Receiver/ Transmitter

(UART) 293 15-7 The MC6850 Asynchronous Receiver/Transmitter (ACIA) . 297 15-8 Registers in the ACIA 297 15-9 The Control Register 299 15-10 The Status Register 300 15-11 Transmitting and Receiving with the ACIA 301 15-12 The Intel 8251A Programmable Communication Interface . 302 15-13 The Control and Status Register on the 8251A 303 15-14 Communicating Using RS-232-C and Modems 305 15-15 RS-232-C Interface 306 15-16 Level Conversion Between RS-232-C and TTL 308 15-17 Communicating Between Two Elementary Microcomputers

Using RS-232-C 310 15-18 Transmission over Telephone Lines Using Modems 310 15-19 Dial-Up Modems 313 15-20 ASCII Characters 313 15-21 One-on-One Communication 313 References 315 Problems 315

16 Dynamic Behavior of Systems 317 16-1 Returning to the Thermal and Mechanical System 317 16-2 On/Off Controls 318 16-3 Make/Break Sensor with On/Off Actuator 319 16-4 Analog Sensor with On/Off Actuator 320 16-5 Modulating Control Strategies 321 16-6 Proportional Control 322 16-7 Proportional-Integral Control 324 16-8 Proportional-Integral-Derivative (PID) Control 327 16-9 Dynamic Analysis 327 16-10 Laplace Transforms 327 16-11 Inverting a Transform 328 16-12 Transforms of Derivatives 330 16-13 Solving Differential Equations by Means of Laplace

Transforms 330

Contents xvii

16-14 Transfer Functions 332 16-15 Feedback Loops 333 16-16 Stability Criteria for a Feedback Control Loop 334 16-17 A Proportional Controller Regulating the Pressure in an

Air-Supply System 336 16-18 Response of a Proportional Air-Pressuro Controller to a

Disturbance in Air-Flow Rate 339 16-19 The Integral Mode of Control 344 16-20 The Proportional-Integral (PI) Mode of Control 350 References 354 Problems 354

17 The Computer and Its Sampling Processes 357 17-1 Unique Features of Computer Control 357 17-2 Numerical Simulation 358 17-3 Sampled Data 362 17-4 Responses to Sampled Values 365 17-5 The z-Transform 370 17-6 Response to a Series of Impulses 376 17-7 The Zero-Order Hold (ZOH) 378 17-8 Inverting a z-Transform 380 17-9 Cascading z-Transforms and Transforms of a Feedback Loop 382 17-10 How a z-Transform Can Indicate Stability of a Control Loop 386 17-11 Proportional Control 390 17-12 Proportional-Integral Control 397 17-13 Forms of Actuator Signals 399 17-14 Non-linearities- Dead Time 400 17-15 Non-linearities Hysteresis 401 17-16 Summary 401 References 402 Problems 402

18 Field Application of Microcomputer Controllers 409 18-1 Applying Microcomputer Controllers to Field Processes . . . 409 18-2 Practical Control Algorithms 410 18-3 Incremental PI Control Algorithm 411 18-4 Position PI Control Algorithm 412 18-5 Criteria for Tuning 414 18-6 Manual Control Test 418 18-7 Trial-and-Error Tuning 419 18-8 Closed-Loop Tuning 422 18-9 Open-Loop Tuning 423

xviii Contents

18-10 Hysteresis Compensation 426 18-11 Summary 427 References 428 Problems 429