You are on page 1of 16

APPLIED MECHATRONICS

A. SMAILI
Mechanical Engineering and Meehatronics Department
Hariri Canadian University—Meshref

F.MRAD
Electrical and Computer Engineering Department
American University of Beirut—Beirut, Lebanon

ULB Darmstadt

IIIIIIIIIIIII
16929590

New York Oxford


OXFORD UNIVERSITY PRESS
2008
Contents

Preface xx
Acknowledgments xxi

1. Meehatronics: An Introduction 1
Objectives 1
1.1 What is Mechatronics? 1
1.2 Essential Skills for Mechatronics 2
1.3 Why is Mechatronics Important? 2
1.4 Components of a Mechatronic System 2
1.5 Brain for Mechatronics 4
Related Reading 5
Questions 5
Problems 5
Project 6

2. Elements and Analysis of Electric Circuits 7


Objectives 7
2.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) 10
2.4.7 Circuit Conditions 10
2.4.2 Electric Circuit Sources 10
2.4.3 Circuit Load 11
2.4.4 Circuit Ground 11
2.5 Circuit Analysis (EE and ME Basic) 12
2.5.1 Circuit Elements in Series and in Parallel 12

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
vi Contents

2.5.2 Kirchhoff's Laws 13


2.5.3 Equivalent Circuit Representation 14
*2.6 Resistor (EE and ME Basic) 15
2.6.7 Voltage Divider 76
2.6.2 Bridge Circuit 18
2.6.3 Small-Signal Resistance 19
2.6.4 Resistance-Based Sensors 79
2.6.5 Measuring Electrical Resistance 79
*2.7 Capacitor (EE and ME Basic) 20
2.Z7 Capacitor Applications 25
*2.8 Inductor (EE and ME Basic) 25
2.8.7 Magnetic Effect of an Electric Current 25
2.8.2 Electromagnetic Force 28
2.8.3 Self-Inductance 28
2.8.4 Inductor-Based Devices 29
*2.9 Alternating Current (EE and ME Basic) 33
2.9.7 Steady-State and Frequency Response 34
2.9.2 Complex Number Representation of Voltage and Current 34
*2.10 Impedance (EE and ME Basic) 35
2.70.7 Generalized Voltage Divider 36
2.10.2 Circuit Loading 37
2.10.3 Impedance Matching 38
+
2.11 Power (EE Basic) 39
2.77.7 Average Power 40
2.11.2 Reactive Power 42
2.11.3 Power Factor 42
+
2.12 Signals and Signal Sources (EE Basic) 42
2.72.7 Signal Sources 43
+
2.13 Time Domain Analysis (EE Basic) 44
2.73.7 Differentiators 46
2.13.2 Integrators 47
2.14 Passive Filters 47
2.74.7 Low-Pass Filters (LPFs) 49
2.14.2 High-Pass Filters (HPFs) 51
2.14.3 Band-Pass and Band-Reject Filters 53
2.14.4 Notch and Trap Filters 55
2.15 Noise and Interference in Circuits 55
2.75.7 Guarding Against Electromagnetic Interference (EMI) 55
2.15.2 Bypass Capacitors 56
2.16 Grounding 56
2.76.7 Ground Loops 56
Contents vii

2.76.2 Grounding Techniques 57


2.16.3 Galvanic Isolation 58
2.17 Summary 59
Related Reading 59
Questions 6 0
Problems 6 0
Laboratory Projects 6 3

3. Diode, Transistor, and Thyristor Circuits 64


Objectives 6 4
f
3.1 Semiconductors (EE Basic) 64
+3.2 Diodes (EE Basic) 65
3.3 Diode Applications 67
3.3.7 Rectification 67
3.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 72
3.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 83
3.9 Phototransistor 86
+3.10 Field-Effect Transistor (FET) (EE Basic) 87
3.70.7 JFETs 87
3.10.2 MOSFETs 88
3.11 Main Features of FETs and BJTs 91
3.12 Power Transistors 91
3.72.7 Packages 92
3.12.2 Power Bipolar Transistors 92
3.12.3 Darlingtons 93
3.12.4 Power MOSFETs 94
3.12.5 Insulated Gate Bipolar Transistors (IGBTs) 96
3.13 Thyristors 97
3.73.7 Silicon-Controlled Rectifiers (SCRs) 97
viii Contents

3.73.2 Gate Turn-Off (GTO) 100


3.13.3 TRIAC 100
3.14 Optocouplers 101
3.15 Summary 102
Related Reading 102
Questions 103
Problems 103
Laboratory Projects 105
4. Operational Amplifier (Op-Amp) Circuits 106
Objectives 106
4.1 Introduction 106
*4.2 Op-Amp Basic Symbol (EE and ME Basic) 108
*4.3 Circuit Model (EE and ME Basic) 108
4.4 Ideal Op-Amp Behavior 110
4.5 Common Op-Amp ICs 110
4.6 Basic Op-Amp Circuits 112
4.6.7 Inverting Amplifier 112
4.6.2 Noninverting Amplifier 113
4.6.3 Follower 114
4.6.4 Differential Amplifier 114
4.6.5 Instrumentation Amplifier 116
4.7 Linear Circuit Applications 118
4.7.1 Summing Amplifier (Adders) 118
4.7.2 Integrators 119
4.7.3 Differentiators 120
4.8 Nonlinear Op-Amp Circuits 121
4.8.7 Comparators 121
4.8.2 Schmitt Triggers 122
4.8.3 Rectifiers 123
4.8.4 Limiters 124
4.9 Nonideal Op-Amp Behavior 125
4.9.7 Feedback with Finite-Gain Amplifiers 125
4.9.2 Offset Voltage and Bias Currents 126
4.10 Active Filters 128
4.70.7 Filter Circuits and Frequency Characteristics 130
4.10.2 Filter Types 130
4.11 Power Op-Amps 133
4.12 Summary 133
Related Reading 133
Questions 134
Problems 134
Laboratory Projects 137
Contents ix

5. Digital Logic and Logic Families 138


Objectives 138
+
5.1 Digital Signals (EE Basic) 138
f
5.2 Combinational and Sequential Logic Circuits (EE Basic) 139
5.3 Clock Signals 140
f
5.4 Boolean Algebra and Logic Gates (EE Basic) 141
5.4.7 Basic Functions and Gates 141
5.4.2 Boolean Laws and Theorems 143
5.4.3 Karnaugh Maps 146
5.4.4 Design of Combinational Logic Circuits 147
5.5 Integrated Circuits and Logic Families 148
5.5.7 Logic Levels 149
5.5.2 Noise Immunity 149
5.5.3 Fan-Out 149
5.5.4 Power Dissipation 150
5.5.5 Propagation Delay 150
5.6 TTL Logic Family 151
5.6.7 TTL Designations 151
5.6.2 TTL Versions 151
5.6.3 Output Configurations 151
5.6.4 TTL Characteristics 154
5.7 The CMOS Family 155
5.8 Interfacing CMOS and TTL 156
5.8.7 Interfacing TTL to CMOS 157
5.8.2 Interfacing CMOS to TTL 158
5.9 Flip-Flops 158
5.9.7 Set-Reset (SR) Flip-Flop 158
5.9.2 Trigger (or J) Flip-Flop 159
5.9.3 Clocked D Flip-Flop 160
5.9.4 J-K Flip-Flop 161
5.10 Buffers and Drivers 162
5.70.7 Bus Drive and Termination 163
5.11 Counters and Registers 164
5.12 Decoders and Encoders 165
5.13 Multiplexers and Demultiplexers 166
5.14 The 555 Timer 167
5.74.7 Operating Modes 168
5.15 Phase-Locked Loop (PLL) 170
5.16 Glossary of Logic Terms 171
5.17 Summary 173
x Contents

Related Reading 173


Questions 174
Problems 174
Laboratory Projects 175

6. Microcontrollers and Programming 177


Objectives 177
+
6.1 Computers and Computer Programs (EE Basic) 177
6.7.7 Microprocessor or Microcontroller 178
6.2 Overview of the 9S12C MCUs 180
6.2.7 Central Processing Unit (CPU12) 182
6.2.2 System Bus 183
6.2.3 System Clocks 185
6.2.4 Operating Modes 185
6.2.5 Memory Map 187
6.2.6 Programming Basics 188
6.2.7 CPU12 Programming Registers 192
6.2.8 Instruction Queue 197
6.3 Addressing Modes 198
6.3.7 Inherent (INH) Mode 799
6.3.2 Immediate (IMM) Mode 199
6.3.3 Extended (EXT) Mode 200
6.3.4 Direct (DIR) Mode 200
6.3.5 Relative (RED Mode 200
6.3.6 Indexed Mode 201
6.4 Instruction Set of the CPU12 207
6.4.7 Data-Handling Instructions 207
6.4.2 Arithmetic Instructions 213
6.4.3 Special Math Instructions 218
6.4.4 Logic Instructions 220
6.4.5 Data-Compare and -Testing Instructions 220
6.4.6 Condition Code Register Instructions 221
6.4.7 Program-Control Instructions 222
6.4.8 Miscellaneous Instructions 230
6.5 Assembler Directives 230
6.5.7 Section Definition Directives 231
6.5.2 Constant Definition Directives 231
6.5.3 Data Allocation Directives 232
6.5.4 Assembly Control Directives 232
6.5.5 Listing File Control 232
6.5.6 Conditional Assembly 233
6.5.7 Macro Control 233
Contents xi

6.6 Development of an Assembly Language Program 233


6.6.7 Program Strategies 234
6.6.2 Source Code Structure 235
6.6.3 Conversion from Assembly Code to Machine Code 236
6.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 242
6.8.7 Background Debug Mode (BDM) 243
6.9 16-Kbyte Flash Module 244
6.9.7 Security 244
6.9.2 Flash Protection 245
6.9.3 Flask Clock 246
6.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 2
Questions 2 5 3
Problems 2 5 3
Laboratory Projects 2 5 5

7. Parallel I/O and I n t e r r u p t M e c h a n i s m 256


Objectives 256
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
xii Contents

7.3 Mechanical Switches 262


Z3.7 Interfacing Binary Switches 263
7.3.2 Switch Debounce 264
7.4 Interfacing Keyboards 265
Z4.7 Hardware Decoding 266
7.5 Displays 267
Z5.7 Light-Emitting Diodes (LEDs) 268
7.6 Interfacing LED Displays 271
7.6.7 Software Decoding 272
7.6.2 Multiplexed Displays 277
7.6.3 Hardware Decoding 279
7.7 LCD Displays 279
7.8 Interrupt Mechanism 280
Z8.7 Maskable and Nonmaskable Interrupts 281
7.8.2 Interrupt Process 281
7.8.3 Vectored Priority Interrupt 282
7.8.4 Interrupt and Reset Vectors 284
7.8.5 Stacking the Registers 284
7.9 Resets 285
Z9.7 External Pin RESET 285
7.9.2 Power-On Reset 286
7.9.3 COP Failure Reset 286
7.9.4 Clock Monitor Reset (CMR) 287
7.9.5 Reset Sequence 287
7.10 Nonmaskable Interrupt (XIRQ) 288
7.11 Maskable Interrupts 289
7.12 Summary 292
Related Reading 2 9 2
Questions 2 9 2
Problems 2 9 3
Laboratory Projects 2 9 4

8. Serial Interface Facility 295


Objectives 2 9 5
8.1 Introduction 295
8.2 Serial Communication Interface (SCI) 296
8.2.7 Communications Protocol (Framing) 296
8.2.2 Data Transfer (Baud) Rate 297
8.3 SCI Registers 298
8.3.7 Data Register 298
8.3.2 SCI Control Registers 299
8.3.3 SCI Status Registers 301
Contents xiii

8.4 SCI Operation 302


8.4.7 SCI Configuration 302
8.4.2 Transmit Operation 303
8.4.3 Receive Operation 304
8.5 Interfacing the 9S12C with the RS232 Port 306
8.6 Serial Peripheral Interface (SPI) 307
8.6.7 Port M Data Direction Register (DDRM) 308
8.6.2 SPI Baud Rate Register (SPIBR) 308
8.7 SPI Registers 309
8.Z7 SPI Data Register (SPIDR) 309
8.7.2 SPI Control Registers 309
8.7.3 SPI Status Register (SPISR) 311
8.8 SPI Topologies 311
8.9 SPI Operation 313
8.10 I/O Expansion of the 9S12C 315
8.70.7 Output Port Expansion 315
8.10.2 Input Port Expansion 317
8.11 Summary 319
Related Reading 319
Questions 319
Problems 320
Laboratory Projects 320

9. Programmable Timer Facility 321


Objectives 321
9.1 Introduction 321
9.2 Timer Module in the 9S12C MCU 322
9.2.7 Free-Running Counter (TCNT) 323
9.2.2 Timer Overflow 324
9.2.3 Clearing the Timer Flag 324
9.3 Output Compare 324
9.3.7 Output Compare Registers 325
9.3.2 General Setup for the Output Compare Operation 326
9.3.3 Operation of the OC7 330
9.3.4 Forced Output Compare 332
9.4 Input Capture Facility 333
9.4.7 Input Capture Pins and Registers 333
9.5 Pulse Accumulator 337
9.5.7 Pulse Accumulator Count Register (PACNT) 337
9.5.2 PA Enable and Active Edge Detection 338
9.5.3 PA Operating Modes 338
xiv Contents

9.6 Real-Time Clock 341


9.7 Pulse-Width Modulation (PWM) 342
9.8 Summary 348
Related Reading 349
Questions 349
Problems 349
Laboratory Projects 350

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


Objectives 351
10.1 Introduction 351
10.2 Fundamentals of A/D Conversion 352
70.2.7 Resolution 353
10.2.2 I/O Mapping 353
10.2.3 Aliasing 356
10.2.4 Amplitude Uncertainty 357
10.2.5 Sample and Hold (S/H) 358
10.2.6 Multiple Sensor Inputs 360
10.3 A/D Conversion Techniques 360
70.3.7 Integrating ADCs 360
10.3.2 Successive-Approximation ADC 363
10.3.3 Flash ADC 364
10.4 ADC Facility of the 9S12CMCU 365
70.4.7 Voltage References 365
10.4.2 ATD Registers 366
10.4.3 ATD Setup 366
10.4.4 Conversion Time 368
10.4.5 Channel Selection 368
10.4.6 Channel Sampling and Conversion Results 369
10.4.7 Input Signal Range 373
10.5 Digital-To-Analog Conversion (DAC) 376
70.5.7 Components of a D/A Converter (DAC) 377
10.5.2 Output Voltage 377
10.5.3 Range 378
10.5.4 Resolution 379
10.5.5 Accuracy 379
10.5.6 Bipolar DACs 380
10.5.7 DAC ICs 381
10.6 Summary 382
Related Reading 3 8 2
Questions 3 8 2
Problems 3 8 3
Laboratory projects 3 8 4
Contents xv

11. Sensors and Their Interface 385


Objectives 385
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
xvi Contents

77.75.3 Theremoresisitive Devices 418


11.15.4 Thermodiode 423
11.15.5 Thermotransistor 424
11.16 Heat Flux Sensor 425
11.17 Magnetic Sensors 426
77.7Z7 Magnetic Reed Switch 426
11.17.2 Hall-Effect Device 427
11.18 Strain Gauges 430
77.78.7 Bridge Circuit 431
11.18.2 Strain-Gauge Measurement 433
11.19 Acoustic Measurement 434
77.79.7 Properties of Wave Propagation 434
11.19.2 Acoustic Sensors 436
11.19.3 Types of Transducer Element 437
11.19.4 Types of Measurements 440
11.20 Piezoelectricity 443
77.20.7 Piezoelectric Effect 443
11.20.2 Piezoelectric Use in MEMS 444
11.20.3 Constitutive Relations in One Dimension 444
11.20.4 Piezoelectric Sensor 445
11.20.5 Piezoelectric Mass-Sensitive Chemical Sensor 447
11.21 Resolver 4 4 8
11.22 Tachometer 449 •
11.23 Capacitive Sensors 449
11.24 Inductive Sensors 451
77.24.7 Motion-Detection Sensor 451
11.24.2 Linear Variable Differential Transformer (LVDT) 451
11.25 Four- to 20-mA Transmitters 453
77.25.7 Voltage-to-Current Converter 454
11.26 Summary 454
Related Reading 4 5 5
Questions 4 5 5
Problems 4 5 6
Laboratory Projects 4 5 9

12. Electric Actuators 460


Objectives 4 6 0
12.1 Actuators 460
12.2 DC Motors 461
72.2.7 Principles of Operation of a DC Motor 461
12.2.2 Modeling of DC Motor Behavior 465
12.2.3 Heat Dissipation in DC Motors 472
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 524
Questions 524
Problems 525
Laboratory 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
xviii Contents

13.4 Adaptive Control 571


73.4.7 Gain Scheduling 571
13.4.2 Model-Reference Adaptive Control (MRAC) 572
13.4.3 Self-Tuning Regulators 573
13.5 Digital Control 574
73.5.7 Discretization Techniques 574
13.5.2 Emulation 575
13.5.3 Direct Digital Control 575
13.6 Intelligent Control 576
73.6.7 Fuzzy Logic Control Design 576
13.7 Adaptive Fuzzy Logic Controllers 583
73.Z7 Introduction 583
13.7.2 Fuzzy Model-Reference Adaptive Controller 583
13.7.3 Membership-Tuning Adaptive Controller 586
13.8 Experimental Comparative Analysis 591
73.8.7 Hardware Platform
13.8.2 Digital Control Workstation 591
13.9 Conclusion 599
Related Reading 5 9 9
Questions 6 0 0
Problems 601

14. Case Studies 603


Objectives 6 0 3
14.1 Introduction 603
14.2 Case Study 1: Autonomous Mobile Robot 604
74.2.7 Introduction 604
14.2.2 Mechanical Design Alternatives 605
14.2.3 Design Specifications 606
14.2.4 Electronic Circuits and Interfacing 612
14.2.5 Software Design 618
14.2.6 Case Outcomes 620
References 621
14.3 Case Study 2: Wireless Surveillance Balloon 621
74.3.7 Problem Definition 621
14.3.2 Design 621
14.3.3 Parts 626
14.3.4 Case Outcomes 635
References 636
14.4 Case Study 3: Firefighting Robot 636
74.4.7 Problem Statement 636
14.4.2 Design Alternatives 638
Contents xix

74.4.3 Implementation 639


14.4.4 Case Outcomes 647
References 649
14.5 Case Study 4: Piezo Sensors and Actuators in Cantilever Beam Vibration Control 649
74.5.7 Introduction 649
14.5.2 Modeling of the Cantilever Beam and PZT Actuator 650
14.5.3 Beam Experimental Setup 652
14.5.4 Instrumentation Setup 654
14.5.5 Controller and Software 658
14.5.6 Simulation and Experimental PID Results 661
14.5.7 Simulation and Experimental Fuzzy Results 665
14.5.8 Conclusions 668
14.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

You might also like