applied mechatronic

16
APPLIED MECHATRONICS A. SMAILI Mechanical Engineering and Meehatronics Department Hariri Canadian UniversityMeshref F.MRAD Electrical and Computer Engineering Department American University of BeirutBeirut, Lebanon ULB Darmstadt IIIIIIIIIIIII 16929590 New York Oxford OXFORD UNIVERSITY PRESS 2008

Upload: duong-van-tu

Post on 22-Nov-2014

473 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: Applied Mechatronic

APPLIED MECHATRONICS

A. SMAILIMechanical Engineering and Meehatronics Department

Hariri Canadian University—Meshref

F.MRADElectrical and Computer Engineering DepartmentAmerican University of Beirut—Beirut, Lebanon

ULB Darmstadt

IIIIIIIIIIIII16929590

New York Oxford

OXFORD UNIVERSITY PRESS

2008

Page 2: Applied Mechatronic

Contents

Preface xx

Acknowledgments xxi

1. Meehatronics: An Introduction 1Objectives 11.1 What is Mechatronics? 11.2 Essential Skills for Mechatronics 21.3 Why is Mechatronics Important? 21.4 Components of a Mechatronic System 21.5 Brain for Mechatronics 4Related Reading 5Questions 5Problems 5Project 6

2. Elements and Analysis of Electric Circuits 7

Objectives 72.1 Introduction 7

*2.2 Electric Field (EE and ME Basic) 7*2.3 Current and Voltage (EE and ME Basic) 8*2.4 Elements of an Electric Circuit (EE and ME Basic)

2.4.7 Circuit Conditions 102.4.2 Electric Circuit Sources 102.4.3 Circuit Load 112.4.4 Circuit Ground 11

2.5 Circuit Analysis (EE and ME Basic) 122.5.1 Circuit Elements in Series and in Parallel 12

10

Sections summarizing information from courses prerequisite to Mechatronics are marked in the Table of Contents.

Readers should focus more on the sections that are new to them.

* = EE and ME Basic: from general engineering sciences

t = EE Basic: mechanical engineers should spend more time studying these sections

t = ME Basic: electrical engineers should spend more time with these sections

Page 3: Applied Mechatronic

vi Contents

2.5.2 Kirchhoff's Laws 132.5.3 Equivalent Circuit Representation 14

*2.6 Resistor (EE and ME Basic) 152.6.7 Voltage Divider 762.6.2 Bridge Circuit 182.6.3 Small-Signal Resistance 192.6.4 Resistance-Based Sensors 792.6.5 Measuring Electrical Resistance 79

*2.7 Capacitor (EE and ME Basic) 202.Z7 Capacitor Applications 25

*2.8 Inductor (EE and ME Basic) 252.8.7 Magnetic Effect of an Electric Current 252.8.2 Electromagnetic Force 282.8.3 Self-Inductance 282.8.4 Inductor-Based Devices 29

*2.9 Alternating Current (EE and ME Basic) 332.9.7 Steady-State and Frequency Response 342.9.2 Complex Number Representation of Voltage and Current 34

*2.10 Impedance (EE and ME Basic) 352.70.7 Generalized Voltage Divider 362.10.2 Circuit Loading 372.10.3 Impedance Matching 38

+2.11 Power (EE Basic) 392.77.7 Average Power 402.11.2 Reactive Power 422.11.3 Power Factor 42

+2.12 Signals and Signal Sources (EE Basic) 422.72.7 Signal Sources 43

+2.13 Time Domain Analysis (EE Basic) 442.73.7 Differentiators 462.13.2 Integrators 47

2.14 Passive Filters 472.74.7 Low-Pass Filters (LPFs) 492.14.2 High-Pass Filters (HPFs) 512.14.3 Band-Pass and Band-Reject Filters 532.14.4 Notch and Trap Filters 55

2.15 Noise and Interference in Circuits 552.75.7 Guarding Against Electromagnetic Interference (EMI) 552.15.2 Bypass Capacitors 56

2.16 Grounding 562.76.7 Ground Loops 56

Page 4: Applied Mechatronic

Contents vii

2.76.2 Grounding Techniques 572.16.3 Galvanic Isolation 58

2.17 Summary 59Related Reading 59Questions 60Problems 60Laboratory Projects 63

3. Diode, Transistor, and Thyristor Circuits 6 4Objectives 64

f3.1 Semiconductors (EE Basic) 64+3.2 Diodes (EE Basic) 65

3.3 Diode Applications 673.3.7 Rectification 673.3.2 Diode Limiter, or Clipper 70

3.3.3 Diode Clamp 70

3.3.4 Inductive Load and Diode Protection 71

3.3.5 Temperature Sensor 723.3.6 Varactor 72

3.4 Zener Diodes 72

3.5 Light-Emitting Diode (LED) 74

3.6 Photodiode 75+3.7 Transistors (EE Basic) 76+3.8 Bipolar Junction Transistor (BJT) (EE Basic) 76

3.8.7 Transistor Characteristics 78

3.8.2 Transistor States 79

3.8.3 DC Biasing of the BJTs 81

3.8.4 Basic BJT Circuits 833.9 Phototransistor 86

+3.10 Field-Effect Transistor (FET) (EE Basic) 873.70.7 JFETs 873.10.2 MOSFETs 88

3.11 Main Features of FETs and BJTs 91

3.12 Power Transistors 913.72.7 Packages 92

3.12.2 Power Bipolar Transistors 92

3.12.3 Darlingtons 93

3.12.4 Power MOSFETs 943.12.5 Insulated Gate Bipolar Transistors (IGBTs) 96

3.13 Thyristors 97

3.73.7 Silicon-Controlled Rectifiers (SCRs) 97

Page 5: Applied Mechatronic

viii Contents

3.73.2 Gate Turn-Off (GTO) 1003.13.3 TRIAC 100

3.14 Optocouplers 1013.15 Summary 102Related Reading 102Questions 103Problems 103Laboratory Projects 105

4. Operational Amplifier (Op-Amp) Circuits 106

Objectives 1064.1 Introduction 106

*4.2 Op-Amp Basic Symbol (EE and ME Basic) 108*4.3 Circuit Model (EE and ME Basic) 1084.4 Ideal Op-Amp Behavior 1104.5 Common Op-Amp ICs 1104.6 Basic Op-Amp Circuits 112

4.6.7 Inverting Amplifier 1124.6.2 Noninverting Amplifier 1134.6.3 Follower 1144.6.4 Differential Amplifier 1144.6.5 Instrumentation Amplifier 116

4.7 Linear Circuit Applications 1184.7.1 Summing Amplifier (Adders) 1184.7.2 Integrators 1194.7.3 Differentiators 120

4.8 Nonlinear Op-Amp Circuits 1214.8.7 Comparators 1214.8.2 Schmitt Triggers 1224.8.3 Rectifiers 1234.8.4 Limiters 124

4.9 Nonideal Op-Amp Behavior 1254.9.7 Feedback with Finite-Gain Amplifiers 1254.9.2 Offset Voltage and Bias Currents 126

4.10 Active Filters 1284.70.7 Filter Circuits and Frequency Characteristics 1304.10.2 Filter Types 130

4.11 Power Op-Amps 1334.12 Summary 133Related Reading 133Questions 134Problems 134Laboratory Projects 137

Page 6: Applied Mechatronic

Contents ix

5. Digital Logic and Logic Families 138Objectives 138

+5.1 Digital Signals (EE Basic) 138f5.2 Combinational and Sequential Logic Circuits (EE Basic) 1395.3 Clock Signals 140

f5.4 Boolean Algebra and Logic Gates (EE Basic) 1415.4.7 Basic Functions and Gates 141

5.4.2 Boolean Laws and Theorems 1435.4.3 Karnaugh Maps 1465.4.4 Design of Combinational Logic Circuits 147

5.5 Integrated Circuits and Logic Families 1485.5.7 Logic Levels 1495.5.2 Noise Immunity 1495.5.3 Fan-Out 1495.5.4 Power Dissipation 150

5.5.5 Propagation Delay 1505.6 TTL Logic Family 151

5.6.7 TTL Designations 151

5.6.2 TTL Versions 1515.6.3 Output Configurations 1515.6.4 TTL Characteristics 154

5.7 The CMOS Family 1555.8 Interfacing CMOS and TTL 156

5.8.7 Interfacing TTL to CMOS 1575.8.2 Interfacing CMOS to TTL 158

5.9 Flip-Flops 158

5.9.7 Set-Reset (SR) Flip-Flop 1585.9.2 Trigger (or J) Flip-Flop 1595.9.3 Clocked D Flip-Flop 1605.9.4 J-K Flip-Flop 161

5.10 Buffers and Drivers 1625.70.7 Bus Drive and Termination 163

5.11 Counters and Registers 1645.12 Decoders and Encoders 165

5.13 Multiplexers and Demultiplexers 1665.14 The 555 Timer 167

5.74.7 Operating Modes 1685.15 Phase-Locked Loop (PLL) 1705.16 Glossary of Logic Terms 1715.17 Summary 173

Page 7: Applied Mechatronic

x Contents

Related Reading 173Questions 174Problems 174Laboratory Projects 175

6. Microcontrollers and Programming 177

Objectives 177+6.1 Computers and Computer Programs (EE Basic) 177

6.7.7 Microprocessor or Microcontroller 1786.2 Overview of the 9S12C MCUs 180

6.2.7 Central Processing Unit (CPU12) 1826.2.2 System Bus 1836.2.3 System Clocks 1856.2.4 Operating Modes 1856.2.5 Memory Map 1876.2.6 Programming Basics 1886.2.7 CPU12 Programming Registers 1926.2.8 Instruction Queue 197

6.3 Addressing Modes 1986.3.7 Inherent (INH) Mode 7996.3.2 Immediate (IMM) Mode 1996.3.3 Extended (EXT) Mode 2006.3.4 Direct (DIR) Mode 2006.3.5 Relative (RED Mode 2006.3.6 Indexed Mode 201

6.4 Instruction Set of the CPU12 2076.4.7 Data-Handling Instructions 2076.4.2 Arithmetic Instructions 2136.4.3 Special Math Instructions 2186.4.4 Logic Instructions 2206.4.5 Data-Compare and -Testing Instructions 2206.4.6 Condition Code Register Instructions 2216.4.7 Program-Control Instructions 2226.4.8 Miscellaneous Instructions 230

6.5 Assembler Directives 2306.5.7 Section Definition Directives 2316.5.2 Constant Definition Directives 2316.5.3 Data Allocation Directives 2326.5.4 Assembly Control Directives 2326.5.5 Listing File Control 2326.5.6 Conditional Assembly 2336.5.7 Macro Control 233

Page 8: Applied Mechatronic

Contents xi

6.6 Development of an Assembly Language Program 2336.6.7 Program Strategies 234

6.6.2 Source Code Structure 235

6.6.3 Conversion from Assembly Code to Machine Code 2366.6.4 Debugging Tools 237

6.7 High-Level Language 237

6.Z7 C-Programming for the 9S12C MCUs 238

6.8 Development Tools for the MC9S12C 2426.8.7 Background Debug Mode (BDM) 243

6.9 16-Kbyte Flash Module 2446.9.7 Security 244

6.9.2 Flash Protection 245

6.9.3 Flask Clock 2466.9.4 Flash Configuration (FCNFG) 246

6.9.5 Flash Operations 246

6.10 Microchip PIC Microcontrollers 248

6.70.7 Architectural Overview of the Microchip PIC 18F452 MCU 249

6.10.2 Instruction Set 249

6.10.3 Pipelining 250

6.10.4 Clocking Scheme 250

6.10.5 Memory Organization 250

6.10.6 Addressing Modes 250

6.10.7 I/O Ports 250

6.10.8 Timers 251

6.10.9 Compare/Capture/PWM (CCP) Module 251

6.10.10 Analog-to-Digital Conversion (ADC) Module 251

6.10.11 Interrupt Structure 251

6.10.12 PIC Development Suite 252

6.11 Summary 252

Related Reading 2 5 2Questions 2 5 3Problems 2 5 3Laboratory Projects 255

7. Parallel I/O and Interrupt Mechanism 2 5 6

Objectives 2 5 6

7.1 Introduction 256

7.2 Parallel Input/Output (I/O) 257

7:2.7 Common Port Features 258

7.2.2 Specific Port Features 259

Page 9: Applied Mechatronic

xii Contents

7.3 Mechanical Switches 262Z3.7 Interfacing Binary Switches 2637.3.2 Switch Debounce 264

7.4 Interfacing Keyboards 265Z4.7 Hardware Decoding 266

7.5 Displays 267Z5.7 Light-Emitting Diodes (LEDs) 268

7.6 Interfacing LED Displays 2717.6.7 Software Decoding 2727.6.2 Multiplexed Displays 2777.6.3 Hardware Decoding 279

7.7 LCD Displays 2797.8 Interrupt Mechanism 280

Z8.7 Maskable and Nonmaskable Interrupts 2817.8.2 Interrupt Process 2817.8.3 Vectored Priority Interrupt 2827.8.4 Interrupt and Reset Vectors 2847.8.5 Stacking the Registers 284

7.9 Resets 285Z9.7 External Pin RESET 2857.9.2 Power-On Reset 2867.9.3 COP Failure Reset 2867.9.4 Clock Monitor Reset (CMR) 2877.9.5 Reset Sequence 287

7.10 Nonmaskable Interrupt (XIRQ) 2887.11 Maskable Interrupts 2897.12 Summary 292Related Reading 292Questions 292Problems 293Laboratory Projects 2 9 4

8 . Serial Interface Facility 2 9 5

Objectives 2958.1 Introduction 2958.2 Serial Communication Interface (SCI) 296

8.2.7 Communications Protocol (Framing) 2968.2.2 Data Transfer (Baud) Rate 297

8.3 SCI Registers 2988.3.7 Data Register 2988.3.2 SCI Control Registers 2998.3.3 SCI Status Registers 301

Page 10: Applied Mechatronic

Contents xiii

8.4 SCI Operation 3028.4.7 SCI Configuration 3028.4.2 Transmit Operation 3038.4.3 Receive Operation 304

8.5 Interfacing the 9S12C with the RS232 Port 3068.6 Serial Peripheral Interface (SPI) 307

8.6.7 Port M Data Direction Register (DDRM) 3088.6.2 SPI Baud Rate Register (SPIBR) 308

8.7 SPI Registers 3098.Z7 SPI Data Register (SPIDR) 3098.7.2 SPI Control Registers 3098.7.3 SPI Status Register (SPISR) 311

8.8 SPI Topologies 3118.9 SPI Operation 3138.10 I/O Expansion of the 9S12C 315

8.70.7 Output Port Expansion 3158.10.2 Input Port Expansion 317

8.11 Summary 319Related Reading 319Questions 319Problems 320Laboratory Projects 320

9. Programmable Timer Facility 321Objectives 321

9.1 Introduction 3219.2 Timer Module in the 9S12C MCU 322

9.2.7 Free-Running Counter (TCNT) 3239.2.2 Timer Overflow 3249.2.3 Clearing the Timer Flag 324

9.3 Output Compare 3249.3.7 Output Compare Registers 3259.3.2 General Setup for the Output Compare Operation 3269.3.3 Operation of the OC7 3309.3.4 Forced Output Compare 332

9.4 Input Capture Facility 3339.4.7 Input Capture Pins and Registers 333

9.5 Pulse Accumulator 3379.5.7 Pulse Accumulator Count Register (PACNT) 3379.5.2 PA Enable and Active Edge Detection 3389.5.3 PA Operating Modes 338

Page 11: Applied Mechatronic

xiv Contents

9.6 Real-Time Clock 3419.7 Pulse-Width Modulation (PWM) 3429.8 Summary 348Related Reading 349Questions 349Problems 349Laboratory Projects 350

10. Analog-to-Digital (A/D) and Digital-to-Analog (D/A) Conversion 351

Objectives 35110.1 Introduction 35110.2 Fundamentals of A/D Conversion 352

70.2.7 Resolution 35310.2.2 I/O Mapping 35310.2.3 Aliasing 35610.2.4 Amplitude Uncertainty 35710.2.5 Sample and Hold (S/H) 35810.2.6 Multiple Sensor Inputs 360

10.3 A/D Conversion Techniques 36070.3.7 Integrating ADCs 36010.3.2 Successive-Approximation ADC 36310.3.3 Flash ADC 364

10.4 ADC Facility of the 9S12CMCU 36570.4.7 Voltage References 36510.4.2 ATD Registers 36610.4.3 ATD Setup 36610.4.4 Conversion Time 36810.4.5 Channel Selection 36810.4.6 Channel Sampling and Conversion Results 36910.4.7 Input Signal Range 373

10.5 Digital-To-Analog Conversion (DAC) 37670.5.7 Components of a D/A Converter (DAC) 37710.5.2 Output Voltage 37710.5.3 Range 37810.5.4 Resolution 37910.5.5 Accuracy 37910.5.6 Bipolar DACs 38010.5.7 DAC ICs 381

10.6 Summary 382Related Reading 382Questions 382Problems 383Laboratory projects 3 8 4

Page 12: Applied Mechatronic

Contents xv

11. Sensors and Their Interface 385Objectives 3 8 5

11.1 Introduction 385

11.2 Classification of Sensors 386

11.3 Smart Sensors 387

11.4 Sensor Models and Response Characteristics 388

11.5 Sensor Characteristics 390

11.6 Signal Conditioning 392

77.6.7 Amplification 393

11.6.2 Conversion 393

11.6.3 Filtering 393

11.6.4 Impedance Buffering 394

11.6.5 Modulation/Demodulation 394

11.6.6 Linearization 394

11.6.7 Grounding and Isolation 395

11.7 Potentiometer Sensors (Pot) 396

11.8 Light Detectors 398

77.8.7 Materials for Light Detectors 400

11.8.2 Types and Modes of Operation of Light Detectors 400

11.8.3 Applications of Light Detectors 400

11.9 Photoresistor (Photocell) 400

77.9.7 Materials for Photocells 401

11.9.2 Interfacing a Photocell to the 9S12C 401

11.10 Photodiode 402

77.70.7 Photodiode Types 402

11.10.2 Photodiode Characteristics 403

11.10.3 Operating Modes 403

11.10.4 Applications 404

11.11 Phototransistor 405

77.77.7 Phototransistor Characteristics 405

11.11.2 Applications 406

11.12 IR Emitter/Detector Packages 407

77.72.7 Optical Interrupter 407

11.12.2 Optical Coupler (Optical Isolator) 408

11.12.3 Optical Reflectors 408

11.12.4 NIR Receiver/Demodulator Sensors 409

11.13 Optical Encoder 410

11.14 Pyroelectric Sensor 412

77.74.7 Signal Conditioning 414

11.15 Thermal Detectors 414

77.75.7 Thermocouple 415

11.15.2 Thermopiles 418

Page 13: Applied Mechatronic

xvi Contents

77.75.3 Theremoresisitive Devices 41811.15.4 Thermodiode 42311.15.5 Thermotransistor 424

11.16 Heat Flux Sensor 42511.17 Magnetic Sensors 426

77.7Z7 Magnetic Reed Switch 42611.17.2 Hall-Effect Device 427

11.18 Strain Gauges 43077.78.7 Bridge Circuit 43111.18.2 Strain-Gauge Measurement 433

11.19 Acoustic Measurement 43477.79.7 Properties of Wave Propagation 43411.19.2 Acoustic Sensors 43611.19.3 Types of Transducer Element 43711.19.4 Types of Measurements 440

11.20 Piezoelectricity 44377.20.7 Piezoelectric Effect 44311.20.2 Piezoelectric Use in MEMS 44411.20.3 Constitutive Relations in One Dimension 44411.20.4 Piezoelectric Sensor 44511.20.5 Piezoelectric Mass-Sensitive Chemical Sensor 447

11.21 Resolver 44811.22 Tachometer 449 •11.23 Capacitive Sensors 44911.24 Inductive Sensors 451

77.24.7 Motion-Detection Sensor 45111.24.2 Linear Variable Differential Transformer (LVDT) 451

11.25 Four- to 20-mA Transmitters 45377.25.7 Voltage-to-Current Converter 454

11.26 Summary 454Related Reading 455Questions 455Problems 456Laboratory Projects 459

12. Electric Actuators 4 6 0

Objectives 4 6 012.1 Actuators 46012.2 DC Motors 461

72.2.7 Principles of Operation of a DC Motor 46112.2.2 Modeling of DC Motor Behavior 46512.2.3 Heat Dissipation in DC Motors 472

Page 14: Applied Mechatronic

Contents xvii

72.2.4 Velocity Profile Optimization 473

12.2.5 Inertia Matching 474

12.2.6 Motor Selection 476

12.2.7 Servo Amplifiers 479

12.2.8 DC Motor Servo Drive 482

12.2.9 Interfacing DC Motors to the 9S12C 485

12.2.10 DC Servos 490

12.3 Stepper Motors 491

72.3.7 Characteristics of a Stepper Motor 491

12.3.2 Classification of Stepper Motors 491

12.3.3 Principle of Operation 494

12.3.4 Step Angle 498

12.3.5 Electrical Model of an Energized Coil 499

12.3.6 Drive Methods 501

12.3.7 Stepper Motor Performance 503

12.3.8 Interfacing Stepper Motors to the 9S12C MCU 509

12.4 AC Induction Motors 515

72.4.7 Three-Phase Motors 516

12.4.2 Speed Control of the Induction Motor 519

12.5 Summary 524

Related Reading 524Questions 524Problems 525Laboratory Projects 526

13. Control Schemes 527

Objectives 527

13.1 Introduction 527

73.7.7 History of Control 527

13.1.2 Open-Loop Control 529

13.1.3 Closed-Loop Control 529

13.2 Classical Control 530

73.2.7 Mathematical Modeling 530

13.2.2 Transfer Function 532

13.2.3 Transient and Steady-State Analyses 533

13.2.4 Root Locus 537

13.2.5 Frequency Response 543

13.2.6 Lag-Lead Compensator 549

13.2.7 Proportional-Integral-Derivative (PID) Controller Design 557

13.3 State-Space-Based Control Strategies 565

Page 15: Applied Mechatronic

xviii Contents

13.4 Adaptive Control 57173.4.7 Gain Scheduling 57113.4.2 Model-Reference Adaptive Control (MRAC) 57213.4.3 Self-Tuning Regulators 573

13.5 Digital Control 57473.5.7 Discretization Techniques 57413.5.2 Emulation 57513.5.3 Direct Digital Control 575

13.6 Intelligent Control 57673.6.7 Fuzzy Logic Control Design 576

13.7 Adaptive Fuzzy Logic Controllers 58373.Z7 Introduction 58313.7.2 Fuzzy Model-Reference Adaptive Controller 58313.7.3 Membership-Tuning Adaptive Controller 586

13.8 Experimental Comparative Analysis 59173.8.7 Hardware Platform13.8.2 Digital Control Workstation 591

13.9 Conclusion 599Related Reading 599Questions 600Problems 601

14. Case Studies 6 0 3

Objectives 60314.1 Introduction 60314.2 Case Study 1: Autonomous Mobile Robot 604

74.2.7 Introduction 60414.2.2 Mechanical Design Alternatives 60514.2.3 Design Specifications 60614.2.4 Electronic Circuits and Interfacing 61214.2.5 Software Design 61814.2.6 Case Outcomes 620References 621

14.3 Case Study 2: Wireless Surveillance Balloon 62174.3.7 Problem Definition 62114.3.2 Design 62114.3.3 Parts 62614.3.4 Case Outcomes 635References 636

14.4 Case Study 3: Firefighting Robot 63674.4.7 Problem Statement 63614.4.2 Design Alternatives 638

Page 16: Applied Mechatronic

Contents xix

74.4.3 Implementation 63914.4.4 Case Outcomes 647References 649

14.5 Case Study 4: Piezo Sensors and Actuators in Cantilever Beam Vibration Control 64974.5.7 Introduction 64914.5.2 Modeling of the Cantilever Beam and PZT Actuator 65014.5.3 Beam Experimental Setup 65214.5.4 Instrumentation Setup 65414.5.5 Controller and Software 65814.5.6 Simulation and Experimental PID Results 66114.5.7 Simulation and Experimental Fuzzy Results 66514.5.8 Conclusions 66814.5.9 Case Outcomes 668

''Appendix A: DC Power Supply (EE Basic) 670

Appendix B: Pinout of Selected ICs 672

Appendix C: Instruction Set, Addressing Modes, and Execution Times for the MC9SI2C 674

Appendix D: MC9S12C Registers and Control Bit Assignments 676

Appendix E: Using the CodeWarrior Integrated Development Environment (IDE) 678

Appendix F: ASCII Code Table 680

''Appendix G: Number Systems (EE Basic) 681

* Appendix H: Mechanisms For Mechatronics (ME Basic) 691

Index 706