Introduction to Mechatronics. An Integrated Approach 9783031293191, 9783031293207


329 41 13MB

English Pages 368 Year 2023

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Preface
Acknowledgments
Contents
About the Author
Chapter 1: Introduction
1.1 Mechatronics
1.2 An Integrated Approach
1.3 Organization of Book Chapters
1.4 Measurement Fundamentals
1.4.1 Basic Statistics
1.4.2 Excel and Matlab Commands for Basic Statistics
1.4.3 Example Problems: Basic Statistics
1.4.4 Uncertainty Analysis
1.4.4.1 Maximum Possible Error
1.4.4.2 Most Probable Error
1.4.5 Estimation of Allowable Uncertainty of Individual Measured Variables
1.4.5.1 Based on Maximum Possible Uncertainty of the Computed Parameter
1.4.5.2 Based on the Most Probable Uncertainty of the Computed Parameter
1.4.6 Example Problems: Uncertainty Analysis
1.4.7 Computer-Aided Analysis of Basic Statistics and Uncertainty
1.4.8 Experiment on Basic Statistics
Exercises
Bibliography
Chapter 2: Basic Electrical Circuit Elements and Circuit Analysis
2.1 Introduction
2.2 Basic Electrical Circuit Elements
2.2.1 Resistor
2.2.2 Capacitor
2.2.3 Inductor
2.3 Basic Electrical Circuit Elements in Series and in Parallel
2.3.1 Resistors in Series and in Parallel
2.3.2 Capacitors in Series and in Parallel
2.3.3 Inductors in Series and in Parallel
2.4 DC Circuit Analysis
2.4.1 Ohm´s Law
2.4.2 Kirchhoff´s Current Law
2.4.3 Kirchhoff´s Voltage Law
2.5 Ideal Voltage and Current Sources and Measuring Devices
2.6 Equivalent Circuits
2.6.1 Thevenin Equivalent Circuit
2.6.2 Norton Equivalent Circuit
2.7 AC Circuit Analysis
2.7.1 AC Signal and Phasor Representation
2.7.2 Impedance
2.8 Power in Electrical Circuits
2.9 Transformer
2.10 Impedance Matching
2.11 Computer-Aided Analysis of Basic Circuits
2.11.1 Analysis Using Matlab
2.11.2 Simulation Using Tinkercad
Exercises
Bibliography
Chapter 3: Basic Electronics
3.1 Introduction
3.2 Introduction to Junction Diodes
3.2.1 Ideal Diode Model
3.2.2 Nonlinear Current-Voltage Characteristics of Junction Diodes
3.2.3 Zener Diode and Voltage Regulation
3.2.4 Analysis of Diode Circuits
3.2.5 Rectifier Circuits
3.3 Bipolar Junction Transistors
3.3.1 Example Problem of npn BJT
3.3.2 Example Problem of pnp BJT
3.4 Metal Oxide Semiconductor Field Effect Transistors
3.4.1 NMOS Example Problem
3.4.2 PMOS Example Problem
3.5 Computer-Aided Analysis of Basic Electronic Circuits
3.5.1 Analysis Using Matlab
3.5.2 Simulation Using Tinkercad
Exercises
Bibliography
Chapter 4: Dynamic System Characteristics
4.1 Introduction
4.2 First-Order Systems
4.2.1 Time Domain Analysis
4.2.2 Frequency Domain Analysis
4.2.3 Experimental Determination of System Parameters
4.3 Second-Order Systems
4.3.1 Time Domain Analysis
4.3.2 Frequency Domain Analysis
4.3.3 Experimental Determination of System Parameters
4.4 Fourier Series Representation of Periodic Signals
4.4.1 Fourier Series
4.4.2 Fourier Transform
4.4.3 Examples of Fourier Transform of Signals Using Matlab
4.5 Computer-Aided Analysis and Simulation of Dynamic System Responses
4.5.1 Analysis Using Matlab
4.5.2 Simulation Using Tinkercad
4.6 Experimental Validation
Exercises
Bibliography
Chapter 5: Analog Signal Processing and Operational Amplifiers
5.1 Introduction
5.2 Operational Amplifiers
5.3 Ideal Operational Amplifier Model
5.4 Inverting Amplifier
5.5 Noninverting Amplifier
5.6 Summing Amplifier
5.7 Difference Amplifier
5.8 Integrator
5.9 Differentiator
5.10 Voltage Follower
5.11 Comparator
5.12 Sample and Hold
5.13 Instrumentation Amplifier
5.14 The Real Operational Amplifier
5.15 Computer-Aided Analysis and Simulation of Operational Amplifier Circuits
5.15.1 Analysis Using Matlab
5.15.2 Simulation Using Tinkercad
5.16 Summary of Operational Amplifier Configurations
5.17 Simulation and Experimental Validation
5.17.1 Basic Operational Amplifier Configurations
5.17.2 Integrator, Differentiator, and Modified Versions
Exercises
Bibliography
Chapter 6: Data Acquisition and Digital Signal Processing
6.1 Introduction
6.2 Analog and Discrete Signals
6.3 Number Systems
6.3.1 Decimal Number System
6.3.2 Binary Number System
6.3.3 Octal and Hexadecimal Number Systems
6.3.4 Decimal to Binary Conversion
6.3.5 Binary to Octal Conversion
6.3.6 Binary to Hexadecimal Conversion
6.4 Analog-to-Digital Conversion
6.4.1 Successive Approximation Register (SAR) ADC
6.4.2 Flash ADC
6.4.3 ADC Relations
6.5 Digital-to-Analog Conversion
6.5.1 Digital-to-Analog Converters
6.5.2 DAC Relation
6.6 Virtual Instruments, Data Acquisition, and Digital Signal Processing Using LabVIEW
6.6.1 Virtual Instruments
6.6.2 Signal Simulation and Analysis
6.6.3 Data Acquisition and Digital Signal Processing
6.7 LabVIEW Experimentation
Exercises
Bibliography
Chapter 7: Sensors
7.1 Introduction
7.2 Position, Displacement, and Velocity Measurement
7.2.1 Proximity Sensors
7.2.2 Potentiometers
7.2.3 Ultrasonic Sensors
7.2.4 Tachogenerators
7.3 Stress and Strain Measurement Using Strain Gages
7.3.1 Electrical Resistance Strain Gage
7.3.2 Wheatstone Bridge
7.3.3 Member with Axial Load
7.3.4 Member with Transverse Load
7.4 Vibration and Acceleration Measurement
7.4.1 Vibration Pickups for Displacement Measurement
7.4.2 Accelerometers
7.4.3 Piezoelectric Accelerometers
7.4.4 Charge Amplifiers
7.4.5 A Piezoelectric Accelerometer with a Charge Amplifier
7.5 Temperature Measurement
7.5.1 Resistance Temperature Detectors
7.5.2 Thermistors
7.5.3 Thermocouples
7.5.3.1 Thermopile in Series
7.5.3.2 Thermopile in Parallel
7.6 Computer-Aided Analysis and Simulation of Wheatstone Bridge
7.6.1 Analysis Using Matlab
7.6.2 Simulation Using Tinkercad
7.7 Experimental Validation
7.7.1 Data Acquisition and Analysis Using LabVIEW and a Thermocouple
7.7.2 Measurement Using a Strain Gage Under Static Condition
7.7.3 Data Acquisition and Analysis Using LabVIEW and a Strain Gage Under Dynamic Condition
Exercises
Bibliography
Chapter 8: Digital Circuits
8.1 Introduction
8.2 Combinational Logic Devices
8.3 Boolean Algebra
8.4 De Morgan´s Laws
8.5 Truth Table and Simplified Boolean Expression from a Given Boolean Expression
8.6 Simplified Boolean Expression and Digital Circuit from a Given Truth Table
8.7 Design of Digital Logic Networks
8.7.1 Define the Problem
8.7.2 Write the Quasi-Logic Statement
8.7.3 Write the Boolean Expression
8.7.4 Simplify the Boolean Expression
8.7.5 Construct the Digital Logic Circuit
8.7.6 Convert to an all-NAND Circuit
8.7.7 Convert to an All-NOR Circuit
8.8 Karnaugh Map (K-Map) for Simplification of Boolean Expressions
8.9 Sequential Logic
8.9.1 SR Flip-Flop
8.9.2 Edge-Triggered SR Flip-Flop
8.9.3 D Flip-Flop
8.9.4 JK Flip-Flop
8.9.5 T Flip-Flop
8.10 Computer-Aided Analysis and Simulation of Digital Logic Circuits
8.10.1 Analysis Using Excel
8.10.2 Simulation Using Tinkercad
Exercises
Bibliography
Chapter 9: Actuators
9.1 Introduction
9.2 Types of Actuators
9.3 Electromechanical Actuators
9.4 DC Motor Characteristics
9.4.1 Dynamic Model of an Armature Controlled DC Motor
9.4.2 Steady-State Characteristics
9.5 Selection of DC Motors
9.6 Electronic Control of DC Motor Speed and Direction
9.6.1 Pulse Width Modulation (PWM)
9.6.2 H-Bridge
9.6.3 L293D Motor Driver IC
9.6.4 L298N Motor Driver Module
9.6.5 DC Motor Speed and Direction Control Using an Arduino
9.7 Stepper Motors
9.7.1 Stepper Motor Characteristics
9.7.2 Driving a Bipolar Stepper Motor Using a Dual H-Bridge and an Arduino
9.8 Computer-Aided Analysis and Simulation of DC Motors
9.8.1 Analysis Using Matlab
9.8.2 Simulation Using Tinkercad
9.9 Laboratory Experiments
9.9.1 Driving a DC Motor Using an H-Bridge (L293N) and an Arduino
9.9.2 Driving a Bipolar Stepper Motor Using a Dual H-Bridge and an Arduino
Exercises
References
Chapter 10: Microcontroller Programming and Interfacing
10.1 Introduction
10.2 Arduino Microcontroller Development Boards
10.3 Arduino Programming Environment
10.4 Arduino Programming Language
10.4.1 Functions
10.4.2 Variables
10.4.3 Structure
10.5 An Example Code
10.6 Virtual Simulation on Tinkercad
10.7 Simulation of Example Codes on Tinkercad
10.7.1 Simulation of digitalRead and digitalWrite on Tinkercad
10.7.2 Simulation of analogRead and analogWrite on Tinkercad
10.7.3 Simulation of Data Type, Time, and Serial Communication on Tinkercad
10.7.4 Simulation of Compound Operators on Tinkercad
10.8 Arduino Programming and Interfacing Examples
10.8.1 Simulation of 3-Bit Binary Patterns (000-111) Using an Arduino and Three LEDs
10.8.2 Simulation of Setting LEDs On/Off Based on the Status of Push Buttons
10.8.3 Simulation of a Digital Logic Circuit for a Multiplexer
10.8.4 Simulation of Ultrasonic Sensor for Distance Measurement with an Arduino
10.9 Simulation on Tinkercad and Physical Validation in Laboratory
10.9.1 Simulation of 4-Bit Binary Patterns (0000-1111) Using an Arduino and 4 LEDs
10.9.2 Simulation of Setting Four LEDs On/Off Based on the Status of Two Push Buttons
10.9.3 Simulation of a Digital Logic Circuit for Implementing
10.9.4 Simulation of Ultrasonic Sensor for Distance Measurement with Arduino
10.9.5 Simulation of a Home Security System Using Digital Logic Gates and an Arduino on Tinkercad
10.9.6 Simulation of a Car Safety System Using Digital Logic Gates and Arduino on Tinkercad
Bibliography
Chapter 11: Basic Control Systems
11.1 Introduction
11.2 Control System Structure
11.2.1 Mathematical Modeling
11.2.2 Open and Closed Loop System Characteristics
11.3 Stability Analysis of Control Systems
11.3.1 Closed Loop Poles on S-Plane
11.3.2 Routh-Hurwitz Criterion
11.3.3 Root Locus Technique
11.3.4 Bode Plot
11.4 Control System Specifications
11.4.1 Design Specifications
11.4.2 Types of Controllers
11.5 Controller Design Method
11.5.1 PID Controller Design Using Time Domain Specifications
11.5.2 PID Controller Design Using Frequency Domain Specifications
11.5.3 Experimental Method: Ziegler-Nichols Method
11.6 Controller Implementation
Exercises
Bibliography
Chapter 12: Mechatronic Systems
12.1 Introduction
12.2 Robotics Project Using Lego Mindstorms EV3
12.3 EV3 Intelligent Brick
12.4 EV3 Sensors
12.5 EV3 Motors
12.6 EV3 Sensor Calibration
12.6.1 Light Sensor Calibration
12.6.2 Touch Sensor Calibration
12.6.3 Ultrasonic Sensor Calibration
12.6.4 Gyro Sensor Calibration
12.7 EV3 Motor Speed Calibration
12.8 EV3 Programming
12.8.1 Line Following
12.8.2 Obstacle Avoidance
12.8.3 Line Following While Avoiding Obstacle
12.8.4 Following a Moving Target
12.9 Project Ideas
Bibliography
Appendices
Appendix A (Tables A.1, A.2, A.3, A.4 and A.5)
Appendix B (Table B.1)
Bibliography
Index
Recommend Papers

Introduction to Mechatronics. An Integrated Approach
 9783031293191, 9783031293207

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

Biswanath Samanta

Introduction to Mechatronics An Integrated Approach

Introduction to Mechatronics

Biswanath Samanta

Introduction to Mechatronics An Integrated Approach

Biswanath Samanta Mechanical Engineering Department Georgia Southern University Statesboro, GA, USA

ISBN 978-3-031-29319-1 ISBN 978-3-031-29320-7 https://doi.org/10.1007/978-3-031-29320-7

(eBook)

© The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature Switzerland AG 2023 This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. The publisher, the authors, and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. This Springer imprint is published by the registered company Springer Nature Switzerland AG The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland

To my wife Rupama, son Rupayan, and daughter Rupabali, and my parents and grandparents

Preface

Mechatronics is an interdisciplinary area synergistically integrating multiple engineering fields like mechanical, electrical and electronics, computer, and control systems for designing, developing, and testing systems with embedded learning capabilities. Mechatronics is an ideal field to incorporate systems thinking and data-information-knowledge-wisdom (DIKW) hierarchy through an integrated approach covering both hardware and software. The book evolved from course materials the author has developed while teaching undergraduate- and graduate-level Mechatronics and related courses like Measurement Systems, Control Systems, and Robotics at different universities over several years. Most of these courses have or used to have companion laboratory components that were also developed by the author. This book presents an integrated approach over 12 chapters covering measurement principles, basic circuits and electronics, instrumentation and data acquisition, signal processing—analog and digital, sensors, actuators, digital circuits, and microcontroller programming and interfacing. Both hardware and software components and their integration are covered. Computer programming is emphasized as an important tool integrating theoretical concepts with visualization through analysis, design, and simulation, virtual experimentation, and actual laboratory experiments, if laboratory facilities are available. The concepts and procedures are illustrated through relevant examples in each chapter. There is a specific section in each chapter to illustrate computer-aided solution primarily using Matlab and simulation of associated circuits/systems using virtual simulation platform of Tinkercad. Three software platforms are covered in the book—Matlab for analysis, design, and simulation; LabVIEW for real-time data acquisition, analysis, and digital signal processing; and C++ for Arduino-based microcontroller programming and interfacing. Exercise problems are provided at end of each chapter to help enhance understanding of the materials covered and consolidate problem-solving skills. This also reinforces “hands-on, minds-on” learning approach emphasized throughout the book.

vii

viii

Preface

Topics of the book can be grouped in following modules: (A) Measurement fundamentals, basic circuits, instrumentation, and analog signal processing (Chaps. 1, 2, 3, 4 and 5); (B) data acquisition and digital signal processing, digital circuits (Chaps. 6 and 8); (C) sensors and actuators (Chaps. 7 and 9), (D) microcontroller programming and interfacing (Chap. 10); and (E) basic control system principles and mechatronic systems (Chaps. 11 and 12). In Chap. 1, Mechatronics is introduced as an interdisciplinary field along with the need for integrating systems thinking and DIKW hierarchy. In this chapter, fundamentals of measurement are presented along with basic statistics and uncertainty analysis. In Chap. 2, basic circuit elements, equivalent circuits, DC and AC circuit analysis, power, and transformer are briefly reviewed. In Chap. 3, basic principles and applications of semiconductor electronics and electronic devices like junction diodes, zener diodes, bipolar junction transistors (BJT), and metal oxide semiconductor field effect transistors (MOSFET) are covered. In Chap. 4, analysis and characterization of mechatronics and measurement system responses under static and dynamic conditions are presented. In Chap. 5, analysis and applications of operational amplifiers in analog signal processing using different configurations that include inverting amplifier, noninverting amplifier, adder, buffer, comparator, integrator, and differentiator are presented. In Chap. 6, number systems, analog-to-digital conversion (ADC), digital-toanalog conversion (DAC), computer-based data acquisition (DAQ) systems, DAQ hardware, and software platform of LabVIEW are covered. In Chap. 7, sensors commonly used in mechatronic systems that include strain gages, vibration measuring instruments, accelerometers, resistance temperature detectors (RTD), thermistors, and thermocouples are presented. In Chap. 8, digital logic, digital logic devices, and their applications in mechatronic systems are presented. In Chap. 9, actuators commonly used in mechatronic systems that include DC servo motors and stepper motors are introduced. In Chap. 10, microcontroller programming and interfacing using Arduino-based hardware and software platforms are covered. In Chap. 11, basic control system principles and applications are introduced. In Chap. 12, a mobile robot platform, Lego Mindstorms EV3, is used to illustrate the application of knowledge gained in previous chapters (Chaps. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and 11) that include sensors, actuators, microcontroller programming, and interfacing in a mechatronic system. The graphical programming language of LabVIEW is used to consolidate the programming knowledge gained in previous chapters. However, similar projects can be done using different hardware and software platforms. For example, in graduate Mechatronics course at Georgia Southern, programming language Python is introduced and EV3 project is carried out in MicroPython environment using the libraries for EV3 (EV3 Brick).

Preface

ix

In Appendix A, tables of SI-based units, SI unit prefixes, and conversion factors from conventional to SI systems of units are presented; in Appendix B, table of Laplace Transform of common functions are presented. The book can be used in a 3-credit hour course at junior undergraduate or beginning graduate level in Mechanical Engineering programs. To provide handson experience, a companion laboratory course (2 hours lab with 1 credit hour) can be offered as a co-requisite course that can be built around the laboratory experiments covered throughout the book. At Georgia Southern University, the author uses the content for a 3-credit hour course (with 4 contact hours: 2 hours of lectures and 2 hours of labs) in the undergraduate Mechanical Engineering program (BSME). The course will be offered, starting in Fall 2023, as a combination of a 3-credit course (3 hours of lectures) and a 1-credit hour lab (2 hours of labs) course as a co-requisite in BSME at Georgia Southern. The book materials can also be used in a 3-credit hour course at beginning graduate level in Mechanical or Mechatronics Engineering programs. The author uses most of the content with additional materials for the first 3-credit hour course on Mechatronics of a 2-course sequence in the graduate program in Mechanical Engineering (MSME) at Georgia Southern. The content of the book, though primarily used in undergraduate- and graduatelevel programs in Mechanical Engineering, can also be suitable for students from other undergraduate programs needing an introductory exposure to areas that include instrumentation, data acquisition, signal processing, microcontroller programming and interfacing, digital circuits, sensors, and actuators. The book can also be used for self-study by practicing engineers for refreshing Mechatronics-related topics. Statesboro, GA, USA

Biswanath Samanta

Acknowledgments

I had a unique opportunity to develop Mechatronics and related courses like Measurement Systems, Control Systems, and Robotics along with companion laboratory facilities from scratch and teach these courses, both undergraduate and graduate, at several universities over the years as a faculty member. The challenging but exciting and professionally satisfying journey started with the junior-level Measurement Systems course (including laboratory) at my alma mater, Indian Institute of Technology (IIT), Kharagpur, and continued to Mechatronics courses, both undergraduate and graduate, at Georgia Southern University, with other courses in between at these and other universities I worked for. I have greatly benefited from this unique experience and am grateful to my colleagues and administration at these universities for their support. Numerous students who took these courses in formative years of my academic career are now well established themselves in their respective professional fields. I acknowledge the positive roles of the students in development and delivery of the courses through the constructive feedback received over the years. I have also presented the development of Mechatronics and related courses in international conferences, published in conference proceedings and journals, and received constructive feedback. I have incorporated all constructive feedback in organizing the content and coverage of topics in the book. The solutions of examples and figures presented in the book were mostly generated using Matlab/Simulink (https://www.mathworks.com). All virtual simulations were carried out using virtual simulation platform Tinkercad (https://www. tinkercad.com). Most Arduino examples were adapted from Arduino (https://www. arduino.cc). All LabVIEW examples were generated using LabVIEW (https://www. ni.com). I thankfully acknowledge the availability of these software platforms online (Tinkercad and Arduino) and through Georgia Southern University (Matlab/ Simulink and LabVIEW). The writing of the book is possible through sacrifice, love, and support of my wife Rupama, son Rupayan, and daughter Rupabali throughout the years, especially the past several years, before and during Covid years. I lovingly acknowledge the xi

xii

Acknowledgments

sacrifice, love, and support of my wonderful family for completion of this book project. The book manuscript was written mostly during long nights passing into early hours, in weekends, and during long breaks, with minimum to no interference from my family, except occasional tea and pizza breaks. The final production of the book from the manuscript draft to final form is possible through the cooperative environment of Springer Nature. I gratefully acknowledge the cooperation and guidance from Springer Nature Publishing group in charge of this project, particularly Michael Luby, Brian Halm, and Bakiyalakshmi RM. Statesboro, GA, USA

Biswanath Samanta

Contents

1

2

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1 Mechatronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 An Integrated Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Organization of Book Chapters . . . . . . . . . . . . . . . . . . . . . . . . 1.4 Measurement Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.1 Basic Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.2 Excel and Matlab Commands for Basic Statistics . . . . . 1.4.3 Example Problems: Basic Statistics . . . . . . . . . . . . . . . 1.4.4 Uncertainty Analysis . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.5 Estimation of Allowable Uncertainty of Individual Measured Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.6 Example Problems: Uncertainty Analysis . . . . . . . . . . . 1.4.7 Computer-Aided Analysis of Basic Statistics and Uncertainty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.8 Experiment on Basic Statistics . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Basic Electrical Circuit Elements and Circuit Analysis . . . . . . . . . . 2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Basic Electrical Circuit Elements . . . . . . . . . . . . . . . . . . . . . . . 2.2.1 Resistor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.2 Capacitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.3 Inductor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Basic Electrical Circuit Elements in Series and in Parallel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3.1 Resistors in Series and in Parallel . . . . . . . . . . . . . . . . 2.3.2 Capacitors in Series and in Parallel . . . . . . . . . . . . . . . 2.3.3 Inductors in Series and in Parallel . . . . . . . . . . . . . . . .

1 1 3 4 5 7 7 8 10 11 12 14 15 17 18 21 21 21 21 23 24 25 25 26 27

xiii

xiv

Contents

2.4

DC Circuit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.1 Ohm’s Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.2 Kirchhoff’s Current Law . . . . . . . . . . . . . . . . . . . . . . 2.4.3 Kirchhoff’s Voltage Law . . . . . . . . . . . . . . . . . . . . . . 2.5 Ideal Voltage and Current Sources and Measuring Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.6 Equivalent Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.6.1 Thevenin Equivalent Circuit . . . . . . . . . . . . . . . . . . . . 2.6.2 Norton Equivalent Circuit . . . . . . . . . . . . . . . . . . . . . . 2.7 AC Circuit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.7.1 AC Signal and Phasor Representation . . . . . . . . . . . . . 2.7.2 Impedance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8 Power in Electrical Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.9 Transformer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.10 Impedance Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.11 Computer-Aided Analysis of Basic Circuits . . . . . . . . . . . . . . . 2.11.1 Analysis Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . 2.11.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Basic Electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Introduction to Junction Diodes . . . . . . . . . . . . . . . . . . . . . . . . 3.2.1 Ideal Diode Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.2 Nonlinear Current-Voltage Characteristics of Junction Diodes . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.3 Zener Diode and Voltage Regulation . . . . . . . . . . . . . . 3.2.4 Analysis of Diode Circuits . . . . . . . . . . . . . . . . . . . . . 3.2.5 Rectifier Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Bipolar Junction Transistors . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.1 Example Problem of npn BJT . . . . . . . . . . . . . . . . . . . 3.3.2 Example Problem of pnp BJT . . . . . . . . . . . . . . . . . . . 3.4 Metal Oxide Semiconductor Field Effect Transistors . . . . . . . . . 3.4.1 NMOS Example Problem . . . . . . . . . . . . . . . . . . . . . . 3.4.2 PMOS Example Problem . . . . . . . . . . . . . . . . . . . . . . 3.5 Computer-Aided Analysis of Basic Electronic Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5.1 Analysis Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . 3.5.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

28 28 28 28 29 29 29 29 30 30 31 33 34 35 35 36 36 37 40 41 41 41 41 42 44 47 51 53 54 55 57 59 60 62 62 63 63 66

Contents

4

5

Dynamic System Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 First-Order Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.1 Time Domain Analysis . . . . . . . . . . . . . . . . . . . . . . . . 4.2.2 Frequency Domain Analysis . . . . . . . . . . . . . . . . . . . . 4.2.3 Experimental Determination of System Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3 Second-Order Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3.1 Time Domain Analysis . . . . . . . . . . . . . . . . . . . . . . . . 4.3.2 Frequency Domain Analysis . . . . . . . . . . . . . . . . . . . . 4.3.3 Experimental Determination of System Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4 Fourier Series Representation of Periodic Signals . . . . . . . . . . . 4.4.1 Fourier Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.2 Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.3 Examples of Fourier Transform of Signals Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5 Computer-Aided Analysis and Simulation of Dynamic System Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.1 Analysis Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . 4.5.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . 4.6 Experimental Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Analog Signal Processing and Operational Amplifiers . . . . . . . . . . . 5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 Operational Amplifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3 Ideal Operational Amplifier Model . . . . . . . . . . . . . . . . . . . . . . 5.4 Inverting Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.5 Noninverting Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.6 Summing Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.7 Difference Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.8 Integrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.9 Differentiator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.10 Voltage Follower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.11 Comparator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.12 Sample and Hold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.13 Instrumentation Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.14 The Real Operational Amplifier . . . . . . . . . . . . . . . . . . . . . . . . 5.15 Computer-Aided Analysis and Simulation of Operational Amplifier Circuits . . . . . . . . . . . . . . . . . . . . . . . 5.15.1 Analysis Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . 5.15.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . .

xv

67 67 67 68 69 71 72 72 79 80 82 82 83 83 85 87 88 88 92 93 95 95 95 96 97 99 101 102 104 107 110 111 112 112 114 114 114 115

xvi

6

7

Contents

5.16 5.17

Summary of Operational Amplifier Configurations . . . . . . . . . . Simulation and Experimental Validation . . . . . . . . . . . . . . . . . . 5.17.1 Basic Operational Amplifier Configurations . . . . . . . . . 5.17.2 Integrator, Differentiator, and Modified Versions . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

116 116 116 124 130 137

Data Acquisition and Digital Signal Processing . . . . . . . . . . . . . . . . 6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2 Analog and Discrete Signals . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3 Number Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3.1 Decimal Number System . . . . . . . . . . . . . . . . . . . . . . 6.3.2 Binary Number System . . . . . . . . . . . . . . . . . . . . . . . . 6.3.3 Octal and Hexadecimal Number Systems . . . . . . . . . . . 6.3.4 Decimal to Binary Conversion . . . . . . . . . . . . . . . . . . 6.3.5 Binary to Octal Conversion . . . . . . . . . . . . . . . . . . . . . 6.3.6 Binary to Hexadecimal Conversion . . . . . . . . . . . . . . . 6.4 Analog-to-Digital Conversion . . . . . . . . . . . . . . . . . . . . . . . . . 6.4.1 Successive Approximation Register (SAR) ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.4.2 Flash ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.4.3 ADC Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5 Digital-to-Analog Conversion . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.1 Digital-to-Analog Converters . . . . . . . . . . . . . . . . . . . 6.5.2 DAC Relation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.6 Virtual Instruments, Data Acquisition, and Digital Signal Processing Using LabVIEW . . . . . . . . . . . . . . . . . . . . . 6.6.1 Virtual Instruments . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.6.2 Signal Simulation and Analysis . . . . . . . . . . . . . . . . . . 6.6.3 Data Acquisition and Digital Signal Processing . . . . . . 6.7 LabVIEW Experimentation . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

139 139 139 140 141 141 142 142 143 143 144

Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2 Position, Displacement, and Velocity Measurement . . . . . . . . . . 7.2.1 Proximity Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.2 Potentiometers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.3 Ultrasonic Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.4 Tachogenerators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3 Stress and Strain Measurement Using Strain Gages . . . . . . . . . . 7.3.1 Electrical Resistance Strain Gage . . . . . . . . . . . . . . . . . 7.3.2 Wheatstone Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.3 Member with Axial Load . . . . . . . . . . . . . . . . . . . . . . 7.3.4 Member with Transverse Load . . . . . . . . . . . . . . . . . .

144 146 147 149 149 151 151 151 152 154 157 160 161 163 163 163 163 164 164 164 165 165 168 170 171

Contents

xvii

7.4

173

Vibration and Acceleration Measurement . . . . . . . . . . . . . . . . . 7.4.1 Vibration Pickups for Displacement Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.2 Accelerometers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.3 Piezoelectric Accelerometers . . . . . . . . . . . . . . . . . . . . 7.4.4 Charge Amplifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.5 A Piezoelectric Accelerometer with a Charge Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5 Temperature Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5.1 Resistance Temperature Detectors . . . . . . . . . . . . . . . . 7.5.2 Thermistors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5.3 Thermocouples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.6 Computer-Aided Analysis and Simulation of Wheatstone Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.6.1 Analysis Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . 7.6.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . 7.7 Experimental Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.7.1 Data Acquisition and Analysis Using LabVIEW and a Thermocouple . . . . . . . . . . . . . . . . . . . . . . . . . . 7.7.2 Measurement Using a Strain Gage Under Static Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.7.3 Data Acquisition and Analysis Using LabVIEW and a Strain Gage Under Dynamic Condition . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Digital Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2 Combinational Logic Devices . . . . . . . . . . . . . . . . . . . . . . . . . 8.3 Boolean Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.4 De Morgan’s Laws . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.5 Truth Table and Simplified Boolean Expression from a Given Boolean Expression . . . . . . . . . . . . . . . . . . . . . . . . . . 8.6 Simplified Boolean Expression and Digital Circuit from a Given Truth Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.7 Design of Digital Logic Networks . . . . . . . . . . . . . . . . . . . . . . 8.7.1 Define the Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.7.2 Write the Quasi-Logic Statement . . . . . . . . . . . . . . . . . 8.7.3 Write the Boolean Expression . . . . . . . . . . . . . . . . . . . 8.7.4 Simplify the Boolean Expression . . . . . . . . . . . . . . . . . 8.7.5 Construct the Digital Logic Circuit . . . . . . . . . . . . . . . 8.7.6 Convert to an all-NAND Circuit . . . . . . . . . . . . . . . . . 8.7.7 Convert to an All-NOR Circuit . . . . . . . . . . . . . . . . . . 8.8 Karnaugh Map (K-Map) for Simplification of Boolean Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

174 177 180 181 182 185 185 186 187 191 191 192 192 192 195 198 202 205 207 207 207 209 211 213 215 218 218 219 219 219 220 220 221 223

xviii

Contents

8.9

9

Sequential Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.9.1 SR Flip-Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.9.2 Edge-Triggered SR Flip-Flop . . . . . . . . . . . . . . . . . . . 8.9.3 D Flip-Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.9.4 JK Flip-Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.9.5 T Flip-Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.10 Computer-Aided Analysis and Simulation of Digital Logic Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.10.1 Analysis Using Excel . . . . . . . . . . . . . . . . . . . . . . . . . 8.10.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

225 225 226 227 227 228

Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.2 Types of Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.3 Electromechanical Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . 9.4 DC Motor Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.4.1 Dynamic Model of an Armature Controlled DC Motor . . . . . . . . . . . . . . . . . . . . . . . . . 9.4.2 Steady-State Characteristics . . . . . . . . . . . . . . . . . . . . 9.5 Selection of DC Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.6 Electronic Control of DC Motor Speed and Direction . . . . . . . . 9.6.1 Pulse Width Modulation (PWM) . . . . . . . . . . . . . . . . . 9.6.2 H-Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.6.3 L293D Motor Driver IC . . . . . . . . . . . . . . . . . . . . . . . 9.6.4 L298N Motor Driver Module . . . . . . . . . . . . . . . . . . . 9.6.5 DC Motor Speed and Direction Control Using an Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.7 Stepper Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.7.1 Stepper Motor Characteristics . . . . . . . . . . . . . . . . . . . 9.7.2 Driving a Bipolar Stepper Motor Using a Dual H-Bridge and an Arduino . . . . . . . . . . . . . . . . . 9.8 Computer-Aided Analysis and Simulation of DC Motors . . . . . . 9.8.1 Analysis Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . 9.8.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . 9.9 Laboratory Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.9.1 Driving a DC Motor Using an H-Bridge (L293N) and an Arduino . . . . . . . . . . . . . . . . . . . . . . 9.9.2 Driving a Bipolar Stepper Motor Using a Dual H-Bridge and an Arduino . . . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

237 237 237 237 238

229 229 230 232 236

239 241 244 246 246 247 248 249 249 254 254 254 257 257 259 261 261 262 262 263

Contents

10

Microcontroller Programming and Interfacing . . . . . . . . . . . . . . . . 10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.2 Arduino Microcontroller Development Boards . . . . . . . . . . . . . 10.3 Arduino Programming Environment . . . . . . . . . . . . . . . . . . . . . 10.4 Arduino Programming Language . . . . . . . . . . . . . . . . . . . . . . . 10.4.1 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.4.2 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.4.3 Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.5 An Example Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.6 Virtual Simulation on Tinkercad . . . . . . . . . . . . . . . . . . . . . . . 10.7 Simulation of Example Codes on Tinkercad . . . . . . . . . . . . . . . 10.7.1 Simulation of digitalRead and digitalWrite on Tinkercad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.7.2 Simulation of analogRead and analogWrite on Tinkercad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.7.3 Simulation of Data Type, Time, and Serial Communication on Tinkercad . . . . . . . . . . . . . . . . . . . 10.7.4 Simulation of Compound Operators on Tinkercad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.8 Arduino Programming and Interfacing Examples . . . . . . . . . . . 10.8.1 Simulation of 3-Bit Binary Patterns (000-111) Using an Arduino and Three LEDs . . . . . . . . . . . . . . . 10.8.2 Simulation of Setting LEDs On/Off Based on the Status of Push Buttons . . . . . . . . . . . . . . . . . . . 10.8.3 Simulation of a Digital Logic Circuit for a Multiplexer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.8.4 Simulation of Ultrasonic Sensor for Distance Measurement with an Arduino . . . . . . . . . . . . . . . . . . 10.9 Simulation on Tinkercad and Physical Validation in Laboratory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.9.1 Simulation of 4-Bit Binary Patterns (0000-1111) Using an Arduino and 4 LEDs . . . . . . . . . . . . . . . . . . 10.9.2 Simulation of Setting Four LEDs On/Off Based on the Status of Two Push Buttons . . . . . . . . . . 10.9.3 Simulation of a Digital Logic Circuit for Implementing X = A  B þ ðA þ BÞ  C . . . . . . . . . . . . . 10.9.4 Simulation of Ultrasonic Sensor for Distance Measurement with Arduino . . . . . . . . . . . . . . . . . . . . . 10.9.5 Simulation of a Home Security System Using Digital Logic Gates and an Arduino on Tinkercad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.9.6 Simulation of a Car Safety System Using Digital Logic Gates and Arduino on Tinkercad . . . . . . . . . . . . Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

xix

265 265 266 267 268 268 270 271 273 274 275 275 276 277 278 280 280 282 284 286 289 289 289 290 291

291 292 294

xx

11

12

Contents

Basic Control Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Control System Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2.1 Mathematical Modeling . . . . . . . . . . . . . . . . . . . . . . . 11.2.2 Open and Closed Loop System Characteristics . . . . . . . 11.3 Stability Analysis of Control Systems . . . . . . . . . . . . . . . . . . . . 11.3.1 Closed Loop Poles on S-Plane . . . . . . . . . . . . . . . . . . 11.3.2 Routh-Hurwitz Criterion . . . . . . . . . . . . . . . . . . . . . . . 11.3.3 Root Locus Technique . . . . . . . . . . . . . . . . . . . . . . . . 11.3.4 Bode Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.4 Control System Specifications . . . . . . . . . . . . . . . . . . . . . . . . . 11.4.1 Design Specifications . . . . . . . . . . . . . . . . . . . . . . . . . 11.4.2 Types of Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . 11.5 Controller Design Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.5.1 PID Controller Design Using Time Domain Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.5.2 PID Controller Design Using Frequency Domain Specifications . . . . . . . . . . . . . . . . . . . . . . . . 11.5.3 Experimental Method: Ziegler-Nichols Method . . . . . . 11.6 Controller Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

295 295 295 296 297 300 300 301 301 304 305 306 307 309

Mechatronic Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.2 Robotics Project Using Lego Mindstorms EV3 . . . . . . . . . . . . . 12.3 EV3 Intelligent Brick . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.4 EV3 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.5 EV3 Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.6 EV3 Sensor Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.6.1 Light Sensor Calibration . . . . . . . . . . . . . . . . . . . . . . . 12.6.2 Touch Sensor Calibration . . . . . . . . . . . . . . . . . . . . . . 12.6.3 Ultrasonic Sensor Calibration . . . . . . . . . . . . . . . . . . . 12.6.4 Gyro Sensor Calibration . . . . . . . . . . . . . . . . . . . . . . . 12.7 EV3 Motor Speed Calibration . . . . . . . . . . . . . . . . . . . . . . . . . 12.8 EV3 Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.8.1 Line Following . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.8.2 Obstacle Avoidance . . . . . . . . . . . . . . . . . . . . . . . . . . 12.8.3 Line Following While Avoiding Obstacle . . . . . . . . . . 12.8.4 Following a Moving Target . . . . . . . . . . . . . . . . . . . . 12.9 Project Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

333 333 333 334 334 335 335 336 337 338 338 339 340 341 342 344 345 346 347

309 314 320 325 329 331

Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

About the Author

Biswanath Samanta received B.Tech. (Honors) and Ph.D. in Mechanical Engineering from Indian Institute of Technology (IIT), Kharagpur. He is an Associate Professor in the Department of Mechanical Engineering at Georgia Southern University (GS), Statesboro, GA, USA. Prior to joining GS, Dr. Samanta held academic positions at Villanova University, Villanova, PA, USA; Sultan Qaboos University, Muscat, Oman (offering ABET-accredited Mechanical Engineering program); and IIT, Kharagpur, India. His expertise and research interests include broad areas of dynamic systems and control, mechatronics, robotics and intelligent systems, advanced signal processing, prognostics and health management, artificial intelligence (AI) and deep learning, and applications of AI in engineering and biomedicine. Dr. Samanta has developed and taught numerous courses in these areas and supervised students at both undergraduate and graduate levels (including 3 PhD and over 45 MS theses). He has over 150 refereed research articles published by professional bodies like ASME, IMechE (UK), AIAA, and IEEE, and other publishers including Elsevier and Springer. The papers are regularly cited by independent researchers in their publications (over 5000 citations). He is a senior member of IEEE and a member of ASME, and currently the President of Robotics Technical Committee, Dynamic Systems and Control Division (DSCD), ASME. He regularly serves as a reviewer of technical papers submitted for publication in several international journals and conference proceedings, as an evaluator of book proposals submitted to different publishers, and as an examiner of Ph.D. theses submitted to different international universities. He is also regularly invited to chair sessions in international conferences. He is on the Editorial Board of international journals as an Associate Editor, ASME Letters in Dynamic Systems and Control; Associate Editor, Neuroimaging and Neuromodulation (specialty section of Frontiers in Neuroimaging); Academic Editor, Sensors; and Advisory Board Member, Sci.

xxi

Chapter 1

Introduction

1.1

Mechatronics

Engineering education in the twenty-first century requires a shift in emphasis from traditional discipline-specific to multidisciplinary domains to promote innovation through STEM education and research. Mechatronics and robotics are viewed as ideal means of multidisciplinary education and research to revitalize STEM education providing real-world, hands-on research experiences to students for better recruitment, retention, progression, and graduation. Multiple engineering disciplines like mechanical (ME), electrical and electronics (EE), computer, and control are integrated in mechatronics leading to application-based systems that can be made adaptive and intelligent. The presence of mechatronic products and systems spanning almost every walk of life from household consumer items to health care, manufacturing, transportation, and defense systems, among others, spurs the interest in mechatronics education. The recent development of Internet of things (IoT) and cloud robotics emphasize the need to integrate computing applications with mechatronics in an even greater way. Mechatronics is a synergistic interdisciplinary integration of multiple engineering fields—mechanical, electrical and electronics, computer, control systems, and information technology—to design, develop, and test intelligent systems with embedded learning capabilities. Applications of mechatronics span over a broad range that include automotive, aerospace, manufacturing, materials processing, medical, defense, robotics, and smart consumer products. Mechatronics as an integrated multidisciplinary field, originally formalized by Kevin Craig (1995), is captured in Fig. 1.1. Mechatronics at the center is enriched integrating the concepts and advances in multiple disciplines and the corresponding subfields. Applications of mechatronics are wide ranging as illustrated by the industries surrounding these fields.

© The Author(s), under exclusive license to Springer Nature Switzerland AG 2023 B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_1

1

2

1

Introduction

Fig. 1.1 Mechatronics as an integrated multidisciplinary field (https://commons.wikimedia.org/w/ index.php?curid=18314501, original credit to Kevin Craig, 1995)

Fig. 1.2 Functional subsystems of typical mechatronic systems

A typical mechatronic system can be considered in terms of functional subsystems as shown in Fig. 1.2. The state of the system can be monitored through the sensors, and the analog sensor outputs are processed through pre-signal conditioning units, converted to digital form, acquired through data acquisition system, and processed in digital devices to output control signals. The digital control signals are converted to analog form using digital-to-analog (DAC) interface, processed

1.2

An Integrated Approach

3

through signal conditioning units like power amplifiers and fed to actuators to achieve the desired system performance specifications. Additionally, there might be display units for visual user interface. The typical signal categories at different levels are indicated (analog in blue or digital in red) in Fig. 1.2. Each of these component subsystems is covered in subsequent chapters of this book.

1.2

An Integrated Approach

With the current trend of Internet of things (IoT) and explosion of data through affordable sensors, there is a strong need for including systems thinking and an understanding of data-information-knowledge-wisdom (DIKW) hierarchy. Abundance of sensors, data explosion, and the need to make sense and utilize the data for better, more reliable, and affordable systems necessitate a thorough understanding of relations, patterns, and principles in DIKW hierarchy, as shown Fig. 1.3. Data can be transformed into information through an understanding of relations (getting rid of extraneous data points/outliers). Information can be transformed into knowledge through an understating of the pattern (connecting the dots). Wisdom is achieved from knowledge as a higher level of understanding of the underlying principles (integrating with knowledge base). Mechatronics is an ideal field to incorporate systems thinking and DIKW hierarchy through an integrated approach covering both hardware and software. This book presents an integrated approach covering measurement principles, basic circuits and electronics, instrumentation and data acquisition, signal processing—analog and digital—sensors, actuators, digital circuits, and microcontroller programming and interfacing. Both hardware and software components are covered. Computer programming is emphasized as an important tool integrating theoretical concepts with visualization through design, simulation and analysis,

Fig. 1.3 Data-informationknowledge-wisdom (DIKW) hierarchy

4

1 Introduction

virtual experimentation, and actual laboratory experiments, if laboratory facilities are available. Three software environments are used with specific purposes to give students an integrated experience. Matlab is used for analysis, design, and simulation; LabVIEW is used for real-time data acquisition, analysis, and digital signal processing; and C++ is used for Arduino-based microcontroller programming and interfacing. Laboratory experiments are presented to demonstrate theoretical concepts for enhancing students’ learning experience, in virtual setting using Tinkercad and actual physical laboratory setting, if facilities are available. This book demonstrates the use of an “integrated” approach to cover multidisciplinary topics of mechatronics, emphasizing theoretical background, validation through analysis, simulation, and implementation in virtual and physical laboratory experiments. Each topic is presented in detail, and the related concepts are illustrated through examples and codes for better visualization and validation. The experimental aspects of relevant topics are illustrated through virtual and physical laboratory settings. The integrated approach to treat theoretical concepts illustrated with examples, hardware and software, programming and interfacing, and virtual and physical experimentation in a single book helps reinforce understanding of the topics covered and enhance problem-solving skills. This also reinforces “hands-on, minds-on” learning approach emphasized throughout the book. The book materials have been time tested in courses offered by the author at university level over the years.

1.3

Organization of Book Chapters

The topics of the book can be grouped in the following modules over 12 chapters: (A) Measurement fundamentals, basic circuits, instrumentation, and analog signal processing (This chapter and Chaps. 2, 3, 4 and 5); (B) data acquisition and digital signal processing, digital circuits (Chaps. 6 and 8); (C) sensors and actuators (Chaps. 7 and 9), (D) microcontroller programming and interfacing (Chap. 10); and (E) basic control system principles and mechatronic systems (Chaps. 11 and 12). In the rest of this chapter, fundamentals of measurement are presented along with basic statistics and uncertainty analysis. Basic circuit elements, equivalent circuits, DC and AC circuit analysis, power, and transformer are briefly reviewed in Chap. 2 for completeness. These topics are generally covered in detail in a prerequisite course on basic circuit analysis. Basic principles and applications of semiconductor electronics and electronic devices like junction diodes, Zener diodes, bipolar junction transistors (BJT), and metal oxide semiconductor field effect transistors (MOSFET) are covered in Chap. 3.

1.4

Measurement Fundamentals

5

Analysis and characterization of responses of mechatronics and measurement systems under static and dynamic conditions are presented in Chap. 4. Analysis and applications of operational amplifiers in analog signal processing using different configurations that include inverting amplifier, noninverting amplifier, adder, buffer, comparator, integrator, and differentiator are presented in Chap. 5. Number systems, analog-to-digital conversion (ADC), digital to analog conversion (DAC), and computer-based data acquisition (DAQ) systems—DAQ hardware and software platform (LabVIEW)—are covered in Chap. 6. Sensors commonly used in mechatronic systems that include strain gages, vibration measuring instruments, accelerometers, resistance temperature detectors (RTD), thermistors, and thermocouples are presented in Chap. 7. Digital logic, digital logic devices, both combinational and sequential, and their applications in mechatronic systems are presented in Chap. 8. Actuators commonly used in mechatronic systems that include DC servo motors and stepper motors are introduced in Chap. 9. Microcontroller programming and interfacing using Arduino-based hardware and software platforms are covered in Chap. 10. Basic control system principles and applications are introduced in Chap. 11. In Chap. 12, a mobile robot platform, Lego Mindstorms EV3, is used to illustrate the application of knowledge gained in previous chapters (This chapter and Chaps. 2, 3, 4, 5, 6, 7, 8, 9, 10 and 11) that include sensors, actuators, microcontroller programming, and interfacing in a mechatronic system. This is generally used as a course project for the undergraduate course on Introduction to Mechatronics. The graphical programming language of LabVIEW is used to consolidate the programming knowledge gained earlier during the course. However, similar projects can be done using different hardware and software platforms. For example, in graduate mechatronics course at Georgia Southern, programming language Python is introduced, and the EV3 project is carried out in MicroPython environment using the libraries for EV3 (EV3 brick). In Appendix A, tables of SI-based units, conversion factors from conventional to SI systems of units, and in Appendix B, table of Laplace transform of common functions are presented.

1.4

Measurement Fundamentals

In measurement systems, the following points need to be emphasized: • No measurement is exact. • Measurement should be accurate—measured values should be close to the actual values. • Measurement process should be precise—measured values should be close to each other.

6

1

Accurate

Introduction

Inaccurate (systematic error)

Precise

Imprecise (reproducibility error)

Fig. 1.4 Accuracy and precision

Table 1.1 Accuracy and precision comments

Accurate Precise Desired

Inaccurate (systematic error) Can be corrected by re-calibration of measurement devices

Imprecise Can be corrected (reproducibility by adjustment of To be avoided error) measurement processes/devices

In measurement systems, accuracy is characterized as closeness of measured values to the actual value. Precision is defined as closeness of measured values to each other (with less spread) and a measure of repeatability. Situations of accuracy and precision are presented in Fig. 1.4 along with comments in Table 1.1. As indicated, the most desirable situation is where measured values are accurate and precise (upper left corners in Fig. 1.4 and Table 1.1), and the worst situation is where measured values are inaccurate and imprecise (lower right corners in Fig. 1.4 and Table 1.1). The situation where measured values are precise but inaccurate (upper right corners in Fig. 1.4 and Table 1.1) can be corrected by recalibrating the measurement devices with known standards. The situation where measured values are reasonably close to the actual value but with wider spread (accurate but imprecise—lower left corners in Fig. 1.4 and Table 1.1) can be corrected by adjustment of measurement processes and/or devices.

1.4

Measurement Fundamentals

1.4.1

7

Basic Statistics

Let us consider the number of measurements (n) of a variable X(xi, i = 1, 2, . . . , n). The basic statistical measures, average or mean (μ), variance (v), and standard deviation (s) for the variable using the measured data can be obtained as follows: μ=

Pn

Pn

i=1 xi

n

- μÞ2 n-1 sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi Pn 2 pffiffiffi i=1 ðxi - μÞ s= v= n-1 v=

i=1 ðxi

ð1:1Þ ð1:2Þ ð1:3Þ

If the sample size (n) is at least 29, the sample standard deviation (s) is approximated to be the population standard deviation (σ) as sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi Pn 2 i=1 ðxi - μÞ σ= n

ð1:4Þ

The standard normal variable (z) with zero mean and standard deviation of 1 is obtained from the variable (x) as follows: x-μ s

ð1:5Þ

x=μ þ s z

ð1:6Þ

z=

The ranges of probability for a normal distribution within  σ,  2σ,  3σ of the mean (μ), also known as 68-95-99.7 rule (Wikipedia 2022), are given in Eqs. (1.7), (1.8) and (1.9) and in Fig. 1.5.

1.4.2

Pðμ - σ ≤ X ≤ μ þ σ Þ ≈ 68:27%

ð1:7Þ

Pðμ - 2σ ≤ X ≤ μ þ 2σ Þ ≈ 95:45%

ð1:8Þ

Pðμ - 3σ ≤ X ≤ μ þ 3σ Þ ≈ 99:7%

ð1:9Þ

Excel and Matlab Commands for Basic Statistics

Excel commands for maximum, minimum, mean, mode, median, variance, and standard deviation for sample are max(x1 : xn), min (x1 : xn), mode. sngl(x1 : xn), median(x1 : xn), var . s(x1 : xn), stdev. s(x1 : xn) with data stored as a column

8

1

Introduction

Fig. 1.5 Normal distribution 68-95-99.7 rule (Wikipedia 2022)

x(x1 : xn). Commands for variance and standard deviation for population are var. p(x1 : xn) and stdev. p(x1 : xn). The probability P(X ≤ x) and P(X ≥ x) are obtained using Excel commands: PðX ≤ xÞ = norm:distðx, μ, s, trueÞ PðX ≥ xÞ = 1 - norm:distðx, μ, s, trueÞ The corresponding Matlab commands are max(x), min (x), mode(x), median (x), var (x), and std(x) with data stored as an array x. The probabilities P(X ≤ x) and P(X ≥ x) are obtained using matlab commands:  x-μ s   x-μ PðX ≥ xÞ = 1 - PðX ≤ xÞ = 1 - normcdf s PðX ≤ xÞ = 1 - PðX ≥ xÞ = normcdf



The Matlab command to obtain histogram is hist(x, N) where N is the number of data groups for histogram.

1.4.3

Example Problems: Basic Statistics

Example 1.1 A set of measurements of a sample of resistors with a nominal value of 120 Ω is obtained as follows: R = (116.9, 118.9, 119.3, 119.5, 119.8, 119.8, 120.4, 121.3, 121.8, 122.1) Ω. Find mean, mode, median, variance, standard deviation, z-score, and probabilities P(Z ≤ z), P(X ≤ x), and P(X > x).

1.4

Measurement Fundamentals

Table 1.2 Statistical parameters for Example 1.1

9

Statistical parameter Maximum Minimum Mode Median Mean (μ) Variance (sample) Variance (population) Standard deviation (sample) (s) Standard deviation (population) (σ)

Value (Ω) 122.1 116.9 119.8 119.8 119.98 2.3484 2.1136 1.5324 1.4538

Table 1.3 Probability distribution for Example 1.1 x-value 116.9 118.9 119.3 119.5 119.8 119.8 120.4 121.3 121.8 122.1

z=

x - μ s

-2.0098 -0.7047 -0.4437 -0.3132 -0.1175 -0.1175 0.2741 0.8614 1.1876 1.3834

P (Z < = z) = norm . s. dist(z, true) 0.0222 0.2405 0.3286 0.3771 0.4532 0.4532 0.6080 0.8055 0.8825 0.9167

P(X < = x) = norm . dist(x, μ, s, true) 0.0222 0.2405 0.3286 0.3771 0.4532 0.4532 0.6080 0.8055 0.8825 0.9167

P(X > x) = 1 - P(X < = x) 0.9778 0.7595 0.6714 0.6229 0.5468 0.5468 0.3920 0.1945 0.1175 0.0833

Solution Using Excel commands, basic statistical parameters for the set of measured values of resistance are obtained as shown in Tables 1.2 and 1.3. Example 1.2 For a set of measured values for a sample of resistors with an average of 119.8 Ω and a standard deviation of 1.1245 Ω, find resistance corresponding to a z-score of 1.125. Find probabilities P(Z ≤ 1.125) and P(Z > z). Solution For the given set of measured values, mean μ = 119.8 Ω, standard deviation σ = 1.1245 Ω, z = 1.125. x = μ + z σ = 119.8 + (1.125) (1.1245) = 121.07 Ω. P(Z ≤ 1.125) = norm . s. dist(z, true) = 0.8697. (Matlab command normcdf(z) should give the same result). P(Z > 1.125) = 1 - norm . s. dist(z, true) = 0.1303. (Matlab command 1 - normcdf(z) should give the same result).

10

1.4.4

1

Introduction

Uncertainty Analysis

Let us consider a variable Y computed from a set of individually measured variables xi Y = f ðx1 , x2 , . . . , xn Þ

ð1:10Þ

Where xi, i = 1, 2, . . . , n are the measured variables, and n being the number of variables with individual uncertainties of measurement Δxi. The uncertainty of the computed parameter Y due to uncertainty of individual measured variables can be computed as first-order approximation in terms of partial derivatives ∂f , i=1, 2, 3, . . . , n, and individual measurement uncertainties Δxi (assuming Δxi as ∂xi very small) as follows: ΔY =

1.4.4.1

 Xn  ∂f Δx i i=1 ∂xi

ð1:11Þ

Maximum Possible Error

The maximum possible error can be computed as the total absolute error, taking the absolute value of contribution of each variable as follows: Xn ∂f ΔY abs = Δxi i=1 ∂xi

ð1:12Þ

The maximum possible range of computed parameter can be expressed as follows: Y = Y 0  ΔY abs

ð1:13Þ

where Y0 represents the nominal value of Y corresponding to the nominal measured values xi0, xi = xi0  Δxi.

1.4.4.2

Most Probable Error

The most probable error can be obtained as the square root of sum of squares or rootsum-square (rss) as follows: sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 2ffi Xn  ∂f Δxi ΔY rss = i=1 ∂xi

ð1:14Þ

1.4

Measurement Fundamentals

11

The maximum possible range of computed parameter can be expressed as follows: Y = Y 0  ΔY rss

ð1:15Þ

where Y0 represents the nominal value of Y corresponding to the nominal measured values xi0, xi = xi0  Δxi. In general, ΔYrss ≤ ΔYabs. Estimation of Uncertainty of Computed Parameter for Given Uncertainty of Individual Measured Variable The uncertainty of computed parameter for given uncertainty of each individual measured variable can be obtained using Eqs. (1.12) and (1.14) for the maximum possible error and most probable error respectively.

1.4.5

Estimation of Allowable Uncertainty of Individual Measured Variables

Allowable uncertainty of individual measured variables can be estimated based on either the maximum possible or most probable uncertainty of the computed parameter.

1.4.5.1

Based on Maximum Possible Uncertainty of the Computed Parameter

The maximum possible uncertainty of the computed parameter, Eq. (1.12) is rewritten here ΔY abs =

Xn ∂f Δxi i=1 ∂xi

ð1:12Þ

Assuming equal error contribution from each measured variable, Eq. (1.12) can be rewritten as (1.16) ∂f ΔY abs = n Δxi ∂xi

ð1:16Þ

Equation (1.16) can be rearranged to express allowable uncertainty of individual measured variables as Δxi,abs =

ΔY abs ∂f n ∂x i

ð1:17Þ

12

1.4.5.2

1

Introduction

Based on the Most Probable Uncertainty of the Computed Parameter

The most probable uncertainty of the computed parameter, Eq. (1.14) is rewritten here: sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 2ffi Xn  ∂f Δxi ΔY rss = i=1 ∂xi

ð1:14Þ

Assuming equal error contribution from each measured variable, Eq. (1.14) can be rewritten as (1.18) sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi  2ffi ∂f Δxi ΔY rss = n ∂xi

ð1:18Þ

Equation (1.18) can be rearranged to express allowable uncertainty of individual measured variables as ΔY Δxi,rss = pffiffiffi rss ∂f n ∂x i

ð1:19Þ

It should be recognized that for n > 1, allowable individual error contribution of each measured variable based on the root-sum-of-square error (Δxi,rss) is higher than that based on maximum possible error (Δxi,abs). In other words, the criterion of most probable uncertainty of computed parameter gives higher value of allowable uncertainty for individual measured variables than that based on the maximum possible uncertainty for n > 1.

1.4.6

Example Problems: Uncertainty Analysis

Example 1.3 In a laboratory testing, the resistance of a conductor (R) is to be estimated using measured values of resistivity (ρ), length (L ), and radius (r) as ρL R = πr 2 . The measured values and their uncertainties are reported as follows: ρ = 1.7 × 10-8(1  0.10)Ω. m, L = 10  0.001 m, and r = 0.5  0.1 mm. Determine the resistance of the conductor and its maximum possible and most probable uncertainties. Solution ρL R = 2 , ρ = 1:7 × 10 - 8 ð1  0:10ÞΩ:m, L = 10  0:001 m, r = 0:5  0:1 mm: πr

1.4

Measurement Fundamentals

13

ð1:7 × 10 - 8 Ω:mÞ ð10 mÞ = 0:2165 Ω 2 π ð0:5 × 10 - 3 mÞ = πrρ2 , ∂R = - 2ρL πr3 ∂r

Nominal value of resistance R = = Partial derivatives: ∂R ∂ρ

L ∂R πr2 , ∂L

Error contributions from individual measured variables:   ð10 mÞ ∂R -9 Δρ =  2 1:7 × 10 Ω:m = 0:0216 Ω -3 ∂ρ π 0:5 × 10 m   1:7 × 10 - 8 Ω:m ∂R -5 ΔRL = ΔL =  2 ð0:001 mÞ = 2:1645 × 10 Ω ∂L π 0:5 × 10 - 3 m   2 1:7 × 10 - 8 Ω:m ð10 mÞ ∂R ð0:0001 mÞ = - 0:0866 Ω ΔRr = Δr =  3 ∂r π 0:5 × 10 - 3 m ΔRρ =

Maximum possible uncertainty ΔRabs = |ΔRρ| + |ΔRL| + |ΔRr| = 0.1082 Ω abs × 100% = 50:01% ffi Percentage uncertainty pΔRabs = ΔRRq ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi

Most probable uncertainty ΔRrss = Percentage uncertainty pΔRrss =

ΔRrss R

ΔRρ 2 þ ΔRL 2 þ ΔRr 2 = 0:0892 Ω × 100% = 41:23%

Example 1.4 For the problem of Example 1.3, estimate the allowable uncertainty in the measurements of resistivity, length, and radius if the most probable uncertainty in resistance is to be within 5%. Check if the currently available measuring instruments are accurate enough for this requirement. Estimate the most probable uncertainty in resistance with the updated allowable uncertainty of the measured variables. Solution GivenΔR = 5%of R, ΔR = 0:0108 Ω, n = 3 ΔR = 4:9075 × Allowable uncertainty in measurement of resistivity Δρ = pffiffiffi n ∂R ∂ρ

10 - 10 Ω.m. This is less than the current uncertainty for resistivity; the current measuring instrument uncertainty needs to be improved. ΔR = 0:2887 m. This Allowable uncertainty in measurement of length ΔL = pffiffiffi n ∂R ∂L

is higher than the current uncertainty for length; the current measuring instrument uncertainty is adequate, ΔL = 1 mm. ΔR = 7:2169 × Allowable uncertainty in measurement of radius Δr = pffiffiffi n ∂R ∂r

10 - 6 m. This is less than the current uncertainty for radius; the current measuring instrument uncertainty needs to be improved.

14

1

Introduction

The updated most probable uncertainty in resistance with the updated uncertainty of individual measured variables is obtained as ΔRrss = ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi rffiffiffiffiffiffiffiffi  ffiffiffiffiffiffiffiffiffiffiffiffiffi 2 ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ∂R 2 ∂R 2 ∂R Δρ þ ∂L ΔL þ ∂r Δr = 0:0088 Ω: ∂ρ Percentage uncertainty pΔRrss =

1.4.7

ΔRrss R

× 100% = 4:08%:

Computer-Aided Analysis of Basic Statistics and Uncertainty

The basic statistical analysis can be done using Excel and Matlab with specific commands and processes. The uncertainty analysis can also be automated using Matlab. In particular, symbolic manipulation feature of Matlab can be used for ∂f . symbolic partial differentiation ∂x i Example 1.5 (Examples 1.3 and 1.4 using symbolic manipulation of Matlab) Matlab code using symbolic manipulation to solve Examples 1.3 and 1.4 is presented here with comments explaining the steps. Results obtained are the same as those presented in Examples 1.3 and 1.4. % Symbolic matlab example % Uncertainty analysis Example 1.5 R=rho*L/(pi*r^2) n = 3 % number of variables: 3 rho, L, r x = sym('x',[1 3]) % symbolic variables rho, L, r % Symbolic expression Y = x(1)*x(2)/(pi*x(3)^2) % R=rho*L/(pi*r^2) % Nominal values of measured variables x0 = [1.7e-8 10 0.5e-3]; % Given uncertainty in individual measured variables dx = [0.1*1.7e-8 1e-3 0.1*1e-3] for i=1:n dYdx(i)=diff(Y,x(i)); %partial derivative dY/dxi delYx(i)=dYdx(i)*dx(i); % individual contribution (dY/dxi)*dxi end %numerical values Yn =double(subs(Y,x,x0)) % Nominal value of Y dYdxn=double(subs(dYdx,x,x0)); % partial derivatives delYxn=double(subs(delYx,x,x0)); % individual contribution from each measured variable Eabs = 0; Ess= 0 for i=1:n Eabs =Eabs + abs(delYxn(i)); Ess = Ess + delYxn(i)^2; end Eabs % Maximum possible error pEabs=Eabs*100/Yn % percantage Erss=sqrt(Ess) % Most probable error pErss=Erss*100/Yn % percentage %Required uncertainty pY =5 % percent_uncertainty in Y: UY dY =pY*Yn/100 for i=1:n ux(i)= abs(dY/(sqrt(n)*dYdxn(i)));

1.4

Measurement Fundamentals

15

uxA(i)=abs(dY/(n*dYdxn(i))); if (ux(i)> dx(i)) ux(i)= dx(i); end end %updated Erss EssN=0; for i=1:n EssN=EssN+(dYdxn(i)*ux(i))^2; end ErssN=sqrt(EssN) % updated uncertainty pErssN=ErssN*100/Yn % percentage uncertainty

1.4.8

Experiment on Basic Statistics

Objectives To measure resistance of a sample of 20 resistors of the same nominal value and compare the sample statistics with that of combined samples (population) from the rest of the groups in the lab class. I. A. Sample Measurements • Take a sample of 20 resistors of the same nominal value (e.g., 1 kΩ). Note down the color code to get the nominal resistance value and the tolerance. Obtain the expected range of resistance values based on the color code. • Measure the resistance using a multimeter. • Record 20 measurements for the sample on the given table. • Upload the table of 20 measurements to share with other groups in the lab session. I. B. Population Measurements • Compile the tables of 20 measurements from each group as a table of measurements for the population (20 × number of groups). • Share the table of measurements for the population with all groups in the lab session. • Calculate the maximum, minimum, range, mean, mode, median, and the standard deviation for the population. II. Data Processing This part of the experiment is using computer programs to help process the data. II. A. Using Excel II. A.1. Sample Statistics • Input the measured sample data into an Excel worksheet. • Use Excel to calculate the maximum, minimum, range, mean, mode, median, and the standard deviation for the sample.

16

1

Introduction

II. A.2. Population Statistics • Use Excel to calculate the maximum, minimum, range, mean, mode, median, and the standard deviation for the population. II. B. Using MATLAB II. B.1. Sample Statistics • Export the data in the Excel worksheet to MATLAB. • Use built-in functions to calculate the statistical parameters (max, min, range, mean, mode, median, and standard deviation) of the measured data for the sample. II. B.2. Population Statistics • Export the data in the Excel worksheet to MATLAB. • Use built-in functions to calculate the statistical parameters (max, min, range, mean, mode, median, and standard deviation) of the measured data for the population. • Use the built-in function to generate two histograms with different intervals (class width) for the population. III. Presentation of Data and Results (Tables 1.4 and 1.5) Lab Report • Present Excel worksheet, MATLAB code, and all results in the Lab report. • Discussion items in the lab report: – Obtain 95.5% confidence interval of the measured data. – Use the measured data to verify the expected resistance values obtained from color codes. – Comment on the difference of statistics between the sample and the population. – Comment on the effect of class width on the shape of the histogram. Table 1.4 Nominal value of R Value Color Code Nominal value Expected max, min

Unit

Exercises

17

Table 1.5 Comparison of sample and population statistics

Sample

Population

unit

% difference

Number of measurements Maximum Minimum Range Mean (µ) Mode Median Std dev (s) µ±s µ ± 2s µ ± 3s

Exercises 1. A set of measurements of a sample of resistors with a nominal value of 120 Ω is obtained as follows: R = (120.5 119.5 118.9 119.4 118.5 119.8 118.7 120.2 121.1 120.3) Ω. Find the mean, mode, median, variance, standard deviation, and probabilities P(R ≤ 118.5 Ω), P(R > 120.1 Ω) and P(119.5 ≤ R ≤ 120.5 Ω). 2. Measurements of a sample of resistors R with a nominal value of 1 kΩ are obtained as follows: R = (0.989 0.998 0.990 0.959 0.985 1.010 1.005 0.997 0.979 0.980 0.987 0.995 1.020 1.035 1.030) kΩ. Find the mean, mode, median, variance, standard deviation, probability P(R ≤ 0.980 kΩ), probability P(R>1.050 kΩ), and probability P(0.980 ≤ R ≤ 1.020 kΩ). 3. For the above sample of measurements of Problem 2, find the z-score corresponding to R = 0.990 kΩ. Find probability P(Z ≤ -1.5), probability P(Z > 1.5), and probability P(-1.5 ≤ Z ≤ 1.5). 4. For the above sample of measurements of Problem 2, find R for a z-score of 2.5. Find the ranges of resistance values R that cover (a) 68.3% of measured values, (b) 95.5% of measured values, and (c) 99.7% of measured values. 5. In a lab, the resistance of a resistor was measured using 10 samples giving the following values: 120.15, 120.12, 119.97, 118.83, 119.56, 121.07, 119.98, 120.23, 120.52, and 119.77 Ω. Estimate the average value of the resistance, the standard deviation, the lower and the upper limits of the resistance values covering 99.7% of the observations, and the z-score for a measurement of 121.27 Ω.

18

1

Introduction

6. In a laboratory testing, the volume (V ) of a cylinder is to be determined from the measurements of diameter (D) and length (L ). The measured values and their uncertainties are reported as follows: D = 10  0.05 cm, L = 20  0.05 cm. Determine the volume of the cylinder and its probable uncertainty. Estimate the allowable uncertainty in the measurements of diameter and length if the uncertainty in volume is to be within 0.5%. Check if the currently available measuring instruments are accurate enough for this requirement. 7. During a laboratory testing of a thin-walled pressure vessel, the cylinder diameter (D), thickness (t), and pressure (P) inside the vessel were measured with the estimated uncertainty as follows: D = 40.25  0.10 in, t = 0.25  0.05 in, and P = 200  5 psi. Estimate the hoop stress ( pθ = PD/2t) and its most probable error. Determine the allowable uncertainty in the measurement of D, t, and P, if the uncertainty in pθ is to be within 5%. 8. During a laboratory testing of deflection of a small cantilever, the beam length (L ), thickness (t), width (b), and the load (P) at the tip were measured with the estimated uncertainty as follows: L = 150  1 mm, t = 5.0  0.1 mm, b = 20.0  0.2 mm, P = 100.0  0.1 N. The modulus of elasticity (E) is taken 3 as 210.0  0.2 GPa. Estimate the tip deflection (δ = 4PL Ebt 3 ). Estimate the maximum possible error and the most probable error. Determine the allowable uncertainty in the measurement of L, t, b, P, and E, if the uncertainty in δ is to be within 0.25%. Comment if the currently available measurement process/instruments are adequate to maintain the uncertainty within the required level. 9. For the calculation of pressure ( p) in a thin-walled vessel, the vessel thickness (t), radius (r), the hoop or transverse strain (εx), and the axial or longitudinal strain (εy) were measured with the estimated uncertainty as follows:t = 20  0.1 mm, r = 0.500  0.001 m, εx = (2.25  0.01) × 10-3, εy = (1.00  0.01) × 10-3. The modulus of elasticity (E) and the Poisson’s ratio (ν ) can be taken as follows: E = 210.0 GPa,  ν = 0.30  0.001. Estimate the vessel internal pressure ε þ ν ε p = rð1 tE x y : Estimate the maximum possible percentage error and the - ν2 Þ most probable percentage error in the calculation of p. Determine the allowable uncertainty in the measurement of t, r, εx, εy, E, and ν , if the most probable uncertainty in p is to be within 0.10% of its nominal value. Comment if the currently available measurement process/instruments are adequate to maintain the uncertainty within the required level.

Bibliography Ackoff RL (1989) From data to wisdom. J Appl Syst Anal 16:3–9 Alciatore DG (2019) Introduction to mechatronics and measurement systems, 5th edn. McGraw Hill, New York Arduino (2022) Arduino. https://www.arduino.cc Beckwith TG, Marangoni RD, Lienhard JH (2006) Mechanical measurements, 6th edn. Prentice Hall, Upper Saddle River Brown AS (2008) Who owns mechatronics? Mechanical Engineering Magazine, American Society of Mechanical Engineers, pp 24–28 Cetinkunt S (2015) Mechatronics with experiments, 2nd edn. Wiley, New York

Bibliography

19

Cloutier A, Dwayer J, Sherrod SE (2016) Exploration of hands-on/minds-on learning in an active STEM outreach program. In: Proceedings of ASEE annual conference, New Orleans, LA, June 26–29, 2016 Craig K (2002) Actuators and sensors in mechatronics (MEAE6960, Summer 2002, NYU, Engineering). http://engineering.nyu.edu/mechatronics/Control_Lab/Criag/Craig_RPI/ SenActinMecha/Comprehensive.pdf Craig K (2022) Mechatronics multidisciplinary innovation for practicing engineers. https://www. multimechatronics.com/ Craig KC, de Marchi JA (1996) Mechatronic system design at Rensselaer. Comp Appl Eng Educ 4(1):67–78 Das S, Yost SA, Krishnan M (2010) A 10-year mechatronics curriculum development initiative: relevance, content, and results. Part I. IEEE Trans Educ 53(2):194–201 Doeblin EO (1990) Measurement systems applications and design, 4th edn. McGraw Hill, New York Hambley A (2017) Electrical engineering: principles and applications, 7th edn. Pearson, Upper Saddle River Krishnan M, Das S, Yost SA (2010) A 10-year mechatronics curriculum development initiative: relevance, content, and results. Part II. IEEE Trans Educ 53(2):202–208 Mathworks (2022) Matlab and Simulink. https://www.mathworks.com National Instruments (2022) LabVIEW. https://www.ni.com Navidi W (2020) Statistics for engineers and scientists, 5th edn. McGraw Hill, New York Ontotext.com (2022) What is the data, information, knowledge, wisdom (DIKW) pyramid? https:// www.ontotext.com/knowledgehub/fundamentals/dikw-pyramid/. Accessed 31 Oct 2022 Pybricks.com (2020) Getting started with LEGO® MINDSTORMS Education EV3 MicroPython. https://pybricks.com/ev3-micropython/ Rowley J (2007) The wisdom hierarchy: representations of the DIKW hierarchy. J Inf Sci 33(2): 163–180 Samanta B (2017) Development of a mechatronics course integrated with lab. In: 2017 ASME dynamic systems and control conference (DSCC), Tyson, VA, October 11–13, 2017 Samanta B, Turner JG (2013) Development of a mechatronics and intelligent systems laboratory for teaching and research. Comput Educ J 23(1):60–72 Sedra AS, Smith KC, Carusone TC, Gaudet V (2020) Microelectronic circuits, 8th edn. Oxford University Press, New York Tinkercad (2022) Learn circuits. https://www.tinkercad.com/learn/circuits UCSD (2022) Resistor color code guide. https://neurophysics.ucsd.edu/courses/physics_120/ resistorcharts.pdf. Accessed 24 Aug 2022 Venkateshan SP (2022) Mechanical measurements, 2nd edn. Springer, Heidelberg Wikipedia (2022). http://en.wikipedia.org/wiki/68-95-99.7_rule. Accessed 24 Aug 2022

Chapter 2

Basic Electrical Circuit Elements and Circuit Analysis

2.1

Introduction

In this chapter, basic circuit elements, Thevenin and Norton equivalent circuits, DC and AC circuit analysis, power, and transformer are briefly reviewed. Examples are presented along with computer-aided analysis and simulation. End-of-chapter exercise problems are provided to help consolidate problem-solving skills and understanding of materials covered.

2.2

Basic Electrical Circuit Elements

The basic electrical circuit elements include passive elements—resistors (R), capacitors (C), and inductors (L )—and ideal energy sources: voltage source (V ) and current source (I). The passive elements (R, C, and L ) require no additional power supply, unlike integrated circuits that require active power to be operational. These passive elements are characterized by the corresp\onding voltage-current relationships. The ideal electrical energy sources are assumed to be without any internal resistance, capacitance, or inductance. The schematic symbols of these basic electrical circuit elements are illustrated in Fig. 2.1.

2.2.1

Resistor

A resistor is an energy dissipative element that converts electrical energy into thermal energy. The ideal behavior of a resistor is characterized in the form of Ohm’s law, Eq. (2.1).

© The Author(s), under exclusive license to Springer Nature Switzerland AG 2023 B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_2

21

22

2

Basic Electrical Circuit Elements and Circuit Analysis

Fig. 2.1 Common electrical circuit elements

V = IR

ð2:1Þ

where V is the voltage (V ) across the resistor, I is the current (A) through the resistor, and R is the resistance (Ω). For an ideal resistor, the voltage-current relationship is linear with a constant slope (R = V/I ). However, for real resistors, the heating effect changes the relationship as resistance increases with temperature. All real resistors have finite dissipative power ratings for safe operations. The resistance of a resistive element composed of homogeneous material is expressed as in Eq. (2.2) R=

ρL A

ð2:2Þ

where ρ (Ω.m) is resistivity or specific resistance of the material, L is its length (m), and (A) is the area of the cross-section (m2). The metric units are specified in parentheses. Resistors are available in different forms including axial-lead, surface mount, single-in-line package (SIP), and dual-in-line package (DIP). The power dissipated in a resistor is expressed in Eq. (2.3): P = I 2R =

V2 R

ð2:3Þ

where R is the resistance, V is the voltage drop across the resistor, and I is the current passing through the resistor. The resistance and tolerance of an axial-lead resistor are commonly coded using a four-band color code (a, b, c, d ) where the first two color bands (a, b) represent the tens and ones digits, respectively. The third color band (c) represents the power of 10, i.e., (10c). The last color band represents the tolerance or uncertainty as a percentage of the color-coded value of the resistor. The table of the four-band color code is presented in Table 2.1, and a representation of the color code value and tolerance is given in Eq. (2.4): R = ab × 10c  tolerance ð%Þ

ð2:4Þ

For example, for a resistor with a four-band color code of brown-black-orangegold, the resistance will be 10 × 103  5 % Ω. It is worth mentioning that though the four-band color codes are the most common, there are also five-band color codes (a, b, c, d, e) for resistors where the first three color bands (a, b, c) represent the hundreds, tens, and ones digits, respectively. The fourth color band (d) represents the power of 10, i.e., (10d). The last color band represents the tolerance or uncertainty as a percentage of the color-coded value of the resistor.

2.2

Basic Electrical Circuit Elements

Table 2.1 Four-band color codes for resistors

2.2.2

23

a, b, and c bands Color Black Brown Red Orange Yellow Green Blue Violet Gray White Gold Silver None

Value 0 1 2 3 4 5 6 7 8 9

Tolerance (d) band Value 1% 2%

5% 10% 20%

Capacitor

A capacitor stores energy in the form of an electric field created by electric charge. The simplest configuration consists of a pair of conducting plates separated by a dielectric material. The amount of charge (Q) stored in a capacitor is proportional to the electric potential (V ) across the capacitor terminals, and the constant of proportionality is called capacitance (C), as given in Eq. (2.5). Q = C V or V =

Q C

ð2:5Þ

where Q is charge stored in coulombs (C), V is in volts (V ), and capacitance is in farads (F). The current (i(t)) passing through the capacitor (under transient condition) is the rate of change of charge (dq(t)/dt): iðt Þ =

dqðt Þ dvðt Þ =C dt dt

ð2:6Þ

where i(t) is current in amperes (A) at time t in seconds (s). The voltage (v(t)) across the terminal of a capacitor is obtained from Eq. (2.6): 1 vð t Þ = C

Z 0

t

iðt Þdt =

qð t Þ C

ð2:7Þ

24

2 Basic Electrical Circuit Elements and Circuit Analysis

The electric energy stored in a capacitor is given by Eq. (2.8): Z

V

E=C

v dv =

0

Q2 CV 2 = 2 2C

ð2:8Þ

where E is energy in joules (J), capacitance C in farads (F), charge Q in coulombs (C), and voltage across the capacitor terminals in volts (V ). The common types of commercial capacitors include electrolytic, ceramic disk, and mylar capacitors. Electrolytic capacitors are polarized with positive and negative terminals and must be connected such that the positive terminal is at a higher voltage than the negative terminal. The capacitors are available in different shapes and sizes. The capacitance value of a capacitor is printed on it with two-digit or three- digit code. A capacitor with two-digit marking denotes the capacitance in picofarads, e.g., 15 means C = 15 pF. A three-digit (abc) code on a capacitor denotes the value in picofarads (pF) given by the first two digits (ab) multiplied by power (c) of 10, i.e., C = ab × 10c pF

ð2:9Þ

For example, a three-digit code of 104 means 10 × 104 pF = 105pF = 0.10 μF. In DC circuits, ideal capacitors with infinite resistance can be treated as open circuit under steady state. Unless the voltage is varying with time, no current flows through an ideal capacitor once it is fully charged.

2.2.3

Inductor

An inductor is in the form of a coil of conducting wire and stores energy as a magnetic field. The induced voltage (v(t)) across the terminals of an inductor is equal to the rate of change of the magnetic flux (λ(t)) vð t Þ =

dλðt Þ dt

ð2:10Þ

where the magnetic flux λ(t) is in webers (Wb) at any time t, in seconds (s), and v(t), in volts (V ). For an inductor, the magnetic flux λ(t) is proportional to the current i(t), and the constant of proportionality is termed inductance (L): λðt Þ = L iðt Þ

ð2:11Þ

where λ(t) is the magnetic flux in webers (Wb), L is the inductance in henries (H), and i(t) is the current in amperes (A). Combining Eqs. (2.10) and (2.11), the voltage across an inductor is expressed as

2.3

Basic Electrical Circuit Elements in Series and in Parallel

vð t Þ = L

diðt Þ dt

25

ð2:12Þ

The current in an inductor i(t) is obtained from Eq. (2.12): iðt Þ =

1 L

Z

t

vðt Þdt

ð2:13Þ

0

The energy stored in an inductor carrying a current I is given as Z

I

E=L

i di =

0

LI 2 2

ð2:14Þ

where E is in joules (J ), L is the inductance in henries (H ), and I is the current in amperes (A). The common values of inductance range from 1 μH to 100 mH. There is no common standard coding method used for inductors, and the values of inductance are generally printed on devices, in μH or mH. In DC circuits, ideal inductors with zero resistance can be treated as direct connection (shorted) under steady state. Unless the current is varying with time, the voltage drop across an ideal inductor is zero.

2.3

Basic Electrical Circuit Elements in Series and in Parallel

The passive electrical circuit elements (resistance, capacitance, and inductance) are often used in series and in parallel combinations. In the analysis of electrical circuits, it is convenient to replace these elements in series and in parallel and their combinations in the form of equivalent ones.

2.3.1

Resistors in Series and in Parallel

A group of resistors connected in series has the same current passing through each and the voltage drop across each adds up to give the total voltage across the group. The equivalent resistance (ReqS) for a group of (n) resistors in series (Fig. 2.2) is equal to the sum of the individual resistances (Ri). ReqS =

Xn

R i=1 i

ð2:15Þ

26

2

Basic Electrical Circuit Elements and Circuit Analysis

Fig. 2.2 Resistors in series

Fig. 2.3 Resistors in parallel

Fig. 2.4 Capacitors in series

A group of resistors connected in parallel (Fig. 2.3) has the same voltage drop (V ) across each, and the current (Ii) through each adds up to give the total current (I) for the group. The equivalent resistance (ReqP) for a group of (n) resistors in parallel can be obtained equating the total current (I) to the sum of the current (Ii) through individual resistances (Ri). I=

Xn V V = i=1 Ri ReqP

ð2:16Þ

The equivalent resistance (ReqP) is obtained from Eq. (2.16) as 1 ReqP = Pn

1 i=1 Ri

2.3.2

ð2:17Þ

Capacitors in Series and in Parallel

A group of capacitors connected in series (Fig. 2.4) has the same charge (Q) for each, and the voltage drop (Vi) across each adds up to give the total voltage drop (V ) across the group. The equivalent capacitance (CeqS) for a group of (n) capacitors in series can be obtained equating the total voltage drop (V ) to the sum of the voltage drop (Vi) across individual capacitances (Ci). V=

Xn Q Q = i=1 C i C eqS

The equivalent capacitance (CeqS) is obtained from Eq. (2.18) as

ð2:18Þ

2.3

Basic Electrical Circuit Elements in Series and in Parallel

27

Fig. 2.5 Capacitors in parallel

Fig. 2.6 Inductors in series

C eqS = Pn

1

1 i=1 C i

ð2:19Þ

A group of capacitors connected in parallel (Fig. 2.5) has the same voltage drop (V ) across each, and the charge (Qi) for each adds up to give the total charge (Q) for the group. The equivalent capacitance (CeqP) for a group of (n) capacitors in parallel can be obtained equating the total charge (Q) to the sum of the charge (Qi) through individual capacitances (Ci). Q = VCeqP =

Xn i=1

ðVC i Þ

ð2:20Þ

The equivalent capacitance (CeqP) is obtained from Eq. (2.20) as C eqP =

2.3.3

Xn i=1

Ci

ð2:21Þ

Inductors in Series and in Parallel

A group of inductors connected in series (Fig. 2.6) has the same current passing through each, and the voltage drop across each adds up to give the total voltage across the group. The equivalent inductance (LeqS) for a group of (n) inductors in series is equal to the sum of the individual inductances (Li). LeqS =

Xn

L i=1 i

ð2:22Þ

A group of inductors connected in parallel (Fig. 2.7) has the same voltage drop (V ) across each, and the current (Ii) through each adds up to give the total current (I) for the group. The equivalent resistance (LeqP) for a group of (n) inductors in parallel can be obtained equating the total current (I) to the sum of the currents (Ii) through individual inductors (Li). The equivalent inductance (LeqP) is obtained as 1 LeqP = Pn

1 i=1 Li

ð2:23Þ

28

2

Basic Electrical Circuit Elements and Circuit Analysis

Fig. 2.7 Inductors in parallel

2.4 2.4.1

DC Circuit Analysis Ohm’s Law

The voltage drop across a resistance is given by Ohm’s law, as in Eq. (2.1), V = IR.

2.4.2

Kirchhoff’s Current Law

Kirchhoff’s Current Law (KCL) states that the net current at a node is zero; i.e., the algebraic sum of all currents (Ii) coming to a node is zero, with currents coming to a node (Iin, i) assigned positive values and current leaving the node (Iout,i) assigned negative values. XN i

I i = 0 or

XN in i

I in,i -

XN out i

I out,i = 0

ð2:24Þ

where Nin and Nout are the numbers of incoming and outgoing currents to and from the node, respectively, and N is the total number of currents coming to and leaving the node.

2.4.3

Kirchhoff’s Voltage Law

Kirchhoff’s Voltage Law (KVL) states that the net voltage along a closed loop is zero; i.e., the algebraic sum of all voltages (Vi) along a closed loop is zero, with voltages from positive to negative along the loop assigned positive values and voltages from negative to positive along the loop assigned negative values. XN i=1

Vi = 0

ð2:25Þ

2.6

Equivalent Circuits

2.5

29

Ideal Voltage and Current Sources and Measuring Devices

In circuit analysis, an ideal behavior is assumed for voltage and current sources and measuring devices (voltmeters and ammeters). A zero output resistance and an infinite supply current are assumed for an ideal voltage source. An infinite output resistance and an infinite supply voltage are assumed for an ideal current source. An infinite input resistance and no current are assumed for an ideal voltmeter. A zero input resistance and no voltage drop are assumed for an ideal ammeter.

2.6 2.6.1

Equivalent Circuits Thevenin Equivalent Circuit

Thevenin equivalent circuit between two terminals in a linear network consists of an equivalent voltage source (VTh) and resistance (RTh) in series. The equivalent voltage source (VTh) is equal to the open-circuit voltage (VOC) across the terminals. The equivalent resistance (RTh) is the resistance across the terminal with the independent voltage sources shorted and independent current sources replaced with open circuits.

2.6.2

Norton Equivalent Circuit

Norton equivalent circuit between two terminals in a linear network consists of an equivalent current source (ISC) and resistance (RTh) in parallel. The short circuit current (ISC) is the current that would flow through the terminals with the terminals shorted, removing the remaining load circuit. The short circuit current (ISC) can be obtained from the open-circuit voltage (VOC) across the terminals and the equivalent resistance (RTh) of Thevenin equivalent circuit. I SC =

V OC RTh

ð2:26Þ

Example 2.1 For the DC circuit of Fig. 2.8, find Thevenin and Norton equivalent circuits. Solution The open-circuit voltage (Voc) between terminals A and B can be expressed as V oc = V s

R2 R1 þ R2

30

2

Basic Electrical Circuit Elements and Circuit Analysis

Fig. 2.8 Example DC circuit

Fig. 2.9 Thevenin equivalent circuit

Fig. 2.10 Norton equivalent circuit

Thevenin equivalent resistance (RTh) can be obtained by replacing the voltage source and calculating the equivalent resistance between terminals A and B as RTh =

R1 R2 : R1 þ R2

Thevenin equivalent circuit is shown in Fig. 2.9. The short circuit current (ISC) for Norton equivalent circuit can be obtained from open-circuit voltage (Voc) and Thevenin equivalent resistance (RTh) as I SC =

V OC V = s RTh R1

Norton equivalent circuit is shown in Fig. 2.10.

2.7 2.7.1

AC Circuit Analysis AC Signal and Phasor Representation

A single-phase AC voltage signal V(t) is represented in the form of sinusoidal waveform with amplitude Vm, frequency ω, and a phase angle ϕ as V ðt Þ = V m sinðωt þ ϕÞ

ð2:27Þ

2.7

AC Circuit Analysis

31

Frequency f in hertz (Hz) is related to frequency ω in rad/s and time period T in seconds (s) as f=

1 ω = T 2π

ð2:28Þ

In the USA and Canada, standard residential AC power supply is 120 V, 60 Hz (single phase) and 240 V, 60 Hz (three phase). In Europe, Asia, Africa, and other regions, the standard residential AC power supplies are mostly 230 V, 50 Hz (one phase), and 400 V, 50 Hz (three phase). Some other variations of AC power supply do exist. Details of variations of the main electricity can be obtained from respective national standards. Phasor representation of voltage V and current I in terms of magnitudes Vm and Im and phase angle ϕ helps steady-state analysis of AC circuits. V = V m ejðωtþϕÞ = V m ∠ϕ

ð2:29Þ

Mathematical relations for complex phasors are useful in AC circuit analysis.

2.7.2

ðV 1 ∠ϕ1 Þ:ðV 2 ∠ϕ2 Þ = ðV 1 :V 2 Þ∠ðϕ1 þ ϕ2 Þ

ð2:30Þ

ðV 1 ∠ϕ1 Þ=ð V 2 ∠ϕ2 Þ = ðV 1 =V 2 Þ∠ðϕ1 - ϕ2 Þ

ð2:31Þ

Impedance

The concept of impedance is useful in analyzing AC circuits consisting of resistors, capacitors, and inductors treating each of these circuit elements in Ohm’s law: V =Z I

ð2:32Þ

where Z is the impedance in ohms (Ω) of the circuit element. In general, Z is a complex number that depends on the frequency of supply and the value and type of circuit elements, i.e., resistors, capacitors, and inductors, Z. In case of a resistor in an AC circuit, Ohm’s law can be written as V =R I

ð2:33Þ

where the impedance for a resistor can be written as ZR = R

ð2:34Þ

32

2

Basic Electrical Circuit Elements and Circuit Analysis

j(ωt + ϕ) In case of a capacitor in an AC circuit, I = C dV dt with V = Vme

I = ðCjωÞ V m ejðωtþϕÞ = ðCjωÞV   1 V= I = ZC I jωC ZC =

1 -j 1 = = ∠ - 90 ° jωC ωC ωC

ð2:35Þ ð2:36Þ ð2:37Þ

where the phase angle means that the voltage across a capacitor lags the current passing through it by 90°. In a DC circuit (ω = 0), the impedance of a capacitor is infinite, implying the capacitor acting as an open circuit. In an AC circuit with very high frequency (ω = 1), the impedance of a capacitor is zero, implying the capacitor acting as a short circuit. j(ωt + ϕ) In case of an inductor in an AC circuit, V = L dI dt with I = Ime V = ðLjωÞ I m ejðωtþϕÞ = ðLjωÞI

ð2:38Þ

V = ðLjωÞI = Z L I

ð2:39Þ

Z L = jωL = ωL∠90 °

ð2:40Þ

where the phase angle means that the voltage across an inductor leads the current passing through it by 90°. In a DC circuit (ω = 0), the impedance of an inductor is zero, implying the inductor acting as a short circuit. In an AC circuit with very high frequency (ω = 1), the impedance of an inductor is infinite, implying the inductor acting as an open circuit. Example 2.2 For the example AC circuit of Fig. 2.11, R1 = 1 kΩ, R2 = 2 kΩ, R3 = 3 kΩ, L = 0.6 H, C = 0.4 μF, and the source voltage is 20 V at 60 Hz and 0°. Find currents I1, I2, and I3. Fig. 2.11 Example AC circuit

2.8

Power in Electrical Circuits

33

Solution Impedance for R1 is Z1 = R1 = 1 kΩ. Impedance for R2 and L in series Z2 = R2 + jωL = 2000 + j(2π (60)  0.6) Ω =2000 + j226.19 Ω. Impedance for R3 and C in series Z3 = R3 + 1/( jωC) = 3000 + 1/j(2π (60)  0.4 × 10-6) Ω = 3000 - j6631.5 Ω. Z3 = 1000þ impedance for the circuit Z eq = Z 1 þ ZZ22þZ Equivalent 3

ð2000þj226:19Þð3000 - j6631:5Þ 2000þj226:19þ3000 - j6631:5

I1 =

Currents

= 2788:7 - j 225:39 Ω = 2797:8 Ω∠ - 4:62 ° .

V 20 V∠0 ° = = 7:1 þ j0:6 mA = 7:15 mA∠4:62 ° Z eq 2797:8 Ω∠ - 4:62 °

ð3000 - j6631:5ÞΩ Z3 = ð7:1 þ j0:6 mAÞ Z2 þ Z3 ð2000 þ j226:19 þ 3000 - j6631:5ÞΩ = 6:3 - j1 mA = 6:40 mA∠ - 9:01 °

I2 = I1

ð2000 þ j226:19ÞΩ Z2 = ð7:1 þ j0:6 mAÞ Z2 þ Z3 ð2000 þ j226:19 þ 3000 - j6631:5ÞΩ = 0:8 þ j1:6 mA = 1:77 mA∠63:1 °

I3 = I1

2.8

Power in Electrical Circuits

Power in a purely resistive circuit can be obtained as P = VI = I 2 R =

V2 R

ð2:41Þ

In an AC circuit with voltage V = Vm sin (ωt) and current I = Im sin (ωt - ϕ), where the phase angle ϕ represents the phase difference between the voltage and the current, the average power can be obtained as Pavg =

1 T

Z

T

V m sinðωt ÞI m sinðωt - ϕÞdt

ð2:42Þ

0

where T = 2π ω is the time period in seconds (s) and ω is frequency in rad/s. Using trigonometric relations, Eq. (2.42)can be rewritten as Pavg =

V mI m T

Z

T 0

Z sin2 ðωt Þ cosðϕÞdt 0

T

 sinðωt Þ cosðωt Þ sinðϕÞdt

ð2:43Þ

34

2

Basic Electrical Circuit Elements and Circuit Analysis

  Z T Z T V mIm Pavg = 1 - cosð2ωt Þdt - sinðϕÞ sinð2ωt Þdt cosðϕÞ 2T 0 0 Pavg =

V I V mI m ðcosðϕÞðT- 0Þ - sinðϕÞð0ÞÞ = m m cosðϕÞ 2T 2

ð2:44Þ ð2:45Þ

The term cos(ϕ) is known as power factor. Eq. (2.45) can be expressed in terms of root-mean-square (rms) of voltage (Vrms) and current (Irms): Pavg = V rms I rms cosðϕÞ

ð2:46Þ

where Vrms and Irms are expressed as sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi Z T 1 V V rms = V 2 sin 2 ðωt Þdt = pmffiffiffi T 0 m 2 sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi Z T 1 I I 2 sin 2 ðωt Þdt = pmffiffiffi I rms = T 0 m 2

2.9

ð2:47Þ

ð2:48Þ

Transformer

A transformer consists of two sets of coils (windings), termed as primary and secondary, wound around a ferromagnetic core that links the magnetic fluxes of the coils. The ratio of number of turns of secondary (NS) and primary (NP) windings is known as turns ratio or transformer ratio (α): α=

NS NP

ð2:49Þ

Assuming an ideal (lossless) transformer, the power in the primary windings is the same as that in the secondary windings, the primary side voltage and current (VP, IP) are related to those in the secondary side (VS, IS) as V PIP = V SI S α=

NS V I = S = P NP V P IS

ð2:50Þ ð2:51Þ

If α > 1, the transformer is termed step-up transformer; if α < 1, the transformer is termed step-down transformer; and if α = 1, the transformer is termed isolation transformer.

2.11

Computer-Aided Analysis of Basic Circuits

35

For an ideal lossless transformer with impedances connected to the primary side (ZP) and the secondary side (ZS), respectively, the equivalent impedances in the primary side (ZeqP) and the secondary side (ZeqS) can be obtained as Z eqP = Z P þ

ZS α2

Z eqS = Z S þ α2 Z P

ð2:52Þ ð2:53Þ

The equivalent impedances can be used to analyze an AC circuit with a transformer, either considering the primary side or the secondary side.

2.10

Impedance Matching

It is necessary to minimize signal reflection or maximize power transfer while connecting a source to a load circuit. The process is termed impedance matching. In an AC circuit with the load input impedance, ZL = RL + jXL where RL is termed load input resistance and XL is termed load input reactance. To minimize signal reflection in an AC circuit, the source output impedance should be equal to the load input impedance ZS = RL + jXL. To maximize power transfer in an AC circuit, the source output impedance should be equal to the complex conjugate of the load input impedance ZS = RL - jXL. In DC circuits, the output resistance of the source should be equal to the input resistance of the load circuit to minimize signal reflection and maximize power transfer.

2.11

Computer-Aided Analysis of Basic Circuits

The analysis of basic circuits can be automated using software platforms like Multisim and LTSpice. The circuit analysis can also be done using Matlab. The virtual simulation of basic circuits can be visualized using Tinkercad. The simulation environment of Tinkercad has the added advantage of creating the circuits on a virtual breadboard using virtual circuit elements that can be easily implemented on a physical platform. In this book, the latter two approaches, namely, using Matlab for analysis and Tinkercad for virtual simulation are emphasized throughout. Example 2.3 For the DC circuit of Fig. 2.12, find the voltage at node A (VA) and the currents I1, I2, and I3 passing through R1, R2, and R3, respectively. Find voltage across R4. Use supply voltage Vs = 60 V, R1 = 100 Ω, R2 = 120 Ω, R3 = 56 Ω, and R4 = 82 Ω.

36

2

Basic Electrical Circuit Elements and Circuit Analysis

Fig. 2.12 DC circuit for Example 2.3

2.11.1

Analysis Using Matlab

Solution Currents through R1, R2, and R3 can be obtained using Ohm’s law for each branch as I1 =

ðV s - V A Þ V VA , I2 = A , I3 = R1 R2 R3 þ R4

Applying KCL at node A I1 - I2 - I3 = 0, VA can be obtained. The voltage across R4 is obtained as V4 = I3R4. Matlab code to solve this problem using symbolic manipulation is presented here with comments explaining the steps. Results obtained are listed at the end. % Example 2.3 % Vs= 60 V, R1=100, R2=120, R3=56, R4=82 ohm syms Vs Va R1 R2 R3 R4 i1=(Vs-Va)/R1; % current through R1 i2=Va/R2; % current through R2 i3=Va/(R3+R4); % current through R3 Va=solve(i1-i2-i3==0, Va); % solve for Va using KCL at A V4=i3*R4; % voltage across R4 % numerical values Vs=60; R1=100; R2=120; R3=56; R4=82; Va = double(subs(Va)) i1 = double(subs(i1)) i2 = double(subs(i2)) i3 = double(subs(i3)) V4 = double(subs(V4))

Results: Va = 23.4561 V, i1 = 0.3654 A, i2 =

2.11.2

0.1955 A, i3 = 0.1700 A, V4 = 13.9377 V

Simulation Using Tinkercad

Tinkercad circuit and simulation results are shown in Figs. 2.13a, b. In Fig. 2.13a, total current I = I1 = I2 + I3 and V4 are shown for clarity. Currents in individual branches can be obtained noting the voltage across each resistance using a multimeter and using Ohm’s law I3 = I4 = V4/R4. Alternatively, multimeters can

Exercises

37

Fig. 2.13 DC circuit in Tinkercad for Example 2.3 (a) original circuit, (b) with an ammeter for current measurement

be used in ammeter mode in the paths the currents need to be measured, as shown in Fig. 2.13b with a multimeter connected as an ammeter between R2 and R3. The values match closely with that obtained using Matlab, as expected.

Exercises 1. Find the equivalent capacitance between terminals A and B of Fig. P2.1.

Fig. P2.1 Capacitors in series for problem 1

38

2

Basic Electrical Circuit Elements and Circuit Analysis

2. For the DC circuit of Fig. P2.2, find the voltage across terminals A and B under steady-state condition for a voltage source of 100 V and resistances R1 = 30 Ω, R2 = 40 Ω, R3 = 22 Ω, and R4 = 18 Ω.

Fig. P2.2 DC circuit for problem 2

3. For the DC circuit of Fig. P2.3, find the voltage across the resistor R4 for voltage sources V1 = 65 V and V2 = 100 V and resistances R1 = 8 Ω, R2 = 10 Ω, R3 = 25 Ω, R4 = 15 Ω, and R5 = 12 Ω.

Fig. P2.3 DC circuit for problem 3

4. For the DC circuit of Fig. P2.4, find Thevenin equivalent resistance (RTh) and voltage (VTh) between terminals A and B. Use a voltage source of 60 V and resistances R1 = 30 Ω, R2 = 10 Ω, R3 = 20 Ω.

Fig. P2.4 DC circuit for problem 4

Exercises

39

5. For the DC circuit of Fig. P2.5, find Thevenin equivalent circuit resistance (RTh) and voltage (VTh) between terminals A and B. Use a current source of 200 mA and resistances R1 = 2 kΩ, R2 = 3 kΩ, R3 = 2.5 kΩ, and R4 = 2.5 kΩ. Find Norton equivalent circuit.

Fig. P2.5 DC circuit for problem 5

6. For the DC circuit of Fig. P2.6, find Thevenin equivalent circuit resistance (RTh) and voltage (VTh) between terminals A and B. Use a voltage source of 10 V, a current source of 20 mA, and resistances R1 = 400 Ω, R2 = 600 Ω, and R3 = 400 Ω. Find Norton equivalent circuit.

Fig. P2.6 DC circuit for problem 6

7. For the AC circuit of Fig. P2.7, find the equivalent impedance when the circuit is connected to a 120 V, 60 Hz supply, R = 150 Ω, C = 100 μF, and L = 200 mH. Find currents through the C, R, and L.

Fig. P2.7 AC circuit for problem 7

40

2

Basic Electrical Circuit Elements and Circuit Analysis

8. For the AC circuit of Fig. P2.8, find equivalent impedance when the circuit is connected to a 120 V and 60 Hz supply. Use R1 = 1.5 kΩ, R2 = 3 kΩ, R3 = 5 kΩ, L = 1.2 H, and C = 2.5 μF. Find currents I1, I2, and I3.

Fig. P2.8 AC circuit for problem 8

Bibliography Alciatore DG (2019) Introduction to mechatronics and measurement systems, 5th edn. McGraw Hill, New York Analog Devices (2022) LTspice Simulator, https://www.analog.com Hambley A (2017) Electrical engineering: principles and applications, 7th edn. Pearson, Upper Saddle River Mathworks (2022) Matlab and Simulink, https://www.mathworks.com National Instruments (2022) Multisim, https://www.ni.com/en-us/support/downloads/softwareproducts/download.multisim.html#452133 Pico Technology (2022) PicoScope 2000 Series, https://www.picotech.com/oscilloscope/2000/ picoscope-2000-overview TEquipment (2022a) Instek GDM-8341 50,000 Counts Dual Measurement Multimeter with USB Device, https://www.tequipment.net/InstekGDM-8341.html TEquipment (2022b) Instek GPE-3323 3 Channels, 217W Linear DC Power Supply, https://www. tequipment.net/Instek/GPE-3323/DC-Power-Supplies Test Equity (2022) Instek GDS-1202B Digital Storage Oscilloscope, https://www.testequity.com Test Equipment Depot (2022) Instek AFG-2105 Arbitrary Waveform Function Generator, https:// www.testequipmentdepot.com/instek/signalgenerators/afg2105.html Tinkercad (2022) Learn Circuits, https://www.tinkercad.com/learn/circuits Wikipedia (2022) Mains electricity by country, https://en.wikipedia.org/wiki/Mains_electricity_ by_country

Chapter 3

Basic Electronics

3.1

Introduction

Semiconductor electronics plays important roles in all major parts of mechatronic systems including sensors, actuators, processors, analog and digital signal processing, and interfacing. In this chapter, the basics of junction diodes, bipolar junction transistors (BJT), and metal oxide semiconductor field effect transistors (MOSFET) and their applications in mechatronics are presented.

3.2

Introduction to Junction Diodes

Diodes are constructed of doped silicon of p-n junctions, with p- and n-type sides termed anode and cathode, respectively, as shown in Fig. 3.1. The diode allows current in the forward direction when a positive voltage is applied across p-n junction. The characteristics of diode are briefly discussed in the following subsections.

3.2.1

Ideal Diode Model

The schematic symbol of a diode is shown in Fig. 3.2a, and the ideal current-voltage (i-v) characteristics can be described in Figs. 3.2b–d. When a positive current in the reference direction shown in Fig. 3.2a is applied to the diode, the ideal diode acts like a short circuit with a zero voltage drop, as shown in Fig. 3.2c. This mode of the diode is called forward biased, and the diode is tuned on. If a negative voltage in the

© The Author(s), under exclusive license to Springer Nature Switzerland AG 2023 B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_3

41

42

3

Basic Electronics

Fig. 3.1 Silicon diode

Fig. 3.2 Ideal diode (a) symbol, (b) i-v characteristics, (c) forward biased, (d) reverse biased

reference direction shown in Fig. 3.2a is applied to the diode, the diode acts like an open circuit allowing no current to flow through it, as shown in Fig. 3.2d. This mode of the diode is called reverse biased, and the diode is turned off. The mechanical analogy of an ideal diode can be a check valve that allows flow only in the forward direction for a positive pressure difference across the valve and prevents flow in the reverse direction.

3.2.2

Nonlinear Current-Voltage Characteristics of Junction Diodes

The approximated current-voltage (i-v) characteristics of a typical p-n junction diode is shown in Fig. 3.3 with three distinct regions of operation. Three regions are based on the junction voltage, v, (a) forward-bias region, v > 0; (b) reverse-bias region, v < 0; and (c) breakdown region, v < - VZ; VZ is called breakdown voltage. The current through a p-n junction diode in the forward-bias region can be expressed in the form of Shockley Eq. (3.1):  v  i = I S enV T - 1

ð3:1Þ

where i is the junction current, IS is called the reverse saturation current, v is the forward-bias junction voltage, n is called the emission coefficient, and VT is termed as thermal voltage. The emission coefficient, n can have a value between 1 and 2, depending on the material and the physical construction of the diode. For diodes from standard integrated-circuit fabrication process, under normal operating condition, the value of n is assumed to be 1. The reverse saturation current IS is proportional to the junction cross-sectional area and strongly dependent on temperature. For small-signal diodes typically used in small-power applications, the reverse saturation current IS is in the order of 10-15 to 10-14 A.

3.2

Introduction to Junction Diodes

43

Fig. 3.3 Nonlinear currentvoltage characteristics of a junction diode

The thermal voltage VT can be expressed in terms of Boltzmann’s constant (k = 1.381 × 10-23 J/K), charge of an electron (q = 1.60 × 10-19 C), and the absolute temperature of the junction in K as VT =

kT q

ð3:2Þ

At room temperature of 20 °C, the thermal voltage can be obtained from Eq. (3.2) as 25.3 mV. For appreciable forward-bias current through a diode, i ≫ IS, Eq. (3.1) can be approximated as v

i = I S enV T

ð3:3Þ

The forward-bias junction voltage, v, can be expressed in term of the junction current, i, from Eq. (3.3) as v = nV T ln

  i IS

ð3:4Þ

In the forward-bias region, the current remains very low for voltage smaller than about 0.5 V and rises exponentially for the junction voltage drop in the range of 0.6–0.8 V. This leads to a simplified model that assumes the diode in the forwardbias region becomes fully conducting with a constant voltage drop of 0.7 V. The constant-voltage-drop model of a diode in forward bias is shown in Figs. 3.4a, b.

44

3

Basic Electronics

Fig. 3.4 Constant-voltage-drop model of diode in forward bias (a) circuit model, (b) i-v characteristics

In the reverse-bias region of the diode with the negative junction voltage, v < 0, v the exponential term in Eq. (3.1) becomes negligible, enV T ≪ 1 for |v| greater than 3 to 4 times of thermal voltage (VT), and the junction current can be approximated as i ≈ - IS

ð3:5Þ

In real diodes, the reverse-bias junction current, i, though small, becomes much larger (in the range of 10-9A) than the reverse saturation current IS (in the range of 10-14A). In the breakdown region of the diode with the junction voltage v < - VZ, the reverse current increases rapidly over a small change in voltage drop. The amount of junction current can be limited by the power dissipation characteristics of the external circuitry the diode is connected to. The near-vertical current-voltage characteristics of the diode in the breakdown region makes some diodes (known as Zener diodes) suitable for voltage regulation applications.

3.2.3

Zener Diode and Voltage Regulation

The steep current-voltage characteristics of diodes in the breakdown region leads to the design of a special class of diode, known as Zener diode, that can allow a large amount of current when the reverse-bias voltage is just past the breakdown voltage, VZ. The schematic symbol for Zener diode is shown in Fig. 3.5 where IZ and Zener voltage VZ are positive. The characteristic of nearly constant voltage of the Zener diode around the breakdown voltage for a wide range of current is utilized in designing voltage regulators. A voltage regulator circuit using a Zener diode and its i-v characteristics are shown in Fig. 3.6. The specifications of a Zener diode, in general, include the breakdown voltage, VZ, the corresponding current, IZK, test voltage, VZt, the corresponding test current, IZt, dynamic resistance, RZ (inverse of

3.2

Introduction to Junction Diodes

45

Fig. 3.5 Model of a Zener diode (a) schematic (b) circuit model

Fig. 3.6 Example of Zener diode voltage regulator (a) circuit, (b) with Zener diode circuit model

slope of i-v curve at test point), and power dissipation rating P. The change in voltage, ΔV, and the change in Zener diode current, ΔI, are related as ΔI =

ΔV RZ

ð3:6Þ

The model of a Zener diode is presented in Fig. 3.5 where VZ0 is close to breakdown voltage VZ. The relation between the current IZ, the voltage VZ, and dynamic resistance RZ of the Zener diode is related as V Z = V Z0 þ I Z RZ

ð3:7Þ

An example of a typical voltage regulator circuit with a Zener diode is shown in Fig. 3.6a, where an unregulated voltage source Vs is connected through a currentlimiting resistor R to limit the power dissipation in Zener diode with the regulated voltage VZ across the load resistance RL. The regulator circuit with the Zener diode circuit model is shown in Fig. 3.6b. It is assumed that the Zener diode is in the breakdown region and the output voltage is VZ. With no load connected, the current in the Zener diode IZ can be obtained as IZ =

V S - V Z0 R þ RZ

ð3:8Þ

46

3

Basic Electronics

With no load connected, the change in Zener diode current (ΔIZ) can be related to change in source voltage (ΔVZ) as ΔI Z =

ΔV S R þ RZ

ð3:9Þ

The change in regulator output voltage (ΔVo = ΔVZ) can be expressed as ΔV o = ΔV Z = ΔI Z RZ =

ΔV S RZ R þ RZ

ð3:10Þ

Equation (3.10) gives the measure of regulation of the output voltage at no load. With the load resistance RL connected, the load current IL is VZ RL

ð3:11Þ

VS - VZ R

ð3:12Þ

IL = The unregulated source current I is I=

The load current is the difference between the source current from the unregulated voltage source and the Zener diode current IZ: IL = I - IZ

ð3:13Þ

The Zener diode current IZ depends on the load resistance RL as   VZ I Zmax = IRLmax

ð3:14Þ

The power dissipated in the Zener diode can be expressed as PZmax = I Zmax V Z =



 V 2Z VS - VZ VZ R RLmax

ð3:15Þ

The current limiting resistance R can be obtained from Eq. (3.15) for given input source voltage, load resistance, and Zener diode power and voltage ratings. Example 3.1 It is required to design a regulated 12 V DC source for an unregulated 20 V DC voltage source using a 1 W 12 V Zener diode, similar to Fig. 3.6a. Assume the maximum load resistance RLmax = 200 Ω.

3.2

Introduction to Junction Diodes

47

Solution The maximum power dissipated in the Zener diode can be obtained from Eq. (3.15):

PZmax = I Zmax V Z =



 V 2Z VS - VZ VZ R RLmax

Substituting Vs = 20 V, VZ = 12 V, RLmax = 200 Ω, and PZmax = 1 W, 1W=



 ð12 V Þ2 20 V - 12 V ð12 V Þ R 200 Ω

The minimum current-limiting resistance R can be obtained as 55.8 Ω. The nearest standard resistance value of 62 Ω is selected for the circuit, similar to Fig. 3.6a. Example 3.2 It is required to use a 5.6 V 45 mA Zener diode as a shunt regulator for an unregulated 15 V DC voltage source through a 240 Ω current-limiting resistance. The incremental resistance of the Zener diode is 10 Ω. Find the regulated voltage output at no load, line regulation, and load regulation. Solution The circuit is similar to Fig. 3.6b with VZ = 5.6 V, IZ= 45 mA, RZ= 10 Ω, and R= 240 Ω. Using Eq. (3.7), VZ = VZ0 + IZ RZ, 5.6 V = VZ0 + (45 mA)(10 Ω), VZ0 = 5.6 - 0.45V = 5.15 V. At no-load, the Zener diode current can be obtained using Eq. (3.8) - V Z0 15 V - 5:15 V I Z = V RS þ RZ = 240 Ωþ10 Ω = 39:4 mA. The no-load output voltage can be obtained from Eq. (3.7) as VZ = VZ0 + IZRZ = 5.15 V + (39.4 mA)(10 Ω) = 5.54 V. Line regulation can be obtained from Eq. (3.10) as 1 V ð10 ΩÞ S RZ = = 40 mV. Line regulation ΔV o = ΔV Z = ΔI Z RZ = ΔV RþRZ 240 Ωþ10 Ω ΔV o = 40 mV=V. ΔV S Load regulation can be obtained from the first part of Eq. (3.10) as ΔVo = ΔVZ = ΔIZRZ = (-1 mA)(10 Ω) = - 10 mV for a 1 mA decrease in Zener current (ΔIZ) due to an increase of 1 mA in load current. Line regulation is -10 mV/mA.

3.2.4

Analysis of Diode Circuits

The analysis of DC circuits with multiple diodes can be started with an educated guess on on-off status of individual diodes. For a diode guessed to be on (or conducting), the diode is replaced with a DC voltage of 0.7 V (battery). For a diode guessed to be off (or non-conducting), the diode is replaced with an open

48

3

Basic Electronics

Fig. 3.7 Example of a DC circuit with diodes

Fig. 3.8 DC circuit with constant-voltage-drop model of each diode (Example 3.3)

circuit. The circuit is analyzed with these replacements. The validity of the on-off guesses has to be checked next. For an on (conducting) diode, the forward current has to be positive; otherwise, the guess is wrong. For an off (nonconducting) diode, the voltage in the forward direction has to be less than 0.7 V; otherwise, the guess is wrong. If any of the guesses is wrong, the analysis has to be repeated with the updated guess till all guess status are validated. The procedure is illustrated through two examples in this section. Example 3.3 For the DC circuit with diodes D1 and D2 in Fig. 3.7, the parameters are as follows: V = 30 V, R1 = 1.0 kΩ, R2 = 0.5 kΩ, and R3 = 1.0 kΩ. Find the currents I1, I2, and I3. Solution As a first guess, it is assumed that both didoes are in forward bias and each diode is replaced with 0.7 V voltage drop model in the direction of forward bias, as shown in Fig. 3.8. Applying Ohm’s law in each branch at the junction (a, at voltage Va), the currents I1, I2, and I3 can be expressed as I1 =

V - 0:7 - V a 30 - 0:7 - V a = R1 1 × 103 V Va I2 = a = R2 0:5 × 103 V - 0:7 V a - 0:7 I3 = a = R3 1 × 103

Applying KCL at the junction a,

3.2

Introduction to Junction Diodes

49

I1 - I2 - I3 = 0 30 - 0:7 - V a Va V - 0:7 - a =0 3 3 1 × 103 1 × 10 0:5 × 10 30 - 0:7 - V a - 2V a - ðV a- 0:7Þ = 0 Va =

30 = 7:5 V 4

Substituting Va = 7.5 V, the currents can be obtained as I1 =

  V - 0:7 - V a 30 - 0:7 - 7:5 V = = 21:8 × 10 - 3 A = 21:8 mA 3 R1 Ω 1 × 10   V V 7:5 I2 = a = = 15 × 10 - 3 A = 15 mA 3 R2 0:5 × 10 Ω   V - 0:7 7:5 - 0:7 V = I3 = a = 6:8 × 10 - 3 A = 6:8 mA R3 1 × 103 Ω

The currents through the diodes I1 and I3 are positive in the forward-bias direction. Hence, the assumption that the diodes are in forward bias and on is valid. Example 3.4 For the DC circuit with diodes D1 and D2 in Fig. 3.9, the parameters are as follows: V1 = 10 V, V2 = 9 V, R1 = 1.0 kΩ, R2 = 0.5 kΩ, and R3 = 3.0 kΩ. Find the currents ID1, ID2, IR1, IR2, and IR3.

Fig. 3.9 Second example of a DC circuit with diodes

Fig. 3.10 DC circuit with constant-voltage-drop model of each diode (Example 3.4)

50

3

Basic Electronics

Solution As a first guess, it is assumed that both didoes are in forward bias (ON) and each diode is replaced with 0.7 V voltage drop model in the direction of forward bias, as shown in Fig. 3.10. The node voltages Va and Vb can be written as follows: V a = V 1 - 0:7 V = 10 - 0:7 V = 9:3 V V b = V 2 - 0:7 V = 9 - 0:7 V = 8:3 V Applying Ohm’s law for each resistor, the resistor currents can be expressed as   Va 9:3 V = = 9:3 × 10 - 3 A = 9:3 mA 3 Ω R1 1 × 10   V - V b 9:3 - 8:3 V I R2 = a = = 2 × 10 - 3 A = 2 mA R2 0:5 × 103 Ω   V V 8:3 I R3 = b = = 2:77 × 10 - 3 A = 2:77 mA R3 3 × 103 Ω I R1 =

Applying KCL at node a, the current in the diode D1 can be obtained from I D1 - I R1 - I R2 = 0 I D1 = I R1 þ I R2 = 11:3 mA Similarly applying KCL at node b, the current in the diode D2 can be obtained from I R2 - I R3 - I D2 = 0 I D2 = I R2 - I R3 = - 0:77 mA The current in diode D2 is negative; it means the initial assumption that both diodes are in forward bias is not correct. Examining the circuit, the new assumption Fig. 3.11 DC circuit with constant-voltage-drop model for D1 and open circuit for D2 (Example 3.4)

3.2

Introduction to Junction Diodes

51

is that diode D1 is in forward bias (ON) and diode D2 in reverse bias (OFF). Under the modified assumption, the diode D1 is replaced with its constant-voltage-drop model and the diode D2 replaced with an open circuit, as shown in Fig. 3.11. The node voltage Va can be written as before: V a = V 1 - 0:7 V = 10 - 0:7 V = 9:3 V

Applying Ohm’s law for resistor R1, the resistor current IR1 can be expressed as I R1 =

  Va 9:3 V = = 9:3 × 10 - 3 A = 9:3 mA 3 Ω R1 1 × 10

The current in the resistors R2 and R3 (in series) can be expressed as I R2 = I R3 =

  V Va 9:3 = = 2:66 × 10 - 3 A = 2:66 mA 3 R2 þ R3 ð0:5 þ 3Þ × 10 Ω

The node voltage Vb can be obtained as   V b = V a - I R2 R2 = 9:3 V - 2:66 × 10 - 3 A 0:5 × 103 Ω = 7:971 V The diode D2 voltage VD2 can be obtained as V D2 = V b - V 2 = 7:971 - 9 V = - 1:029 V It confirms that the diode D2 is in reverse bias (OFF). The assumption that the diode D1 is in forward bias (ON) and the diode D2 is in reverse bias (OFF) is valid.

3.2.5

Rectifier Circuits

The diodes can be used in rectifier circuits to produce DC output from AC voltage sources. The rectifier circuits can be in two forms: half-wave and full-wave rectifiers. In half-wave rectifier, alternate half-cycles of input AC sinusoid are utilized through a diode circuit shown in Fig. 3.12a. In full-wave rectifiers, both half-cycles are utilized through a bridge rectifier circuit shown in Fig. 3.13a. Half-Wave Rectifier A half-wave rectifier circuit is shown in Fig. 3.12a. The input and output waveforms are shown in Fig. 3.12b using a constant-voltage-drop model of the diode. The peak of the output voltage (vo(t)) is lower than the peak of input voltage (vS(t)) by diode voltage drop VD = 0.7 V as diode starts conducting only in forward bias, i.e., vo(t) = 0 for vS(t) < VD and vo(t) = vS(t) - VD for vS(t) > VD.

52

3

Basic Electronics

Fig. 3.12 Half-wave rectifier (a) circuit, (b) half-wave rectifier input and output waveforms

Fig. 3.13 Full-wave rectifier (a) circuit, (b) full-wave rectifier input and output waveforms

Full-Wave Rectifier The bridge circuit of a full-wave rectifier is shown in Fig. 3.13a with four diodes. The input and output waveforms of the circuit are shown in Fig. 3.13b. In the positive half-cycle, diodes D1 and D3 are in forward bias and diodes D2 and D4 are in reverse bias, thus allowing the current to flow through R giving the output voltage vo. In the negative half-cycle diodes D4 and D2 are in forward bias and diodes D1 and D3 are in reverse bias, thus allowing the current to flow through R in the same direction as before giving the output voltage vo. A constant-voltage-drop model is assumed for each diode with voltage drop of VD = 0.7 V. The peak of output voltage waveform (vo(t)) is lower than the peak of input voltage (vS(t)) by twice diode voltage drop 2 VD = 1.4 V as the group of two diodes start conducting only in forward bias, i.e., vo(t) = 0 for vS(t) < 2VD and vo(t) = vS(t) - 2VD for vS(t) > 2VD.

3.3

3.3

Bipolar Junction Transistors

53

Bipolar Junction Transistors

A bipolar junction transistor (BJT) consists of three adjacent semiconductor regions of doped silicon, each connected to a terminal labeled emitter (E), base (B), and collector (C). There are two types of BJT, npn and pnp. In an npn transistor, a thin slice of p-type (base) is between two n-type silicon layers (emitter and collector). In a pnp transistor, the base is formed of n-type silicon in between two p-type layers (emitter and collector). The schematics of npn and pnp BJTs are shown in Figs. 3.14a–d. In each transistor, there are two pn junctions, emitter-base junction (EBJ) and collector-base junction (CBJ). The operation of a transistor depends on the bias status (forward or reverse) of these junctions. For operation of a BJT as an amplifier, the transistor has to be in active mode with EBJ in forward bias and CBJ in reverse bias. A npn BJT is operated in active mode by connecting external voltage sources (such that VC > VB > VE) to establish forward bias in base-emitter junction (VBE > 0) and reverse bias in base-collector junction (VCB > 0) to create base, emitter, and collector currents IE, IB, and IC, respectively, as shown in Fig. 3.14b. For the active mode operation of an npn BJT, the junction voltages should be VBE ≈ 0.7 V and VCB ≥ 0.4 V. A pnp BJT is operated in active mode by connecting two external voltage sources (such that VE > VB > VC) to establish forward bias in base-emitter junction (VEB > 0) and reverse bias in collector-base junction (VBC > 0) to create base, emitter, and collector currents IE, IB, and IC, respectively, as shown in Fig. 3.14d. For active mode operation of a pnp BJT, the junction voltages should be VEB ≈ 0.7 V and VCB ≤ 0.4 V. The relations for transistor currents and voltages are related as follows: IE = IB þ IC

Fig. 3.14 Models of BJT (a) npn, (b) npn, (c) pnp, (d) pnp

ð3:16Þ

54

3

Basic Electronics

V BE = V B - V E

ð3:17Þ

V CE = V C - V E

ð3:18Þ

I C = βI B

ð3:19Þ

where the parameter β is known as transistor gain with a typical value around 100. The solution procedure includes making an assumption of the transistor mode of operation—active, saturation, and cutoff—analysis of the BJT circuits, and validating the assumed states. In the active mode operation, assumed voltage and current relations are as follows: VBE = 0.7 V (npn), VEB = 0.7 V (pnp), for positive bias in EBJ and IC = β IB. In the saturation mode, assumed voltage relations are VBE = 0.7 V (npn), VEB = 0.7 V (pnp), for positive bias in EBJ, and VCB = - 0.5 V (npn), VBC = - 0.5 V (pnp), for reverse bias in CBJ. In the cutoff mode, both EBJ and CBJ are in reverse bias and no currents, IB = 0, IC = 0, and IE = 0. The emitter-base and collector-base loops are analyzed to obtain the remaining variables. For the active mode, the reverse bias at CBJ has to be validated by checking VCB > 0 (npn) and VBC > 0 (pnp) alternatively, VCE > 0.7 V (npn) and VEC > 0.7 V (pnp), and currents are positive, IB > 0, IC > 0, and IE > 0. For the saturation mode, IC < βIB, currents are positive, IB > 0, IC > 0, and IE > 0. For the cutoff mode, junctions are reverse biased, VBE < 0 (npn), VEB < 0 (pnp), VCB > 0 (npn), and VBC > 0 (pnp). If any of the conditions in the validation stage fails, the analysis has to be repeated with a new assumption of mode till all validation conditions are satisfied.

3.3.1

Example Problem of npn BJT

Example 3.5 An example of npn BJT circuit is shown in Fig. 3.15. The circuit parameters are as follows: VCC = 12.7 V, VBB = 6.8 V, RC = 1.2 kΩ, RB = 12 kΩ, RE = 2.2 kΩ, and β = 100. Find transistor currents IB, IC, and IE and voltages VBE, VCE, and VCB. Fig. 3.15 Example of npn BJT Circuit

3.3

Bipolar Junction Transistors

55

Solution The analysis process is started assuming that the npn BJT is in active mode. The following two relations are enforced: VBE = 0.7 V and IC = β IB = 100 IB. Applying KVL in base-emitter (B-E) loop: V BB - RB I B - V BE - RE I E = 0 V BB - RB I B - V BE - RE ð1 þ βÞI B = 0 IB = IB =

V BB - V BE RB þ RE ð1 þ βÞ

V 6:8 - 0:7 3 Ω ð12 þ ð1 þ 100Þ2:2 Þ × 10

= 0:026 × 10 - 3 A = 0:026 mA I C = βI B = 100ð0:026Þ mA = 2:6 mA, I E = I B þ I C = ð1 þ βÞ I B = 2:63 mA Applying KVL in collector-emitter (C-E) loop: V CC - RC I C - V CE - RE I E = 0 V CE = V CC - RC I C - RE I E V CE = 3:787 V The voltage between collector and base VCB can be obtained from V CE = V CB þ V BE V CB = V CE - V BE = 3:087 V For the validity of the initial assumption that the npn BJT is operating in active mode, the following inequality conditions need to be checked. V CE = 3:787 V > 0:7 V and I B = 0:026 mA > 0: Both conditions are satisfied. Hence, the original assumption that the npn BJT is operating in active mode is valid.

3.3.2

Example Problem of pnp BJT

Example 3.6 An example of pnp BJT circuit is shown in Fig. 3.16a. The circuit parameters are as follows: VEE = 8.5 V, V1 = 7.5 V, R1 = 12 kΩ, R2 = 42 kΩ, RC = 3.5 kΩ, RE = 1.2 kΩ, and β = 100. Find transistor currents IB, IC, and IE and voltages VEB, VEC, and VBC.

56

3

Basic Electronics

Fig. 3.16 Example of pnp BJT circuit (a) original circuit, (b) equivalent circuit

Solution First, the base side circuit is replaced with an equivalent Thevenin circuit with equivalent resistance RTh and open-circuit voltage VOC as RTh =

ð12Þð42Þ R1 R2 = kΩ = 9:333 kΩ 12 þ 42 R1 þ R2

V OC = V 1

R2 42 = ð7:5V Þ = 5:833 V R1 þ R2 12 þ 42

The analysis process is started assuming the pnp BJT is in active mode. The following two relations are enforced: VEB = 0.7 V and IC = β IB = 100 IB. Applying KVL in emitter-base (E-B) loop: V EE - RE I E - V EB - RTh I B - V OC = 0 V EE - RE ð1 þ βÞI B - V EB - RTh I B - V OC = 0 IB = IB =

V EE - V EB - V OC RTh þ RE ð1 þ βÞ

8:5 - 0:7 - 5:833 V ð9:333 þ ð1 þ 100Þ1:2 Þ × 103 Ω

= 0:0151 × 10 - 3 A = 0:0151 mA I C = βI B = 100ð0:0151 Þ mA = 1:51 mA, I E = I B þ I C = ð1 þ βÞ I B = 1:52 mA Applying KVL in emitter-collector (E-C) loop: V EE - RE I E - V EC - RC I C = 0

3.4

Metal Oxide Semiconductor Field Effect Transistors

57

V EC = V EE - RC I C - RE I E V EC = 1:401 V The voltage between base and collector VBC can be obtained from V EC = V EB þ V BC V BC = V EC - V EB = 0:701 V For the validity of the initial assumption that the pnp BJT is operating in active mode, the following inequality conditions need to be checked. V EC = 1:401 V > 0:7 V and I B = 0:015 mA > 0: Both conditions are satisfied. Hence, the original assumption that the pnp BJT is operating in active mode is valid.

3.4

Metal Oxide Semiconductor Field Effect Transistors

A metal oxide semiconductor field effect transistor (MOSFET) consists of three doped silicon semiconductor regions: drain (D), source (S), and body (B) or substrate and an insulated (through a layer of silicon dioxide, SiO2) terminal gate (G) on the substrate between the drain and the source. When no voltage is applied to the gate, the pn junctions between substrate and the drain form two back-to back diodes and prevent any current flow between the drain and the source with a positive voltage applied to the drain. The applied voltage at the gate helps create a field that leads to a channel of current flow between the drain and the source. MOSFETs are primarily of two types—NMOS or PMOS. In NMOS, the n-type drain and source are on the p-type substrate. In PMOS, p-type drain and source are on the n-type substrate. The third type, known as complementary MOS or CMOS, combines NMOS and PMOS on the p-type substrate with PMOS on the n-type well and a SiO2 insulator between NMOS and PMOS. The circuit symbols for NMOS and PMOS are shown in Figs. 3.17a, b, respectively. MOSFETs are used in three modes of operation: cutoff, triode, and saturation depending on the voltages VGS and VDS. It should be pointed out that for a MOSFET, the drain and source currents are the same as there is no gate current, i.e., ID = IS

ð3:20Þ

IG = 0

ð3:21Þ

In the cutoff mode, VGS < Vtn(NMOS) or VSG < | Vtp| (PMOS) ID = 0

ð3:22Þ

58

3

Basic Electronics

Fig. 3.17 Circuit symbol of MSFET (a) NMOS, (b) PMOS

where VGS and VSG denote the voltage between gate and source, and Vtn and Vtp are the threshold voltages for NMOS and PMOS, respectively. ID is the drain current. The overdrive voltage (VOV) is defined as VOV = VGS - Vtn (NMOS) and VOV = VSG - Vtp (PMOS). In triode mode, VDS ≤ VOV(NMOS) or VSD < | VOV| (PMOS), I D = K ð2ðV GS- V tn Þ - V DS ÞV DS ðNMOSÞ   I D = K 2 V SG- V tp - V SD V SD ðPMOSÞ

ð3:23Þ ð3:24Þ

where VDS and VSD denote voltage between drain and source for NMOS and PMOS, respectively, and K is a constant that depends on the MOSFET. In the saturation mode, VDS ≥ VOV(NMOS) or VSD ≥ | VOV| (PMOS), I D = K ðV GS - V tn Þ2 ðNMOSÞ  2 I D = K V SG - V tp ðPMOSÞ

ð3:25Þ ð3:26Þ

The analysis of a MOSFET in DC circuit involves finding one current ID and two voltages, VGS and VDS (NMOS) or VSG and VSD (PMOS). The analysis starts with an assumption of the operation mode, if not specified otherwise. The circuit is analyzed enforcing the corresponding equations of the mode of operation. In the cutoff mode, Eq (3.22) is assumed. In triode mode, Eq. (3.23) is used for NMOS, and (3.24), for PMOS. In the saturation mode, Eq. (3.25) is used for NMOS, and (3.26), for PMOS. The assumption has to be validated using the corresponding conditions (mode inequalities) for assumed mode of operation. In the cutoff mode, the inequality condition is VGS < Vtn(NMOS) or VSG < |Vtp| (PMOS). In the triode mode, the inequality conditions to check are VGS > Vtn and VDS < VGS - Vtn(NMOS) and VSG > |Vtp| and VSD < VSG - |Vtp|(PMOS). In the saturation mode, the corresponding condition is VDS ≥ VGS - Vtn(NMOS) or VSD ≥ VSG - |Vtp| (PMOS). It should also be pointed out that.

3.4

Metal Oxide Semiconductor Field Effect Transistors

V GS = V tn þ V OV ðNMOSÞ V SG = V tp þ jV OV j ðPMOSÞ

59

ð3:27Þ ð3:28Þ

If the assumed conditions are not satisfied, the analysis has to be repeated with modified assumption till the conditions are validated.

3.4.1

NMOS Example Problem

Example 3.7 An example of NMOS circuit is shown in Fig. 3.18. The circuit parameters are as follows: VDD = 6.5 V, VSS = -8.5 V, RD = 1.5 kΩ, RS = 2.5 kΩ, K = 0.4 mA/V2, and Vtn = 2 V. Find ID, VGS, and VDS. Solution Let us assume that the NMOS is operating in saturation mode. Applying KVL in the gate-source loop: V GG - V GS - RS I D - V SS = 0 or 0 - V GS - 2:5 × 103 I D - ð - 8:5Þ = 0 or 8:5 - V GS ID = × 10 - 3 A: 2:5 Applying KVL in the drain-source loop: V DD - RD I D - V DS - RS I D - V SS = 0 or 6:5 - 1:5 × 103 I D - V DS - 2:5 × 103 I D - ð- 8:5Þ = 0 After rearranging: VDS = 15 - 4 × 103ID Fig. 3.18 Example problem of NMOS

60

3

Basic Electronics

For assumed saturation mode of operation of NMOS, the drain current ID can be written as I D = K ðV GS - V tn Þ2 : Equating ID from both K ðV GS - V tn Þ2 =

8:5 - V GS 2:5

or 0:4 × 10 - 3 ðV GS - 2Þ2 =

× 10 - 3

8:5 - V GS × 10 - 3 2:5

The solution of VGS from this equation gives two values -1.098 V and 4.098 V. Of these two values, VGS = 4.098 V is selected as it satisfies the saturation mode condition VGS > Vtn. Substituting VGS = 4.098 V, the drain current can be obtained as ID = 1.76 × 10-3 A = 1.76 mA. Substituting the value of ID = 1.76 × 10-3 A, in VDS = 15 - 4 × 103ID, the drainsource voltage is obtained as VDS = 7.957 V = 7.96 V. To validate the assumption of saturation, the inequality conditions VGS > Vtn and VDS ≥ VGS - Vtn should be checked. VGS = 4.098 V > Vtn = 2 V and VDS = 7.96 V > VGS - Vtn = 2.098 V. So both conditions are satisfied. Hence, the original assumption that the NMOS is operating in saturation mode is valid.

3.4.2

PMOS Example Problem

Example 3.8 An example of PMOS circuit is shown in Fig. 3.19. The circuit parameters are as follows: VDD = 0 V, VD = 4.5 V, VSS = 6.5 V, RD = 4.7 kΩ, RS = 0 kΩ, RG = 10 kΩ, K = 0.2 mA/V2, and Vtp = -2 V. Find ID, VSG, and VSD. Solution Let us assume that the PMOS is operating in saturation mode. From the known characteristics of MOSFETs and the given parameters of PMOS, the following can be written: I G = 0, I S = I D V S = V SS = 6:5 V V G = V GG –I G RG = V GG V SD = V S –V D = 6:5 - 4:5 V = 2:0 V V SG = V S –V G = 6:5 - V GG ID =

V D - V DD 4:5 - 0 V = = 0:957 × 10 - 3 A = 0:957 mA RD 4:7 × 103 Ω

3.4

Metal Oxide Semiconductor Field Effect Transistors

61

Fig. 3.19 Example problem of PMOS

For the assumed saturation mode of operation of PMOS, the drain current ID can be written as 2 I D = K V SG - V tp  2 or K V SG - V tp = 0:957 × 10 - 3 or 0:2 × 10 - 3 ðV SG - 2Þ2 = 0:957 × 10 - 3 The solution of VGS from this equation gives two values -0.188 V and 4.188 V. Of these two values, VSG = 4.188 V is selected as it satisfies the saturation mode condition VSG > |Vtp|. Substituting VSG = 4.188 V, VGG can be obtained as VGG = 6.5 - 4.188 = 2.312 V. To validate the assumption of saturation, the inequality conditions VSG > |Vtp| and VSD ≥ VSG - |Vtp| should be checked. V SG = 4:188 V > V tp = 2 V and V SD = 2:0 V < V SG - V tp = 2:188 V: One of the conditions is not satisfied. Hence, the original assumption that the PMOS is operating in saturation mode is not valid. The process is repeated with the assumption that the PMOS is operating in triode mode. For this mode, the drain current relation is changed to   I D = K 2 V SG- V tp - V SD V SD 0:957 × 10 - 3 = 0:2 × 10 - 3 ð2ðV SG- 2Þ - 2Þ2

62

3 Basic Electronics

The solution of VSG is obtained as VSG = 4.197 V. The value of VGG is obtained as VGG = 2.303 V. To validate the assumption of triode mode, the inequality conditions VSG > |Vtp| and VSD < VSG - |Vtp| should be checked. V SG = 4:197 V > V tp = 2 V and

V SD = 2:0 V < V SG - V tp = 2:197 V:

Both conditions are satisfied. Hence, the modified assumption that the PMOS is operating in triode mode is valid.

3.5

Computer-Aided Analysis of Basic Electronic Circuits

Basic circuits containing electronic components can be analyzed using software platforms like Multisim, LTspice, and Matlab, among others. Matlab code and results are presented for solution of Example 3.3 using Matlab symbolic manipulation as an illustration of the procedure. The results match with those presented using manual analysis. Results of all examples in this chapter are obtained using Matlab codes using symbolic manipulation.

3.5.1

Analysis Using Matlab

%ch3- Example 3.3 circuit analysis % using constant voltage drop model for diodes syms Vs R1 R2 R3 vD vA % declare symbolic variables i1=(Vs-vD -vA)/R1; % current through D1 assuming in forwrad bias i2=vA/R2; % current through R2 i3=(vA-vD)/R3; %current through R3 and D2 assuming in forward bias vA=solve(i1-i2-i3==0, vA); % solve for vA using KCL at node A % numerical values Vs=30; R1=1e3;R2=0.5e3;R3=1.0e3;vD=0.7; vA=vpa(subs(vA),6) % vA at node A i1=vpa(subs(i1),6) % current through R1 and D1 assuming in forward bias i2=vpa(subs(i2),6) % current through R2 i3=vpa(subs(i3),6) % current through R3 and D2 assuming in forward bias Results: vA = 7.5 V, i1 = 0.0218 A=21.8 mA, i2 = 0.015 A= 15 mA, i3 = 0.0068 A= 6.8 mA

_______________________________________________________

Exercises

63

Fig. 3.20 DC circuit of Example 3.3 implemented on Tinkercad along with results

3.5.2

Simulation Using Tinkercad

The DC circuit of Fig. 3.8 (Example 3.3) as implemented in Tinkercad along with simulation results is shown in Fig. 3.20. The constant-voltage-drop model of each diode is implemented using a DC supply voltage of 0.7 V. Currents in 0.7 V power supply models are indicated in reverse polarity; these values should be considered positive in the direction of current flows. Results are close to those obtained using Matlab code, as expected. The difference in values are due to lower precision of Tinkercad compared to Matlab.

Exercises 1. It is required to design a regulated 5.1 V DC source for a 12 V DC voltage source using a 0.5 W 5.1 V Zener diode, similar to Fig. P3.1. Assume the maximum load resistance RLmax = 470 Ω. Fig. P3.1 DC voltage regulator circuit for problem 1

64

3

Basic Electronics

2. For the DC circuit with diodes D1 and D2 in Fig. P3.2, the parameters are as follows: V1 = 5 V, V2 = 6 V, R1 = 2.2 kΩ, R2 = 0.68 kΩ, and R3 = 3.3 kΩ. Find the currents ID1, ID2, IR1, IR2, and IR3. Fig. P3.2 DC circuit with diodes for problem 2

3. For the DC circuit with diodes D1 and D2 in Fig. P3.3, the parameters are as follows: V1 = 4 V, R1 = 1.8 kΩ, R2 = 3.3 kΩ, and I1 = 4.0 mA. Find the currents ID, IR1, and IR2. Fig. P3.3 DC circuit with diodes for problem 3

4. For the npn BJT circuit of Fig. P3.4, the circuit parameters are as follows: VCC = 10.5 V, VBB = 5.8 V, RC = 1.0 kΩ, RB = 10 kΩ, RE = 2.7 kΩ, and β = 99. Find transistor currents IB, IC, and IE and voltages VBE, VCE, and VCB. Fig. P3.4 A circuit with a npn BJT for problem 4

Exercises

65

5. For the pnp BJT circuit of Fig. P3.5, the circuit parameters are as follows: VEE = 7.5 V, V1 = 6.5 V, R1 = 10 kΩ, R2 = 39 kΩ, RC = 3.3 kΩ, RE = 1.8 kΩ, and β = 99. Find transistor currents IB, IC, and IE and voltages VEB, VEC, and VBC.

Fig. P3.5 A circuit with a pnp BJT for problem 5

6. An example NMOS circuit is shown in Fig. P3.6. The circuit parameters are as follows: VDD = 5.5 V, VSS = -7.5 V, RD = 1.8 kΩ, RS = 2.7 kΩ, K = 0.4 mA/ V2, and Vtn = 2 V. Find ID, VGS, and VDS.

Fig. P3.6 NMOS circuit for problem 6

66

3

Basic Electronics

7. A PMOS circuit is shown in Fig. P3.7. The circuit parameters are as follows: VDD = 0 V, VD = 4.0 V, VSS = 5.5 V, RD = 3.9 kΩ, RS = 0 kΩ, RG = 12 kΩ, K = 0.2 mA/V2, and Vtp = -2 V. Find ID, VSG, and VSD. Fig. P3.7 PMOS circuit for problem 7

Bibliography Alciatore DG (2019) Introduction to mechatronics and measurement systems, 5th edn. McGraw Hill, New York Hambley A (2017) Electrical engineering: principles and applications, 7th edn. Pearson, Upper Saddle River Mathworks (2022) Matlab and Simulink, https://www.mathworks.com Sedra AS, Smith KC, Carusone TC, Gaudet V (2020) Microelectronic circuits, 8th edn. Oxford University Press, New York Tinkercad (2022) Learn circuits, https://www.tinkercad.com/learn/circuits

Chapter 4

Dynamic System Characteristics

4.1

Introduction

In this chapter, analysis and characterization of responses of mechatronics and measurement systems under static and dynamic conditions are presented. Details of first-order and second-order system characteristics and experimental determination of these characteristics are covered. Examples including computer-aided analysis and simulation are presented. Experimentation using the virtual simulation platform Tinkercad is presented along with actual laboratory implementation. Endof-chapter exercise problems are provided to help enhance understanding of the materials covered and consolidate problem-solving skills.

4.2

First-Order Systems

First-order systems are characterized in the form of a nonhomogeneous, first-order ordinary differential Eq. (4.1): τ

dyðt Þ þ yðt Þ = Kxðt Þ dt

ð4:1Þ

where τ is termed time constant, x(t), y(t) are input and output variables as functions of time t, and K is termed static sensitivity.

© The Author(s), under exclusive license to Springer Nature Switzerland AG 2023 B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_4

67

68

4.2.1

4

Dynamic System Characteristics

Time Domain Analysis

The solution of first-order differential Eq. (4.1) depends on the type of input x(t). As an example, the response of a step input is considered in this section. A step input is given in Eq. (4.2): xðt Þ = Auðt Þ, uðt Þ = 1, t ≥ 0, uðt Þ = 0, otherwise

ð4:2Þ

where A is a constant. The solution of Eq. (4.1) for the step input of Eq. (4.2) consists of two parts, complementary function, yCF(t), and particular integral, yPI(t),as given in Eq. (4.3): yðt Þ = yCF ðt Þ þ yPI ðt Þ

ð4:3Þ

The complementary function, yCF(t), is the solution of homogeneous first-order differential Eq. (4.1) with x(t) = 0. It also depicts the transient response of the system. The particular integral, yPI(t), depends on input x(t) and depicts the steadystate response of the system. The complementary function, yCF(t), can be represented as yCF ðt Þ = Ce - t=τ

ð4:4Þ

where C is the constant of integration, and it is determined from initial condition. The particular integral, yPI  (t), can  be obtained for the particular input x(t). Here, an operator approach using D≜ dtd is presented. yPI ðt Þ =

1 Kxðt Þ ð1 þ τDÞ

ð4:5Þ

For step input of Eq. (4.2), the particular integral can be obtained using binomial expansion of the operator term as shown in Eqs. (4.6) and (4.7):   1 = ð1 þ τDÞ - 1 = 1- τD þ ðτDÞ2 - ðτDÞ3 þ . . . ð1 þ τDÞ

ð4:6Þ

1 Kxðt Þ ð1 þ τDÞ   = 1- τD þ ðτDÞ2 - ðτDÞ3 þ . . . KAuðt Þ

yPI ðt Þ =

  = KA 1- τ:0 þ τ2 :0 - τ2 :0 þ . . . = KA

ð4:7Þ

4.2

First-Order Systems

69

The solution, y(t), is expressed in terms of its components, given in Eqs. (4.4) and (4.7), in the form of Eq. (4.8): yðt Þ = Ce - t=τ þ KA

ð4:8Þ

The constant of integration, C, can be obtained by applying the initial condition at t = 0, y(t) = 0. Applying the initial condition to the solution (4.8) results in Eq. (4.10): 0 = Ce - τ þ KA, C = - KA,   t yðt Þ = KA 1- e - τ 0

ð4:9Þ ð4:10Þ

The value of y(t) of a first-order system for a step input at t = τ is shown in Eq. (4.11):  τ yðτÞ = KA 1- e - τ = 0:632 KA

ð4:11Þ

In other words, the output of a first-order system for step input reaches 63.2% of the final steady-state value. The time taken for the output to reach 90% of the steady-state values is known as rise time tR. From Eq. (4.10), putting y(t = tR) = 0.90KA,   tR yðt= t R Þ = KA 1- e - τ = 0:90 KA tR

tR

1 - e - τ = 0:90, e - τ = 0:10, t R = - lnð0:1Þτ = 2:303τ

ð4:12Þ

The normalized response (y(t)/KA) of a first-order system versus normalized time (t/τ)  t is shown in Fig. 4.1. The normalized output (y(t)/KA) at normalized time The normalized output (y(t)/KA) is 0.9 at normalized time τt = 1 is 0:632:  = 2:303 . τ

4.2.2

Frequency Domain Analysis

The response of the first-order system represented in Eq. (4.13) for a sinusoidal input x(t) = A sin (ωt) under steady condition can be obtained using operator approach.

70

4

Dynamic System Characteristics

Fig. 4.1 Normalized step response of a first-order system

τ

dyðt Þ þ yðt Þ = KA sinðωt Þ dt

ð4:13Þ

ð1 - τDÞ 1 KA sinðωt Þ KA sinðωt Þ = 1 þ τD ð1 þ τDÞð1 - τDÞ   ð1 - τDÞ d 2 2 KA sinðωt Þ D  , D  - ω = dt 1 þ ðτωÞ2

yðt Þ =

=

1 KAðsinðωt Þ - τω cosðωt ÞÞ 1 þ ðτωÞ2

KA = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi sinðωt - φÞ 1 þ ðτωÞ2

ð4:14Þ

The amplitude ratio (AR = Y/KA) and phase lag (φ) are obtained as shown in Eqs. (4.15) and (4.16). 1 AR = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 1 þ ðτωÞ2

ð4:15Þ

φ = tan - 1 ðτωÞ

ð4:16Þ

4.2

First-Order Systems

71

Fig. 4.2 Amplitude ratio versus normalized frequency for a first-order system

It is worth mentioning that the frequency response can also be obtained using Laplace transform, assuming zero initial condition, replacing dtd with s, and s = jω. 1 At τω = 1 or ω = 1/τ, AR = pffiffiffiffiffiffi = p1ffiffi2 = 0:707, ωc = 1τ rad s is termed corner or 1þ1 cut-off frequency of a first-order low-pass filter. The corner or cut-off frequency in Hz is given as f c = ω2πc . The amplitude ratio (AR) versus normalized frequency ( f/fc) is shown in Fig. 4.2. The amplitude ratio at corner frequency (ff = 1Þ is 0.707. c

4.2.3

Experimental Determination of System Parameters

It is necessary to experimentally determine the parameters, static sensitivity (K ), and time constant (τ) of a first-order system. The static sensitivity can be obtained from Eq. (4.10) as the ratio of steady-state output (yss = y(t), t → 1, yss = KA) and step input (A) as K = yAss : Time constant (τ) can be obtained from the step response of a first-order system using Eq. (4.11). From the step response of a first-order system, time constant can be obtained as the time the system output y(t) reaches 63.2% of its steady-state value. Time constant can also be determined from the frequency response of a first-order system using Eq. (4.15) and Fig. 4.2. Time constant can be obtained as the reciprocal of the corner frequency (ωc in rad/s) at which the amplitude ratio (AR) is 0,707, i.e., τ = 1/ωc.

72

4

Dynamic System Characteristics

Time constant can also be obtained from the step response of a first-order system. Reorganizing the Eq. (4.10) as  1-

 t yð t Þ = e-τ KA

ð4:17Þ

Taking the logarithm of both sides of Eq. (4.17), 

 yð t Þ t = - ln 1KA τ

ð4:18Þ

 It means that time constant is equal to the reciprocal of the slope of - ln 1-



yð t Þ KA

versus t graph (a straight-line approximation or trend line).

4.3

Second-Order Systems

Second-order systems are characterized in the form of a nonhomogeneous, secondorder ordinary differential Eq. (4.19): d2 yðt Þ dyðt Þ þ ωn 2 yðt Þ = Kxðt Þ þ 2ζωn 2 dt dt

ð4:19Þ

where ζ and ωn are termed as damping ratio and undamped natural frequency, x(t), y(t) are input and output variables as functions of time t, and K is termed static sensitivity.

4.3.1

Time Domain Analysis

The solution of second-order differential Eq. (4.19) depends on the type of input x(t). As an example, the response of a step input is considered in this section. A step input is given in Eq. (4.20): xðt Þ = Auðt Þ, uðt Þ = 1, t ≥ 0, uðt Þ = 0, otherwise

ð4:20Þ

where A is a constant. The solution of Eq. (4.19) for the step input of Eq. (4.20) consists of two parts, complementary function, yCF(t), and particular integral yPI(t),as given in Eq. (4.21): yðt Þ = yCF ðt Þ þ yPI ðt Þ

ð4:21Þ

4.3

Second-Order Systems

73

The complementary function, yCF(t), is the solution of homogeneous first-order differential Eq. (4.19) with x(t) = 0. It also depicts the transient response of the system. The particular integral, yPI(t), depends on input x(t) and depicts the steadystate response of the system. The complementary function, yCF(t), shown in Eq. (4.22) is substituted in Eq. (4.19) to obtain Eq. (4.23): yCF ðt Þ = Cest 2  s þ 2ζωn s þ ωn 2 Cest = 0

ð4:22Þ ð4:23Þ

The characteristic Eq. (4.24) for the system is obtained from Eq. (4.23) as s2 þ 2ζωn s þ ωn 2 = 0

ð4:24Þ

The solution (roots) of quadratic Eq. (4.24) is obtained as Eq. (4.25): qffiffiffiffiffiffiffiffiffiffiffiffi s1,2 = - ζωn  ωn ζ2 - 1

ð4:25Þ

There are three cases depending on the value of damping ratio ζ, namely, ζ < 1, underdamped; ζ = 1, critically damped; and ζ > 1, overdamped. Case I: ζ < 1, underdamped system. The roots are complex conjugates, as shown in Eq. (4.26), where j = qffiffiffiffiffiffiffiffiffiffiffiffi s1,2 = - ζωn  jωn 1 - ζ2

pffiffiffiffiffiffiffiffi - 1: ð4:26Þ

The complementary function, yCF(t),can be represented as Eq. (4.27), which can further be expressed in the form of Eq. (4.28): yCF ðt Þ = C 1 e



- ζωn þjωn

pffiffiffiffiffiffiffiffi2ffi 1-ζ

t

þ C2 e



- ζωn - jωn

pffiffiffiffiffiffiffiffi2ffi

yCF ðt Þ = e - ζωn t ðC 3 cosðωd tÞ þ C4 sinðωd tÞÞ

1-ζ

t

ð4:27Þ ð4:28Þ

where ωd is termed damped natural frequency, which is given in Eq. (4.28), and C3, C4 are constants of integration to be determined using initial conditions: ω d = ωn

qffiffiffiffiffiffiffiffiffiffiffiffi 1 - ζ2

ð4:29Þ

Case II: ζ = 1, critically damped system. The roots are repeated real, as shown in Eq. (4.30): s1,2 = - ζωn

ð4:30Þ

74

4 Dynamic System Characteristics

The complementary function, yCF(t),can be represented as Eq. (4.31): yCF ðt Þ = e - ζωn t ðC 1 þ C2 tÞ

ð4:31Þ

where C1 and C2 are constants of integration to be determined using initial conditions. Case III: ζ > 1, overdamped system. The roots are distinct real and the complementary function, yCF(t),can be represented as Eq. (4.32): yCF ðt Þ = C1 e



- ζþ

pffiffiffiffiffiffiffiffi ffi 2

ζ - 1 ωn t

þ C2 e



-ζ-

pffiffiffiffiffiffiffiffi ffi 2

ζ - 1 ωn t

ð4:32Þ

where C1 and C2 are constants of integration to be determined using initial conditions. Free Response of a Second-Order System Transient response of a second-order system can be obtained depending on the damping ratio, ζ, applying the initial condition at t = 0, yðt Þ = Y 0 , dydtðtÞ = 0 for each case. Case I: ζ < 1, underdamped system. Applying initial conditions, at t = 0, yðt Þ = Y 0 , dydtðtÞ = 0, to Eq. (4.28), the constants of integration can be obtained as given in Eqs. (4.33) and (4.34): C3 = Y 0

ð4:33Þ

ζ C 4 = pffiffiffiffiffiffiffiffiffiffiffiffi :Y 0 1 - ζ2

ð4:34Þ

The transient response can be expressed in the form of Eq. (4.35): e - ζωn t yðt Þ = Y 0 pffiffiffiffiffiffiffiffiffiffiffiffi cosðωd t - φÞÞ 1 - ζ2

ð4:35Þ

where the phase angle is obtained as shown in Eq. (4.36): φ = tan

-1

ζ pffiffiffiffiffiffiffiffiffiffiffiffi 1 - ζ2

! ð4:36Þ

4.3

Second-Order Systems

75

Case II: ζ = 1, critically damped system. Applying initial conditions, at t = 0, yðt Þ = Y 0 , dydtðtÞ = 0, to Eq. (4.31), the constants of integration can be obtained as given in Eqs. (4.37) and (4.38): C1 = Y 0

ð4:37Þ

C 2 = Y 0 ωn

ð4:38Þ

The transient response can be expressed in the form of Eq. (4.39): yðt Þ = Y 0 e - ωn t ð1 þ ωn tÞÞ

ð4:39Þ

Case III: ζ > 1, overdamped system. Applying initial conditions, at t = 0, yðt Þ = Y 0 , dydtðtÞ = 0, to Eq. (4.32), the constants of integration can be obtained as given in Eqs. (4.40) and (4.41): pffiffiffiffiffiffiffiffiffiffiffiffi ζ þ ζ2 - 1 pffiffiffiffiffiffiffiffiffiffiffiffi Y 0 2 ζ2 - 1 pffiffiffiffiffiffiffiffiffiffiffiffi - ζ þ ζ2 - 1 pffiffiffiffiffiffiffiffiffiffiffiffi Y 0 C2 = 2 ζ2 - 1 C1 =

ð4:40Þ ð4:41Þ

The transient response can be expressed in the form of Eq. (4.42):  qffiffiffiffiffiffiffiffiffiffiffiffi  pffiffiffiffiffiffiffiffiffi 2 1 ζ þ ζ2 - 1 e - ζ - ζ - 1 ω n t Y 0 pffiffiffiffiffiffiffiffiffiffiffiffi 2 1 yð t Þ =  2 ζ qffiffiffiffiffiffiffiffiffiffiffiffi  pffiffiffiffiffiffiffiffiffi 2 þ - ζ þ ζ2 - 1 e - ζþ ζ - 1 ωn t ÞÞ

ð4:42Þ

The transient response for a second-order system with normalized initial conditions (at t = 0, yðt Þ = 1, dydtðtÞ = 0Þ for different damping ratios is shown in Fig. 4.3. Step Response of a Second-Order System The particular integral, yPI  (t), can  be obtained for the particular input x(t). Here, an operator approach using D≜ dtd is presented. yPI ðt Þ = 

1  Kxðt Þ D2 þ 2ζωn D þ 1

ð4:43Þ

For step input of Eq. (4.20), the particular integral can be obtained using binomial expansion of the operator term, similar to Sect. 4.2.1.

76

4

Dynamic System Characteristics

Fig. 4.3 Free response of a second-order system for different damping ratios

yPI ðt Þ = 

1  KA D þ 2ζωn D þ 1 2

= KA

ð4:44Þ

The solution, y(t), is expressed in terms of its components, given for three cases, depending the value of damping ratio ζ. Case I: ζ < 1, underdamped system. The complete solution, y(t), for underdamped case is given in Eq. (4.45): yðt Þ = e - ζωn t ðC 3 cosðωd tÞ þ C4 sinðωd tÞÞ þ KA

ð4:45Þ

Applying initial conditions, at t = 0, yðt Þ = 0, dydtðtÞ = 0, to Eq. (4.45), the constants of integration can be obtained as given in Eqs. (4.46) and (4.47): C 3 = - KA

ð4:46Þ

ζ C4 = - KA pffiffiffiffiffiffiffiffiffiffiffiffi 1 - ζ2

ð4:47Þ

4.3

Second-Order Systems

77

The step response of an underdamped system can be expressed in the form of Eq. (4.48): e - ζωn t yðt Þ = KA 1- pffiffiffiffiffiffiffiffiffiffiffiffi cosðωd t - φÞ 1 - ζ2

! ð4:48Þ

where the phase angle is obtained as shown in Eq. (4.49): φ = tan

-1

ζ pffiffiffiffiffiffiffiffiffiffiffiffi 1 - ζ2

! ðð4:49Þ

Case II: ζ = 1, critically damped system. The complete solution, y(t), for critically damped case is given in Eq. (4.50): yðt Þ = e - ζωn t ðC 1 þ C 2 tÞ þ KA

ð4:50Þ

Applying initial conditions, at t = 0, yðt Þ = 0, dydtðtÞ = 0, to Eq. (4.50), the constants of integration can be obtained as given in Eqs. (4.51) and (4.52): C 1 = - KA

ð4:51Þ

C2 = - KAωn

ð4:52Þ

The step response of a critically damped system can be expressed in the form of Eq. (4.53): yðt Þ = KAð1- e - ωn t ð1 þ ωn tÞÞ

ð4:53Þ

Case III: ζ > 1, overdamped system. The complete solution, y(t), for underdamped case is given in Eq. (4.54): yð t Þ = C 1 e



- ζþ

pffiffiffiffiffiffiffiffi ffi 2

ζ - 1 ωn t

þ C2 e



-ζ-

pffiffiffiffiffiffiffiffi ffi 2

ζ - 1 ωn t

þ KA

ð4:54Þ

Applying initial conditions, at t = 0, yðt Þ = 0, dydtðtÞ = 0, to Eq. (4.54), the constants of integration can be obtained as given in Eqs. (4.55) and (4.56): pffiffiffiffiffiffiffiffiffiffiffiffi ζ þ ζ2 - 1 C 1 = - KA pffiffiffiffiffiffiffiffiffiffiffiffi 2 ζ2 - 1

ð4:55Þ

78

4

Dynamic System Characteristics

Fig. 4.4 Step response of a second-order system for different damping ratios

pffiffiffiffiffiffiffiffiffiffiffiffi - ζ þ ζ2 - 1 pffiffiffiffiffiffiffiffiffiffiffiffi C 2 = - KA 2 ζ2 - 1

ð4:56Þ

The step response of an overdamped system can be expressed in the form of Eq. (4.57):  qffiffiffiffiffiffiffiffiffiffiffiffi  pffiffiffiffiffiffiffiffiffi 2 1 ζ þ ζ2 - 1 e - ζ - ζ - 1 ω n t KA 1 - pffiffiffiffiffiffiffiffiffiffiffiffi 2 2 ζ -1 yð t Þ =  qffiffiffiffiffiffiffiffiffiffiffiffi  pffiffiffiffiffiffiffiffiffi 2 þ - ζ þ ζ2 - 1 e - ζþ ζ - 1 ωn t ÞÞ

ð4:57Þ

The time responses of a second-order system for the three cases, underdamped, critically damped, and overdamped, are illustrated in Fig. 4.4. The underdamped system has an overshoot (α = (ymax-ysteady-state)/ysteady-state) = 52.4% at peak time Tp = 3.31 s. The settling time is defined as time when the system response is settled within a certain percentage of the steady-state value. The settling time for the underdamped system for 5% is shown in Fig. 4.4 as Ts = 13.75 s. Only underdamped system response is oscillatory, and all responses settle to the same normalized value (ysteady - state = 1.0).

4.3

Second-Order Systems

4.3.2

79

Frequency Domain Analysis

The response of a second-order system represented in Eq. (4.19) for a sinusoidal input x(t) = X0 sin (ωt) under steady-state condition can be obtained applying Laplace transform to both sides of Eq. (4.19), assuming zero initial conditions. The Eq. (4.19) is represented, after applying Laplace transform, as Eq. (4.58), with X(s) and Y(s) as the Laplace transforms of input and output functions, respectively. 

 s2 þ 2ζωn s þ ωn 2 Y ðsÞ = KX ðsÞ

The transfer function (GðsÞ = Eq. (4.59): GðsÞ =

Y ðsÞ X ðsÞ

ð4:58Þ

) of the second-order system is obtained as

Y ðs Þ K = X ðsÞ s2 þ 2ζωn s þ ωn 2

ð4:59Þ

The steady-state system response y(t) = Y0 sin (ωt + φ) due to harmonic input x(t) = X0 sin (ωt) can be obtained substituting s = jω in Eq. (4.59): GðjωÞ = =

K ðjωÞ þ 2ζωn ðjωÞ þ ωn 2 2

 1ωn 2

K ω2 ωn 2



þ j2ζ ωωn



ð4:60Þ

2 n Y0 The normalized amplitude ratio (AR = ωKX ) can be obtained from the 0 magnitude  ωn 2 Y ðsÞ mag =  KX ðsÞ 1

ω2 ωn 2

1 

þ j2ζ ωω

1 ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi AR = r 2  2 2 1 - ωωn 2 þ 2ζ ωωn

ð4:61Þ

n

ð4:62Þ

The phase angle between the output and the input can be obtained as the argument (angle) of the complex transfer function φ = argðGðjωÞÞ = ∠GðjωÞ

ð4:63Þ

80

4

Dynamic System Characteristics

Fig. 4.5 Amplitude ratio versus frequency ratio of a second-order system

From Eq. (4.60), the phase angle can be expressed in Eq. (4.64); the negative sign indicates that output lags behind the input. φ = - tan - 1

2ζ ωωn 1-

!

ω2 ωn 2

ð4:64Þ

The plots of normalized amplitude ratio versus frequency ratio of a second-order system for different values of damping ratio are presented in Fig. 4.5. The plots of phase angle versus frequency ratio of a second-order system for different values of damping ratio  arepresented in Fig. 4.6. All plots pass through ϕ = -90° at frequency ratio ωωn = 1 :

4.3.3

Experimental Determination of System Parameters

The system parameters of a second-order system are static sensitivity (K), undamped natural frequency (ωn), and damping ratio (ζ). It is necessary to determine these parameters experimentally for a second-order system. In this section, the system is assumed to be an underdamped system, as most of the second-order mechatronic

4.3

Second-Order Systems

81

Fig. 4.6 Phase angle versus frequency ratio of a second-order system

systems are underdamped. The static sensitivity can be obtained from Eq. (4.48) as the ratio of steady-state output (yss = y(t), t → 1, yss = KA) and step input (A) as K = yAss : The damping ratio can be obtained from the free response Eq. (4.35) and Fig. 4.3 for the underdamped system. From Eq. (4.35) and Fig. 4.3, it should be recognized that at the peaks, ζωn t ζωn t e -ffiffiffiffiffiffiffiffi e -ffiffiffiffiffiffiffiffi p ffi2 cosðωd t - φÞ = p ffi2 cosðnπ - φÞ = e - ζωn t , n = 0, 2, 4, . . . and ωd t = nπ. 1-ζ

1-ζ

If two successive peaks of free response graph (Fig. 4.3) are denoted as An and An + 1, then these peaks are related as follows: ζωn e - ζωn t   =e

An = Anþ1 e

- ζωn

  2π ωd

=e

 pffiffiffiffiffiffiffiffiffi 2 ζ=

1-ζ



ð4:65Þ

tþω2π d

Taking the logarithm of both sides, Eq. (4.65) can be written as  qffiffiffiffiffiffiffiffiffiffiffiffi   An = = ζ= 1 - ζ2 2π ln Anþ1

ð4:66Þ

82

4 Dynamic System Characteristics

Equation (4.66) can be reorganized to obtain damping ratio as follows:  ln

δ=

An Anþ1

 ð4:67Þ

2π δ ζ = pffiffiffiffiffiffiffiffiffiffiffiffiffi 1 þ δ2

ð4:68Þ

The undamped natural frequency can be obtained from the time between two successive peaks as the damped response time period (Td): Td =

2π 2π = pffiffiffiffiffiffiffiffiffiffiffiffi ωd ωn 1 - ζ 2

ð4:69Þ

2π pffiffiffiffiffiffiffiffiffiffiffiffi T d 1 - ζ2

ð4:70Þ

ωn =

4.4 4.4.1

Fourier Series Representation of Periodic Signals Fourier Series

Any periodic signal f(t) of time period T can be represented as a sum of infinite series of sine and cosine waveforms as in Eq. (4.71): f ðt Þ = C 0 þ

X/

A cos n=1 n

  X/   2nπt 2nπt B sin þ n n=1 T T

ð4:71Þ

The coefficients An and Bn of cosine and sine terms are obtained as shown in Eqs. (4.72) and (4.73): 2 An = T

Z

2 Bn = T

T 0

Z

T

  2nπt f ðt Þ cos dt T

ð4:72Þ

  2nπt dt T

ð4:73Þ

f ðt Þ sin

0

The DC component C0 represents the average value of the signal over the period, and it can be obtained as in Eq. (4.74): C0 =

1 T

Z

T 0

f ðt Þdt =

A0 2

ð4:74Þ

4.4

Fourier Series Representation of Periodic Signals

83

  The fundamental frequency ω0 = 2π and its integer multiples appear in the T component signals. The expression (4.71) can be expressed in terms of cosine signals with corresponding amplitudes Cn and phase angles ϕn as in Eq. (4.75): f ðt Þ = C 0 þ

  2nπt C cos þ ϕ n n=1 n T

X/

ð4:75Þ

where the amplitude Cn and phase ϕn of each component are expressed as in Eqs. (4.76) and (4.77): qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi C n = An 2 þ Bn 2   B ϕn = - tan - 1 n An

4.4.2

ð4:76Þ ð4:77Þ

Fourier Transform

Fourier transform F(ω) of any aperiodic signal f(t) can be obtained as an infinite integral of the signal as in Eq. (6.69): Z F ð ωÞ =

/ -/

f ðt Þe - iωt dt

ð4:78Þ

Inverse Fourier transform is obtained, also as an infinite integral as presented in Eq. (4.79): Z f ðt Þ =

4.4.3

/ -/

F ðωÞeiωt dω

ð4:79Þ

Examples of Fourier Transform of Signals Using Matlab

Example 4.1 Fourier Transform of a Square Wave A square wave of frequency f = 40 Hz and its frequency spectrum obtained using Matlab command fft() are shown in Figs. 4.7 and 4.8, respectively. In Fig. 4.8, peaks at odd multiples of 40 Hz with decreasing amplitudes confirm the constituent harmonics of a square wave.

84

4

Dynamic System Characteristics

Fig. 4.7 Square waveform of frequency 40 Hz

Fig. 4.8 Frequency spectrum of a square wave of frequency 40 Hz

4.5

Computer-Aided Analysis and Simulation of Dynamic System Responses

85

Fig. 4.9 Example of random noise-corrupted signal

Example 4.2 Fourier Transform of a Noisy Signal A random noise-corrupted signal consisting of two component sinusoidal signals, with amplitudes of 0.8 and 1.2 at frequencies f1 = 40 Hz and f2 = 100 Hz, respectively, is shown in Fig. 4.9. The frequency components are masked by the added random noise. The amplitude spectrum of the noise-corrupted signal is shown in Fig. 4.10. The one-sided amplitude spectrum was obtained using Matlab command fft(). The main frequency components of the noisy signal are represented by peaks at f1 = 40 Hz and f2 = 100 Hz in the frequency spectrum. The amplitudes are different from the original values, though close, due to the addition of random noise. The smaller amplitude band across the entire frequency range represents the random noise.

4.5

Computer-Aided Analysis and Simulation of Dynamic System Responses

Responses of electrical systems in time and frequency domains can be analyzed and simulated using software platforms like Multisim, LTspice, and Matlab/Simulink. In addition, the virtual simulation environment of Tinkercad is very useful for

86

4

Dynamic System Characteristics

Fig. 4.10 Amplitude spectrum of a noisy signal

Fig. 4.11 Example of an RC circuit

simulating the responses of such circuits. Here, an example of an RC circuit of Fig. 4.11 representing a first-order system is considered as an illustration of the procedure. For the example problem of Fig. 4.11, the values of R and C are taken as follows: R = 10 kΩ and C = 0.10 μF. Amplitude of input voltage Vin = 1 V. Time constant of RC circuit τ = R C = (10 kΩ)(0.10 μF) = 1 ms. Corner frequency ωc ωc = 1τ = 1000 rad s , f c = 2π = 159:09 Hz.

4.5

Computer-Aided Analysis and Simulation of Dynamic System Responses

87

Fig. 4.12 Time response of an RC circuit for a step input

4.5.1

Analysis Using Matlab

Matlab code for simulation of RC circuit response in time and frequency domains is presented along with comments explaining the steps. Time and frequency response graphs are presented in Figs. 4.12 and 4.13, respectively. % Simulation of an RC circuit response clear all; close all % Circuit parameters Vin = 1; R = 10e3; C = 1e-7; n = 100; % number of points tau = R*C % time constant wc =1/tau % corner frequency in rad/s fc =wc/(2*pi) % corner frequency in Hz % Time response t = linspace(0,5*tau, n); % n points t=0-5*tau Vout = Vin*(1-exp(-t/tau)); % Vout expression figure; plot(t,Vout) title('Time response Vout vs Time') xlabel('Time (t, sec)'); ylabel('Output voltage (Vout, V) '); grid on % Frequency response w = linspace(0,4*wc,n); f = w/(2*pi); for i=1:n AR(i) = 1/sqrt(1+tau^2*w(i)^2); end figure; semilogx(f,AR) title('Frequency response AR vs Frequency') xlabel('Frequency (f, Hz)'); ylabel('Amplitude Ratio (AR)');grid on

88

4

Dynamic System Characteristics

Fig. 4.13 Frequency response of an RC circuit for a sinusoidal input

4.5.2

Simulation Using Tinkercad

The RC circuit on Tinkercad with a power supply and two oscilloscopes to observe the input and the output waveforms Vin(t) and Vout(t) are shown in Fig. 4.14. The response Vout(t) for the input voltage Vin(t) of a square wave of frequency f = 50 Hz, and amplitude of 1 V is shown. The response for other waveforms, sinusoidal and triangular, can similarly be simulated and observed over a frequency range.

4.6

Experimental Validation

Objectives To build a simple RC low-pass circuit on the prototyping board, measure the characteristics of the filter using time and frequency domain responses, and compare these with expected values. Brief Steps I. Construction of the RC Circuit Select a resistor and a capacitor of nominal values R = 10 kΩ and C = 0.10 μF. Measure R and C using a multimeter. Note the color code of the resistor and threedigit code for the capacitor, and complete Table 4.1. Calculate the expected values of

4.6

Experimental Validation

Table 4.1 Codes for R and C

89

R Color code C code

Table 4.2 Nominal and measured values of R and C, characteristic values

Based on Nominal Values of R and C

Based on Measured Values of R and C

% Difference

R (kΩ) C (μF) τ =RC (ms) tR=2.303 τ (ms) wc=(1/ τ)× 10 (rad/s) fc = wc/(2π) (Hz)

Fig. 4.14 RC circuit simulation on Tinkercad

the characteristic parameters, time constant, rise time, corner frequency based on the nominal values and the measured values of R and C. Complete Table 4.2. Build the circuit of Fig. 4.14.

90

4

Dynamic System Characteristics

II. Step Response Characteristics 1. Select a square wave of 1 V amplitude and frequency of 100 Hz. Switch on the function generator and the oscilloscope. Observe the waveforms on the oscilloscope (for physical lab, both waveforms can be observed on a dualchannel oscilloscope). Record time, t and Vout(t) at different points on step response waveform from initial to close (about 90% of) the steady-state value of Vout(t).   2. Complete Table 4.3 and plot - ln 1-

V out ðt Þ V in,pp

versus t: Note down the slope

of the trend line. Inverse of the slope is an estimate of time constant (τ). III. Frequency Response Characteristics (a) Change the output on the function generator to a sine wave. (b) Record the following values for the RC circuit response (Vout) with a sinusoidal input signal (Vin) for different frequencies (f), fc/10 ≤ f ≤ 10fc. Complete Table 4.4. (c) Plot the curve of amplitude ratio (|Vout/Vin|) versus frequency (f, Hz) using semilog, AR vs log10(f). Estimate the corner frequency (ωc = 2π fc, rad/s) from the graph. Complete Table 4.5.

Table 4.3 Time response characteristics

Time t (sec)

0

Vout(t)

0

− ln 1 − 0

( ) ,

4.6

Experimental Validation

91

Table 4.4 Frequency response of RC circuit Estimated Frequency (Hz)

Actual frequency

Input Amplitude Vin (V)

f (Hz)

Output Amplitude

Log10 (f)

Amplitude Ratio AR=Vout/Vin

Vout (V)

fc/10

fc-10 fc fc+10

10 fc

Table 4.5 Characteristic parameters: Comparison of theoretical and experimental values Experimental

Characteristic parameters τ (ms) tR = 2.303 τ (ms) ωc = (1/ τ) ×103 (rad/s) fc = ωc/(2π) (Hz) a

Theoretical valuesa

Time response % Valuesb Errorc

Frequency response Valuesd

Comments % Errorc

Based on measured values of R and C (column 3 of Table 4.2) Based on τ and tR obtained from time response (Part II). Use this τ to compute ωc and fc and complete the column c These are with reference to theoretical values (column 3 of Table 4.2) d Based on frequency response (Part III). Use fc (with AR = B/A about 0.707) to get ωc = fc*(2π), τ =1/ωc, and tR = 2.303 τ and complete the column b

92

4

Dynamic System Characteristics

IV. Deliverables 1. Values of circuit elements (R, C) and estimation of characteristic parameters 2. Step response characteristics 3. Frequency response characteristics Lab Report 1. Present the screenshot of the RC circuit implementation and virtual simulation on Tinkercad. 2. Present all the results in the full lab report. 3. Develop a Matlab script to obtain theoretical step response curve for the value of time constant (τ = RC, based on actual measured values of R and C). Compare it with the one obtained experimentally. 4. Develop a Matlab script to obtain theoretical frequency response curve for the value of time constant (τ = RC, based on actual measured values of R and C). Use semi-log plot. Compare it with the one obtained experimentally. 5. Submit Matlab script of steps 3 and 4. 6. Discuss the results.

Exercises 1. It is necessary to select R and C elements for a low-pass filter RC circuit such that its rise time (tR) for a step input is not more than 46.1 μs and the amplitude ratio (AR) is at least 0.707 at 7.5 kHz. Obtain time constant and the values of R and C elements to satisfy the required criteria. Select R and C from the available ranges R: 5 k Ω, 15 k Ω, 20 k Ω, 30 k Ω, and C: 0.002 μF, 0.003 μF, 0.004 μF, 0.05 μF. 2. An RC circuit with R = 50 kΩ and C = 25 nF is being tested with a square wave input of peak-to-peak Vpp = 2.5 V. Find the time constant (τ) of the circuit and the time (t60) the output voltage across the capacitor takes to reach 60% of its final value. 3. A low-pass RC filter with a time constant of 4.0 ms is used to filter a noisy signal. Obtain the corner frequency (fc) in Hz and the amplitude ratio (AR) at an input signal frequency (f) of 60 Hz. 4. A low-pass RC filter is required to have a bandwidth of at least 10 kHz and a rise time less than 40 μs. Find the time constant and select values of R and C that will closely match the desired specifications. 5. In a measurement setup using a strain gage on a cantilever beam, a Wheatstone bridge, and a difference amplifier, all four arms of the Wheatstone bridge were initially at 120 Ω, including the strain gage as the active arm. The voltage output from the amplifier, recorded via LabVIEW, represented a sine wave with exponentially decreasing amplitude that finally reduced to zero. The values of the first two consecutive peaks were 12 mV and 8 mV, separated by 35 ms. Estimate the damping ratio (ζ) and the undamped natural frequency ( fn, Hz).

Bibliography

93

6. In an experiment, the voltage output from the amplifier, recorded via LabVIEW, represented a sine wave with exponentially decreasing amplitude that finally reduced to zero. The first two consecutive peaks were 10 mV and 7 mv, 28 ms apart. Estimate the damping ratio (ζ) and damped (ωd) and undamped (ωn) natural frequencies of the cantilever. 7. In a measurement setup using a strain gage on a cantilever beam, a Wheatstone bridge, and a difference amplifier, all four arms of the Wheatstone bridge were initially at 120 Ω, including the strain gage as the active arm. The voltage output from the amplifier, recorded via LabVIEW, represented a sine wave with exponentially decreasing amplitude that finally reduced to zero. The voltage waveform, from the cantilever without any tip mass, when analyzed using frequency spectrum in LabVIEW, resulted in a peak at 32 Hz. The voltage waveform, from the cantilever with tip mass (mTip), when analyzed using frequency spectrum in LabVIEW, resulted in a peak at 16 Hz. The cantilever beam mass was found to be 200 g. Estimate the tip mass mTip. Note the effective mass of the beam is mBeam, effective = 0.2357 mBeam. The frequencies without and with tip mass can be related rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi k =ðmBeam,effectiveÞ mBeam,effective þmTip f Beam as f = = k= m mBeam,effective . BeamWithTipMass ð Beam,effective þmTip Þ

Bibliography Alciatore DG (2019) Introduction to mechatronics and measurement systems, 5th edn. McGraw Hill, New York Analog Devices (2022) LTspice Simulator, https://www.analog.com Doeblin EO (1990) Measurement systems applications and design, 4th edn. McGraw-Hill, New York Hambley A (2017) Electrical engineering: principles and applications, 7th edn. Pearson, Upper Saddle RiverJ Mathworks (2022) Matlab and Simulink, https://www.mathworks.com National Instruments (2022) Multisim, https://www.ni.com/en-us/support/downloads/softwareproducts/download.multisim.html#452133 Pico Technology (2022) PicoScope 2000 Series, https://www.picotech.com/oscilloscope/2000/ picoscope-2000-overview Test Equity (2022) Instek GDS-1202B Digital Storage Oscilloscope, https://www.testequity.com Test Equipment Depot (2022) Instek AFG-2105 Arbitrary Waveform Function Generator, https:// www.testequipmentdepot.com/instek/signalgenerators/afg2105.html TEquipment (2022a) Instek GDM-8341 50,000 Counts Dual Measurement Multimeter with USB Device, https://www.tequipment.net/InstekGDM-8341.html TEquipment (2022b) Instek GPE-3323 3 Channels, 217W Linear DC Power Supply, https://www. tequipment.net/Instek/GPE-3323/DC-Power-Supplies Tinkercad (2022) Learn Circuits, https://www.tinkercad.com/learn/circuits

Chapter 5

Analog Signal Processing and Operational Amplifiers

5.1

Introduction

In this chapter, analysis and applications of operational amplifiers in analog signal processing using different configurations that include inverting amplifier, noninverting amplifier, adder, buffer, comparator, integrator, and differentiator are presented. Examples including computer-aided analysis and simulation are presented. Experimentation using virtual simulation platform Tinkercad is presented along with actual laboratory implementation. End-of-chapter exercise problems are provided to help enhance understanding of the materials covered and consolidate problem-solving skills.

5.2

Operational Amplifiers

Operational amplifiers or op-amps are used for analog signal processing in mechatronic systems. An op-amp is a low-cost, versatile integrated circuit comprised of many internal transistors, resistors, and capacitors packaged into a chip of silicon. The op-amp can be combined with external electrical circuit elements, resistors, capacitors, and inductors for creating various analog signal processing circuits. Typical applications of op-amps include the following: 1. Inverting amplifiers—inverting the polarity of the input signal with amplification. 2. Noninverting amplifiers—maintaining the polarity of the input signal with amplification. 3. Summing amplifiers—adding up signals with or without amplification. 4. Integrators—the input signal is integrated over time to produce the output signal.

© The Author(s), under exclusive license to Springer Nature Switzerland AG 2023 B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_5

95

96

5

Analog Signal Processing and Operational Amplifiers

5. Differentiators—the input signal is differentiated with respect to time to produce the output signal. 6. Buffers/ voltage followers/isolators—the output is the same as the input signal. 7. Comparators—the input signal is compared with a fixed reference and the output flips between two levels based on the input signal level compared to the reference signal. 8. A/D and D/A converters—analog-to-digital (A/D) and digital-to-analog (D/A) converters using op-amps. 9. Active filters—filters of different types (e.g., low pass, high pass, band pass, etc.) using op-amps. 10. Instrument amplifiers—used as precision amplifiers. 11. Sample and hold amplifiers—used in A/D converters.

5.3

Ideal Operational Amplifier Model

An operational amplifier is generally packaged in eight-pin dual-in-line package (DIP) integrated circuit (IC) chip. A general purpose op-amp commercially available is designated as 741. The top view of 741 with pin-out diagram is shown in Fig. 5.1. The notch and dot mark the starting pin (pin 1), and the pins are numbered serially 1–4 and then 5–8 as shown. Pin 2 is the inverting input, pin 3 is the noninverting input, pin 6 is the op-amp output, pin 4 is for -15 V, and pin 7 is for +15 V supply. Pins 1, 5, and 8 are not normally connected. A schematic of an op-amp 741 with relevant pins marked is shown in Fig. 5.2: Fig. 5.1 Pin-out diagram of 741 op-amp

Fig. 5.2 Schematic diagram of a 741 op-amp

5.4

Inverting Amplifier

97

An op-amp is characterized by high-input impedance at both inputs, low-output impedance, and a very high open-loop gain. These characteristics lead to ideal op-amp model assumptions. 1. Infinite input impedance at both inputs: the currents input to the op-amp are close to 0. I þ ≈ 0, I - ≈ 0,

ð5:1Þ

2. Infinite gain: the finite output voltage of the op-amp is the difference of the input voltages at the input pins (V+, V-) multiplied by the infinite gain, making the difference between the input voltages negligible, i.e., the voltages at the input pins are close to each other. Vþ ≈ V -

ð5:2Þ

3. Zero output impedance. The op-amp output voltage is independent of the output current.

5.4

Inverting Amplifier

An op-amp can be used to configure as an inverting amplifier by connecting the inverting input (pin 2) to an input signal through a resistor Ri, connecting the noninverting input (pin 3) to the ground, and adding a resistor Rf in the feedback path between the op-amp output (pin 6) and the inverting input (pin 2). The configuration is shown in Fig. 5.3. Pins 4 and 7 are connected to -15 V and +15 V external power supply, but generally not shown. The objective is to obtain the op-amp output voltage Vout in terms of input voltage Vin and resistances Ri and Rf

Fig. 5.3 Schematic diagram of an inverting amplifier

98

5

Analog Signal Processing and Operational Amplifiers

  V out = f V in , Ri , Rf

ð5:3Þ

Since the noninverting input pin (pin 3) is grounded, the noninverting voltage (V+) is zero. Using the ideal op-amp assumption that input voltages to the op-amp are almost equal, the inverting input voltage (V-) is also close to zero, i.e., Vþ = 0

ð5:4Þ

V - ≈ Vþ ≈ 0

ð5:5Þ

The voltage at C (VC) is the same as V-, making C a virtual ground: VC ≈ 0

ð5:6Þ

The current (Ii) through the input resistor can be expressed in terms of the voltage difference across the resistor and the resistance Ri, using Ohm’s law: Ii =

ðV in - V C Þ V in ≈ Ri Ri

ð5:7Þ

Similarly, the current (If) through the resistor in the feedback path can be expressed in terms of the voltage difference across the resistor and the resistance Rf, using Ohm’s law: If =

ðV out - V C Þ V out ≈ Rf Rf

ð5:8Þ

Applying Kirchhoff’s current law (KCL) at node C and using the ideal op-amp model assumption of negligible current to the op-amp at the input pins, the currents Ii, If can be related as Ii þ If ≈ 0

ð5:9Þ

Using Ii, If from Eqs. (5.7) and (5.8) in Eq. (5.9), the relationship between the input voltage Vin and the output voltage Vout can be obtained: V in V out þ =0 Ri Rf   Rf V in V out = Ri

ð5:10Þ ð5:11Þ

In Eq.(5.11), the output voltage (Vout) is the amplified input voltage (Vin) with a  Rf gain of Ri and reversing the polarity of the input voltage. The negative sign justifies the “inverting” part of the name of the amplifier for this op-amp circuit.

5.5

Noninverting Amplifier

99

In general, the Eq. (5.11) is applicable if the input resistor (Ri) and the feedback resistor (Rf) are replaced with impedances (Zi) and (Zf), respectively: V out = -

  Zf V in Zi

ð5:12Þ

Example 5.1 For the inverting amplifier circuit of Fig. 5.3, find the output voltage Vout if Ri = 2.4 kΩ, Rf = 5 kΩ, and Vin = 3 V. Solution For the given parameters, the output voltage Vout can be obtained using Eq. (5.11) as   Rf 5 kΩ ð3 VÞ = - 6:25 V: V in = V out = Ri 2:4 kΩ

5.5

Noninverting Amplifier

An op-amp can be used to configure as a noninverting amplifier by connecting the inverting input (pin 2) to the ground through a resistor Ri, connecting the noninverting input (pin 3) to the input signal, and adding a resistor Rf in the feedback path between the op-amp output (pin 6) and the inverting input (pin 2). The configuration is shown in Fig. 5.4 The pins 4 and 7 are connected to -15 V and +15 V external power supply, but generally not shown. The objective is to obtain the op-amp output voltage Vout in terms of input voltage Vin and resistances Ri and Rf:   V out = f V in , Ri , Rf

Fig. 5.4 Schematic diagram of a noninverting amplifier

ð5:13Þ

100

5

Analog Signal Processing and Operational Amplifiers

Since the noninverting input pin (pin 3) is connected directly to the input voltage (Vin), the noninverting voltage (V+) is the same as Vin. Using the ideal op-amp assumption that input voltages to the op-amp are almost equal, the inverting input voltage (V-) is also close to Vin, i.e., V þ = V in

ð5:14Þ

V - ≈ V þ ≈ V in

ð5:15Þ

The voltage at C (VC) is the same as V-: V C ≈ V in

ð5:16Þ

The current (Ii) through the input resistor can be expressed in terms of the voltage difference across the resistor and the resistance Ri, using Ohm’s law: Ii =

ð0 - V C Þ V ≈ - in Ri Ri

ð5:17Þ

Similarly, the current (If) through the resistor in the feedback path can be expressed in terms of the voltage difference across the resistor and the resistance Rf, using Ohm’s law: If =

ðV out - V C Þ ðV out - V in Þ ≈ Rf Rf

ð5:18Þ

Applying Kirchhoff’s current law (KCL) at node C and using the ideal op-amp model assumption of negligible current to the op-amp at the input pins, the currents Ii, If can be related as Ii þ If ≈ 0

ð5:19Þ

Using Ii, If from Eqs. (5.17) and (5.18) in Eq. (5.19), the relationship between the input voltage Vin and the output voltage Vout can be obtained: -

V in ðV out - V in Þ þ =0 Rf Ri   Rf V in V out = 1 þ Ri

ð5:20Þ ð5:21Þ

In Eq.  (5.21), the output voltage (Vout) is the amplified input voltage (Vin) with a R gain of 1 þ Rfi and maintaining the polarity of the input voltage. The absence of negative justifies the “noninverting” part of the name of the amplifier for this op-amp circuit.

5.6

Summing Amplifier

101

Example 5.2 For the noninverting amplifier circuit of Fig. 5.4, find the output voltage Vout if Ri = 2.7 kΩ, Rf = 5.6 kΩ, and Vin = 2.5 V. Solution For the given parameters, the output voltage Vout can be obtained using Eq. (5.21) as 

   Rf 5:6 kΩ V in = 1 þ ð2:5 VÞ = 5:19 V: V out = 1 þ Ri 2:7 kΩ

5.6

Summing Amplifier

The inverting amplifier circuit of Fig. 5.3 can be modified by replacing the single input voltage (Vin) with a number (n) of parallel voltage sources (Vi) through individual resistors (Ri), as shown in Fig. 5.5. Applying Eq. (5.11) for each input voltage source, the expression of the output voltage Vout can be written as V out = - Rf

Xn V i  i=1 Ri

ð5:22Þ

Making Ri = Rf = R, Eq. (5.22) can be written as V out = -

Xn

Fig. 5.5 Schematic diagram of a summing amplifier

i=1

Vi

ð5:23Þ

102

5

Analog Signal Processing and Operational Amplifiers

Fig. 5.6 Schematic diagram of a summing amplifier without polarity reversal

Fig. 5.7 Schematic diagram of a difference amplifier

To make the output voltage as the sum of all input voltages (Vi) without polarity reversal, another op-amp with equal input and feedback resistances can be added after the first op-amp, as shown in Fig. 5.6, V out =

5.7

Xn i=1

Vi

ð5:24Þ

Difference Amplifier

The op-amp circuit of noninverting and inverting amplifier of Figs. 5.3 and 5.4 can be combined to get the configuration of Fig. 5.7, also known as difference amplifier. In Fig. 5.7, the inverting input pin (pin 2) is connected to one voltage source (V1) through the resistor (R); the output (pin 6) is connected to the inverting input through the feedback resistor (Rf). The noninverting input (pin 3) is connected to the second input voltage source (V2) through a resistor (R), and another resistor (Rf) is connected to the ground.

5.7

Difference Amplifier

103

The objective is to find an expression for the output voltage Vout in terms of input voltages V1, V2 and resistances R and Rf:   V out = f V 1 , V 2 R, Rf

ð5:25Þ

The noninverting input pin (pin 3) is connected to the input voltage (V2) through resistors R and Rf. Under the ideal op-amp assumption, the current input to the op-amp are negligible. The noninverting voltage (V+) can be obtained using the principle of voltage divider: Vþ = V2

Rf R þ Rf

ð5:26Þ

Using the ideal op-amp assumption that input voltages to the op-amp are almost equal, the inverting input voltage (V-) is close to V+, i.e., V - ≈ Vþ = V2

Rf R þ Rf

ð5:27Þ

The voltage at C (VC) is same as V-: VC ≈ V2

Rf R þ Rf

ð5:28Þ

The current (Ii) through the input resistor R can be expressed in terms of the voltage difference across the resistor and the resistance R, using Ohm’s law: Ii =

ðV 1 - V C Þ R

ð5:29Þ

Similarly, the current (If) through the resistor in the feedback path can be expressed in terms of the voltage difference across the resistor and the resistance Rf, using Ohm’s law: If =

ðV out - V C Þ Rf

ð5:30Þ

Applying Kirchhoff’s current law (KCL) at node C and using the ideal op-amp model assumption of negligible current to the op-amp at the input pins, the currents Ii, If can be related as Ii þ If ≈ 0

ð5:31Þ

104

5

Analog Signal Processing and Operational Amplifiers

Using Ii, If from Eqs. (5.29) and (5.30) in Eq. (5.31), the relationship between the input voltages V1, V2 and the output voltage Vout can be obtained:

V out Rf

ðV 1 - V C Þ ðV out - V C Þ þ =0 R Rf     V out 1 1 1 = VC þ V R Rf Rf R 1      Rf 1 1 1 = V2 þ V R þ Rf R Rf R 1

ð5:32Þ ð5:33Þ ð5:34Þ

After simplification, the output voltage Vout can be obtained: V out =

  Rf ðV 2- V 1 Þ R

ð5:35Þ

In Eq. (5.35), the output voltage  (Vout) is the difference of input voltages R (V2 - V1) amplified with a gain of Rf justifying the name of the amplifier as the “difference amplifier” for this op-amp circuit. Example 5.3 For the difference amplifier circuit of Fig. 5.7, find the output voltage Vout if R = 2.7 kΩ, Rf = 5.6 kΩ, V1 = 2.5 V, and V2 = 4.5 V. Solution For the given parameters, the output voltage Vout can be obtained using Eq. (5.35) as V out =

5.8

    Rf 5:6 kΩ ð4:5 V - 2:5 VÞ = 4:15 V ðV 2- V 1 Þ = 2:7 kΩ R

Integrator

An integrator is obtained by replacing the resistor (Rf) in the feedback path of an inverting amplifier with a capacitor (C), keeping everything else the same, as shown in Fig. 5.8: The objective is to obtain the op-amp output voltage Vout(t) in terms of input voltage Vin(t), and resistance R, and capacitance C: V out ðt Þ = f ðV in ðt Þ, R, CÞ

ð5:36Þ

5.8

Integrator

105

Fig. 5.8 Schematic diagram of an integrating amplifier

Since the noninverting input pin (pin 3) is grounded, the noninverting voltage (V+) is zero. Using the ideal op-amp assumption that input voltages to the op-amp are almost equal, the inverting input voltage (V-) is also close to zero, i.e., Vþ = 0

ð5:37Þ

V - ≈ Vþ ≈ 0

ð5:38Þ

The voltage at C (VC) is the same as V-, making C a virtual ground: VC ≈ 0

ð5:39Þ

The current (Ii) through the input resistor can be expressed in terms of the voltage difference across the resistor and the resistance R, using Ohm’s law: Ii =

ðV in ðt Þ - V C Þ V in ðt Þ ≈ R R

ð5:40Þ

Similarly, the current (If) through the capacitor in the feedback path can be expressed as the rate of change of charge in the capacitor: If =

dqðt Þ d d = C ðV out ðt Þ - V C Þ ≈ C V out ðt Þ dt dt dt

ð5:41Þ

Applying Kirchhoff’s current law (KCL) at node C and using the ideal op-amp model assumption of negligible current to the op-amp at the input pins, the currents Ii, If can be related as Ii þ If ≈ 0

ð5:42Þ

Using Ii, If from Eqs. (5.40) and (5.41) in Eq. (5.42), the relationship between the input voltage Vin(t) and the output voltage Vout(t) can be obtained: V in ðt Þ d þ C V out ðt Þ = 0 R dt

ð5:43Þ

106

5

Analog Signal Processing and Operational Amplifiers

Fig. 5.9 Schematic diagram of a modified integrator

V out ðt Þ = -

1 RC

Z

t

V in ðτÞdτ

ð5:44Þ

0

In Eq. (5.44), the output voltage (Vout(t)) is the scaled integral of the input voltage (Vin(t)) with the polarity of the input voltage reversed. An improved version of the integrator can be obtained by adding a shunt resistor Rs in the feedback path across the capacitor, as shown in Fig. 5.9. The shunt resistor should be such that Rs ≥ 10R. The circuit of modified integrator of Fig. 5.9 can be analyzed using the concept of impedance, and the ratio of amplitudes of output voltage Vout(t) = B sin (ωt - ϕ) and the input Vin(t) = A sin ωt in terms of source frequency ω and circuit parameters R, C, and Rs can be expressed as B 1 ðωÞ = rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi  2 A R þ ðRCωÞ2 Rs

ð5:45Þ

The cutoff or corner frequency for the modified integrator can be obtained, equating the two terms in the denominator as ωci =

1 Rs C

ð5:45aÞ

At corner frequency ω = ωci, the amplitude ratio BA = RRs p1ffiffi2 . For frequency ω ≪ ωci, the modified integrator acts as an inverting amplifier with a gain of Rs B A = - R , and for frequency ω > ωci, the modified integrator acts as an integrator. Example 5.4 For the modified integrator circuit of Fig. 5.9, find the corner frequency ωci and the output voltage amplitude B if R = 10 kΩ, C = 0.10 μF, Rs = 50 kΩ, A = 1 V, at fci= ωci/2π.

5.9

Differentiator

107

Fig. 5.10 Frequency response of a modified integrator

Solution For the given parameters, the cutoff frequency is ωci = using Eq. (5.45a) with f ci =

ωci 2π

1 Rs C

= 200 rad=s

= 31:82 Hz: The output voltage amplitude can be

obtained from Eq. (5.45) as 1 1V ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi B = r A = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 2 2 ffi   3 -6 10 kΩ 2 2 R þ 10 × 10 × 0:10 × 10 × 200 þ ðRCωÞ 50 kΩ Rs = 3:535 V: The frequency response graph for the modified integrator, obtained from Eq. (5.45) using Matlab, is shown in Fig. 5.10.

5.9

Differentiator

A differentiator is obtained by replacing the resistor (Ri) in the input path of an inverting amplifier with a capacitor (C), keeping everything else the same, as shown in Fig. 5.11.

108

5

Analog Signal Processing and Operational Amplifiers

Fig. 5.11 Schematic diagram of a differentiator

The objective is to obtain the op-amp output voltage Vout(t) in terms of input voltage Vin(t) and resistance R and capacitance C: V out ðt Þ = f ðV in ðt Þ, R, CÞ

ð5:46Þ

Since the noninverting input pin (pin 3) is grounded, the noninverting voltage (V+) is zero. Using the ideal op-amp assumption that input voltages to the op-amp are almost equal, the inverting input voltage (V-) is also close to zero, i.e., Vþ = 0

ð5:47Þ

V - ≈ Vþ ≈ 0

ð5:48Þ

The voltage at C (VC) is same as V-, making C a virtual ground: VC ≈ 0

ð5:49Þ

The current (Ii) through the capacitor in the input path can be expressed as the rate of change of charge in the capacitor: Ii =

dqðt Þ d d = C ðV in ðt Þ - V C Þ ≈ C V in ðt Þ dt dt dt

ð5:50Þ

The current (If) through the feedback resistor can be expressed in terms of the voltage difference across the resistor and the resistance R, using Ohm’s law: Ii =

ðV out ðt Þ - V C Þ V out ðt Þ ≈ R R

ð5:51Þ

Applying Kirchhoff’s current law (KCL) at node C and using the ideal op-amp model assumption of negligible current to the op-amp at the input pins, the currents Ii, If can be related as Ii þ If ≈ 0

ð5:52Þ

5.9

Differentiator

109

Fig. 5.12 Schematic diagram of a modified differentiator

Using Ii, If from Eqs. (5.50) and (5.51) in Eq. (5.52), the relationship between the input voltage Vin(t) and the output voltage Vout(t) can be obtained: V ðt Þ d V ðt Þ þ out = 0 R dt in d V out ðt Þ = - RC V in ðt Þ dt

C

ð5:53Þ ð5:54Þ

In Eq. (5.54), the output voltage (Vout(t)) is the scaled derivative of the input voltage (Vin(t)) with the polarity of the input voltage reversed. An improved version of the differentiator can be obtained by adding a series resistor Rs in the input path with the capacitor, as shown in Fig. 5.12. The series resistor should be such that Rs ≤ R/10. The circuit of modified differentiator of Fig. 5.12 can be analyzed using the concept of impedance, and the ratio of amplitudes of output voltage Vout(t) = B sin (ωt - ϕ) and the input Vin(t) = A sin ωt in terms of source frequency ω and circuit parameters R, C, and Rs can be expressed as B 1 ðωÞ = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi R 2  1 2ffi A s þ RCω R

ð5:55Þ

The cutoff or corner frequency for the modified differentiator can be obtained, equating the two terms in the denominator, as ωcd =

1 Rs C

ð5:55aÞ

At corner frequency ω = ωcd, the amplitude ratio BA = RRs p1ffiffi2. For frequency ω < ωcd, the modified differentiator acts as a differentiator, and for frequency ω ≫ ωcd, the modified differentiator acts as an amplifier with a gain of BA = - RRs .

110

5

Analog Signal Processing and Operational Amplifiers

Fig. 5.13 Frequency response of a modified differentiator

Example 5.5 For the modified differentiator circuit of Fig. 5.12, find the corner frequency ωcd and the output voltage amplitude B if R = 10 kΩ, C = 0.10 μF, Rs = 1 kΩ, A = 1 V, at fcd= ωcd/2π. Solution For the given parameters, the cutoff frequency is ωcd = R1s C = 10, 000 rad=s using Eq. (5.55a) with f cd = ω2πcd = 1592 Hz: The output voltage amplitude can be obtained from Eq. (5.55) as 1V 1 B = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi  2 = 7:070 V: R 2  1 2ffi A = rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi  s 1 kΩ 2 1 þ þ RCω R 3 -6 10 kΩ

10 × 10 × 0:10 × 10

× 10000

The frequency response graph for the modified differentiator, obtained from Eq. (5.55) using Matlab, is shown in Fig. 5.13:

5.10

Voltage Follower

A special case of a noninverting amplifier of Fig. 5.4 can be obtained replacing the resistor in the feedback path with a wire, i.e., shorted (Rf → 0) and removing the input resistor, i.e., open circuit (Ri → 1), as shown in Fig. 5.14. For this special case

5.11

Comparator

111

Fig. 5.14 Schematic diagram of a voltage follower

Fig. 5.15 Schematic diagram of a comparator

configuration, the output voltage is the same as the input voltage, from Eq. (5.21) with Rf = 0 and Ri = 1, Vout = Vin. The op-amp circuit is known as buffer or voltage follower.

5.11

Comparator

The op-amp circuit with a fixed voltage connected to the inverting input as a reference (Vref) and an input voltage (Vin) connected to the noninverting input is shown in Fig. 5.15 with no feedback. The op-amp gain without feedback is infinite, and the output voltage will saturate to most positive and most negative values depending on the level of the input voltage Vin compared with the reference voltage Vref as V out =

9 8 < þV sat V in > V ref = :

- V sat V in < V ref

;

ð5:56Þ

112

5

Analog Signal Processing and Operational Amplifiers

Fig. 5.16 Schematic diagram of a sample and hold

5.12

Sample and Hold

A sample and hold circuit of Fig. 5.16 consists of a voltage follower and a voltageholding capacitor: The output voltage is equal to the input voltage when the switch is closed: V out ðt Þ = V in ðt Þ

ð5:57Þ

The capacitor holds the input voltage at the last sampled value, when the switch is opened:     V out t- t sampled = V in t sampled

5.13

ð5:58Þ

Instrumentation Amplifier

The configuration of an instrumentation amplifier consisting of a two-stage op-amp circuit with precision resistors is shown in Fig. 5.17. The pair of op-amps in the first stage is used to amplify each of the input signals V1 and V2 separately providing a high-impedance amplifier stage with a moderate common mode rejection rate (CMRR). The second stage is an op-amp acting as the difference amplifier for the first-stage output voltages V3 and V4 with a potentiometer R5 to maximize the overall CMRR. Assuming ideal op-amp model, the output voltages from the first-stage V3 and V4 can be expressed in terms of the input voltages V1 and V2 and the resistances R1 and R2. The current (I) through the resistors R1 and R2 can be obtained applying KCL and Ohm’s law: V 3 - V 1 = IR2

ð5:59Þ

V 2 - V 4 = IR2

ð5:60Þ

5.13

Instrumentation Amplifier

113

Fig. 5.17 Schematic diagram of an instrumentation amplifier

Applying Ohm’s law to R1, V 1 - V 2 = IR1

ð5:61Þ

Eliminating I from Eqs. (5.59) and (5.61), the output voltage V3 can be expressed in terms of input voltages V1 and V2:   R R V3 = 1 þ 2 V1 - 2 V2 R1 R1

ð5:62Þ

Similarly, eliminating I from Eqs. (5.60) and (5.61), the output voltage V4 can be expressed in terms of input voltages V1 and V2: 

 R2 R V - 2V V4 = 1 þ R1 2 R1 1

ð5:63Þ

Assuming R5 = R4, the output voltage Vout can be expressed in terms of the input voltages V1 and V2: V out =

 

R4 R 1 þ 2 2 ðV 2- V 1 Þ R3 R1

ð5:64Þ

114

5.14

5

Analog Signal Processing and Operational Amplifiers

The Real Operational Amplifier

The real operational amplifiers are characterized by finite input impedance, though quite high in the range of 2–6 MΩ, finite gain in the range of 20–200, maximum output voltage in the range of ±13.6 V for a supply voltage of ±15 V, slew rate in the range of 0.3–0.7 V/μs, and bandwidth of 0.4–1.5 MHz. Details of op-amp characteristics can be obtained from the data sheets provided by the manufacturer.

5.15

Computer-Aided Analysis and Simulation of Operational Amplifier Circuits

An example of op-amp circuit in Fig. 5.18 is considered to illustrate the procedure. For this circuit, the parameters are as follows: R1 = 5 kΩ, R2 = 7.5 kΩ, R3 = 3 kΩ, R4 = 4 kΩ, R5 = 4.8 kΩ, V1 = 2 V, and V2 = 3 V. Assuming ideal op-amp model, find the output voltages of op-amps, Vout1 and Vout.

5.15.1

Analysis Using Matlab

Matlab code using symbolic manipulation to analyze the op-amp circuit of Fig. 5.18 along with results is presented. The expressions for currents I1 and I2 through R1 and R2 are expressed in symbolic form using Ohm’s law. The output voltage (Vout1) of the first-stage op-amp (op-amp1) is obtained using KCL at the junction meeting I1

Fig. 5.18 An example of op-amp circuit

5.15

Computer-Aided Analysis and Simulation of Operational Amplifier Circuits

115

and I2. The output voltage (Vout) of the second-stage op-amp (op-amp2) is obtained considering it as a noninverting amplifier. Numerical values of Vout1 and Vout are obtained substituting the numerical values of the circuit parameters. % Ch5 - Example of Op-Amp Circuit clear all % Declare symbolic variables syms R1 R2 R3 R4 R5 V1 V2 Vo1 Vo Vp1=V2; % Op-amp1 V+ Vn1=Vp1; % Op-amp 1 Vi1=(V1-Vn1)/R1; % Op-amp1 I1 through R1 i2=(Vo1-Vn1)/R2;% Op-amp1 I2 through R2 (feedback path) Vo1=solve(i1+i2==0,Vo1); % solve for op-amp output voltage Vout1 Vp2=Vo1; % Op-amp2 V+ Vo=Vo1*(1+R5/R4); % Op-amp2 output as a non-inverting amplifier % Numerical Values R1=5e3; R2=7.5e3; R3=3e3; R4=4e3;R5=4.8e3;V1=2;V2=3 Vo1 = double(subs(Vo1)) % output voltage of op-amp1 Vo = double(subs(Vo)) % output voltage of op-amp 2

Results: Vo1 = 4.5000 V, Vo = 9.9000 V

5.15.2

Simulation Using Tinkercad

The op-amp circuit of Fig. 5.18 implemented on Tinkercad along with output voltages Vout1 and Vout is presented in Fig. 5.19. The ±15 V supply to pins 7 and

Fig. 5.19 Example op-amp circuit on Tinkercad

116

5

Analog Signal Processing and Operational Amplifiers

4 are created from a 30 V DC supply using the right side of the circuit. The output of op-amps (Vout1 and Vout) are displayed on the multimeters. Results match exactly with those obtained from Matlab, as expected.

5.16

Summary of Operational Amplifier Configurations

The op-amp configurations considered in this chapter are summarized in Table 5.1 for quick reference.

5.17 5.17.1

Simulation and Experimental Validation Basic Operational Amplifier Configurations

Objectives To build and analyze different basic configurations of operational amplifier (op-amp) circuits, namely, inverting amplifier, noninverting amplifier, voltage follower, and comparator. Basic Steps I. Basic Measurements and Calculation of Expected Gains 1. Collect two resistors with nominal values R1 = 1 kΩ and R2 = 10 kΩ. Measure and record the actual values in Table 5.2. 2. Use the measured values of R1 and R2 to complete column 5 of Table 5.3 for different operational amplifier (op-amp) configurations.

II. Construction of Op-Amp Circuits and Studying the Circuit Characteristics (a) Inverting amplifier: Construct the op-amp circuit of inverting amplifier on Tinkercad as shown in Fig. 5.20. The physical circuit can be constructed in physical laboratory setting. The power supply for +15 V and -15 V can be obtained from a physical power supply with proper setting. Set the input waveform to a square wave 1 Vp-p at 100 Hz, and observe the output waveform on the oscilloscope. Repeat for other waveforms and complete the first group of rows of Table 5.3 for inverting amplifier.

Op-amp configuration Inverting amplifier

Noninverting amplifier

Serial number 1

2

Fig

Table 5.1 Summary of op-amp configurations

Rf Ri

 

V in

(continued)

  R V out = 1 þ Rfi V in

V out = -

Relation

5.17 Simulation and Experimental Validation 117

Op-amp configuration Summing amplifier

Difference amplifier

Serial number 3

4

Table 5.1 (continued)

Fig Ri

  Rf R ðV 2- V 1 Þ

i=1

n   P Vi

5

V out =

V out = - Rf

Relation

118 Analog Signal Processing and Operational Amplifiers

Integrator

Modified integrator

5

6

1 RC

0 V in ðτÞdτ

Rt

(continued)

1 ffi τ = RC, BA ðωÞ = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 2 ðRRs Þ þðτωÞ2 Rs ≥ 10R

V out ðtÞ = -

5.17 Simulation and Experimental Validation 119

Op-amp configuration Differentiator

Modified differentiator

Serial number 7

8

Table 5.1 (continued)

Fig d dt V in ðt Þ

5

1 ffi τ = RC, BA ðωÞ = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 2 2 ðRRs Þ þðτω1 Þ Rs ≤ R/10

V out ðtÞ = - RC

Relation

120 Analog Signal Processing and Operational Amplifiers

Voltage follower

Comparator

Instrumentation amplifier

9

10

11

R4 R3

1 þ 2 RR21

i

- V sat V in < V ref

h 

:

[V2 - V1]

V out =

V out =

;

8 9 < þV sat V in > V ref =

Vout = Vin

5.17 Simulation and Experimental Validation 121

122

5

Analog Signal Processing and Operational Amplifiers

Table 5.2 Nominal and measured values of resistance Resistance R1 R2

Color code

Nominal value from color code (kΩ)

Measured value (kΩ)

% Difference

Table 5.3 Comparison of theoretical and experimental gains for op-amp circuits Op-Amp Configuration

Vin p-p

Inverting Amplifier

1V

Non-inverting Amplifier

1V

Voltage Follower

1V

Vout p-p

Amplifier Gain (G) Theoretical Experimental Expression Gaina Gain (Vout / Vin) p-p

% Difference



1+

Comparator

a

Use measured values of R1 and R2 from Table 5.2

Fig. 5.20 Schematic of an inverting amplifier circuit on Tinkercad

Waveforms to include from Oscilloscope Vin,(t), Vout(t) Square wave Triangular wave Sinusoidal (50 Hz) Sinusoidal (10 kHz) Square wave Triangular wave Sinusoidal (50 Hz) Sinusoidal (10 kHz) Square wave Triangular wave Sinusoidal (50 Hz) Sinusoidal (10 kHz) Vin (Triangular) and Vout

5.17

Simulation and Experimental Validation

123

Fig. 5.21 Schematic of a noninverting amplifier circuit on Tinkercad

Fig. 5.22 Schematic of a voltage follower circuit on Tinkercad

(b) Noninverting amplifier: Construct the op-amp circuit of noninverting amplifier on Tinkercad as shown in Fig. 5.21. Repeat for waveforms and complete the second group of rows of Table 5.3 for noninverting amplifier. (c) Voltage follower: Construct the op-amp circuit of voltage follower on Tinkercad as shown in Fig. 5.22. Repeat for waveforms and complete the third group of rows of Table 5.3 for voltage follower. (d) Comparator: Construct the op-amp circuit of comparator on Tinkercad as shown in Fig. 5.23. Repeat for waveforms and complete the final row of Table 5.3 for comparator.

124

5

Analog Signal Processing and Operational Amplifiers

Fig. 5.23 Schematic of a comparator circuit on Tinkercad

III. Deliverables Complete Table 5.3.

Lab Report Present all experimental results and Tables 5.2 and 5.3 (including all waveforms using the downloaded waveform data) in the lab report and include the following specific items: 1. Compare the observed gains with the theoretical values, as presented in Table 5.3. 2. Comment on the observed effects of frequencies on the output signals for each configuration. 3. Discuss the usage of the voltage follower or buffer. Explain the waveforms observed for voltage follower. 4. Discuss the usage of a comparator.

5.17.2 Integrator, Differentiator, and Modified Versions Objectives To build and analyze basic integrating and differentiating circuits using operational amplifier (op-amp) and the corresponding modified versions.

5.17

Simulation and Experimental Validation

125

Table 5.4 Nominal and measured values of R and C and calculation of characteristic parameters Resistance R Rsi Rsd Capacitance C Time constant = ∗ (s) = (Hz)

Color Code

code 104

Nominal value from Color code 10 kΩ 100 kΩ 1 kΩ Nominal value from code 0.10 μF

Measured value

Measured value

Corner frequency (Modified Integrator) 1 = ( ) 2 Corner frequency (Modified Differentiator)

Basic Steps I. Basic Measurements and Calculation of Expected Frequencies 1. Collect three resistors with nominal values of 1 kΩ, 10 kΩ, and 100 kΩ and a capacitor of code 104. Measure and record the actual values in Table 5.4. 2. Complete Table 5.4 using the measured values of R and C.

II. Construction of Op-Amp Circuits and Studying the Circuit Characteristics (a) Integrator: Construct the op-amp circuit of an integrating amplifier on Tinkercad as shown in Fig. 5.24. The physical circuit can be constructed in physical laboratory setting. The power supply for +15 V and -15 V can be obtained from a physical power supply with proper setting. Set the input waveform to a square wave 1 Vp-p at 100 Hz and observe the output waveform on the oscilloscope. Repeat for other waveforms and complete the first group of rows of Table 5.5 for an integrator. (b) Differentiator: Construct the op-amp circuit of a differentiating amplifier on Tinkercad as shown in Fig. 5.25. Repeat for waveforms and complete the second group of rows of Table 5.5 for a differentiator. (c) Modified integrator: Construct the op-amp circuit of a modified integrator on Tinkercad as shown in Fig. 5.26 with shunt resistor Rs in parallel with C in the feedback path. Change the input waveform to sine wave and complete the frequency response Table 5.6 for the modified integrator in the frequency range f : [0.1fci, 10fci] and plot AR vs log10(f).

126

5

Analog Signal Processing and Operational Amplifiers

Fig. 5.24 Schematic of an integrator circuit on Tinkercad

(d) Modified differentiator: Construct the op-amp circuit of a modified integrator on Tinkercad as shown in Fig. 5.27 with a resistor Rs in series with C in the input path. Keep the input waveform to sine wave and complete the frequency response in Table 5.7 for the modified integrator in the frequency range f : [0.1fcd, 10fcd] and plot AR vs log10(f).

III. Deliverables (a) Complete Tables 5.5, 5.6 and 5.7. (b) Complete Table 5.8 for modified integrator and differentiator.

Lab Report I. Present all the experimental results (including all waveforms using the downloaded waveform data) in the lab report and include the following specific items. II. Integrator. 1. Obtain the relation for voltage output of the integrator in terms of input voltage (i) without the shunt resistance and (ii) with the shunt resistance (using the values of R and C in the circuit).

a

p-p

Vin

- RC2πf 1 2πRC

Hz

1/(RC2πf) Observe and record input and output waveforms

Get amplifier gain with sinusoidal wave as input at f =

Differentiator

Op-amp configuration Integrator

1 Amplifier gain (G) at f = 2πRC Hza Expected gain (based on measured values) Vout Experimental gain (Vout/ Expression Gain Vin)p-p p-p Observe and record input and output waveforms

Table 5.5 Results of integrating and differentiating amplifiers

% Difference

Waveforms to include from oscilloscope, Vin, Vout Square Triangular Sinusoidal Square Triangular Sinusoidal

5.17 Simulation and Experimental Validation 127

128

5

Analog Signal Processing and Operational Amplifiers

Fig. 5.25 Schematic of a differentiator circuit on Tinkercad

Fig. 5.26 Schematic of a modified integrator circuit on Tinkercad

2. Develop a Matlab script to simulate input and output waveforms. Compare the simulated output waveform with the experimental one, without and with the shunt resistor.

5.17

Simulation and Experimental Validation

129

Table 5.6 Frequency response of a modified integrator

Frequency (f) Hz

Log10(f)

Vin p-p

Vout p-p

AR =(Vout/Vin ) p-p

Fig. 5.27 Schematic of a modified differentiator circuit on Tinkercad

3. Discuss the effects of the shunt resistance on the output voltage for different input signal frequencies. 4. Discuss the applications of an integrator in analog signal processing. III. Differentiator. 1. Obtain the relation for voltage output of the differentiator in terms of input voltage (i) without the shunt resistance, and (ii) with the shunt resistance.

130

5

Analog Signal Processing and Operational Amplifiers

Table 5.7 Frequency response of a modified differentiator

Frequency (f) Hz

Log10(f)

Vin p-p

Vout p-p

AR =(Vout/Vin ) p-p

2. Develop a Matlab script to simulate input and output waveforms. Compare the simulated output waveform with the experimental one, without and with the series resistor. 3. Discuss the effects of the series resistance on the output voltage for different input signal frequencies. 4. Discuss the applications of a differentiator in analog signal processing.

Fig. P5.1 Op-amp circuit for problem 1

Actual

p-p

Vin p-p

Vout

Get amplifier gain with sinusoidal wave as input at f c =

Expected

1 2πRs C

R Rsd

Hz

2

2

  p1ffiffi

Amplifier gain (G) at f c = 2πR1 s C Hza Expected gain Experimental Gain (Vout/ Expression Gain Vin)p-p   Rsi p1ffiffi R

Estimate fc from Table 5.6 (modified integrator) at which AR is close to expected value RRsi

b

  p1ffiffi 2  c Estimate fc from Table 5.7 (modified integrator) at which AR is close to expected value RRsd p12ffiffi

a

Op-amp configuration Modified integratorb Modified differentiatorc

Corner freq. fc

Table 5.8 Results of modified integrating and differentiating amplifiers

% Difference

Vin, Vout (sinusoidal)

Waveforms to include from oscilloscope Vin, Vout (sinusoidal)

Simulation and Experimental Validation 131

132

5

Analog Signal Processing and Operational Amplifiers

Exercises

Fig. P5.2 Op-amp circuit for problem 2

1. Assuming ideal op-amp behavior for the op-amp circuit shown in Fig. P5.1, obtain the output voltage Vout in terms of R and Vin. Use R = 1 kΩ and Vin = 10 V.

Fig. P5.3 Op-amp circuit for problem 3

Exercises

133

2. Assuming ideal op-amp behavior for the op-amp circuit shown in Fig. P5.2, obtain the output voltage Vout in terms of R, T, and Vin. Use R = 1 kΩ, T = 0.8, and Vin = 10 V.

Fig. P5.4 Op-amp circuit for problem 4

3. Assuming ideal op-amp behavior for the op-amp circuit shown in Fig. P5.3, find the value of R4 if the gain of the op-amp circuit (Vout/Vin) is 7.5. Use R1 = 1 kΩ, R2 = 2 kΩ, R3 = 3 kΩ.

Fig. P5.5 Op-amp circuit for problem 5

4. Assuming ideal op-amp behavior for the op-amp circuit shown in Fig. P5.4, obtain the output voltage Vout in terms of R1, R2, R3, R4, R5, V1, and V2. Use R1 = 5 kΩ, R2 = 15 kΩ, R3 = 5 kΩ, R4 = 2 kΩ, R5 = 4 kΩ, V1 = 1.5 kΩ, and V2 = 3 V.

134

5

Analog Signal Processing and Operational Amplifiers

Fig. P5.6 Op-amp circuit for problem 6

5. Assuming ideal op-amp behavior for the op-amp circuit shown in Fig. P5.5, obtain the output voltage Vout in terms of R1, R2, R3, R4, R5, R6, R7, V1, V2, and V3. Use R1 = 2.5 kΩ, R2 = 2 kΩ, R3 = 3 kΩ, R4 = 5 kΩ, R5 = 3 kΩ, R6 = 4 kΩ, R7 = 6 kΩ, V1 = 1.5 V, V2 = 3 V, and V3 = 2 V.

Fig. P5.7 Op-amp circuit for problem 7

6. Assuming ideal op-amp behavior for the op-amp circuit shown in Fig. P5.6, obtain the output voltage Vout in terms of R1, R2, R3, R4, R5, R6, R7, R8, R9, V1, and V2. Use R1 = 2.5 kΩ, R2 = 2 kΩ, R3 = 3 kΩ, R4 = 5 kΩ, R5 = 3 kΩ, R6 = 4 kΩ, R7 = 6 kΩ, R8 = 4.5 kΩ, R9 = 3 kΩ, V1 = 1.5 V, and V2 = 3 V.

Exercises

135

Fig. P5.8 Op-amp circuit for problem 8

7. Assuming ideal op-amp behavior for the op-amp circuit shown in Fig. P5.7, obtain the output voltage Vout in terms of R1, R2, R3, R4, R5, R6, R7, R8, I1, and V1. Use R1 = 2.5 kΩ, R2 = 2 kΩ, R3 = 3 kΩ, R4 = 5 kΩ, R5 = 3.6 kΩ, R6 = 4 kΩ, R7 = 2.5 kΩ, R8 = 3.5 kΩ, I1 = 2.5 mA, and V2 = 8 V.

Fig. P5.9 Op-amp circuit for problem 9

8. Assuming ideal op-amp behavior for the op-amp circuit shown in Fig. P5.8, obtain the output voltage Vout in terms of R1, R2, R3, R4, R5, and I1. Use R1 = 5 kΩ, R2 = 3 kΩ, R3 = 3.5 kΩ, R4 = 5 kΩ, R5 = 5.5 kΩ, and I1 = 2.5 mA.

136

5

Analog Signal Processing and Operational Amplifiers

Fig. P5.10 Op-amp circuit for problem 10

9. Assuming ideal op-amp behavior for the op-amp circuit shown in Fig. P5.9, Fig. P5.11 Op-amp circuit for problem 11

obtain the output voltage Vout in terms of R1, R2, R3, R4, R5, V1, and V2. Use R1 = 5 kΩ, R2 = 3 kΩ, R3 = 3.6 kΩ, R4 = 5 kΩ, R5 = 6 kΩ, V1 = 2.0 V, and V2 = 5 V. 10. Assuming ideal op-amp behavior for the op-amp circuit shown in Fig. P5.10, obtain the output voltage Vout in terms of R1, R2, R3, R4, R5, and V1. Use R1 = 5 kΩ, R2 = 3 kΩ, R3 = 3.6 kΩ, R4 = 5 kΩ, R5 = 6 kΩ, and V1 = 2.5 V.

Bibliography

137

Fig. P5.12 Op-amp circuit for problem 12

11. Assuming ideal op-amp behavior for the op-amp circuit of Fig. P5.11, obtain the expression for the output voltage V0(t) in terms of R, L, and Vi(t). 12. Assuming ideal op-amp behavior for the op-amp circuit of Fig. P5.12, obtain the expression for the output voltage V0(t) in terms of R1, R2, C1, C2, and Vi(t). Use the concept of impedance.

Bibliography Alciatore DG (2019) Introduction to mechatronics and measurement systems, 5th edn. McGraw Hill, New York Analog Devices (2022) LTspice simulator. https://www.analog.com Hambley A (2017) Electrical engineering: Principles and applications, 7th edn. Pearson, Upper Saddle River Mathworks (2022) Matlab and Simulink. https://www.mathworks.com National Instruments (2022) Multisim. https://www.ni.com/en-us/support/downloads/softwareproducts/download.multisim.html#452133 Pico Technology (2022) PicoScope 2000 series. https://www.picotech.com/oscilloscope/2000/ picoscope-2000-overview Test Equity (2022) Instek GDS-1202B digital storage oscilloscope. https://www.testequity.com Test Equipment Depot (2022) Instek AFG-2105 arbitrary waveform function generator. https:// www.testequipmentdepot.com/instek/signalgenerators/afg2105.html TEquipment (2022a) Instek GDM-8341 50,000 counts dual measurement multimeter with USB device. https://www.tequipment.net/InstekGDM-8341.html TEquipment (2022b) Instek GPE-3323 3 Channels, 217W linear DC power supply. https://www. tequipment.net/Instek/GPE-3323/DC-Power-Supplies Texas Instruments (2022) LM741 operational amplifier datasheet (Rev. D). https://www.ti.com › lit › symlink › lm741 Tinkercad (2022) Learn circuits. https://www.tinkercad.com/learn/circuits

Chapter 6

Data Acquisition and Digital Signal Processing

6.1

Introduction

In this chapter, analog and discrete signals, number systems, analog-to-digital conversion (ADC), digital-to-analog conversion (DAC), and computer-based data acquisition (DAQ) systems—DAQ hardware, and software platform of LabVIEW— are covered. Examples of computer-aided analysis and simulation using Matlab and LabVIEW are presented. Experimentation using LabVIEW is presented along with actual laboratory implementation. End-of-chapter exercise problems are provided to help consolidate the understanding of materials covered.

6.2

Analog and Discrete Signals

In mechatronic systems, digital devices like microprocessors, microcontrollers, microcomputers, and computers are used widely. It is necessary to use interfaces that can transform continuous time or analog signals to discrete time or digital signals and vice versa. The interface that is used to convert analog signals to digital signals is called analog-to-digital converter (ADC). The interface that is used to convert digital signals to analog signals is called digital-to-analog converter (DAC). Both ADC and DAC are together called data acquisition (DAQ) systems. In an ADC, the analog signal is sampled, the analog value is converted to a discrete number for each sample, and the process is repeated for the entire signal, resulting in a series of discrete values representing the analog signal. A typical example is shown in Fig. 6.1. The frequency of sampling the analog signal should have some relationship with the frequency of the analog signal. For reasonably well discrete-time (digital) representation of the sampled analog signal, the sampling frequency must be at least twice the highest frequency of the analog signal. This is known as Shannon’s © The Author(s), under exclusive license to Springer Nature Switzerland AG 2023 B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_6

139

140

6

Data Acquisition and Digital Signal Processing

Fig. 6.1 Example of a continuous-time signal and its sampled (discrete) version (a) analog, (b) discrete

sampling theorem. The sampling rate or frequency ( fs) is related to the highest frequency ( fmax) of the analog signal as fs ≥ 2fmax. The sampling time (Δt) or the time interval between two successive samples is related to sampling frequency as fs = 1/Δt, where fs in Hz and Δt is in seconds. If the sampling frequency is less than twice the highest frequency of the analog signal, the sampled version of the signal (digital signal) may not represent the original analog signal and may result in a different one or an alias; the process is known as aliasing. An example of aliasing when the analog signal is sampled at a rate ( fs) lower than the required minimum sampling rate (2f), fs < 2f, is shown in Fig. 6.2 where the sampled signal (in blue) is not representing the original signal (in red).

6.3

Number Systems

A number system is characterized with a specific number of digits, a specific base, and place value of each digit in the number representation as a power of base. In this section, four commonly used number systems, namely, decimal, binary, octal, and hexadecimal, are discussed.

6.3

Number Systems

141

Fig. 6.2 An example of an analog signal (red) and its alias (blue) sampled at fs < 2f

6.3.1

Decimal Number System

In decimal number system, the digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9; the base is 10; and the place value of a digit (in the nth position) in the decimal number is 10(n-1). For example, for a decimal number, dn-1 . . . d2 d 1 d0 = dn-1 :10ðn-1Þ þ . . . þ d2 :102 þ d1 :101 þ d0 :100

ð6:1Þ

where n is the total number of digits and di is one of the ten digits (0–9) of the number system. As an example, the decimal number 314 can be expressed as 314 = 3 × 102 þ 1 × 101 þ 4 × 100

6.3.2

ð6:2Þ

Binary Number System

In the binary number system, the digits are 0 and 1, the base is 2, and the place value of a digit (in the nth position) in the binary number is 2(n-1). For example, for a binary number, ðdn-1 . . . d 2 d1 d0 Þ2 = dn-1 :2ðn-1Þ þ . . . þ d 2 :22 þ d1 :21 þ d0 :20

ð6:3Þ

where n is the total number of digits and di is one of the two digits (0, 1) of the binary number system. As an example, the binary number (1011)2 can be expressed as (11)10 in decimal number system: ð1011Þ2 = 1 × 23 þ 0 × 22 þ 1 × 21 þ 1 × 20 = ð8 þ 0 þ 2 þ 1Þ10 = ð11Þ10

ð6:4Þ

142

6

Data Acquisition and Digital Signal Processing

In binary number system, digits are also called binary digits of bits, the leftmost bit is known as the most significant bit (MSB), and the rightmost bit is known as the least significant bit (LSB). A group of 8 bits is called byte. One kilobyte (KB) is 210 or 1024 bytes, one megabyte (MB) is 210 KB or 220 bytes, one gigabyte (GB) is 210 MB or 230 bytes, and one terabyte (TB) is 210 GB or 240 bytes.

6.3.3

Octal and Hexadecimal Number Systems

In general, the value of a n-digit number represented in any base b can be expanded in terms of digits di (0, 1, .., (b-1)) as ðdn-1 . . . d 2 d1 d0 Þb = dn-1 :bðn-1Þ þ . . . þ d 2 :b2 þ d1 :b1 þ d0 :b0

ð6:5Þ

For example in octal number system, b = 8 and digits are 0, 1, 2, 3, 4, 5, 6, and 7. In hexadecimal number system, b = 16, and digits are alphanumeric, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F; the decimal values of alphabets A–F are 10–15, respectively.

6.3.4

Decimal to Binary Conversion

A number in the decimal number system can be converted to another number system of base b dividing the decimal number successively by base b, recording the remainder after each division. The remainders, written in reverse order from left to right, with the remainder of the last division as the MSB and the remainder of the first division as the LSB, represent the digits of the number in base b. An example of converting a number (135)10 to binary number (1000111)2 is shown in Table 6.1. The process can be used for converting a decimal number to other number systems like octal (base 8) and hexadecimal (base 16) where the divisor is the base of the corresponding number system. Table 6.1 Example of a decimal to binary conversion

Successive division 135/2 67/2 33/2 16/2 8/2 4/2 2/2 1/2 Result

Remainder 1 1 1 0 0 0 0 1 (10000111)2

LSB

MSB

6.3

Number Systems

6.3.5

143

Binary to Octal Conversion

The conversion from binary to octal number system can be done representing each group of 3 bits from the right by an octal digit (0–7); if there are not enough digits for the leftmost group, the remaining positions can be filled with leading 0. An example is shown next: ð10000111Þ2 = ð010 000 111Þ2 = ð207Þ8

6.3.6

ð6:6Þ

Binary to Hexadecimal Conversion

The conversion from binary to hexadecimal number system can be done representing each group of 4 bits from the right by hexadecimal digit (0–9, A–F); if there are not enough digits for the leftmost group, the remaining positions can be filled with leading 0. An example is shown next: ð10000111Þ2 = ð1000 0111Þ2 = ð87Þ16

ð6:7Þ

Decimal numbers 0–15 are represented in binary, octal, and hexadecimal number systems in Table 6.2. Matlab commands for conversion between number systems include dec2bin(), bin2dec(), dec2hex(), hex2dec(), dec2base(), and base2dec().

Table 6.2 Decimal numbers in different number systems

Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

Octal 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17

Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F

144

6.4

6

Data Acquisition and Digital Signal Processing

Analog-to-Digital Conversion

An analog-to-digital converter (ADC) is characterized in terms of number of bits (n), the minimum and the maximum input voltage, Vmin and Vmax, and the maximum sampling rate. The sampling rate of ADC depends on the analog-to-digital (A/D) conversion time and type of the converter. Among different types of ADC, two most commercially available types include successive approximation register (SAR) and flash ADC. Of these two, SAR is very widely used because of its simpler design and applicability for higher number of bits, though the conversion time increases linearly with the number of bits. The flash type ADC is faster as the conversion is done in parallel than in SAR where the conversion is done successively. However, the flash ADC is not suitable for higher number of bits, as the number of comparators needed for n-bit digital output is (2n-1), doubling for each added bit.

6.4.1

Successive Approximation Register (SAR) ADC

A successive approximation register (SAR) ADC consists of a sample and hold amplifier (S&H), a comparator, a SAR, a DAC, a latch, and a control unit, as shown in Fig. 6.3. With the start signal on, the S&H unit latches the analog input, and the control unit starts an iterative process, where the digital value is approximated successively from the MSB to LSB, converted to analog value through a DAC and compared with the input analog signal in the comparator till all bits are covered. Assuming the input signal is well within the input range of the ADC, the successive approximation is expected to give the DAC value close to the input signal, and the end of conversion (EOC) is set by the control unit, giving the digital output of the ADC.

Fig. 6.3 An example of a SAR ADC

6.4

Analog-to-Digital Conversion

145

1 Vin

Vout

Vin and Vout (V)

0.75

0.5

0.25

0

bit 3 =1 (MSB))

bit 2=0

bit 1=1

bit 0 =1 (LSB)

Fig. 6.4 An example of SAR operation of a 4-bit ADC

For a n-bit ADC, the approximation is done in n-steps. The input is compared to combinations of binary fractions 21 , 14 , 81 , . . . , 21n of full scale (FS) of the ADC, starting from MSB being 1 with rest being 0. The DAC output is compared with the input signal; if the input signal is higher than the DAC output, the MSB is set at 1; otherwise, it is reset to 0. The process is continued to the next bit till all bits (MSB to LSB) are covered. An example of a 4-bit ADC with a full scale of 1 V and an input signal of 0.70 V is shown in Fig. 6.4. First MSB (bit 3) is set at 1, giving the DAC output for bit pattern 1000 as FS/2 = 0.5 V which is lower than the input signal; thus, MSB will be set at 1. Next bit 2 is set at 1, giving the combined DAC output for bit pattern 1100 as (1/2 + 1/4)FS = 0.75 V, which is higher than the input signal; thus, bit 2 is reset to 0. Next bit 1 is set at 1, giving the DAC output for the bit pattern 1010 as (1/2 + 0 + 1/ 8)FS = 0.625 V, which is lower than the input voltage, thus keeping bit 1 at 1. Finally the LSB is set at 1, giving the DAC output for the bit pattern 1011 as (1/2 + 0 + 1/ 8 + 1/16)FS = 0.6875 V that is lower than the input voltage, thus keeping the LSB at 1. The ADC output 1011 (0.6875 V) is the closet approximation for the input voltage (0.70 V). The 4-bit approximation for the example is shown in Fig. 6.4. It should be mentioned that higher number of bits would be needed for better approximation. The conversion time for a n-bit ADC with a cycle time of ΔT is nΔT. The conversion time for typical SAR ADCs (n = 8 to 12) is in the range of 1–100 μs.

146

6.4.2

6

Data Acquisition and Digital Signal Processing

Flash ADC

In a flash n-bit ADC, the analog input voltage is compared in a bank of (2n-1) comparators, each with a reference voltage, decreasing fractions of (Vmax - Vmin). The digital logic outputs (1 for positive saturation when the input signal is higher than the reference; 0, otherwise) of the comparators are processed through a combinational logic circuit to give the digital (binary) output of the ADC. An example of a 2-bit flash ADC is shown in Fig. 6.5 with three op-amp comparators. For each comparator, the noninverting input terminal is connected to the analog input signal, and the inverting input terminal is connected to the decreasing fraction of the reference signal, e.g., (3/4)(Vmax-Vmin), (2/4)(Vmax-Vmin), and (1/4)(Vmax-Vmin). The digital logic outputs of the comparators C2C1C0 are processed through a combinational logic circuit to convert to the ADC digital output B1B0. The output of the 2-bit flash ADC for four possible levels of the input signal in relation to the reference voltage level are shown in Table 6.3. B0 = C 0 ∙ ðC 1  C 2 Þ

ð6:8Þ

B1 = C 0 ∙ C 1

ð6:9Þ

Fig. 6.5 An example of a 2-bit flash-ADC

6.4

Analog-to-Digital Conversion

147

Table 6.3 2-bit flash converter output Input voltage range 0 ≤ V in ≤ V4 V 2V 4 ≤ V in ≤ 4 2V 3V 4 ≤ V in ≤ 4 3V 4 ≤ V in ≤ V

6.4.3

Comparator output (C2C1C0) 000

ADC output (B1B0) 00

001

01

011

10

111

11

ADC Relations

The type of voltage input to an ADC can be unipolar or bipolar. The resolution of an n-bit ADC can be expressed in terms of input voltage range, Vmin and Vmax, and number of bits as R=

ðV max - V min Þ 2n - 1

ð6:10Þ

The number of bits for a given range of input voltage, Vmin and Vmax, and desired resolution R, can be from the Eq. (6.10):  n=

log 10

ðV max - V min Þ R

þ1



log 10 2

ð6:11Þ

The number of bits (n) obtained from Eq. (6.11) is rounded upward to the nearest positive even integer. The digital output as a number in decimal number system (x)10 of an n-bit ADC for an input voltage Vin in terms of Vmin, Vmax, Vin and n can be expressed as x = ð2n- 1Þ

ðV in - V min Þ ðV max - V min Þ

ð6:12Þ

The decimal number can be converted to any other number systems as required for the display system. Example 6.1 Find the resolution of an 8-bit ADC with 5 V. Find the digital value for an input voltage of 2.1 V in decimal number system and convert it to binary, octal, and hexadecimal forms. Solution Given V max = 5 V, V min = - 5 V, n = 8, and V in = 2:1 V

Resolution R =

ðV max - V min Þ 10 5—V = V=bit = 8 255 2n - 1 2 -1

148

6

Data Acquisition and Digital Signal Processing

Fig. 6.6 Calibration curve of ADC for Example 6.1

The digital output in decimal number system x = ð2n- 1Þ

 ð2:1 - ð - 5ÞÞ ðV in - V min Þ = 181:05 ≈ 181 = 28- 1 ð 5 - ð - 5Þ Þ ðV max - V min Þ

This is shown on the calibration curve of the ADC (Fig. 6.6). The decimal number (181)10 can be converted to binary form (10110101)2. The octal number can be obtained from the regrouped (groups of 3 bits from right) binary number (010 110 101)2 as (265)8. The hexadecimal number can similarly be obtained from the regrouped (groups of 4 bits from right) binary number (1011 0101)2 as (B5)16. Example 6.2 Find the minimum number of bits (n) required for an ADC such that the resolution is 0.10% of the full range of 5 V. Find the ADC output in decimal, binary, octal, and hexadecimal number systems for an input voltage of 2 V. Solution Given R = 0:10%of full range, V max = 5 V, V min = - 5 V, and V in = 2 V

R=

ðV max - V min Þ 2n - 1

5 - ð - 5Þ V 0:10 ð5- ð- 5Þ V Þ = 100 2n - 1

6.5

Digital-to-Analog Conversion

149

2n = 1000 þ 1 n=

log 10 ð1001Þ = 9:96 log 10 2

In general, n is rounded up to the next even integer. In this case, n = 10 is selected. Find the digital output in decimal number system for the input voltage of 2 V x = ð2n- 1Þ

 ð2 - ð - 5ÞÞ ðV in - V min Þ = 716:1 ≈ 716 = 210- 1 ð5 - ð - 5ÞÞ ðV max - V min Þ

The decimal number (716)10 can be converted to binary form (1011001100)2. The octal number can be obtained from the regrouped (groups of 3 bits from right) binary number (001 011 001 100)2 as (1314)8. The hexadecimal number can similarly be obtained from the regrouped (groups of 4 bits from right) binary number (0010 1100 1100)2 as (2CC)16.

6.5

Digital-to-Analog Conversion

Digital-to-analog conversion is needed to convert a digital device output to an analog signal as input to an analog system that can be the part of a mechatronic system.

6.5.1

Digital-to-Analog Converters

One of the simplest forms of DAC is a R-2R resistor ladder network connected to a summing op-amp circuit. A 4-bit R-2R ladder DAC is shown in Fig. 6.7. For the network, precision resistors with only two values (R and 2R) are used. The source voltage Vs or Vref is connected to the R-2R network; the other end of each of the 2R resistors is connected to the switch that represents the DAC input bits bn-1bn-2 bn-3, . . . , b2b1b0, with MSB as the leftmost switch and LSB as the rightmost switch. The status of ith bit bi decides the position of the switch; it is connected to the op-amp circuit if bi = 1; otherwise, the switch is connected to the ground (bi = 0). The node voltage Vn-1, Vn-2, Vn-3, . . . ,V2, V1, V0 with all switches grounded can be shown to be V n-1 = V s , V n-2 =

1 1 1 V , . . . , V 1 = V 2, V 0 = V 1 2 n-1 2 2 1 V 0 = n-1 V s 2

ð6:13Þ ð6:14Þ

150

6

Data Acquisition and Digital Signal Processing

Fig. 6.7 An example of a 4-bit R-2R ladder DAC

For a DAC input with only LSB b0 = 1, the corresponding switch is connected to the op-amp circuit, the output V out0 = -

1 1 V = - n Vs 2 0 2

ð6:15Þ

Similarly, with b1 = 1, the corresponding switch is connected to the op-amp circuit, the output 1 1 V out1 = - V 1 = - n-1 V s 2 2

ð6:16Þ

Similarly with MSB bn-1 = 1, the corresponding switch is connected to the op-amp circuit, the output. V outðn-1Þ = -

1 1 V = - Vs 2 n-1 2

ð6:17Þ

Using the principle of superposition, the op-amp output can be obtained as V out = bn-1 V outðn-1Þ þ bn-1 V outðn-1Þ þ . . . þ b1 V out1 þ b0 V out0

ð6:18Þ

For the DAC n-bit input pattern with all zeros (0) to all 1 (2n-1), the output range n is from 0 to - ð2 2-n 1Þ V s : with 4 bits changing 0000–1111, the For the example of 4-bit R-2R ladder DAC  1 V ref = - 15 output ranges from 0 to - 12 þ 14 þ 18 þ 16 16 V ref :

6.6

Virtual Instruments, Data Acquisition, and Digital Signal Processing. . .

6.5.2

151

DAC Relation

The output Vout of an n-bit DAC for an input number (x)10, with input voltage range, Vmin, Vmax, can be obtained: V out = x

ðV max - V min Þ þ V min ð 2 n - 1Þ

ð6:19Þ

Example 6.3 Find the output voltage of a 12-bit DAC for a hexadecimal input (4EF)16, with DAC voltage range of 7.5 V. Solution Given V min = - 7:5 V, V max = 7:5 V, n = 12, x = ð4EF Þ16 = ð1263Þ10

V out = x

ðV max - V min Þ ð7:5 - ð - 7:5ÞÞV  þ ð- 7:5 V Þ = þ V min = ð1263Þ  ð2n - 1Þ 212 - 1

- 2:874 V

6.6 6.6.1

Virtual Instruments, Data Acquisition, and Digital Signal Processing Using LabVIEW Virtual Instruments

LabVIEW (Laboratory Virtual Instrument Engineering Workbench) programs are called virtual instruments, or VIs, as the VIs resemble in appearance and operation of the physical instruments, such as oscilloscopes and multimeters. LabVIEW contains a comprehensive set of tools for acquiring, analyzing, displaying, and storing data, as well as tools to help troubleshoot the code written using graphical programming. In LabVIEW, each VI leads to two windows, namely, the front panel and the block diagram panel. The front panel is the user interface with controls and indicators found on Controls palette. Controls include knobs, push buttons, dials, and other input mechanisms. Indicators include graphs, charts, LEDs, and other output displays. The block diagram consists of the graphical code of LabVIEW for simulating, acquiring, processing, and analyzing data. After the user interface (front panel) is built, the graphical codes are added using terminals (from front panel), sub-VIs, functions, structures, constants, and mathematical and other processing from Functions palette. Wiring tool is used to connect the block diagram objects for transferring data between objects and communicating with the front panel objects for the desired functional objectives.

152

6.6.2

6

Data Acquisition and Digital Signal Processing

Signal Simulation and Analysis

LabVIEW provides built-in template VIs that include the sub-VIs, functions, structures, and front panel objects that are used to build common measurement applications. A representative VI with the front panel and the block diagram with their corresponding Controls palette and Functions palette is shown in Figs. 6.8 and 6.9. In Fig. 6.8, a waveform graph from graph indicators group is placed by first clicking on the graph icon on the Controls palette and then clicking at the desired location on

Fig. 6.8 VI Front panel with Controls palette

Fig. 6.9 VI Block diagram panel with Functions palette

6.6

Virtual Instruments, Data Acquisition, and Digital Signal Processing. . .

153

Fig. 6.10 VI showing the front panel and the block diagram for spectral analysis of sum of two sine waveforms: (a) front panel, (b) block diagram panel

the front panel. The waveform graph icon appears automatically as a terminal on the block diagram panel. In Fig. 6.9, two simulate signal blocks from the Input group are added through scaling and mapping blocks, and the combined signal is connected to the waveform graph terminal to display the waveform on the front panel. An example of VI for spectral analysis of a signal consisting of two sine waves with frequencies of 100 Hz and 160 Hz is shown in Fig. 6.10a, b. An example of VI for spectral analysis of a signal consisting of two square waves with frequencies of 100 Hz and 160 Hz is shown in Fig. 6.11a, b.

154

6

Data Acquisition and Digital Signal Processing

Fig. 6.11 VI showing the front panel and the block diagram for spectral analysis of sum of two square waveforms: (a) front panel, (b) block diagram panel

6.6.3

Data Acquisition and Digital Signal Processing

Two of the popular data acquisition modules from National Instruments include NI-USB-TC01 thermocouple module and NI-USB-6009 DAQ module. NI-USB-TC01 is a single-channel thermocouple module that is compatible with several types of thermocouples J, K, R, S, T, N, E, and B. An NI-USB-6009 is a low-cost multifunction DAQ with eight analog input (AI 14 bit, 48 kS/s), two analog output (150 Hz), and 13 digital I/O. These modules can be interfaced with relevant sensors and LabVIEW software platform. There are some newer low-cost USB-based DAQ modules available from National Instruments.

6.6

Virtual Instruments, Data Acquisition, and Digital Signal Processing. . .

155

Fig. 6.12 VI for measurement of temperature using thermocouple module (NI-USB-TC01): (a) front panel, (b) block diagram panel

In Fig. 6.12a, b, the front panel and block diagram panel of a VI for the measurement of temperature using an NI-USB-TC01 thermocouple module are shown. Two waveform charts are shown on the front panel to display measured temperature in °C and °F, respectively. The NI-USB-TC01 thermocouple module is represented on the block diagram panel by the DAQ Assistant icon from the Input group on Functions palette. The conversion of °C to °F F= 95 C þ 32 is represented by the math operation blocks. The temperature data (°C) are stored as a .lvm file using a Write to Measurement File. The While structure on the block diagram panel is used to run the process till it is terminated by pressing the push button on the front panel.

156

6

Data Acquisition and Digital Signal Processing

Fig. 6.13 VI for measurement of analog voltage signals using an NI-USB-6009 DAQ board: (a) front panel, (b) block diagram panel

In Fig. 6.13a, b, the front panel and the block diagram of a VI are shown for the measurement of analog input voltage using an NI-USB-6009 DAQ module. In the front panel of Fig. 6.13a, the signal from a vibrating cantilever (through a strain gage-Wheatstone bridge-difference amplifier setup, discussed in detail in Chap. 7) is shown along with its frequency spectrum. In the block diagram of Figure 6.13b, the signal is acquired through the DAQ Assistant module, processed through the low-pass filter and analyzed through a spectrum analyzer. The filtered signal and the frequency spectrum are fed to the terminal indicators of waveform graphs.

6.7

LabVIEW Experimentation

6.7

157

LabVIEW Experimentation

Objectives To simulate generation and processing of multiple signals in LabVIEW. Brief Steps I. Generation and Processing of Multiple Signals (a) Multiple signals: Create a block diagram to simulate sine, square, triangle, and triangular waveforms copying four Simulate blocks from the Input group on Functions palette. Create three Graph blocks on the front panel that appear on the block diagram panel. Complete the block diagram as shown in Fig. 6.14b. Set the frequency and amplitude of each waveform by doubleclicking on each simulate block. The spectrum analyzer block can be copied from the Spectral Analysis VI from Signal Analysis group on Express Functions palette. The spectral analyzer can be set to power spectrum (dB scale), keeping other default parameters. Run the VI and the waveform graphs, and the frequency spectrum should appear on the front panel as shown in Fig. 6.14a. (b) Sine waves: Modify the block diagram of step (a) and front panel of Fig. 6.14a to simulate the generation of two sine waves with frequencies of 30 Hz and 80 Hz and amplitudes of 1 and 0.4, respectively, and to analyze the frequency spectrum of the combined signal, similar to Fig. 6.10. Run the VI and the waveform graph, and the frequency spectrum should appear on the front panel similar to Figure 6.10a at frequencies of constituent signals (30 Hz and 80 Hz). (c) Square waves: Modify the signals of step (b) to square to get a block diagram similar to Fig. 6.11b. Run the VI and the waveform graph and the frequency spectrum should appear on the front panel similar to Fig. 6.11a at frequencies closer to that of constituent signals (30 Hz and 80 Hz) with some higher harmonics. (d) Sine waves with noise: Modify the block diagram of step (c) to change back to sine wave, add a filter block from the Signal Analysis block on Express Functions palette, and get a block diagram similar to Fig. 6.15b. Add a Gaussian noise waveform block and set its standard deviation to 1. Run the VI and the waveform graphs, noisy and filtered, and the frequency spectrum of filtered should appear on the front panel similar to Fig. 6.15a at frequencies of constituent signals (30 Hz and 80 Hz).

II. Deliverables Complete the list of deliverables of Table 6.4. Lab Report Include front panel and block diagram panels for each step (a–d) in the report. Discuss the frequency spectrum of each case. Discuss the effects of noise and filtering on frequency spectrum.

158

6

Data Acquisition and Digital Signal Processing

Fig. 6.14 VI for simulating and processing signals: (a) front panel, (b) block diagram panel

6.7

LabVIEW Experimentation

159

Fig. 6.15 VI for simulating sum of two sine waves with noise and its frequency spectrum: (a) front panel, (b) block diagram panel Table 6.4 Summary of deliverables Signal details Multiple signals displayed together on a graph, sum of signals, and its frequency spectrum Sum of two sine signals with frequencies of 30 Hz and 80 Hz and amplitudes of 1 and 0.4, respectively, and its frequency spectrum Sum of two square signals with frequencies of 30 Hz and 80 Hz and amplitudes of 1 and 0.4, respectively, and its frequency spectrum Sum of two sine signals with frequencies of 30 Hz and 80 Hz and amplitudes of 1 and 0.4, respectively (with Gaussian noise of standard deviation of 1), frequency of filtered signal

Vis Front panel and block diagram Front panel and block diagram

Front panel display Sine, square, triangle, sawtooth Waveform of input signal and frequency spectrum

Front panel and block diagram

Waveform of input signal and frequency spectrum

Front panel and block diagram

Waveform of input signal and frequency spectrum

160

6

Data Acquisition and Digital Signal Processing

Exercises

1. 2. 3. 4.

5.

6.

7.

8.

9.

10.

11.

Convert decimal number (125)10 to binary, octal, and hexadecimal numbers. Convert hexadecimal number (25D)16 to binary, octal, and decimal numbers. Convert octal number (756)8 to binary, hexadecimal, and decimal numbers. A 12-bit ADC has an input voltage range of 5.5 V. Find its resolution in mV/bit. Find the digital output (x) in decimal number system for an input voltage of 3.2 V. An ADC has an input voltage range of 0–5 V. Find the required number of bits (n) for a resolution of 0.01 V/bit. Find the input voltage Vin if the output (x) in decimal number system is (607)10. A 10-bit ADC has an input voltage range of 7.0 V. Find its resolution in mV/bit. Find digital output (x) in decimal number system for an input voltage of 4.5 V. An ADC has an input voltage range of 0–10 V. Find the required number of bits for a resolution of 0.02 V/bit. Find the input voltage Vin if the output (x) in decimal number system is (580)10. For an ADC with 10 bits and a range of 0–5 V, find the resolution. Find the digital output of the ADC for an input voltage of 2.4 V. Find the digital output in binary, octal, and hexadecimal number systems. Plot the graph of output vs input for the ADC showing the full range, the input voltage (2.4 V), and its digital output. It is required to select an ADC with a range of 7.5 V and a resolution of 0.025% of the full range. Find the minimum number of bits for the ADC. Select the number of bits and calculate the resolution. Find the digital output of the ADC for an input voltage of 3.5 V. Find the digital output in binary, octal, and hexadecimal number systems. Plot the graph of output vs input for the ADC showing the full range, the input voltage (3.5 V), and its digital output. It is required to select an n-bit ADC for a data acquisition system for measuring temperature in a process with the range of temperature (T) as 0 °C –400 °C. The temperature sensor has a sensitivity (k) of 25 mV/ °C. The resolution of the temperature measuring system should be 0.1 °C. The sensor output (V = k T) is to be connected to an input channel of the ADC. Obtain the input voltage range (Vmin, Vmax), the required number of bits (n), and the resolution (R) (mV/bit) of the ADC. Determine the digital output of the ADC in decimal number system, (x)10, for a temperature of 275 °C (Hint: Get ADC parameters from the given specifications of the temperature measurement system). For a DAC with 10 bits and a range of 5 V, find the analog output of the DAC for a hexadecimal digital input of (35E)16. Plot the graph of output vs input for the DAC showing the full range, the digital input of (645)10,and its analog output. (Hints: First convert from hex to decimal number (x); use x in DAC relation to get Vout.).

Bibliography

161

Bibliography Alciatore DG (2019) Introduction to mechatronics and measurement systems, 5th edn. McGraw Hill, New York Arduino (2022) Arduino. https://www.arduino.cc Mathworks (2022) Matlab and simulink. https://www.mathworks.com National Instruments (2022a) Entry-level, plug-and-play USB data acquisition. https://www.ni.com National Instruments (2022b) LabVIEW. https://www.ni.com National Instruments (2022c) USB-TC01 temperature input device. https://www.ni.com Tinkercad (2022) Learn circuits. https://www.tinkercad.com/learn/circuits

Chapter 7

Sensors

7.1

Introduction

The sensors, also termed as transducers, are widely used to measure variables of engineering importance that include position, displacement, velocity, acceleration, stress, strain, force, pressure, flow, and temperature. In general, the sensors with appropriate signal conditioning are used to transduce the physical variables to electrical signals, mostly in form of voltage that can further be processed and analyzed for getting the information of the measured variables. In this chapter, various sensors along with corresponding signal conditioning are presented.

7.2 7.2.1

Position, Displacement, and Velocity Measurement Proximity Sensors

Proximity sensors are widely used in industrial applications to detect small distance (gap) of an object relative to the sensor without making any contact with the object. Proximity sensors are generally of inductive, capacitive, and magnetic type and the sensor output depends on the sensor type. For commonly used inductive proximity sensors, the sensor output voltage (eo) is proportional to the distance (x) with constant of proportionality as k eo = k x

© The Author(s), under exclusive license to Springer Nature Switzerland AG 2023 B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_7

ð7:1Þ

163

164

7.2.2

7

Sensors

Potentiometers

For potentiometers—translational and rotational—the output voltage (e0) is proportional to the displacement (x, translation) or angle of rotation (θ), with the constant of proportionality as kx, kθ:

7.2.3

eo = k x x ðtranslationÞ

ð7:2aÞ

eo = kθ θ ðrotationÞ

ð7:2bÞ

Ultrasonic Sensors

Ultrasonic sensors are commonly used in measuring distance of an object from the sensor in the range of a few centimeters to about 1 m using ultrasound wave (of frequency around 40 kHz). An ultrasonic sensor consists of an ultrasound wave transmitter and a receiver. The time taken by the ultrasound wave from the transmitter to the receiver, after being reflected from an object in front of the sensor is proportional to the distance of the object from the sensor. Distance (d, cm) is calculated using the speed of sound in air (Vsound, m/s) and the time (t, μs) elapsed between transmission and reception as       m t × 10 - 6 s cm 344:6  - 4  102 10 d = V sound t = s 2 m 2

7.2.4

cm

ð7:3Þ

Tachogenerators

Tachogenerators are widely used in measuring rotational speed for control and measurement systems. The output voltage (e0) of a tachogenerator is proportional to the rotational speed (ω), with the constant of proportionality kω: eo = k ω ω

ð7:4Þ

7.3

Stress and Strain Measurement Using Strain Gages

7.3

165

Stress and Strain Measurement Using Strain Gages

Stress measurement is quite common in mechanical engineering applications to make sure the mechanical components are working within the safe range of stress. Stress is most commonly measured using electrical resistance strain gages. Strain gages are also quite commonly used to measure other variables like force (through measurement of strain of the loaded flexible member), pressure (through measurement of strain of a flexible diaphragm), and temperature (by measurement of strain due to thermal effects). In this section, details of characteristics of a strain gage and signal conditioning for the measurement of strain under different conditions are presented.

7.3.1

Electrical Resistance Strain Gage

Strain gages in form of metal foil in flexible protected cover that can be placed and pasted on a surface of a test sample are quite widely used. The relationship between the variable (x) to be measured to the output signal (Vout) can be understood by examining the individual subsystems. As an example of measurement of load (force) applied at the tip of a cantilever beam with a strain gage pasted near the root of the beam, the load (P) results in stress (σ) and strain (E) on the beam cross-section near the strain gage. A schematic diagram of a load measurement system with a strain gage pasted on the top surface of a cantilever near the root is shown in Fig. 7.1 along with a Wheatstone bridge and a difference amplifier: Assuming a cantilever beam of rectangular cross-section with width b, thickness, h, and length Lbeam, the load (P) at the tip and the stress (σ) on the top surface of the beam near the root can be expressed as

Fig. 7.1 Schematic diagram of a load measurement system (transverse loading) using a strain gage, a Wheatstone bridge, and a difference amplifier

166

7

Sensors

Fig. 7.2 A generalized conductor of rectangular cross section

σ=

PLbeam

h 2

bh3 12

=6

PLbeam bh2

ð7:5Þ

The strain on the strain gage is assumed to be the same as that on the top surface of the beam underneath the strain gage. The strain (E) can be expressed using Hooke’s law: E=

σ PL = 6 beam E Ebh2

ð7:6Þ

where E is the elasticity constant for the material of the beam. Strain Gage  Relations  The strain E = ΔL in the strain gage can be related to the relative change in its ΔR L resistance R : A generalized conductor of length L, width w, and thickness t is shown in Fig. 7.2. The relation can be derived considering the expression of resistance (R) of the strain gage in terms of resistivity (ρ) of its material, total length (L ) of strain gage wire, cross-section width (w), and thickness (t): R=

ρL wt

ð7:7Þ

To study the effect of change in length on the change in resistance for the strain gage, it is necessary to take the differential of Eq. (7.7). Taking natural logarithm of both sides of Eq. (7.7) results in Eq. (7.8): lnðRÞ = ln ðρÞ þ lnðLÞ - lnðwÞ - lnðt Þ

ð7:8Þ

Taking the differential of both sides of Eq. (7.8) and applying d ðln xÞ = dxx, x : R, ρ, w, t , Eq. (7.9) is obtained: dR dρ dL dw dt = þ R ρ L w t

ð7:9Þ

  and thickness the relative changes in width Δw w ΔtApplying Poisson’s ratio(ν),  ΔL related to strain strain gage, in Eqs. (7.10) and (7.11) as can be for the t L ΔL Δw = -ν L w

ð7:10Þ

7.3

Stress and Strain Measurement Using Strain Gages

167

Δt ΔL = -ν t L

ð7:11Þ

Replacing differential (dx) with finite change (Δx) for each of the variables in Eq. (7.9) and applying Eqs. (7.10) and (7.11), Eq. (7.12) is obtained: ΔR Δρ ΔL ΔL ΔL = þ þν þν R ρ L L L  Using the definition of strain E =

ΔL L



ð7:12Þ

, the Eq. (7.12) can be written as

ΔR Δρ = þ E ð1 þ 2ν Þ R ρ The ratio of relative change in resistance ΔR R

E

ΔR R

= 1 þ 2ν þ

ð7:13Þ

and strain (E) can be written as

Δρ ρ

ð7:14Þ

E

The terms on the right-hand side of Eq. (7.14) depend on the material   of the strain gage, in terms of Poisson’s ratio (ν) and piezoresistive effect

Δρ ρ

E

and can be

considered constant over the normal operating range of the strain gage. The ratio ΔR R E is specified for commercially available strain gages. The ratio is known as gage factor (GF): GF =

ΔR R

ð7:15Þ

E

Equation (7.15) can be used to obtain relative change in resistance strain (E) for the strain gage: ΔR = ðGF Þ E R

ΔR R

to its

ð7:16Þ

Gage factor for a thin film strain gage is close to 2, and nominal resistance (R) is close to 120 Ω. In addition to gage factor and resistance, transverse sensitivity of strain gages is specified to account for the effect of transverse strain (perpendicular to the measuring strain axis) on the strain gage. In general, the transverse sensitivity is usually quite  small, about 1% of the axial sensitivity. The relative change of is quite small assuming the strain is in general quite small in the resistance ΔR R range of 1–100 μStrain (microstrain).

168

7.3.2

7

Sensors

Wheatstone Bridge

  of the strain gage can be detected using the The small change of resistance ΔR R strain gage as one of the resistors in a Wheatstone bridge. The Wheatstone bridge is constructed by connecting the network of four resistors (Ri, i = 1,. . . , 4) with a DC power supply (Vin) between two terminals (A, B) and measuring the output voltage (Vout) across the other two terminals (C, D), as shown in Fig. 7.3: The currents (Ii) can be related in terms of input voltage (Vin) between the terminals A and B and the resistances (Ri, i = 1, . . . , 4) as I1 = I4 =

V in R1 þ R4

ð7:17Þ

I2 = I3 =

V in R2 þ R3

ð7:18Þ

The output voltage (Vout) can be expressed as V out = V C - V D V out = ðV in- I 1 R1 Þ - ðV in- I 2 R2 Þ = I 2 R2 - I 1 R1     R2 R2 R4 - R1 R3 R1 = V in V out = V in R2 þ R3 R1 þ R4 ðR1 þ R4 ÞðR2 þ R3 Þ

ð7:19Þ ð7:20Þ ð7:21Þ

For the balanced bridge, Vout = 0, R2 R4 - R1 R3 = 0

ð7:22Þ

R1 R2 = R4 R3

ð7:23Þ

Alternatively,

Fig. 7.3 Schematic diagram of a Wheatstone bridge and a difference amplifier

7.3

Stress and Strain Measurement Using Strain Gages

169

In general, for the balanced bridge with Vout = 0, all four resistors are taken equal, Ri = R, i = 1, . . . , 4. The effects of change in resistances, Ri = Ri+ΔRi, can be expressed in the output voltage Vout:  V out = V in

ðR2 þ ΔR2 ÞðR4 þ ΔR4 Þ - ðR1 þ ΔR1 ÞðR3 þ ΔR3 Þ ðR1 þ ΔR1 þ R4 þ ΔR4 ÞðR2 þ ΔR2 þ R3 þ ΔR3 Þ

 ð7:24Þ

In general, initial resistances are equal, Ri = R, i = 1, . . . , 4, and the relative ΔRi i changes ΔR R are quite small, e.g., for R = 120 Ω, R ≈ 0:01. Under these conditions, i the Eq. (7.24) can be expressed in terms of first-order changes ΔR R , neglecting terms ΔR 2 i involving R as V out =

V in ðΔR1 - ΔR2 þ ΔR3 - ΔR4 Þ 4R

ð7:25Þ

In Eq. (7.25), the changes in resistances (ΔRi, i = 1, . . . , 4) appear with alternating signs, meaning the placement of the strain gages (with multiple strain gages) on the loaded test sample and on the Wheatstone bridge needs careful consideration to maximize the output voltage. In general, the output voltage is amplified through a difference amplifier. The output voltage terminals of the Wheatstone bridge are connected through resistors R5 to the inverting and the noninverting inputs of a difference amplifier and feedback resistor R6, connected between the op-amp output to the inverting input, and a voltage divider resistor R6 connected to the noninverting input, as shown in Fig. 7.3. The amplified voltage Vout,A of the difference amplifier can be expressed as V out,A = A

V in ðΔR1 - ΔR2 þ ΔR3 - ΔR4 Þ 4R

ð7:26Þ

where the difference amplifier gain (A) is given: A=

R6 R5

ð7:27Þ

The causal relation between input and output of each subsystem in the load measurement system of Fig. 7.1 using a strain gage, a Wheatstone bridge, and a difference amplifier is represented in Fig. 7.4. The corresponding mathematical relations are presented in Eqs. (7.6, 7.16, 7.25, and 7.26).

∆ P

Structural member

Strain Gage



Wheatstone bridge

Fig. 7.4 Representation of causal relations in a load measurement system

∆ Difference amplifier

,

170

7

Sensors

Fig. 7.5 Schematic diagram of a load measurement system (axial loading) using a strain gage, a Wheatstone bridge, and a difference amplifier

7.3.3

Member with Axial Load

For a test sample in axial loading, the stress is the same across any cross section, so the strain gages placed anywhere parallel to the loading axis should have the same strain. A schematic diagram of an axially loaded member with one strain gage bonded on the top surface along with a Wheatstone bridge and a difference amplifier, similar to that in Fig. 7.1 for transverse loading, is shown in Fig. 7.5: One Strain Gage One strain gage can be placed as any of the arms (R1) of the initially balanced Wheatstone bridge with all other resistances remaining constant. Applying ΔR1 = ΔR and ΔR2 = ΔR3 = ΔR4 = 0 in Eq. (7.26), the amplified output voltage can be expressed as V out,A = A

V in ðΔRÞ 4R

ð7:28Þ

Two Strain Gages A maximum of two strain gages can be used on a test sample in axial loading, and strain gage terminals can be connected to opposing arms of a Wheatstone bridge for maximizing the voltage output. Two strain gages can be placed on the opposing arms (R1, R3) or (R2, R4) of the Wheatstone bridge. Applying ΔR1 = ΔR3 = ΔR and ΔR2 = ΔR4 = 0 or ΔR2 = ΔR4 = ΔR and ΔR1 = ΔR3 = 0 in Eq. (7.26), the amplified output voltage can be expressed as V out,A = A

V in ð2ΔRÞ 4R

ð7:29Þ

7.3

Stress and Strain Measurement Using Strain Gages

7.3.4

171

Member with Transverse Load

Strain depends on the placement of strain gages on the test sample in transverse loading. There are four possible combinations of strain gages on the test sample (top or bottom surface) as well as on the Wheatstone bridge (Ri, i = 1, . . . , 4). One Strain Gage With one strain gage, the strain gage can be placed on either top or bottom surface of the test sample and used as any of the arms (R1) of the initially balanced Wheatstone bridge with all other resistances remaining constant. Applying ΔR1 = ΔR and ΔR2 = ΔR3 = ΔR4 = 0 in Eq. (7.26), the amplified output voltage can be expressed as V out,A = A

V in ðΔRÞ 4R

ð7:30Þ

Two Strain Gages With two strain gages, each strain gage can be placed on either surface (top and bottom) of the test sample and used as two adjacent arms (R1, R2) or (R3, R4) of the initially balanced Wheatstone bridge with all other resistances remaining constant. Applying ΔR1 = -ΔR2 = ΔR and ΔR3 = ΔR4 = 0 or ΔR3 = -ΔR4 = ΔR and ΔR1 = ΔR2 = 0 in Eq. (7.26), the amplified output voltage can be expressed as V out,A = A

V in ð2ΔRÞ 4R

ð7:31Þ

Alternatively, both strain gages can be placed side by side on the same surface (top or bottom) of the test sample and used as two opposing arms (R1, R3) or (R2, R4) of the initially balanced Wheatstone bridge with all other resistances remaining constant. Applying ΔR1 = ΔR3 = ΔR and ΔR2 = ΔR4 = 0 or ΔR2 = ΔR4 = ΔR and ΔR1 = ΔR3 = 0 in Eq. (7.26), the amplified output voltage can be expressed as V out,A = A

V in ð2ΔRÞ 4R

ð7:32Þ

Three Strain Gages With three strain gages, two strain gages can be placed on the top surface of the test sample, and the third strain gage is placed on the bottom surface. The first two strain gages are used as two opposing arms (R1, R3) or (R2, R4) and the third strain gage is used as adjacent arm (R2 or R4) or (R1, or R3) of the initially balanced Wheatstone bridge with the resistance remaining constant.

172

7

Sensors

Applying ΔR1 = -ΔR2 = ΔR3 = ΔR and ΔR4 = 0 or ΔR2 = -ΔR1 = ΔR4 = ΔR and ΔR3 = 0 in Eq. (7.26), the amplified output voltage can be expressed as V out,A = A

V in ð3ΔRÞ 4R

ð7:33Þ

Four Strain Gages With four strain gages, pairs of strain gage can be placed on either surface (top and bottom) of the test sample, and each pair is used as opposing arms (R1, R3) and (R2, R4) of the initially balanced Wheatstone bridge. Applying ΔR1 = -ΔR2 = ΔR3 = -ΔR4 = ΔR in Eq. (7.26), the amplified output voltage can be expressed as V out,A = A

V in ð4ΔRÞ 4R

ð7:34Þ

The sensitivity of output voltage for the same load becomes proportional to the number of strain gages used in case of transverse loading. Example 7.1 A cantilever steel specimen of circular cross section with length L = 300 mm and diameter d = 18 mm is subjected to a transverse load P = 100 N at its tip. A strain gage with an original resistance of 120 Ω and a gage factor of 2.15 is attached to the top surface of the cantilever near its root. The strain gage is used as an active arm of an originally balanced Wheatstone bridge with resistances R = 120 Ω and input voltage of Wheatstone bridge Vin = 10 V. The output of the Wheatstone bridge is amplified through a difference amplifier of gain A = 10. The schematic of the measurement system is similar to Fig. 7.1. Find stress, strain, the change in resistance of the strain gage, the output voltage of the Wheatstone bridge, Vout, the amplified output voltage, Vout,A, and the sensitivity of the measurement system (mV/MPa). Assume E for steel as 200 Gpa. Solution Stress at the top surface of the cantilever near its root can be obtained, similar to Eq. (7.5), as

σ=

PL

d 

2 πd4 64

= 32

100 ðN Þð0:300 mÞ PL = 32 = 52:397 × 106 Pa = 52:397 MPa 3 πd π ð0:018 mÞ3

Strain can be obtained from Eq. (7.6) as E =

σ E

= 2:6198 × 10 - 4:

Relative change in resistance ΔR R can be obtained from Eq. (7.15) GF =

ΔR R

E

as

ΔR = E GF = 2:6198 × 10 - 4 ð2:15Þ = 5:6326 × 10 - 4 R Change in resistance of the strain gage ΔR = R 10 - 4 = 0:0676 Ω

ΔR R

= ð120 ΩÞ5:6326 ×

7.4

Vibration and Acceleration Measurement

173

Output voltage Vout can be obtained from Eq. (7.25) with ΔR1 = ΔR andΔR2 = ΔR3 = ΔR4 = 0 V in ðΔR1 - ΔR2 þ ΔR3 - ΔR4 Þ 4R   10V V ΔR = in = 5:6326 × 10 - 4 = 0:00141 V = 1:41 mV 4 R 4 V out =

Amplified voltage output can be obtained from Eq. (7.26) as V out,A = A V out = 14:1 mV Sensitivity can be obtained as k =

7.4

V out,A 14:1 mV = = 0:2687 mV=MPa σ 52:397 MPa

Vibration and Acceleration Measurement

Measurement of amplitudes of displacement, velocity, and acceleration of periodic movement of machine components is broadly termed as vibration measurement. The vibration measuring instruments can be modeled using a single degree of freedom mass-spring-damper system, on a vibrating object, as shown in Fig. 7.6: A mass-spring-damper system with mass (m) supported on a spring with spring stiffness (k) and a damper with a damping coefficient (c) is placed on a vibrating object, xi(t) being the input displacement, and xo(t) being the displacement of the seismic mass (m). Considering the force due to the spring, -k( xo(t) - xi(t)), and the force due to the damper, - cð x_ 0 ðt Þ - x_ i ðt ÞÞ, the equation of motion can be written as ð" þÞ

X

F x = m €x0 ðt Þ

- kð xo ðt Þ - xi ðt ÞÞ - cð x_ 0 ðt Þ - x_ i ðt ÞÞ = m €x0 ðt Þ

Fig. 7.6 Schematic diagram of a mass-springdamper system on a vibrating object

ð7:35Þ ð7:36Þ

174

7

Sensors

Equation (7.36) can be rewritten in terms of relative displacement, xr(t) in Eq. (7.38): xr ðt Þ = xo ðt Þ - xi ðt Þ

ð7:37Þ

m €xr ðt Þ þ c x_ r ðt Þ þ k xr ðt Þ = - m €xi ðt Þ

ð7:38Þ

Equation (7.38) can be rewritten as €xr ðt Þ þ Substituting mc = 2ζωn

k m

c k x_ ðt Þ þ xr ðt Þ = - €xi ðt Þ m r m

ð7:39Þ

= ω2n , Eq. (7.39) can be written as

€xr ðt Þ þ 2ζωn x_ r ðt Þ þ ω2n xr ðt Þ = - €xi ðt Þ

ð7:40Þ

where the undamped natural frequency is given as rffiffiffiffi k ωn = m

ð7:41Þ

And the damping ratio is given as c ζ = pffiffiffiffiffiffi 2 km

ð7:42Þ

The damping ratio (ζ) can be either ζ < 1, underdamped system; ζ = 0, undamped system; or ζ > 1, overdamped system. In general, the damping ratio for vibration measuring instruments is less than 1 (underdamped).

7.4.1

Vibration Pickups for Displacement Measurement

Equation (7.40) can be used to obtain the steady-state response of the instrument, xr(t), for sinusoidal input displacement: xi ðt Þ = X i sinðωt Þ

ð7:43Þ

xr ðt Þ = X r sinðωt - ϕÞ

ð7:44Þ

Following the procedure of Sect. 4.3.2, the frequency analysis results in the expression of the amplitude ratio AR = XXri as Xr r2 = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi Xi ð1 - r2 Þ2 þ ð2ζ rÞ2

ð7:45Þ

7.4

Vibration and Acceleration Measurement

175

where r is termed as the frequency ratio: r=

ω ωn

ð7:46Þ

and ϕ is the phase lag given as ϕ = tan - 1



2ζ r 1 - r2

 ð7:47Þ

The amplitude ratio (AR) versus frequency ratio (r = ωωn) for a vibration pick up is shown in Fig. 7.7 for different values of damping ratio (ζ): The AR versus frequency ratio (r) curve becomes nearly flat near the value of AR = 1, after certain value of frequency ratio r > rcritical. In other words, a vibrometer should be used in the flat region of the AR versus frequency ratio curve, r > rcritical. The value of the critical frequency ratio rcritical can be obtained from Eq. (7.45) to keep the value of AR within α of the ideal value of 1 as AR =

r2 Xr = 1  α = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi Xi ð1 - r 2 Þ2 þ ð2ζ rÞ2

Fig. 7.7 Frequency response of a vibrometer

ð7:48Þ

176

7

Sensors

For AR = 1+α, and damping ratio ζ < p12ffiffi, there are two real-positive solutions for frequency ratio: vffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi u      2 2 u 2 1 4ζ - 2 - 4 1 - ð1þα u - 4ζ - 2  2 Þ u   r 1,2 = t 1 2 1 - ð1þα Þ2   2 where it is assumed 4ζ2 - 2 > 4 1-

1 ð1þαÞ2

ð7:49Þ

 to keep both solutions real and

distinct. For AR = 1 - α, there is one real-positive solution for frequency ratio: vffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi u     2 2 u 2 4ζ - 2 þ 4 ð1 -1αÞ2 - 1 u 4ζ - 2 þ u   r3 = t 2 ð1 -1 αÞ2 - 1

ð7:50Þ

The maximum of the three possible solutions (r1, r2, r3), from Eqs. (7.46) and (7.47), is to be considered as the critical frequency ratio, i.e., r critical = maxðr 1 , r 2 , r 3 Þ

ð7:51Þ

Example 7.2 A vibration measuring instrument is to be selected for measuring vibration of machine running at speeds 3000 rpm to 10,000 rpm. Select the instrument (vibrometer) if α=5% and ζ =0.4. Find the actual vibration amplitude (Xi) if the vibrometer output voltage (V) is 15 mV when the   machine is operating at V mV . 2700 rpm. Use the sensitivity of the instrument k = X r as 10 mm Solution (a) Given α=5% and ζ =0.4, find ωn. Substituting the values of α=0.05 and ζ =0.4 in Eq. (7.48), r2 1  0:05 = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð1 - r 2 Þ2 þ ð2ζ rÞ2 The values of frequency ratio (r) can be obtained as (0.8347, 0.8812, 3.7218). The critical frequency ratio is selected as the maximum of these values based on Eq. (7.51): r critical = max ð0:8347, 0:8812, 3:7218Þ = 3:7218

7.4

Vibration and Acceleration Measurement

177

Minimum of the given speed range is 3000 rpm ωmin = r critical =

3000 60 ð2π Þ = 314:16

rad=s

314:16 rad=s ωmin ω or ωn = min = = 84:4106 rad=s 3:7218 ωn r critical

(b) Given ζ =0.4, ωn = 84:4106 rad s , ω = 2700 rpm = r=

2700 60 ð2π Þ = 282:86

rad=s

282:86 rad=s ω = = 3:3496 ωn 84:4106 rad=s

r ffi = 1:0620 Substituting r = 3.3496 in Eq. (7.45), XXri = pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 2 2 2 2

ð1 - r Þ þð2ζ rÞ

From V = 15 mV, k = Input amplitude

7.4.2

V mV 15 mV = 10 = 1:5 mm: , Xr = Xr mm 10 mV=mm

Xr Xr 1:5 mm = 1:0620, X i = = = 1:4125 mm: Xi 1:062 1:062

Accelerometers

For the measurement of acceleration, the input acceleration is represented as €xi ðt Þ = - X i ω2 sinðωt Þ = Ai sinðωt Þ

ð7:52Þ

Equation (7.40) can be written as €xr ðt Þ þ 2ζωn x_ r ðt Þ þ ω2n xr ðt Þ = Ai sinðωt Þ

ð7:53Þ

The amplitude ratio, under steady state, can be obtained, following the procedure of Sect. 4.3.2, as AR =

ω2n X r 1 = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi Ai 2 ð1 - r Þ2 þ ð2ζ rÞ2

ð7:54Þ

The frequency response graphs, amplitude ratio (AR) versus frequency ratio (r = ωωn ) and phase angle (ϕ) versus frequency ratio, for an accelerometer are shown in Figs. 7.8 and 7.9, respectively.

178

Fig. 7.8 Frequency response of an accelerometer

Fig. 7.9 Variation of phase angle over frequency ratio for an accelerometer

7

Sensors

7.4

Vibration and Acceleration Measurement

179

The AR versus frequency ratio (r) curve for an accelerometer remains nearly flat near the value of AR close to 1, up to certain value of frequency ratio r < rcritical. In other words, an accelerometer should be used in the flat region of the AR versus frequency ratio curve, r < rcritical. The value of the critical frequency ratio rcritical can be obtained from Eq. (7.54) to keep the value of AR within +α of the ideal value of 1 as AR =

ω2n X r 1 = 1 þ α = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi Ai ð1 - r 2 Þ2 þ ð2ζ rÞ2

ð7:55Þ

For AR = 1+α, and damping ratio ζ < p12ffiffi, there are two real-positive solutions for frequency ratio:

r 1,2 =

vffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi u     2 2 u  2 1 u - 4ζ - 2  4ζ 2 4 1 2 t ð1þαÞ 2

ð7:56Þ

The minimum of the two possible solutions (r1, r2) from Eq. (7.56) is to be considered as the critical frequency ratio, i.e., rcritical = minðr 1 , r 2 Þ

ð7:57Þ

Example 7.3 An accelerometer is to be selected for measuring vibration of machine running at speeds 3000 rpm to 10,000 rpm. Select the accelerometer if α = 5% and ζ =0.4. Find the actual acceleration amplitude (Ai) if the accelerometer output voltage (V) is 15 mV when is operating at ω =11,000 rpm. Use the sensitivity of  the machine  V mV the instrument k = X r ωn 2 as 10 mm=s 2 : Solution (a) Given α=5% and ζ =0.4, find ωn. Substituting the values of α = 0.05 and ζ =0.4 in Eq. (7.55), 1 1 þ 0:05 = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð1 - r 2 Þ2 þ ð2ζ rÞ2 The values of frequency ratio (r) can be obtained as (1.1348 0.2687). The critical frequency ratio is selected as the minimum of these values based on Eq. (7.57): r critical = minð1:1348

0:2687Þ = 0:2687

Maximum of the given speed range is 10,000 rpm ωmax =

10000 60 ð2π Þ = 1047:2

rad=s

180

7

r critical =

1047:2 rad=s ωmax ω rad or ωn = max = = 3897:5 = 620:3 Hz 0:2687 s ωn r critical

(b) Given ζ =0.4, ωn = 3897:5 rad s , ω = 11000 rpm = r=

From V = 15 mV, k = Input amplitude

11000 60 ð2π Þ = 1151:9

rad=s

1151:9 rad=s ω = = 0:2956 ωn 3897:5 rad=s

Substituting r = 0.2956 in Eq. (7.54),

7.4.3

Sensors

ω2n X r Ai

1 ffi = 1:0607. = pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 2 2 2 ð1 - r Þ þð2ζ rÞ

V mV 15 mV = 10 , ω2n X r = = 1:5 mm=s2 : mV ω2n X r mm=s2 10 mm=s 2

ω2n X r ω2 X r 1:5 mm=s2 = 1:0607, Ai = n = = 1:4142 mm=s2 : Ai 1:0607 1:0607

Piezoelectric Accelerometers

For piezoelectricaccelerometers, damping ratio ζ is negligible. The Eq. (7.50) for  ω2n X r amplitude ratio Ai in terms of frequency ratio r = ωωn can be simplified for a piezoelectric accelerometer as AR =

ω2n X r 1 = Ai 1 - r2

ð7:51Þ

where r < 1. The operating range of an accelerometer is selected to keep the operating curve (AR versus r) nearly flat with AR within α percent of the ideal value of 1 as AR =

ω2n X r 1 =1 þ α= Ai 1 - r2 rffiffiffiffiffiffiffiffiffiffiffi α r= 1þα

ð7:52Þ ð7:53Þ

For a typical value of α = 5% or 0.05 and r = 0.2182, it means that the operating range of the accelerometer should be 0 < r < 0.2182 to maintain the amplitude ratio (AR) within the range 1 < AR < 1.05.

7.4

Vibration and Acceleration Measurement

7.4.4

181

Charge Amplifiers

Piezoelectric accelerometers are used in dynamic measurement conditions in combination with charge amplifiers. A charge amplifier circuit connected to the output of a piezoelectric accelerometer is shown in Fig. 7.10 where the piezoelectric accelerometer output is represented as a current source k q x_ r ðt Þ. kq is the charge sensitivity of the piezoelectric accelerometer (quartz crystal), and x_ r ðt Þ is the rate of change of the relative displacement of the seismic mass with respect to the base. The equivalent capacitance of the crystal and the connecting cables can be represented as Ceq. The inverting input of the op-amp is connected to the accelerometer output and is also connected to the op-amp output, V0(t),through the feedback path consisting of Rf and Cf in parallel, and the op-amp noninverting input is grounded, as shown in Fig. 7.10: The current through the equivalent capacitance is negligible. Applying ideal op-amp model assumptions, the voltage at inverting input V- can be close to the noninverting input V+ = 0, V - = V þ = 0, or V A = 0

ð7:54Þ

The current in the input path can be expressed as ii ðt Þ = k q x_ r ðt Þ

ð7:55Þ

The currents (i1(t), i2(t)) in the feedback path through Rf and Cf can expressed as in Eqs. (7.56) and (7.57), respectively: i1 ðt Þ =

Fig. 7.10 Schematic of a charge amplifier connected to the output of a piezoelectric accelerometer

ð V o ðt Þ - V A Þ V o ðt Þ ≈ Rf Rf

ð7:56Þ

182

7

i 2 ðt Þ = C f

Sensors

d d ðð V o ðt Þ - V A ÞÞ ≈ Cf V o ðt Þ dt dt

ð7:57Þ

Applying Kirchhoff’s current law (KCL) at node A and applying ideal op-amp assumption of no current flowing to the op-amp at A, the relations of the currents (ii(t), i1(t), i2(t)) can be obtained as i i ðt Þ þ i 1 ðt Þ þ i 2 ðt Þ = 0

ð7:58Þ

Using Eqs. (7.55, 7.56, and 7.57) in Eq. (7.58), the relationship between the op-amp output voltage Vo(t) and the accelerometer seismic mass relative displacement xr(t) in Eq. (7.59): τ

dV o ðt Þ dx ðt Þ þ V o ðt Þ = - kq τ r dt dt

where τ = RfCf is termed time constant of the charge amplifier and k q = modified charge constant for the charge amplifier. In s-domain, the Eq. (7.59) can be represented as a transfer function:

ð7:59Þ kq Cf

V o ðsÞ τs = - kq 1 þ τs X r ðsÞ

is the

ð7:60Þ

The frequency response of the   charge amplifier can be obtained using s = jω. The amplitude ratio AR= kV X0 r can be expressed as q

AR =

τω V0 = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi kq X r 1 þ ðτωÞ2

For low-frequency range such that τω ≪ 1, AR ≈ frequency range τω ≫ 1, AR ≈ τω τω = 1.

7.4.5

τω 1

ð7:61Þ

= τω, whereas for higher-

A Piezoelectric Accelerometer with a Charge Amplifier

The characteristics of a piezoelectric accelerometer and a charge amplifier combination can be expressed by cascading the individual characteristic Eqs. (7.51) and (7.61): ω2n X r V 0 τω 1 qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi : = Ai k q X r 1 - r2 1 þ ðτωÞ2

ð7:62Þ

7.4

Vibration and Acceleration Measurement

183

Vo The left-hand side of Eq. (7.62) can be simplified as kA where k is termed as i voltage sensitivity of the piezoelectric accelerometer-charge amplifier combination mV and is expressed in m=s 2:

τω V0 1 qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi = kAi 1 - r 2 1 þ ðτωÞ2

ð7:63Þ

The amplitude ratio (AR) versus frequency ratio (r = ωωn ) for a piezoelectric accelerometer with a natural frequency (ωn) of 100 kHz (314,000 rad/s) and charge amplifier time constant (τ) of 0.1 ms or τωn = 31.4 is shown in Fig. 7.11. The characteristics of the piezoelectric accelerometer-charge amplifier combination can be studied over different frequency ranges. For low-frequency range such that τω ≪ 1 and r ≪ 1, the behavior is dominated by the charge amplifier as the AR V0 ≈ 1: τω of the accelerometer is close to 1, i.e., kA 1 = τω. Whereas for frequency range i τω ≫ 1, the behavior is dominated by the accelerometer as the AR of the charge V0 1 ≈ 1 -1 r2 : τω amplifier is close to 1, i.e., kA τω = 1 - r 2 . The amplitude ratio of Eq. (7.63) i can be shown in Fig. 7.11 for the piezoelectric accelerometer-charge amplifier combination. The operating frequency range for a piezoelectric accelerometer-charge amplifier can be obtained keeping the AR within α of the ideal flat value of 1, i.e., in Eq. (7.63):

Fig. 7.11 Frequency response for a piezoelectric accelerometer-charge amplifier combination

184

7

1 τω qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi = 1  α 1 - r2 1 þ ðτωÞ2

Sensors

ð7:64Þ

V0 = 1 - α with accelerometer For finding the lower limit of the frequency ωL, kA i part in Eq. (7.64) can be approximated close to 1 as

τωL ffi =1-α 1: qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 1 þ ðτωL Þ2

ð7:64Þ

1 1-α qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi τ 1 - ð1 - αÞ2

ð7:65Þ

ωL =

V0 Similarly, for finding the upper limit of the frequency ωH, kA = 1 þ α with i charge amplifier part in Eq. (7.64) can be approximated close to 1 for τω ≫ 1 as

1 :1 = 1 þ α 1 - r2 rffiffiffiffiffiffiffiffiffiffiffi α ωH = ωn 1þα

ð7:66Þ ð7:67Þ

Example 7.4 For a piezoelectric accelerometer-charge amplifier combination, find the frequency range in terms of the time constant τ = 10 ms of the charge amplifier and the natural frequency of the piezoelectric accelerometer ωn = 100 kHz for α = 0.05. Solution Given α = 0.05, =10 ms, ωn = 100 kHz. Applying these values in Eq. (7.65), the lower limit of the frequency range is obtained as ωL =

1 rad 1 1-α 1 - 0:05 qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi = 304:2 = 48:4 Hz -3 s τ 1 - ð1 - αÞ2 10 × 10 s 1 - ð1 - 0:05Þ2

Applying the values in Eq. (7.67), the upper limit of the frequency range is obtained as ωH = ωn

rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi rffiffiffiffiffiffiffiffiffiffiffi 0:05 α = ð100 kHzÞ = 21:812 kHz 1 þ 0:05 1þα

The frequency range of the piezoelectric accelerometer-charge amplifier combination is 48.4 Hz–21.812 kHz.

7.5

Temperature Measurement

7.5

185

Temperature Measurement

Temperature measurement is quite widespread from day-to-day life to various engineering applications. Common sensors for temperature measurement in engineering applications include resistance temperature detectors (RTD), thermistors, and thermocouples. Common temperature scales used include Celsius (°C), Kelvin (K), Fahrenheit (°F), and Rankine (°R), of which the first two are use in SI system of units, and the last two are in conventional system of units. Of these, the first and the third (temperature °C and °F) are used for relative temperature, and the rest (K and °R) are used for absolute thermodynamic temperature. The temperature scales are related to each other as expressed in Eqs. (7.68, 7.69 and 7.70):

7.5.1

T K = T C þ 273:15   9 TF = T þ 32 5 C

ð7:68Þ ð7:69Þ

T R = T F þ 459:67

ð7:70Þ

Resistance Temperature Detectors

Resistance temperature detectors (RTDs) are hermetically sealed metallic resistive elements, and the resistance change due to change in temperature is detected to measure temperature. The resistance-temperature relationship can be expressed as RT = R0 ð1 þ αðT- T 0 ÞÞ

ð7:71Þ

where RT is the resistance at temperature T, R0 is the resistance at temperature T0, and α is the resistance coefficient. Platinum RTD is commonly used due to a wide operating range of temperature (-220 °C to 750 °C), resistance to oxidation, and linear characteristics. The resistance coefficient (α) for platinum RTD is 0.00385 Ω/ ° C. The sensitivity of RTDs is relatively low due to small value of resistance coefficient. The change in resistance can be measured through op-amp circuits. A typical op-amp circuit using RTD for temperature measurement is shown in Fig. 7.12 where the op-amp output voltage Vout can be expressed in terms of fixed resistances R1, R2, R3, and RF and the temperature measuring RTD (RT). The temperature T can in turn be obtained from the value of RT using Eq. (7.71).

186

7

Sensors

Fig. 7.12 An op-amp circuit for measurement of temperature using RTD

Fig. 7.13 An op-amp circuit for measurement of temperature using thermistor

7.5.2

Thermistors

A thermistor is a semiconductor device for which resistance changes exponentially with temperature, as given in Eq. (7.72):  R = R0 e

β

 1 1 T - T0

ð7:72Þ

where R is the resistance at temperature T (K), R0 is the resistance at temperature T0 (K ), and β (K ) is termed characteristic temperature of the material of the thermistor. The sensitivity of thermistors is higher than that of RTDs. However, thermistor have nonlinear characteristics and narrower temperature range than RTDs. Thermistors are used in special purpose for relatively high temperature applications. A typical op-amp circuit to measure temperature using a thermistor is shown in Fig. 7.13. The thermistor resistance RT can be related to the output voltage Vout, which in turn can be related to the temperature (T) of the thermistor.

7.5

Temperature Measurement

187

Fig. 7.14 Schematic of a typical thermocouple

Fig. 7.15 Illustration of law of leadwire temperatures for thermocouples

7.5.3

Thermocouples

Thermocouples are widely used in engineering applications due to the simple construction, wide temperature range, and low cost. However, sensitivity of thermocouples is relatively low. Thermocouples work on the principle of Seebeck effect. A typical thermocouple is shown in Fig. 7.14: For a thermocouple, shown in Fig. 7.14, constructed of two dissimilar materials (A, B) with two thermoelectric junctions at two different temperatures T1 and T2, the thermoelectric voltage output Vois proportional to the difference of two junction temperatures: V 0 = k ðT 1- T 2 Þ

ð7:73Þ

where k is termed sensitivity of the thermocouple, and it depends on the combination of materials of the thermocouple. There are several commercially available thermocouples with documented characteristics; the common designation of thermocouples include J and K. Thermocouples are designed and used applying a set of basic thermocouple laws. 1. Law of lead wire temperatures. The thermoelectric voltage of a thermocouple constructed of two different materials with two junctions at different temperatures depends on the junction temperatures T1 and T2 and is independent of the temperatures (T3, T4, T5) of the lead wires away from the junctions (Fig. 7.15). 2. Law of intermediate leadwire metals. The thermoelectric voltage of a thermocouple constructed of two different materials (A, B) with two junctions at different temperatures (T1, T2) depends on the junction temperatures, not on the junctions created by an intermediate material (C) if the new junctions (AC, C-A) are kept at the same temperature (T3) (Fig. 7.16).

188

7

Sensors

Fig. 7.16 Illustration of the law of intermediate lead wire metals for thermocouples

Fig. 7.17 Illustration of the law of intermediate junction metals for thermocouples

Fig. 7.18 Illustration of the law of intermediate temperatures for thermocouples

3. Law of intermediate junction metals. The thermoelectric voltage of a thermocouple constructed of two different materials (A, B) with two junctions at different temperatures (T1, T2) depends on the junction temperatures, not on the junctions created by an intermediate material (C) if the new junctions (AC, C-B) are kept at the same temperature (T1 = T3) (Fig. 7.17). 4. Law of intermediate temperatures. The thermoelectric voltage of a thermocouple constructed of two different materials (A, B) with a pair of junctions at temperatures (T1, T3) is the same as that of two pairs of junctions of the same material combination (A, B) at temperatures (T1, T2) and (T2, T3) (Fig. 7.18). V 1-3 = V 1-2 þ V 2-3

ð7:74Þ

5. Law of intermediate metals. The thermoelectric voltage produced by a thermocouple of two materials (A, B) is the same as the sum of voltages produced by the thermocouples (A, C) and (B, C) with another material (C), as long as the junctions are at the same pair of temperatures (T1, T2) (Fig. 7.19). V A=B = V A=C þ V B=C

ð7:75Þ

A standard thermocouple configuration with a measuring junction and a reference junction is shown in Fig. 7.20. Thermocouple junctions are made of metals A and B, and the terminals are made of metal C. An ice bath (at 0 °C) is commonly used as a reference temperature.

7.5

Temperature Measurement

189

Fig. 7.19 Illustration of the law of intermediate metals for thermocouples Fig. 7.20 Standard thermocouple configuration

Fig. 7.21 Schematic of a thermopile

7.5.3.1

Thermopile in Series

To increase the sensitivity, a group of (N ) thermocouples are used in series with one set of junctions at one temperature (T ) and the other set of junctions at the reference temperature (Tref), as shown in Fig. 7.21. The group of thermocouples is termed thermopile. The voltage output of the thermopile is obtained adding the voltage from each pair of junctions at temperatures (T, Tref): Vo =

XN i=1

V i = k:N ðT- T ref Þ

ð7:76Þ

where k represents the sensitivity of the thermocouple and N is the number of junction pairs for the thermopile.

7.5.3.2

Thermopile in Parallel

Alternatively, a thermopile consisting of N junction pairs can be used in parallel such that the measuring junction of each junction pair is placed at temperature Ti and the other junction reference temperature (Tref). The voltage output of the thermopile is obtained averaging the voltage from each pair of junctions at temperatures (Ti, Tref):

190

7

Vo =

PN

i = 1V i

N

=

PN

i = 1 k:ðT i

- T ref Þ

N

Sensors

ð7:77Þ

where k represents the sensitivity of the thermocouple and N is the number of junction pairs for the thermopile. Example 7.5 A J-type thermocouple is used in a standard two-junction thermocouple configuration with a reference temperature of 50 °C. Find the measurement temperature if the measured voltage is 35 mV. Obtain the measured voltage if the reference temperature is changed to 0 °C for the same measurement temperature. Solution Given Tref = 50 °C, Vo = 35 mV, thermocouple type J. Sensitivity k = 0.054 mv/°C (from Table of J-type thermocouple properties). Applying the condition for Eq. (7.73) with T2 = Tref = 50 °C, T1 = T, V 0 = k ðT- T ref Þ, 35 mV = 0:054 mV= ° C ðT- 50Þ ° C T=

35 þ 50 ° C = 698:15 ° C 0:054

For T ref = 0 ° C, T = 698:15 ° C

V 0 = k ðT- T ref Þ = 0:054

mV ð698:15 - 0Þ ° C = 37:7 mV °C

Example 7.6 A thermopile is to be designed for measuring temperature of a fluid in a process using the room temperature of 20 °C as the reference temperature. (a) Find the output voltage V0 of a 50-fold J-type thermopile when the temperature of measurement junction is 300 °C. (b) Find the number of junction pairs if the output voltage is 75.6 mV, with the measurement junction temperature of 300 °C and the reference junction temperature of 20 °C for the J-type thermopile. (c) Find the output voltage if the reference junction temperature is changed to 0 °C. (d) Repeat part (b), and the J-type thermopile is changed to E-type with the output voltage of 88.5 mV. Use sensitivity k for E-type thermocouples as 0.079 mv/°C. Solution (a) N = 50, k = 0:054 mV ° C , T = 300 ° C, T ref = 20 ° C Applying these values to the Eq. (7.76)   mV V o = k:N ðT- T ref Þ = 0:054 ð50Þð300- 20Þ ° C = 756 mV °C

7.6

Computer-Aided Analysis and Simulation of Wheatstone Bridge

191

(b) V 0 = 75:6 mV, k = 0:054 mV ° C , T = 300 ° C, T ref = 20 ° C V o = k:N ðT- T ref Þ, N =

75:6 mV Vo = mV  =5 0:054 ° C ð300 - 20Þ ° C k: T - T ref 

(c) N = 5, k = 0:054 mV ° C , T = 300 ° C, T ref = 0 ° C   mV V o = k:N ðT- T ref Þ = 0:054 ð5Þð300- 0Þ ° C = 81 mV °C (d) V 0 = 88:5 mV, k = 0:079 mV ° C , T = 300 ° C, Tref = 20 ° C V o = k:N ðT- T ref Þ, N =

7.6

Vo 88:5 mV   = =4 k:ðT - T ref Þ 0:079 mV ° C ð300 - 20Þ ° C

Computer-Aided Analysis and Simulation of Wheatstone Bridge

Example 7.1 is considered as an illustration of Matlab code. The Wheatstone bridge and the difference amplifier part of the measurement system are considered for illustration of Tinkercad simulation.

7.6.1

Analysis Using Matlab

%Example 7.1_SG_Transverse_loading clear all; clc % Parameters E=200e9; d=18e-3; P=1e2; GF=2.15; R=120; Vex=10; R5=1e3; R6=10e3; L=0.30; I=pi*d^4/64 ; % Area moment of intertia stress = P*L*(d/2)/I % stress due to load P at the tip strain =stress/E % strain dR_R =strain *GF % relative change in strain gage resistance dR/R dR1 = dR_R *R % change in strain gage resistance dR dR2=0; dR3=0; dR4=0 % dR1=dR, for all other arms dR=0 Vout = (R6/R5)*Vex*(dR1 -dR2+dR3-dR4)/(4*R) % Amplified output voltage k= Vout*1e3/(stress *1e-6) % sensitivity in mV/MPa

Results: stress = 5.2397e+07 Pa =52.397 MPa, strain = 2.6198e-04, dR_R = 5.6326e-04, dR1 = Vout,A =

0.0141 V =14.1 mV, k =

0.2687 mV/MPa

0.0676 Ω,

192

7

Sensors

Fig. 7.22 Wheatstone bridge and difference amplifier implemented on Tinkercad

7.6.2

Simulation Using Tinkercad

The Wheatstone bridge and the difference amplifier combination for Example 7.1 is implemented on Tinkercad as shown in Fig. 7.22. The Wheatstone bridge is originally with all R = 120 Ω. The change in strain gage resistance is simulated by increasing R1 by 0.0676 Ω, keeping all other resistances unchanged. The output voltage of the difference amplifier is displayed on the multimeter as 13.4 mV that is close to the calculated value from Matlab. The slight difference is due to the lower precision in Tinkercad compared to Matlab.

7.7 7.7.1

Experimental Validation Data Acquisition and Analysis Using LabVIEW and a Thermocouple

Objectives The objectives are to introduce temperature measurement with thermocouples and data acquisition using the LabVIEW DAQ Assistant and to estimate thermocouple characteristic parameters. Brief Steps In this experiment, the NI USB-TC01 thermocouple data acquisition board will be used to investigate temperature measurement, general data acquisition, and data logging in LabVIEW. The NI USB-TC01 consists of a J-type thermocouple, an amplifier, a single-channel analog data acquisition card, and a USB interface.

7.7

Experimental Validation

193

I. Construction of LabVIEW VI (a) Plug in the NI USB-TC01 and close the application that starts. Launch LabVIEW and create a blank VI. (b) Construct LabVIEW VI—front panel and block diagram panel—as shown in Fig. 7.23. Add a while loop control structure to the block diagram so that the data acquisition can occur repeatedly. Configure NI USB-TC01 for temperature measurement (on DAQ Assistant), chart waveforms, and Write to Measurement File. The DAQ Assistant VI can be found in the functions palette by selecting Express → Output → DAQ Assistant.

Fig. 7.23 LabVIEW VI for TC-01: (a) front panel and (b) block diagram panel

194

7

Table 7.1 Time response characteristics of thermocouple

Time t (sec) 0

T(t) T0

T ðt Þ - T 0 Tf - T0

0

 - ln 10

Sensors

T ðt Þ - T 0 Tf - T0



1. Configure DAQ Assistant VI is by selecting Acquire Signals → Analog Input → Temperature → Thermocouple. 2. A list of the available devices appears; expand the device associated with the NI USB-TC01, and select the available channel ai0. 3. The default acquisition mode setting for TC01 is 1 Sample (On Demand). 4. Chart axes can be configured as shown in the front panel of Fig. 7.23a. 5. Write to Measurement File can be configured to file format text (.lvm), one header only, X-value- one column only, delimiter-tabulator, and save to one file with overwrite option.

II. Estimation of Thermocouple Time Constant and Rise Time (a) Acquire time response of the thermocouple (holding the thermocouple tip firmly). (b) Export the time response data to Excel, and analyze to get the thermocouple time constant. Record time, t and Vout(t), at different points on step response graph from initial (T0) to close (about  90% of)the steady-state value (Tf). (c) Complete Table 7.1 and plot— ln 1-

T ðt Þ - T 0 Tf - T0

versus t, where T0 and Tf

denote the initial and final (steady state) temperature, respectively. Note down the slope of the trend line. Inverse of the slope is an estimate of time constant (τ) of the thermocouple. (d) Estimate rise time (tR) assuming the thermocouple behaving as a first-order system, i.e., tR = 2.303 τ. III. Estimation of Thermocouple Sensitivity (a) Reconfigure the DAQ Assistant block to measure the sensor output voltage directly by selecting to acquire an analog voltage instead of an analog temperature value. (b) Measure the temperature and the voltage output of the sensor at four conditions (melting ice bath, room, hand of group member 1 (P1), and member 2 (P2)) and complete Table 7.2. (c) Plot the voltage versus temperature data, and find a best-fit trend line for the data points. The slope of that best-fit trend line will represent the sensitivity of the thermocouple. Compare it with the sensitivity of typical J-type thermocouples.

7.7

Experimental Validation

195

Table 7.2 Data for thermocouple calibration Calibration environment Ice Room Hand (P1) Hand (P2)

Temperature, T (°C)

Voltage, Vo (mV)

Table 7.3 Summary of thermocouple characteristics Time Constant, (s)

Rise time, (s)

% Difference for

Sensitivity, k (mV/°C)

Expected Range of k (mV/ °C)

% Difference for k from midrange value

IV. Deliverables Complete Tables 7.1, 7.2 and 7.3. Lab Report Present all results including the following: 1. LabVIEW VI—front panel (with measured temperature plots on chart) and block diagram panel. 2. Time response data (Table 7.1) and graph. 3. Calibration data (Table 7.2) and calibration graph. 4. Summary of results (Table 7.3). 5. Discussion on the factors that influence time constant of a thermocouple. 6. Discussion on the factors that influence sensitivity of a thermocouple.

7.7.2

Measurement Using a Strain Gage Under Static Condition

Objectives The objectives are to use a strain gage and signal conditioning circuit and to calibrate the output voltage to the tip deflection of a cantilever. Brief Steps For this experiment, a measurement system (with transverse loading) using a strain gage, a Wheatstone bridge, and a difference amplifier, similar to Fig. 7.1, is considered under static condition. A static deflection measurement setup (with a clamp on one end and a dial gage on the other end) is used in physical laboratory experiment.

196

7

Sensors

Table 7.4 Resistance values Element Strain gage (R4 or Rg) WB R1 WB R2 WB R3 R5 R5 R6 R6

Color code

Nominal value Rn (Ω) 120 120 120 120 1k 1k 10 k 10 k

Measured value R (Ω)

% Difference

Fig. 7.24 Schematic of Wheatstone bridge and difference amplifier

I. Selection and Measurement of Resistance (a) Select resistors, and measure and record the resistance values in Table 7.4.

II. Construct Signal conditioning Circuit (a) Construct Wheatstone bridge and the difference amplifier circuit on Tinkercad, similar to Fig. 7.24. This circuit can be used for virtual simulation of strain gage (by simulating a change in strain gage resistance). In the physical laboratory setting, replace one of the resistors (top one) of Wheatstone bridge with a strain gage mounted on a steel beam by connecting the strain gage which leads to the corresponding arm of the Wheatstone bridge.

7.7

Experimental Validation

197

Table 7.5 Amplifier output voltage vs cantilever tip deflection Sl. No. 0 1 2 3 4 5 6 7 8 9 10

Tip deflection, d (mm) 0 2.54 5.08

Output voltage, Vout (mV) V0

Difference voltage, ΔVout = Vout – V0 (mV) 0

25.4

III. Collect Calibration Data (a) Take a static deflection measurement setup (with a clamp on one end and a dial gage on the other end). Place the cantilever strain gage end near the clamp (make sure the strain gage is close to the clamp but not directly under the clamp to avoid damaging the strain gage). The tip of the cantilever (on the other end) should be under the dial gage probe (the sliding link). (b) Adjust the dial gage indicator to 0 when the dial gage probe touches the cantilever tip, measure voltage (Vout, mV), and use this as the base value (V0, mV) of row 1 in Table 7.5. (c) Gradually increase the tip deflection for one complete revolution of the larger indicator (0.01 inch or 2.54 mm) and measure the voltage (Vout, mV). (d) Repeat for each tip deflection (d, mm) and complete Table 7.5. (e) Plot ΔVout (mV) vs tip deflection, d (mm). Obtain the trend line and display the equation. Get the slope of the trend line as the sensitivity (k, mV/mm) of static deflection measurement calibration plot. IV. Deliverables (a) Obtain the sensitivity (k) of the setup. Use this value (k) to estimate the voltage output (Vout1E) corresponding to tip deflection δtip1 (say, 10.16 mm), refer to Table 7.6. Comment on the difference, if any, between Vout1 and Vout1E. (b) Estimate the change in resistance (ΔRg) for the measured voltage output Vout1. (c) Estimate the strain and the change in length of the bar for the measured voltage output Vout1. Use gage factor (GF) as 2.06. (d) Complete Table 7.6. Discuss the experimental results.

198

7

Sensors

Table 7.6 Estimated values for a known tip deflection

Tip deflection δtip1 (mm) 10.16

Estimated voltage output Vout1E (mV)

Experimental voltage output Vout1 (mV)

% Difference in voltage output

Estimated change in resistance ΔRg1 (Ω)

Estimated strain ε1

Estimated change in length ΔL (mm)

Lab Report (a) Present all results (Tables 7.4, 7.5 and 7.6) and calibration graph. (b) Discuss the factors that affect the sensitivity of the measurement setup. (c) Use your knowledge of previous courses to discuss how the calibration curve can be used to measure the load at the cantilever tip if the dimensions of the beam and the modulus of elasticity of the cantilever material are known. (d) Estimate the sensitivity of the voltage output versus load curve if the modulus of elasticity of the cantilever material is 200 GPa. Redraw the calibration curve for load measurement. (e) Discuss the experimental results.

7.7.3

Data Acquisition and Analysis Using LabVIEW and a Strain Gage Under Dynamic Condition

Objectives The objectives are to acquire and analyze data Using LabVIEW and a strain gage on a cantilever under dynamic condition. Brief Steps For this experiment, a measurement system (with transverse loading) using a strain gage, a Wheatstone bridge, and a difference amplifier, similar to that in Fig. 7.1, is considered under dynamic condition. A steel beam specimen with a strain gage attached to the fixed end of the cantilever is used in physical laboratory experiment. The DAQ board NI DAQ USB-6009 is used in this experiment. Any other similar DAQ board can be used for the experiment. The circuit of Fig. 7.24 with resistances of Table 7.4 are used in this experiment. I. Construct VI (a) Plug in the NI DAQ USB-6009 board. Launch LabVIEW and construct VI, similar to Fig. 7.25. Configure DAQ Assistant, Write to Measurement File (similar to thermocouple experiment), and Spectral Measurement. Connect the output of the difference amplifier to DAQ input channel (ai0) and common ground to ai0GND. DAQ Assistant is configured for single-channel (ai0) analog voltage input of the DAQ device. The sampling mode is configured to N samples with 1 k samples at 1 k samples/s.

7.7

Experimental Validation

199

Fig. 7.25 LabVIEW VI for data acquisition and analysis: (a) front panel, (b) block diagram panel

II. Acquire and Analyze Time Response Data (a) Clamp the cantilever using a C-clamp on the edge of the table close to the strain gage end (make sure to avoid damaging the strain gage). Gently hold down the tip of the cantilever and release. Run LabVIEW VI and record the data. Present time response graph (without tip mass) and complete Table 7.7. Note that peak amplitudes An and An+1 are to be measured from the final (steady state, yss) value of the time response curve. For example, if y values at two consecutive max points (peaks) are yn and yn+1, then An = yn - yss, An+1 = yn+1 - yss. (b) Record and analyze frequency spectrum of the time response of the cantilever. Record the frequency (f1 Hz) at the peak from the power spectrum plot, and compare it with the average frequency fn obtained in Table 7.7; complete Table 7.8. (c) Repeat with a tip mass attached firmly on the cantilever tip. Present power spectrum plot of output voltage for the vibrating cantilever beam with the known tip mass (mTip).

Sl. Amplitude of No. peak An (mV) 1 2 Average

Amplitude of next peak An + 1 (mV)

Time period T (sec) δ = ln An Anþ1

Logarithmic Decrement   =2π 1þδ2

δ ffi pffiffiffiffiffiffiffi

Damping ratio ζ =

Table 7.7 Undamped natural frequency and damping ratio from time response graph

T

1-ζ

Undamped natural frequency ffiffiffiffiffiffiffiffi2ffi ωn rad/s ωn = p2π

Undamped natural frequency fn Hz f n =

ωn 2π

200 7 Sensors

7.7

Experimental Validation

201

Table 7.8 Comparison of natural frequency of cantilever beam without tip mass Frequency from power spectrum, f1 (Hz)

Average frequency from time response fn Hz

% Difference

Comment

Table 7.9 Comparison of tip mass Frequency from power spectrum, without tip mass, f1 (Hz)

Frequency from power spectrum, with tip mass f2 (Hz)

Measured beam mass Mbeam (kg)

Effective beam mass = 0.2357 ∗ (kg)

Measur ed tip mass (kg)

Calculated tip mass

% Difference of tip mass

,

= −1 (kg)

(d) Record mTip,frequencies without and with tip mass ( f1 and f2 Hz) and complete the calculations of Table 7.9. For a typical steel cantilever specimen, use L = 304.8 mm, L′ =260.4 mm, b = 25.4 mm, h = 3.175 mm, ρ = 7800 kg/m3, and E = 200 GPa. III. Deliverables (a) Complete Tables 7.7, 7.8 and 7.9.

Lab Report (a) Present all results and graphs and frequency spectrum without and with tip mass. (b) Compare the values of frequency obtained from spectrum analysis and that calculated from time domain tip vibration data. (c) Comment on the damping ratio of the system. (d) How does the tip mass value obtained from the experiment compare with its known value? Explain the factors that contribute to any differences.

202

7

Sensors

Exercises

1. In a measurement setup using a strain gage on a transverse loading specimen, a Wheatstone bridge, and a difference amplifier, all four arms of the Wheatstone bridge were initially at 120Ω, including the strain gage as the active arm, similar to that in Fig. 7.1. The supply voltage to the Wheatstone bridge is 7.5 V, the difference amplifier gain is 5, and the gage factor is 2.12. Find the change in resistance of the strain gage (ΔR) and the strain (ε), and the sensitivity k (mV/MPa) if the amplified output voltage is 25 mV when the specimen is under load. Use E = 200 GPa for the specimen material. 2. In a measurement setup using a strain gage on an axial loading specimen, a Wheatstone bridge, and a difference amplifier, all four arms of the Wheatstone bridge were initially at 120Ω, including the strain gage as the active arm, similar to that in Fig. 7.5. The supply voltage to the Wheatstone bridge is 7.5 V, the difference amplifier gain is 10, and the gage factor is 2.16. Find the change in resistance of the strain gage (ΔR), the strain (ε), and the sensitivity k (mV/MPa) if the amplified output voltage is 22 mV when the specimen is under load. Use E = 200 GPa for the specimen material. 3. A steel bar with modulus of elasticity 200 GPa and diameter 12.5 mm is loaded in tension with an axial load of 50 kN. A strain gage with gage factor of 2.115 and resistance 120 Ω is mounted on the bar in the axial direction. The strain gage is placed in one branch of a Wheatstone bridge (R1) with the other three legs having the same base resistance (R2 = R3 = R4 = 120 Ω), similar to that in Fig. 7.5. (a) Find the stress in the loaded bar. (b) Find the change in resistance of the strain gage under loaded state. (c) Find the out voltage of the Wheatstone bridge if the excitation voltage for the Wheatstone bridge is 5 V. (d) If the Wheatstone bridge output voltage is connected to a difference amplifier with feedback resistance and input resistance of R6 = 10 kΩ and R5 = 1 kΩ, find the amplified output voltage. (e) Find the sensitivity of the setup K (mV/MPa). Draw the calibration curve of voltage output versus applied stress. (f) Show the arrangement of strain gages in the Wheatstone bridge for maximum sensitivity. Estimate the maximum sensitivity. (g) Show the schematic of the entire setup (strain gages mounted on the bar, Wheatstone bridge, and the difference amplifier).

Exercises

203

4. Repeat Exercise Problem 3 if the loading is transverse (P = 50 N) instead of being axial, and the round bar is replaced with a rectangular specimen of length L = 300 mm, width, b = 25.4 mm, thickness, and h = 3.2 mm. 5. It is required to design a stress measurement system using strain gages on a transverse loading specimen. Each of the four available strain gages has a resistance of 120 Ω and a gage factor of 2.14. The strain gages are to be used as active branches of a Wheatstone bridge with other branches having the same base resistance. The input voltage to the bridge is 5.5 V. The output voltage of the bridge is amplified using a differential amplifier with a gain of 7.5. Use the modulus of elasticity for steel, E = 210 GPa. When the circuit was tested with four strain gages (two on the top face of the beam and two on the bottom face, near the supported end) used in all arms of the Wheatstone bridge, the output voltage was 0.0 mV. Explain what might have gone wrong assuming both voltage source and the difference amplifier were switched on and the Wheatstone bridge was functioning properly. Assuming the mistake was corrected, draw the schematic of the bridge circuit identifying the arms, the strain gage locations on the cantilever, and the op-amp circuit for the difference amplifier, for maximum sensitivity. For the corrected setup, find the magnitude of change in resistance (ΔR) of each strain gage, the strain (ε), the value of the applied stress (σ), and the sensitivity (k) (mV/MPa), if the amplified output voltage was 35.0 mV. 6. It is required to design a stress measurement system using strain gages on an axial loading specimen. Each of the two available strain gages has a resistance of 120 Ω and a gage factor of 2.14. The strain gages are to be used as active branches of a Wheatstone bridge with other branches having the same base resistance. The input voltage to the bridge is 5.5 V. The output voltage of the bridge is amplified using a differential amplifier with a gain of 7.5. Use the modulus of elasticity for steel, E = 210 GPa. When the circuit was tested with two strain gages (near the supported end) used in two arms of the Wheatstone bridge, the output voltage was 0.0 mV. Explain what might have gone wrong assuming both voltage source and the difference amplifier were switched on and the Wheatstone bridge was functioning properly. Assuming the mistake was corrected, draw the schematic of the bridge circuit identifying the arms, the strain gage locations on the cantilever, and the op-amp circuit for the difference amplifier, for maximum sensitivity. For the corrected setup, find the magnitude of change in resistance (ΔR) of each strain gage, the strain (ε), the value of the applied stress (σ), and the sensitivity (k) (mV/MPa), if the amplified output voltage was 20.0 mV. 7. A vibration measuring instrument is to be selected for measuring vibration of machines running at speeds 3600 rpm to 12,000 rpm. (a) Select the instrument (vibrometer) if α = 5% and ζ =0.55. (b) Draw the operating curve (AR = Xr/Xi vs r = ω/ωn).

204

7

Sensors

(c) Find the actual vibration amplitude (Xi) if the vibrometer output voltage (V0) is 18 mV when the machine is operating at 3000 rpm. Use the sensitivity of the instrument k = VXor = 12 mV/mm. (d) Select the minimum speed of the machine at which vibration can be measured within α = 5% with a vibrometer having ωn =25 Hz. 8. A vibration pickup has a sensitivity (k) of 10 mV/mm, an undamped natural frequency (ωn) of 45 Hz, and a damping ratio (ζ) of 0.45. Determine the minimum frequency ratio (rmin) and the lowest frequency (ωmin) of vibration that can be measured with a maximum error of 3.5%. The vibration pickup, when mounted on a machine block vibrating at 135 Hz, gives an output (Vout) of 25 mV. Determine the actual amplitude of vibration (Xi) of the machine block. Use Vout = k Xr and notations followed in the textbook. 9. An accelerometer is to be selected for measuring vibration of machines running at speeds 3600 rpm to 12,000 rpm. (a) Select an accelerometer if α = 5% and ζ =0.55. X ω2

(b) Draw the operating curve (AR = Ar i n vs r = ωωn ). (c) Find the actual acceleration amplitude (Ai) if the accelerometer output voltage (V0) is 20 mV when the machine is operating at ω =11,600 rpm. Use the sensitivity of the instrument k = XVr ωo 2 =15 mV/ms2. n (d) Select the maximum speed of the machine at which acceleration can be measured within α = 5% with an accelerometer having ωn = 100 kHz. 10. A piezoelectric accelerometer is to be used with a charge amplifier for vibration measurement over a frequency range of 50.0 Hz to 2.50 kHz with a maximum error of 2.5%. (a) Determine the time constant (τ) of the feedback path of the charge amplifier. Select the charge amplifier Rf and Cf elements to satisfy the time constant (check from internet the preferred values of R and C). (b) Obtain the lowest natural frequency (ωn) of the piezoelectric accelerometer. Select an accelerometer from a vendor (check from internet for a possible vendor list) for the purpose. Give the full specification of the accelerometer selected. (c) The accelerometer is mounted on a machine block vibrating at 0.40 kHz. The charge amplifier sensitivity is set at 20 mV/mm/s2. Determine the amplitude of vibration when the charge amplifier output is 35 mV. Show the operating point on the frequency response plot of the charge amplifieraccelerometer set. 11. A J-type thermocouple with its reference junction at room temperature of 21 °C gives an output of 6.85 mV when the measurement junction is dipped into a process fluid. Find the temperature (T) of the process fluid if sensitivity (k) of the thermocouple is 0.042 mV/°C. Find the thermocouple output voltage (V0) if the reference junction is moved to a melting ice bath (0 °C). 12. It is required to design a thermopile consisting of J-type thermocouples for measuring temperature in a process. The measurement temperature range is

Bibliography

205

75–425 °C, and the reference temperature is 22 °C. The sensitivity of a J-type thermocouple can be taken as 0.052 mV/°C. Determine the number (N) of junction pairs for the thermopile if the voltage is required to be at least 0.5 V for the upper limit of the input temperature range. Find the temperature (T) if the output voltage of the thermopile is 0.435 V for the reference temperature of 22 °C. 13. A thermopile is to be designed for measuring temperature of fluid in a process using the room temperature of 20 °C as the reference temperature. (a) Find the output voltage V0 of a 40-fold (N = 40) J-type thermopile when the measurement junction temperature is 350 °C. Use sensitivity k = 0.050 mV/°C. (b) Find number of folds (N) if the voltage output is 82.5 mV for T = 350 °C, Tref = 20 °C for a J-type thermopile. (c) Find the voltage output from part (b) if Tref = 10 °C, other conditions being the same as in part (b). (d) Repeat parts (b) and (c) if the J-type thermopile is replaced with an E-type. Use k for E-type thermocouple as 0.084 mV/°C.

Bibliography Alciatore DG (2019) Introduction to mechatronics and measurement systems, 5th edn. McGraw Hill, New York Arduino (2022) Arduino. https://www.arduino.cc Beckwith TG, Marangoni RD, Lienhard JH (2006) Mechanical measurements, 6th edn. Prentice Hall, New Jersey Doeblin EO (1990) Measurement systems applications and design, 4th edn. McGraw-Hill, New York Mathworks (2022) Matlab and Simulink. https://www.mathworks.com National Instruments (2022a) LabVIEW. https://www.ni.com National Instruments (2022b) Entry-level, plug-and-play USB data acquisition. https://www.ni.com National Instruments (2022c) USB-TC01 Temperature input device. https://www.ni.com National Instruments (2022d) Multisim. https://www.ni.com/en-us/support/downloads/softwareproducts/download.multisim.html#452133 Pico Technology (2022) PicoScope 2000 series. https://www.picotech.com/oscilloscope/2000/ picoscope-2000-overview Test Equity (2022) Instek GDS-1202B digital storage oscilloscope. https://www.testequity.com Test Equipment Depot (2022) Instek AFG-2105 arbitrary waveform function generator. https:// www.testequipmentdepot.com/instek/signalgenerators/afg2105.html TEquipment (2022a) Instek GDM-8341 50,000 counts dual measurement multimeter with USB device. https://www.tequipment.net/InstekGDM-8341.html TEquipment (2022b) Instek GPE-3323 3 channels, 217W linear DC power supply. https://www. tequipment.net/Instek/GPE-3323/DC-Power-Supplies Tinkercad (2022) Learn circuits. https://www.tinkercad.com/learn/circuits

Chapter 8

Digital Circuits

8.1

Introduction

In digital domain, signals are characterized by a finite number of states or values. In digital logic devices, signals are of only two levels, high or low, on or off, 1 or 0, and true or false. Digital logic devices are classified as combinational or sequential logic devices. In case of combinational logic devices, the output depends on the instantaneous values of the inputs. In case of sequential logic devices, the output depends on sequencing history, or timing, of the inputs. In this chapter, the main emphasis is on combinational logic devices and applications, with a brief introduction to sequential logic devices.

8.2

Combinational Logic Devices

Combinational logic devices deal with binary inputs and binary outputs. The basic combinational logic devices or gates, the logic operations, schematic symbols, the mathematical expressions, and truth tables are presented in Table 8.1. Of these, the buffer and inverter (NOT gate) are 1-input gates, and the rest of standard gates AND, NAND, OR, NOR, XOR, and XNOR are two-input gates. However, nonstandard multi-input gates are also available, but only standard two-input gates are discussed in this chapter. In general, multiple gates of the same type are packaged in integrated circuit (IC). For example, 4 NAND gates are packaged in quad NAND gate IC 5400/ 7400 with 14 pins. The starting pin (1) is noted by a notch and a dot with pins 1–7 on one side and pins 8–14 on the other side, pin 7 as the ground (GND), and pin 14 as Vcc (5 V supply). Four NAND gates arranged in pins: inputs 1 and 2 and output 3, inputs 4 and 5 and output 6, inputs 10 and 9 and output 8, and inputs 13 and 12 and output 11. Similarly, four AND gates are packaged in 14-pin quad AND gate IC 5408/7408; four OR gates are packaged in 14-pin quad OR gate IC 5432/7432. © The Author(s), under exclusive license to Springer Nature Switzerland AG 2023 B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_8

207

208

8

Digital Circuits

Table 8.1 Summary of commonly used combinational logic gates Serial number 1

Schematic symbol

Mathematical expression Q=A

Logic gate Buffer

Logic operation Increase the output current

2

Inverter (NOT, INV)

Invert (complement) signal

Q=A

3

AND gate

AND logic

Q=A∙B

4

NAND gate

Inverted AND logic

Q=A∙B

5

OR gate

OR logic

Q=A+B

6

NOR gate

Inverted OR logic

Q=A þ B

7

XOR

Exclusive OR logic

Q=A

8

XNOR gate

Exclusive NOR logic

Q=A

L

L

B

B

Truth table A Q 0 0 1 1 A Q 0 1 1 0 A B 0 0 0 1 1 0 1 1 A B 0 0 0 1 1 0 1 1 A B 0 0 0 1 1 0 1 1 A B 0 0 0 1 1 0 1 1 A B 0 0 0 1 1 0 1 1 A B 0 0 0 1 1 0 1 1

Q 0 0 0 1 Q 1 1 1 0 Q 0 1 1 1 Q 1 0 0 0 Q 0 1 1 0 Q 1 0 0 1

Similarly, four XOR gates are packaged in quad XOR gate IC 5486/7486. Four NOR gates are packaged in quad NOR gate IC 5402/7402 with orientation of input, and out pins are different from other gate ICs. In 5402/7402 quad NOR gate IC pins are assigned as follows: inputs 2 and 3 and output 1, inputs 5 and 6 and output 4, inputs 8 and 9 output 10, and inputs 11 and 12 and output 13. In hex inverter (NOT) gate IC

8.3

Boolean Algebra

209

5404/7404, six NOT gates are packaged with assigned pins: input 1, output 2; input 3, output 4; input 5, output 6; input 13, output 12; input 11, output 10; and input 9, output 8. Details of these and similar gate ICs can be obtained from manufacturers’ product datasheets (e.g., https://www.ti.com).

8.3

Boolean Algebra

Boolean algebra is used to state and simplify digital (binary) logic expressions of binary variables (0 and 1). Boolean algebra is governed by certain laws, like basic laws, commutative laws, associative laws, distributive laws, and some useful identities. In these, the variables A, B, and C are all logic variables. Basic Boolean Algebra Laws OR

AND

+0=

∙0=0

+1 = 1

∙1=

NOT

̿=

Commutative Laws A þ B=B þ A

ð8:2Þ

A∙B=B∙A

ð8:3Þ

ðA þ B Þ þ C = A þ ðB þ C Þ

ð8:4Þ

ðA ∙ BÞ ∙ C = A ∙ ðB ∙ C Þ

ð8:5Þ

A ∙ ðB þ C Þ = ðA ∙ BÞ þ ðA ∙ CÞ

ð8:6Þ

A þ ðA ∙ BÞ = A ∙ 1 þ A ∙ B = A ∙ ð1 þ BÞ = A ∙ 1 = A

ð8:7Þ

Associative Laws

Distributive Laws

Useful Identities

210

8

Digital Circuits

A ∙ ðA þ BÞ = A ∙ A þ A ∙ B = A þ A ∙ B = A ∙ ð1 þ BÞ = A ∙ 1 = A

ð8:8Þ

 ∙ BÞ = A ∙ ð1 þ BÞ þ ðA  ∙ B Þ = A ∙ 1 þ ðA þ A  Þ ∙ B = A þ 1 ∙ B = A þ B ð8:9Þ A þ ðA   A þ B þ A ∙ B = A ∙ 1 þ A ∙ B þ B = A ∙ 1 þ B þ B = A ∙ 1 þ B = A þ B ð8:10Þ ðA þ B Þ ∙ ðA þ C Þ = A ∙ A þ A ∙ C þ B ∙ A þ B ∙ C = A þ A ∙ C þ B ∙ A þ B ∙ C = A ∙ ð1 þ B þ C Þ þ B ∙ C = A þ B ∙ C ð8:11Þ    ðA ∙ BÞ þ ðB ∙ CÞ þ B ∙ C = ðA ∙ BÞ þ B þ B ∙ C = ðA ∙ BÞ þ 1 ∙ C = ðA ∙ BÞ þ C 







   ðA ∙ BÞ þ ðA ∙ C Þ þ B ∙ C = ðA ∙ BÞ þ ðA ∙ CÞ ∙ B þ B þ B ∙ C   = ðA ∙ BÞ þ A ∙ B ∙ C þ ðA ∙ C Þ ∙ B þ B ∙ C   = ðA ∙ BÞ ∙ ð1 þ C Þ þ ðA þ 1Þ ∙ B ∙ C  ∙ C Þ = ðA ∙ BÞ þ ðB  ∙ CÞ = ðA ∙ BÞ ∙ 1 þ 1 ∙ ðB

ð8:12Þ

ð8:13Þ

Example 8.1 For the digital logic circuit of Fig. 8.1, find the Boolean expression for the output (Z) in terms of the inputs (X, Y). Using Boolean algebra, obtain the simplified expression (ZS) of the output for its implementation through minimum number of two-input logic gates. Solution The expression for Z can be obtained as Z = X þ X ∙ Y The expression can be simplified using Boolean algebra as follows: Z = X ∙ 1 þ X ∙ Y = X ∙ ð1 þ Y Þ þ X ∙ Y ðsince 1 = 1 þ Y Þ   =X ∙1 þ X ∙Y þ X ∙Y =X þ X þ X ∙Y   = X þ 1 ∙ Y since X þ X = 1 =X þY The simplified expression can be implemented using an OR gate, as shown in Fig. 8.2: Example 8.2 For the digital logic circuit of Fig. 8.3, find the Boolean expression for the output (X) in terms of the inputs (A, B). Using Boolean algebra, obtain the simplified expression (XS) of the output for its implementation using the minimum number of two-input logic gates. Fig. 8.1 A combinational logic circuit (Example 8.1)

8.4

De Morgan’s Laws

211

Fig. 8.2 Digital circuit for simplified expression (Example 8.1)

Fig. 8.3 A combinational logic circuit (Example 8.2)

Solution The expression for the output is obtained as X =A∙B þ A∙B þ A∙B     = A þ A ∙ B þ A ∙ B = 1 ∙ B þ A ∙ B since A þ A = 1 = A þ B ðusing the results of Example 8:1Þ The simplified expression can be implemented using a two-input OR gate similar to Example 8.1.

8.4

De Morgan’s Laws

De Morgan’s laws are used to simplify Boolean expressions involving NOR and NAND gates. The first De Morgan’s law is to express complement of a group of OR-ed Boolean variables as AND of each of complemented Boolean variables, i.e., a NOR to an AND of complemented variables, as in Eq. (8.14): A þ B þ C þ ...=A∙B∙C...

ð8:14Þ

A NOR operation of two Boolean variables is transformed to an AND operation of each complemented Boolean variable, as shown in Fig. 8.4:

212

8

Digital Circuits

Fig. 8.4 De Morgan’s Law 1

The second of De Morgan’s law is to express complement of a group of AND-ed Boolean variables as OR of each of complemented Boolean variables, i.e., a NAND to an OR of complemented variables, as in Eq. (8.15): A∙B∙C...=A þ B þ C þ ...

ð8:15Þ

A NAND operation of two Boolean variables is transformed to an OR operation of each complemented Boolean variable, as shown in Fig. 8.5: Example 8.3 For the digital logic circuit of Fig. 8.6, find the Boolean expression for the output (R) in terms of the inputs (P, Q). Using De Morgan’s laws, Boolean algebra, and the truth table, obtain the simplified expression (RS) of the output for its implementation through the minimum number of two-input logic gates. Solution The expression for the output R can be obtained as (Table 8.2)   R = P ∙ Q ∙ ðP þ Q Þ     = P þ Q ∙ ðP þ QÞ using De Morgan’ s Law 2 =P∙P þ P∙Q þ Q∙P þ Q∙Q   = 0 þ P ∙ Q þ Q ∙ P þ 0 since P ∙ P = 0 and Q ∙ Q = 0 = P  Q ðconfirmed by truth tableÞ Example 8.4 For the digital logic circuit of Fig. 8.7, find the Boolean expression for the output (Q) in terms of the inputs (X, Y, Z). Using De Morgan’s theorems and Boolean algebra, obtain the simplified expression of the output for its implementation using AND and NOT gates. Solution The expression for the output Q can be obtained as       Q = X þ Y ∙ Z = X ∙ Y ∙ Z using De Morgan’ s Law 1     = X ∙ ðY ∙ Z Þ since Y ∙ Z = Y ∙ Z

8.5

Truth Table and Simplified Boolean Expression from a Given Boolean Expression

213

Fig. 8.5 De Morgan’s Law 2

Fig. 8.6 A combination logic circuit (Example 8.3)

Table 8.2 Truth table for R=P∙Q þ Q∙P

P 0 0 1 1

Q 0 1 0 1

P∙Q 0 1 0 0

Q∙P 0 0 1 0

R 0 1 1 0

P 0 1 1 0

L

Q

Fig. 8.7 A combination logic circuit using NAND and NOR gates (Example 8.4)

Fig. 8.8 Combination logic circuit using AND gates for Example 8.4

The simplified expression can be implemented using one inverter and two two-input AND gates, as shown in Fig. 8.8.

8.5

Truth Table and Simplified Boolean Expression from a Given Boolean Expression

The procedure of obtaining simplified expression from a given Boolean expression and truth table is illustrated through an example in this section. Example 8.5 Given the Boolean expression, X = A ∙ B ∙ C þ ðA þ BÞ ∙ C. Simplify the Boolean expression, verify it from the truth table, and draw a digital logic circuit for implementing the simplified expression using two-input logic gates.

214

8

Digital Circuits

Solution The Boolean expression can be simplified as follows: X = A ∙ B ∙ C þ ðA þ BÞ ∙ C   = A∙C þ C ∙B þ A∙C     = A ∙ C þ 1 ∙ C ∙ B þ A ∙ C since 1 ∙ C = C       = A ∙ C þ A þ A ∙ C ∙ B þ A ∙ C since A þ A = 1   = A∙C þ A∙C þ A∙C ∙B þ A∙C    = A∙ C þ C Þ∙B þ A∙C∙B þ A∙C   = A ∙ 1 ∙ B þ A ∙ C ∙ ðB þ 1Þ since C þ C = 1 = A ∙ B þ A ∙ C ðsince B þ 1 = 1Þ The truth table for the expression X = A ∙ B ∙ C þ ðA þ BÞ ∙ C and X1 = A ∙ Bþ A ∙ C is presented in Table 8.3. The digital logic circuit using two-input gates (2 AND, 1 OR) and two NOT gates for implementing the simplified expression is shown in Fig. 8.9. There are two methods for writing the Boolean expression representing the logic of digital logic circuit. The methods are called sum of products (SOP) and product of sums (POS). In SOP, the output can be expressed as a sum of products of inputs. For an example of digital logic system with three inputs X, Y, and Z, the output P can be expressed as a Boolean expression containing inputs AND-ed to form product terms that are OR-ed together to give the output P, as shown in Eq. (8.16):       P= X ∙Y ∙Z þ X ∙Y ∙Z þ X ∙Y ∙Z

ð8:16Þ

The truth table for the Boolean expression is presented in Table 8.4, and the digital logic circuit for implementing the expression is shown in Fig. 8.10. In POS method, the output can be expressed as a product of sums of inputs. For an example of digital logic system with three inputs X, Y, and Z, the output P can be expressed as a Boolean expression containing inputs OR-ed to form sum terms that are AND-ed together to give the output P, as shown in Eq. (8.17):       P= X þ Y þ Z ∙ X þ Y þ Z ∙ X þ Y þ Z

ð8:17Þ

The truth table for the Boolean expression is presented in Table 8.5, and the digital logic circuit for implementing the expression is shown in Fig. 8.11.

8.6

Simplified Boolean Expression and Digital Circuit from a Given Truth Table

215

Table 8.3 Truth Table for X = A ∙ B ∙ C þ ðA þ BÞ ∙ C, X1 = A ∙ B þ A ∙ C A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

C 0 1 0 1 0 1 0 1

A∙B 0 0 1 1 0 0 0 0

A∙B∙C 0 0 0 1 0 0 0 0

(A + B) 0 0 1 1 1 1 1 1

ðA þ BÞ ∙ C 0 0 1 0 1 0 1 0

X 0 0 1 1 1 0 1 0

X1 0 0 1 1 1 0 1 0

X ∙Y ∙Z 0 0 0 0 0 1 0 0

X∙Y ∙Z 0 0 0 0 0 0 1 0

P 0 0 0 1 0 1 1 0

Fig. 8.9 Schematic of digital logic circuit for X = A ∙ B þ A ∙ C

Table  8.4 Truth  table for P= X ∙Y ∙Z þ X ∙Y ∙Z   þ X ∙Y ∙Z

8.6

X 0 0 0 0 1 1 1 1

Y 0 0 1 1 0 0 1 1

Z 0 1 0 1 0 1 0 1

X ∙Y ∙Z 0 0 0 1 0 0 0 0

Simplified Boolean Expression and Digital Circuit from a Given Truth Table

There are two methods for writing the Boolean expression representing the logic of the truth table. The methods are called sum of products (SOP) and product of sums (POS). In SOP, the output can be expressed as a sum of products of inputs. For the given truth table, each row of 1 for the output should be constructed as product of the

216

8

Digital Circuits

      Fig. 8.10 Schematic of digital logic circuit for P = X ∙ Y ∙ Z þ X ∙ Y ∙ Z þ X ∙ Y ∙ Z

      Table 8.5 Truth table for P = X þ Y þ Z ∙ X þ Y þ Z ∙ X þ Y þ Z X 0 0 0 0 1 1 1 1

Y 0 0 1 1 0 0 1 1

Z 0 1 0 1 0 1 0 1

XþY þZ 1 0 1 1 1 1 1 1

XþY þZ 1 1 0 1 1 1 1 1

XþY þZ 1 1 1 1 0 1 1 1

P 1 0 0 1 0 1 1 1

inputs or their complements. For the example truth table of Table 8.6, there are three digital logic variables (X, Y, and Z ) with eight rows (0–7), and the output (P) is 1 in rows 3, 5, and 6. In canonical SOP form, the truth table can be represented using sum of min terms as P = ∑ ( m3, m5, m6). Min terms can be defined as when the minimum combinations of inputs are high, the output will be high. Min terms can be considto an AND gate. For row 3, (X = 0, Y = 1, Z = 1), the AND-edterm ered as inputs  X ∙ Y ∙ Z results in 1 in the output (P). Similarly, for rows 5 and 6, X ∙ Y ∙ Z and   X ∙ Y ∙ Z result in 1 in the output (P). The truth table can be represented in sum-ofproducts form as

8.6

Simplified Boolean Expression and Digital Circuit from a Given Truth Table

217

      Fig. 8.11 Schematic of digital logic circuit for P = X þ Y þ Z ∙ X þ Y þ Z ∙ X þ Y þ Z Table 8.6 Truth table P = ∑ ( m3, m5, m6)

X 0 0 0 0 1 1 1 1

Y 0 0 1 1 0 0 1 1

Z 0 1 0 1 0 1 0 1

P 0 0 0 1 0 1 1 0

      P= X ∙Y ∙Z þ X ∙Y ∙Z þ X ∙Y ∙Z In POS, the output can be expressed as a product of sums of inputs. For the given truth table, each row of 0 for the output should be constructed as sum of the inputs or their complements. For the example truth table in Table 8.7, there are three digital logic variables (X, Y, and Z ) with eight rows (0–7), and the output (P) is 0 in rows 1, 2, and 4. In canonical SOP form, the truth table can be represented using product of max terms as P = ∏ (M1, M2, M4). Max terms are OR of complemented otherwise noncomplemented inputsto get the output low. For row 1, (X = 0, Y = 0, Z = 1), the  OR-ed term X þ Y    þ Z results  in 0 in the output (P). Similarly, for rows 2 and 4, X þ Y þ Z , X þ Y þ Z result in 0 in the output (P). The truth table can be represented in product-of-sums form as       P= X þ Y þ Z ∙ X þ Y þ Z ∙ X þ Y þ Z

218

8

Table 8.7 Truth table for P = ∏ (M1, M2, M4)

8.7

X 0 0 0 0 1 1 1 1

Y 0 0 1 1 0 0 1 1

Z 0 1 0 1 0 1 0 1

Digital Circuits P 1 0 0 1 0 1 1 1

Design of Digital Logic Networks

As an example, a simple home security system is to be designed using combinational digital logic gates that take inputs from break-in sensors near doors and windows and motion sensors around the house and gives an output that produces an alarm while the occupants are sleeping or away. The system should not produce an alarm during the normal hours of the day with the occupants in the house doing normal activities. The design process can be considered in the following steps: 1. Define the problem, and identify the digital logic inputs and the output. 2. Write a quasi-logic statement for the problem that can be translated to a Boolean expression in terms of inputs and the output. 3. Write the Boolean expression. 4. Simplify the Boolean expression, to the extent possible. 5. Construct the digital logic circuit for the simplified Boolean expression. 6. Convert the simplified Boolean expression to an all-NAND or an all-NOR circuit with some inverters (NOT), if necessary.

8.7.1

Define the Problem

The inputs from all break-in sensors can be combined as one digital logic signal (P), and inputs from all motion sensors can also be combined as one digital logic signal (Q). These signals (P, Q) will be high (1), if any of the constituent sensor signal is high (1). The alarm (A) will be activated for combinations of these signals under three operating states: (a) The alarm should be activated if there is a break-in while the occupants are sleeping. (b) The alarm should be activated if either there is a break-in or a motion is detected while the occupants are away. (c) The alarm should not be activated during normal household activities of the occupants.

8.7

Design of Digital Logic Networks

219

The input Boolean variables to the digital logic system can be summarized as follows: 1. Break-in sensors: P 2. Motion sensors: Q 3. States: 2-bit code RS representing three states with the first three combinations and the last (11) not used. R 0 1 0 1

8.7.2

S 1 0 0 1

State Sleeping Away Normal Not used

Write the Quasi-Logic Statement

The word statement can be translated to quasi-logic statements. The security system will produce an alarm (A = 1) if P is high (P = 1) in the sleeping state (R S = 0 1) OR if P is high (P = 1) or Q is high (Q = 1) in the away state (R S = 1 0). The security system should not issue a false alarm during normal household activities of the occupants, i.e., A = 0, in normal state (R S = 0 0).

8.7.3

Write the Boolean Expression

The Boolean expression from the quasi-logic statements can be written as     A = P ∙ R ∙ S þ ðP þ Q Þ ∙ R ∙ S

ð8:18Þ

    The alarm signal will be high (1) if P ∙ R ∙ S = 1 or ðP þ QÞ ∙ R ∙ S = 1. The alarm signal will be low (A = 0), for the normal state (R S = 0 0).

8.7.4

Simplify the Boolean Expression

The Boolean expression of Eq. (8.18) can be simplified taking into the special combinations of the state codes, applied for the first three states, and the last combination (R S = 1 1) not being used (don’t care). For the first three states used, R ∙ S = S and R ∙ S = R can be used to simplify the Boolean expression of Eq. (8.18) as

220

R 0 1 0 1

8

S 1 0 0 1

R∙S 1 0 0 Don’t care

A = P ∙ S þ ðP þ Q Þ ∙ R

Digital Circuits R∙S 0 1 0 Don’t care

ð8:19Þ

The truth table for the Boolean expression is presented in Table 8.8. Out of the total 16 rows, only 12 rows are considered, ignoring every fourth row with both R and S as 1 (R S = 1 1). Of the 12 combinations, only 5 result in alarm being high (A = 1), as shown in rows (6, 9, 10, 13, 14).

8.7.5

Construct the Digital Logic Circuit

The digital circuit corresponding to the simplified Boolean expression of Eq. (8.19) is shown using logic gates (AND, OR) in Fig. 8.12.

8.7.6

Convert to an all-NAND Circuit

The Boolean expression of Eq. (8.19) consists of two AND gates (from two-input quad AND gate IC 7408) and two OR gates (from two-input quad OR gate IC 7432). The OR gates can be converted to NAND gates by considering the double inversion of the whole expression first and then working through the innermost OR gate. The inner complement converts the first OR gate to a NAND gate (using De Morgan’s law) in Eq. (8.20): A = P ∙ S þ ðP þ Q Þ ∙ R = P ∙ S ∙ ðP þ Q Þ ∙ R

ð8:20Þ

The remaining OR gate can be converted to a NAND gate taking double inversion and applying De Morgan’s law for the inner complement as shown in Eq. (8.21):   A=P∙S∙ P þ Q ∙R   =P∙S∙ P∙Q ∙R

ð8:21Þ

8.7

Design of Digital Logic Networks

Table 8.8 Truth table for home security system

0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

221

0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1

0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

∙ 0 0 0 X 0 0 0 X 0 1 0 X 0 1 0 X

( + )∙ 0 0 0 X 0 0 1 X 0 0 1 X 0 0 1 X

0 0 0 0 0 0 1 0 0 1 1 0 0 1 1 0

Fig. 8.12 Schematic of digital logic circuit for A = P ∙ S + (P + Q) ∙ R

The Boolean expression can be realized in an all-NAND configuration with four two-input NAND gates and two NOT gates (inverters), as shown in Fig. 8.13. The entire circuit can be realized using one quad two-input NAND gate IC (7400) and one hex inverter IC (7404).

8.7.7

Convert to an All-NOR Circuit

The Boolean expression of Eq. (8.19) consists of two AND and two OR gates. The AND gates can be converted to NOR gates by considering the double inversion of the left and the right side individually first, using De Morgan’s law, as shown in Eq. (8.22):

222

8

Digital Circuits

Fig. 8.13 Schematic of digital logic circuit with NAND and NOT gates for A = P ∙ S + (P + Q) ∙ R

Fig. 8.14 Schematic of digital logic circuit with NOR and NOT gates for A = P ∙ S + (P + Q) ∙ R

A = P ∙ S þ ðP þ Q Þ ∙ R = P þ S þ ðP þ Q Þ þ R

ð8:22Þ

Next, the main OR gate is converted to a NOR gate taking double inversion of the whole expression. The inner complement converts the first OR gate to a NOR gate, and inverting the output, as in Eq. (8.23): A = P þ S þ ðP þ Q Þ þ R

ð8:23Þ

The Boolean expression can be realized in an all-NOR configuration with four two-input NOR gates and four NOT gates (inverters), as shown in Fig. 8.8. The entire circuit can be realized using one quad two-input NOR gate IC (7402) and one hex inverter IC (7404) (Fig. 8.14). Example 8.6 It is required to design a combinational logic system for material handling using a conveyor belt. The speed (X), the load (Y), and the rate of loading (Z) in the conveyor system are monitored for safe operation. The signal-conditioning circuit for each of the monitored variables (X, Y, and Z) generates a logic HIGH (1) when the sensor output exceeds the corresponding threshold value; otherwise, the output is logic LOW (0).

8.8

Karnaugh Map (K-Map) for Simplification of Boolean Expressions

Table 8.9 Truth table for A=X ∙Y ∙Z þ X∙Y ∙Z þ   X∙ Y þZ

X 0 0 0 0 1 1 1 1

Y 0 0 1 1 0 0 1 1

Z 0 1 0 1 0 1 0 1

X∙Y∙Z 0 0 0 0 0 0 0 1

X ∙Y ∙Z 0 0 0 1 0 0 0 0

223   X∙ Y þZ 0 0 0 0 1 1 1 0

A 0 0 0 1 1 1 1 1

The following conditions are considered unsafe and warrant the initiation of an alarm (A): (i) If all three signals (X, Y, Z) are HIGH (ii) If the motor speed is LOW with both load and the rate of loading are HIGH (iii) If the motor speed is HIGH and either load or the rate of loading is LOW Construct a Boolean expression for the alarm output (A). Obtain the corresponding truth table. Using the truth table and/or Boolean algebra, De Morgan’s laws obtain the simplified expression (AS) of the output for its implementation using the minimum number of two-input logic gates. Verify from truth table that the simplified expression output (AS) is identical to the original output (A) for each input combination. Draw the combinational logic circuit for the implementation of the simplified expression (AS) and identify the gates (type and number). Solution The Boolean expression for the alarm output A can be expressed in terms of inputs (X, Y, Z) as   A=X ∙Y ∙Z þ X ∙Y ∙Z þ X ∙ Y þ Z The truth table for the expression is presented in Table 8.9. Examining the truth table, it is evident that A is true (HIGH) if X =1 or Y=1 and Z=1. In other words, the simplified Boolean expression can be expressed as A = X + Y ∙ Z. The combinational logic circuit to implement this Boolean expression is presented in Fig. 8.15 with one AND gate and one OR gate:

8.8

Karnaugh Map (K-Map) for Simplification of Boolean Expressions

Karnaugh maps, or in short K-maps, are used to simplify Boolean expressions through two-dimensional mapping of truth table in a systematic way. First, a two-dimensional map is created grouping Boolean variables in two groups and

224

8

Digital Circuits

Fig. 8.15 Combinational logic circuit for A=X+Y∙Z

Table 8.10 Truth table of a four-variable system

P 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

Q 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1

R 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1

S 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

X 0 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1

Row 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

listing these combinations such that only one bit changes between two adjacent cells. For example, in a four-variable case (P, Q, R, S), two groups can be made as PQ and RS and the combinations for either group that can be placed in two-dimensional cells in sequence of 00, 01, 11, 10, as shown in Table 8.10, where each cell is designated with its position in the usual truth table having all combinations of Boolean variables (P, Q, R, S) covering (0–15) as 0000 to 1111. The usual truth table is mapped into the K-map. In sum-of-products (SOP) form, adjacent cells with all 1 can be grouped in groups of power of 2, i.e., 2, 4, 8. Each such grouping is represented by the corresponding Boolean expression. The final simplified expression of the system is the OR-ed version of the Boolean expressions of the component groups. As an example, a truth table of four Boolean variables (P, Q, R, S) is shown in Table. 8.10. From the truth table, it is evident that the output is high (1) in rows 3, 7, 11–15. In canonical SOP form, the truth table can be represented using sum of min terms as X = ∑ ( m3, m7, m11, m12, m13, m14, m15). There are four input variables, so the K-map can be constructed of 24 or 16 cells numbered 0–15 (noted in right corner of each cell) in K-map of Table 8.11. The K-map cells 3, 7, 11–15 are filled with 1, as shown in Table 8.11.

8.9

Sequential Logic

225

Table 8.11 K-Map for truth table of Table 8.10

00

01

00

0

01

4

11 10

11 1

10 3

2

7

6

1 5

1 12

1

13

1 8

15

1 9

14

1 11

10

1

From the K-map, two groups of four adjacent cells all with 1 can be obtained corresponding to PQ and RS, respectively. The simplified Boolean expression for the digital logic system represented by the truth table of Table 8.11 can be written as X =P∙Q þ R∙S

ð8:24Þ

The Boolean expression in Eq. (8.24) can be changed to an all-NAND gate realization taking double inversion and applying De Morgan’s law as in Eq. (8.25): X =P∙Q þ R∙S=P∙Q∙R∙S

ð8:25Þ

The Boolean expression in Eq. (8.25) can be realized using three of a two-input quad NAND gate IC (7400), as shown in Fig. 8.16b:

8.9

Sequential Logic

Flip-flops are sequential digital devices with widespread applications in digital computing and communication devices that include shift registers, data registers, binary counters, frequency dividers, and serial and parallel interfaces. Some of the basic flip-flops are briefly discussed in this section.

8.9.1

SR Flip-Flop

The SR flip-flop schematic and the internal design are shown in Fig. 8.17a, b, respectively, where S is the set input, R is the reset input, and Q and Q are the

226

8

Digital Circuits

Fig. 8.16 Schematic of digital circuit for X = P ∙ Q + R ∙ S (a) AND, OR gates, (b) all NAND gates

Fig. 8.17 SR flip-flop (a) schematic diagram, (b) internal design Table 8.12 Truth table for SR flip-flop

Inputs S 0 1 0 1

R 0 0 1 1

Outputs Q Q0 1 0 NA

Q Q0 0 1

outputs. The truth table for SR flip-flop is presented in Table 8.12. The outputs remain unchanged at the initial logic values (Q0 and Q0 ) when both inputs S and R are 0. The outputs change to Q = 1 and Q = 0 for S = 1 and R = 0. The outputs change to Q = 0 and Q = 1 for S = 0 and R = 1. The outputs are unpredictable when both inputs S and R are 1 and the inputs are designated as not allowed (NA).

8.9.2

Edge-Triggered SR Flip-Flop

Flip-flop states are, in general, synchronized with a clock (CK) pulse. The trigger can be positive edge (",clock signal transition from 0 to 1) or negative edge (#,clock signal transition from 1 to 0). The schematic of an edge-triggered SR flip-flop, and

8.9

Sequential Logic

227

Fig. 8.18 Edge-triggered RS flip-flop (a) schematic, (b) internal design

Table 8.13 Truth table for a positive edge-triggered SR flip-flop

S 0 1 0 1 X

R 0 0 1 1 X

CK " " " " 0, 1, #

Q Q0 1 0 NA Q0

Q Q0 0 1 Q0

the internal design are shown in Fig. 8.18a, b, respectively. The truth table for a positive edge-triggered SR flip-flop is presented in Table 8.13. The clock signal transition from 0 to 1 (",positive edge) is required for any change in the outputs for input combinations S = 1 and R = 0 and S = 0 and R = 1. The input combination of both being 1 is not allowed (NA). The input states do not have any effects on the outputs without a positive-edge transition of the clock signal (CK).

8.9.3

D Flip-Flop

The schematic and internal design of a D flip-flop are presented in Figs. 8.19a, b, respectively, where the input D (data) is stored in the output Q at the edge (transition) of a clock signal (CK). The truth table of a positive edge-triggered D flip-flop is presented in Table 8.14, where the output Q changes to the input D at the positive edge of CK.

8.9.4

JK Flip-Flop

JK flip-flops are similar to SR flip-flops with one exception that both inputs can be high simultaneously causing the outputs to toggle at the clock edge, i.e., J =1, K = 1, Q = Q0 , and Q = Q0 : If both inputs are low, the outputs remain unchanged.

228

8

Digital Circuits

Fig. 8.19 D flip-flop, (a) schematic, (b) internal design Table 8.14 Truth table for a positive edge-triggered D flipflop

D 0 1 X X

CK " " 0 1

Q 0 1 Q0 Q0

Q 1 0 Q0 Q0

Fig. 8.20 JK flip-flop, (a) schematic, (b) internal design

If the inputs are different (either high or low), the output Q takes the value of J. The schematic of JK flip-flop and internal design are presented in Figs. 8.20a, b, respectively. The truth table of a negative edge-triggered JK flip-flop is presented in Table 8.15.

8.9.5

T Flip-Flop

T flip-flops are modified version of JK flip-flops wherein both inputs (J, K) are treated as one input (T). The outputs are toggled when input is high T=1 at the clock edge; otherwise, the outputs remain unchanged. The schematic and the internal design of a T flip-flop are shown in Figs. 8.21a, b, respectively. The truth table for a positive edge-triggered T flip-flop is presented in Table 8.16.

8.10

Computer-Aided Analysis and Simulation of Digital Logic Circuits

Table 8.15 Truth table for a negative edge-triggered JK flip-flop

CK # # # # 0,1

J 0 0 1 1 X

K 0 1 0 1 X

229

Q Q0 0 1 Q0 Q0

Q Q0 1 0 Q0 Q0

Fig. 8.21 T flip-flop, (a) schematic, (b) internal design Table 8.16 Truth table for T flip-flop

8.10

CK " " " "

T 0 0 1 1

Q Q0 Q0 Q0 Q0

Q Q0 Q0 Q0 Q0

Computer-Aided Analysis and Simulation of Digital Logic Circuits

The generation of truth tables from Boolean expressions, simplification of Boolean expressions using Boolean algebra, and K-map can be automated using online truth table generators and K-map simplifiers. Truth tables can also be generated using logical function features of Excel. The virtual simulation platform Tinkercad can be used to simulate combinational logic circuits. In this section, the use of Excel for analysis and Tinkercad for simulation of digital logic circuits is briefly discussed.

8.10.1

Analysis Using Excel

In this section, the procedure of truth table generation using logical functions  in Excel is illustrated for the Example 8.6 A = X ∙ Y ∙ Z þ X ∙ Y ∙ Z þ X ∙ Y þ Z . The

230

8

Table 8.17 Truth table for Example 8.6 using Excel

X 0 0 0 0 1 1 1 1

Y 0 0 1 1 0 0 1 1

Z 0 1 0 1 0 1 0 1

X.Y.Z FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE

X’.Y.Z FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE

Digital Circuits

X.(Y′+Z’) FALSE FALSE FALSE FALSE TRUE TRUE TRUE FALSE

A FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE

truth table generated using Excel is presented in Table 8.17. The columns of X, Y, and Z are entered on Excel spreadsheet. Next, the formula for (X ∙ Y ∙ Z ) can be entered on cell D2 as =AND(A2, B2, C2) assuming X, Y, and Z are on columns A, B, and C, respectively. This formula can be copied for the rest of the rows of column D. The formula for E2 is =AND(NOT(A2), B2, C2). Similarly the formula for F2 is =AND(A2,OR(NOT(B2),NOT(C2))). The truth table matches with that of Table 8.9 generated manually.

8.10.2

Simulation Using Tinkercad

The simulation of combinational logic circuits is illustrated using simplified combinational logic circuit of Fig. 8.15 for Example 8.6, A = X + Y ∙ Z. The logic circuit of Fig. 8.15 can be simulated using a two-input quad AND gate IC 7408 and a two-input quad OR gate IC 7432. An Arduino Uno board is used for generating the input bit patterns (X, Y, Z) and monitoring the circuit output (A). The circuit implemented on Tinkercad is shown in Fig. 8.22. The digital input/output pins 5, 4, and 3 are used to output X, Y, and Z form Arduino (inputs to the logic circuit) and pin 6 as the input to Arduino (output of logic circuit). Z and Y are connected to pins 1 and 2 of quad AND gate IC 7408, and the output (Y.Z) is connected to pin 1 of quad OR gate IC 7432. The input X is connected to pin 2 of OR gate IC, and the output (X+Y.Z) from pin 3 is connected to the positive (longer arm) of LED. The logic circuit output is connected pin 6 of Arduino to monitor it. The Arduino power pins 5 V and ground (GND) are used to power the quad AND and OR gate ICs 7408 and 7432 via pins 14 and 7, respectively. The Arduino Uno is programmed to output the bit patterns XYZ 000–111 through pins 5, 4, and 3 and monitor A through pin 6. The input and output combination is displayed on serial monitor as well as the LED. The code snippet and the serial monitor display are shown in Fig. 8.23. The serial monitor display matches with the truth table of Table 8.9. The C++ code for Arduino Uno is presented for completeness. Details of code are discussed later in Chap. 10.

8.10

Computer-Aided Analysis and Simulation of Digital Logic Circuits

231

Fig. 8.22 Logic circuit on Tinkercad for Example 8.6

Fig. 8.23 Logic circuit on Tinkercad for Example 8.6 with code snippet and serial monitor display

_________________________________________________________________ // C++ code for Example 8.6 Fig 8.15 // A = X + Y.Z // Inputs X:pin5, Y:pin4, Z:pin3 // Output A:pin6 // Define constants const int pinX=5; const int pinY=4; const int pinZ=3; const int pinA=6; // setup input/output pinModes void setup() { pinMode(pinX, OUTPUT); pinMode(pinY, OUTPUT); pinMode(pinZ, OUTPUT); pinMode(pinA, INPUT); // set baudRate as 9600 for serial monitor Serial.begin(9600); }

232

8

Digital Circuits

void loop() { int A =0; for (int X=0; X= 0; --i) { analogWrite(enA, i); analogWrite(enB, i); delay(20); } // Now turn off motors digitalWrite(in1, LOW); digitalWrite(in2, LOW); digitalWrite(in3, LOW); digitalWrite(in4, LOW); }

Example 9.3 Modify the C++ code to generate a motion profile of Fig. 9.12 for DC motor using Arduino and the L298N motor driver board. Solution It is assumed that only Motor A is connected to the L298N driver board, and enA, in1, and in2 pins on motor driver are connected to Arduino DIO pins 9, 8, and 7, respectively. The C++ code for the Arduino can be modified to achieve the desired motion profile.

Speed profile for DC motor

60

Speed (rpm)

40 20 0 0

1

2

3

4

5

-20 -40 -60

time (s)

Fig. 9.12 Speed profile of DC motor (Example 9.3)

6

7

8

9

10

9.6

Electronic Control of DC Motor Speed and Direction

253

_________________________________________________________________ // Motor A connections int enA = 9; int in1 = 8; int in2 = 7; void setup() { // Set all the motor control pins to outputs pinMode(enA, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); // Turn off motors - Initial state digitalWrite(in1, LOW); digitalWrite(in2, LOW); } void loop() { delay(1000); // move motor CW motorMotionCW(); motorProfile(); // move motor CCW motorMotionCCW(); motorProfile(); } // function to control direction of rotation of motors void motorMotionCW() { // set motor motion direction CW digitalWrite(in1, HIGH); digitalWrite(in2, LOW); } void motorMotionCCW() { // set motor motion direction CCW digitalWrite(in1, LOW); digitalWrite(in2, HIGH); } void motorProfile() { // Accelerate from zero to maximum speed over 1 s for (int i = 0; i < 251; i++) { analogWrite(enA, i); delay(4); } delay(1000); // Decelerate from maximum speed to zero for (int i = 250; i >= 0; --i) { analogWrite(enA, i); delay(4); } // Turn off motors and wait for 1 s digitalWrite(in1, LOW); digitalWrite(in2, LOW); delay(1000); } _________________________________________________________________

254

9.7

9

Actuators

Stepper Motors

Stepper motors are brushless DC motors that can be driven in discrete step angles. Stepper motors are available with different steps per revolution. For a 200-step stepper motor, the motor rotates one complete revolution in 200 steps with 1.8° per step. Stepper motors are mostly two-phase motors that can be unipolar and bipolar. In unipolar configuration, there are two windings (coils) per phase with 5, 6, or 8 leads. In bipolar configuration, there is one winding per phase. The stepping modes can be wave drive, full drive, and half drive. In wave drive, one phase is energized at a time; in full drive, two phases are energized at a time; and in half drive, alternately one and two phases are energized. The full-drive bipolar stepper motor can be driven using the L298N H-bridge module and an Arduino.

9.7.1

Stepper Motor Characteristics

A stepper motor can be controlled in direction, speed, and number of steps. The direction can be controlled by the sequence of energizing the stator coils (A and B). The speed can be controlled by the rate the signals are given to the coils. The number of steps can be controlled by giving the number of steps.

9.7.2

Driving a Bipolar Stepper Motor Using a Dual H-Bridge and an Arduino

The dual H-bridge L298N can be used to drive a bipolar stepper motor in full-drive mode with pins IN1 and IN2 connected to phase A and pins IN3 and IN4 connected to phase B (Fig. 9.13). The signal sequences to pins IN1, IN2, IN3, and IN4 given in Table 9.2 can be used to control the direction of stepper motor movement (CW # and CCW "). In full-drive mode, two of the four pins are high at any point energizing both coils. The schematic of driving a bipolar stepper motor using the L298N motor driver module and an Arduino Uno board is shown in Fig. 9.14. The L298N driver module is powered with an external 12 V supply to drive the motors. The L298N IC logic circuit is powered by the onboard 5 V regulator (deriving 5 V from 12 V external supply to the board), with 5 V-EN jumper in place. One of the phases (phase A, red and blue) of the stepper motor is connected to the driver module using screw terminals OUT1 and OUT2. The other phase (B, black and green) is connected to screw terminals OUT3 and OUT4. The four input pins of the L298N motor driver module, IN1, IN2, IN3, and IN4 are connected to Arduino Uno DIO pins 6, 5, 4, and 3, respectively. The enabled pins ENA and ENB on the L298N motor driver module are kept in place.

9.7

Stepper Motors

255

Fig. 9.13 Internal connection of a bipolar stepper motor using a dual H-bridge L298N

Table 9.2 Signal combinations to control the rotation of a bipolar stepper motor direction Step 1 2 3 4

IN1 High (1) High (1) Low (0) Low (0)

IN2 Low (0) Low (0) High (1) High (1)

IN3 Low (0) High (1) High (1) Low (0)

IN4 High (1) Low (0) Low (0) High (1)

CW # # # #

Fig. 9.14 Connection diagram for a bipolar stepper motor using L298N driver module

CCW " " " "

256

9

Actuators

The Arduino code for driving the bipolar stepper motor using the Arduino stepper library is listed. First, the stepper motor library is included in the code using #include

Next, a variable named stepsPerRev is defined as the number of steps needed for the stepper motor to complete one revolution. Assuming a 200-step stepper motor, the variable is defined as const int stepsPerRev =200;

Next, an object of the Stepper library, testStepper, is created with stepsPerEv, Arduino DIO pin numbers for IN1, IN2, IN3, and IN4 as arguments, i.e., Stepper testStepper (stepsPerRev, 6, 5, 4, 3).

Next, setup() is created to specify the speed of the stepper motor in rpm (e.g., 50 rpm) and serial monitor baud rate to 9600 as setup() { testStepper.setSpeed(50); Serial.begin(9600); }

Then, the main loop () is created to run the stepper motor in CW direction one revolution, wait for 1 s, run the motor CCW for one revolution, and wait for 1 s. The CW and CCW can be displayed on serial monitor using Serial.println(“CW”) and Serial.println(“CCW”). The comments in the code list are provided to explain the steps. // Include the Arduino Stepper motor Library #include // Define Number of steps per revolution for the stepper motor const int stepsPerRev = 200; // assuming a 200-step motor // Create Instance (Object) of Stepper library Stepper testStepper(stepsPerRev, 6,5,4,3); void setup() { // set the motor speed at 50 rpm: testStepper.setSpeed(50); // initialize the serial port: Serial.begin(9600); }

9.8

Computer-Aided Analysis and Simulation of DC Motors

257

void loop() { // step one revolution in one direction (CW): Serial.println(" Motor in CW rotation"); testStepper.step(stepsPerRev); delay(1000); // step one revolution in the other direction (CCW): Serial.println("Motor in CCW rotation"); testStepper.step(-stepsPerRev); delay(1000); }

________________________________________________________________

9.8 9.8.1

Computer-Aided Analysis and Simulation of DC Motors Analysis Using Matlab

Example 9.4 A DC servomotor is available with an input voltage of 12.0 V, armature resistance of 2.8 Ω, motor constant of 0.20 N.m/A, and equivalent rotor inertia of 5.8 × 10-3 kg.m2. Find the maximum armature current, starting torque, maximum motor speed, starting acceleration, maximum power, speed at maximum power (optimum motor speed), and the operating speed lower and upper limits within 10% of the optimum motor speed. Show torque-speed and power-speed graphs for the DC motor. Matlab code to solve this example is listed along with results. Motor torque-speed and power-speed characteristics graphs are shown in Fig. 9.15a, b. The optimum motor speed and its lower and upper limits of operating speed are shown on the plot of power speed in Fig. 9.15b. ________________________________________________________________ % Example 9.4 clear all; clc; close all Va=12; % Armature voltage (V) Ra=2.8; % Armature resistance (ohm) k=0.20; % Motor constant (N.m/A V.s/rad) Jeq = 5.8e-3; % Rotor inertia (kg.m2) tol = 10; % tolerance (%) tol = tol/100; % tolerance Ia = Va/Ra % Max armature current (A) Ts = k*Ia % Starting torque (N.m) wMax = Va/k % Max motor speed (rad/s) wMaxRpm = wMax*60/(2*pi) % Max motor speed (rpm) Pmax = Ts*wMax/4 % Max power (W) aMax = Ts/Jeq % Starting acceleration (rad/s2)

258

9

(a)

Actuators

(b)

Fig. 9.15 Motor performance characteristics (a) torque speed, (b) power speed aMaxrev = aMax/(2*pi) % Starting acceleration (rev/s2) wOpt = wMax/2 % Speed at max power wL = wOpt*(1-tol) % Lower limit of operating speed (rad/s) wM = wOpt*(1+tol) % Upper limit of operating speed (rad/s) w = linspace(0,wMax,121);% motor speed vector T = Ts*(1-w/wMax); % motor torque vector for i=1: length(w) P(i)=T(i)*w(i); % motor power vector End % plotting normalized motor torque-speed and power-speed characteristics w_norm=w/wMax; T_norm=T/Ts; P_norm = P/Pmax; plot(w_norm,T_norm,'b', w_norm, P_norm, 'r--') grid on xlabel('Normalized motor speed \omega/\omega_m_a_x') ylabel('Normalized motor torque and power') legend('Normalized torque T/T_s','Normalized power P/P_m_a_x') % plotting motor torque-speed characteristics subplot(1,2,1) plot(w,T) grid on xlabel('Motor speed \omega (rad/s)') ylabel('Motor torque T (N.m)') % plotting motor power-speed characteristics

9.8

Computer-Aided Analysis and Simulation of DC Motors

259

subplot(1,2,2) plot(w,P) grid on xlabel('Motor speed \omega (rad/s)') ylabel('Motor power P (W)') Results: Ia = 4.2857 A, Ts = 0.8571 N.m, wMax = 60 rad/s, wMaxRpm = 572.9578 rpm Pmax = 12.8571 W, aMax = 147.7833rad/s2 aMaxrev = 23.5204 rev/s2 wOpt = 30 rad/s, wL = 27 rad/s, wM = 33 rad/s

________________________________________________________________

9.8.2

Simulation Using Tinkercad

The simulation of driving DC motor using the L293D dual H-bridge and an Arduino Uno is illustrated for the motor speed profile of Fig. 9.16. The motor speed profile of Fig. 9.16 is similar to that of Fig. 9.12 except that the speed changes over a longer period, i.e., 5.1 s instead of 1 s. Schematic of driving a DC motor using the L293D dual H-bridge and Arduino Uno on the virtual simulation platform of Tinkercad is shown in Fig. 9.17. The L293D IC is powered with the Arduino by connecting L293D pins 8 and 16 to Arduino 5 V and L293D pins 4, 5, 12, and 13 to Arduino GND. Only one of the H-bridges is necessary to drive the DC motor. Arduino DIO pins 3, 4, and 5 are connected to ENA, IN1, and IN2 pins of L293D (pins 1, 2, and 7). The output pins of L293D OUT1 and OUT2 (pins 3 and 6) are connected to the DC motor terminals.

DC Motor Speed Profile

60

Motor speed (rpm)

40 20 0 0

5

10

15

-20 -40 -60

Time (s)

Fig. 9.16 Speed profile of DC motor (Example 9.5)

20

25

30

260

9

Actuators

Fig. 9.17 Schematic of driving a DC motor using L293D and Arduino on Tinkercad

C++ code for Arduino is also listed for quick reference. The code is similar to the one presented for Example 9.3 with change in delay time (20 ms instead of 4 ms) for acceleration and deceleration periods. ________________________________________________________________ // C++ code // Motor A connections int enA = 3; int in1 = 4; int in2 = 5; void setup() { // Set all the motor control pins to outputs pinMode(enA, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); // Turn off motor - Initial state digitalWrite(in1, LOW); digitalWrite(in2, LOW); } void loop() { directionCW(); speedControl(); directionCCW(); speedControl(); } // control spinning direction of motor CW void directionCW() { // Set motors to maximum speed analogWrite(enA, 0); // Turn on motor A digitalWrite(in1, HIGH); digitalWrite(in2, LOW); }

9.9

Laboratory Experiments

261

// control spinning direction of motor CCW void directionCCW() { // Set motors to maximum speed analogWrite(enA, 0); // Turn on motor A & B digitalWrite(in1, LOW); digitalWrite(in2, HIGH); } // control speed of the motor void speedControl() { // Accelerate from zero to maximum speed for (int i = 0; i < 256; i++) { analogWrite(enA, i); delay(20); } delay(2000); // Decelerate from maximum speed to zero for (int i = 255; i >= 0; --i) { analogWrite(enA, i); delay(20); } // Now turn off motors digitalWrite(in1, LOW); digitalWrite(in2, LOW); delay(1000); }

________________________________________________________________

9.9

Laboratory Experiments

Laboratory experiments can be designed to drive a DC motor and a stepper motor using a double H-bridge IC (L298N) and an Arduino.

9.9.1

Driving a DC Motor Using an H-Bridge (L293N) and an Arduino

The Tinkercad simulation of driving a DC motor using an H-bridge and an Arduino of Sect. 9.8.2 can be implemented in a physical laboratory experiment using a DC motor, an L298N dual H-bridge and an Arduino Uno board. The speed profile of Fig. 9.17 can be realized in a physical environment and can be compared with simulated results.

262

9.9.2

9

Actuators

Driving a Bipolar Stepper Motor Using a Dual H-Bridge and an Arduino

The Tinkercad simulation of driving a bipolar stepper motor using an H-bridge and Arduino of Sect. 9.7.2 can be implemented in a physical laboratory experiment using a bipolar stepper motor, an L298N dual H-bridge IC and an Arduino Uno board. The results of the physical environment can be compared with simulated results.

Exercises 1. For a DC motor with input voltage of 12 V, armature resistance of 3.5 Ω, motor constant of 0.20 N.m/A, and an equivalent rotor inertia of 6.0 × 10-3 kg.m2, find the maximum armature current, stall torque (Ts), and maximum angular acceleration (αmax). 2. For a DC motor with input voltage of 10 V, armature resistance of 2.0 Ω, and motor constant of 0.25 N.m/A, find the maximum rotational speed (ωmax), maximum power (Pmax), the lower limit (ωL), and the upper limit (ωM) of the motor operating speed within 15% of the optimum operating speed. 3. The parameters of an available DC servomotor are given as follows: nominal input voltage (Va) = 10 V, armature resistance (Ra) = 2.5 Ω, armature inductance (La) = 0.24 mH, torque constant (kt) = 0.15 N.m/A, motor constant (ki) = 0.15 V/ rad/s, and equivalent rotor inertia (Jeq) = 9 × 10-3 kg.m2. Obtain the maximum armature current, the starting torque, the maximum motor rotational speed, the maximum power, the speed at which the power is maximum, and the starting angular acceleration. Find the lower and the upper limits of motor speed within 10% of the optimum speed for maximum power. Sketch the torque-speed curve and the power-speed curve. Show the operating speed range of the motor: show all the required parameters. 4. It is necessary to select a DC servomotor such that its stall current is limited to 5A, the starting torque is at least 0.85 N.m, and the power is at least 14.2 W. A DC servomotor is available with an input voltage of 12 V, armature resistance of 2.5 Ω, and motor constant of 0.18 N.m/A. Find the maximum armature current (Ia), the starting torque (Ts), and the maximum power (Pmax) of the available DC servomotor. Verify if the available DC servomotor meets the required specifications. 5. A small DC servomotor with an equivalent rotor inertia of 5.8 × 10-3 kg.m2 is available for a mechatronics project. The motor, when connected to a 13.5 V DC supply, draws a current of 4.5 A producing a starting torque of 0.90 N.m. Find the maximum speed of the motor in rpm, the maximum power, and the starting acceleration (αmax) in rev/s2. Draw the torque-speed and the power-speed characteristics graphs of the DC motor, showing all relevant values for each graph. Label the axes appropriately.

References

263

6. For a DC servomotor, the transfer functions are as follows: the motor armature Þ ωðsÞ 1000 1000 dynamics G1 ðsÞ = V ðsÞI a-ðsEb ðsÞ = 0:28sþ2500 , rotor dynamics G2 ðsÞ = T ðsÞ = 6sþ2, electromechanical coupling between motor torque and armature current G3 ðsÞ = ITaððssÞÞ = 0:21, and back-emf to motor speed G4 ðsÞ = EωbððssÞÞ = 0:21. For an input armature voltage of 10.5 V, find the maximum armature current (Ia), the stall torque (Ts), the maximum power (Pmax), and the maximum acceleration (αmax) for the DC servomotor.

References Alciatore DG (2019) Introduction to mechatronics and measurement systems, 5th edn. McGraw Hill, New York Arduino (2022) Arduino, https://www.arduino.cc Mathworks (2022) Matlab and Simulink, https://www.mathworks.com STMicroelectronics (2022) L298 Dual full bridge driver, https://www.st.com/en/motor-drivers/l2 98.html Texas Instruments (2022) L293D Quadruple half-H drivers, https://www.ti.com/product/L293D Test Equity (2022) Instek GDS-1202B Digital Storage Oscilloscope, https://www.testequity.com Test Equipment Depot (2022) Instek AFG-2105 Arbitrary Waveform Function Generator, https:// www.testequipmentdepot.com/instek/signalgenerators/afg2105.html TEquipment (2022a) Instek GDM-8341 50,000 Counts Dual Measurement Multimeter with USB Device, https://www.tequipment.net/InstekGDM-8341.html TEquipment (2022b) Instek GPE-3323 3 Channels, 217W Linear DC Power Supply, https://www. tequipment.net/Instek/GPE-3323/DC-Power-Supplies Tinkercad (2022) Learn Circuits, https://www.tinkercad.com/learn/circuits

Chapter 10

Microcontroller Programming and Interfacing

10.1

Introduction

A microcomputer is a relatively small, inexpensive, limited capability computer on a single printed circuit board (PCB) with a microprocessor as the central processing unit (CPU), memory for storage of programs and data, and input/output (I/O) interfaces for communication with external peripherals. A microprocessor consists of control unit (CU) and arithmetic logic unit (ALU). A microcontroller is a single IC (integrated circuit) consisting of a microprocessor, memory, analog and digital I/O capabilities, and other on-chip resources for communication, A/D, D/A conversion with peripheral devices. Microcontrollers are widely used in mechatronic systems. Microcomputer architecture consists of major components: microprocessor, bus (data, address, control), memory (read only memory (ROM), random access memory (RAM), erasable programmable read only memory (EPROM)), computer peripherals, and external mechatronic system hardware. Programming languages include two types: low level—machine code (binary), assembly language (mnemonic)—and high level (C/C++, Matlab, and Python, among others). High-level languages include interpreted language- Matlab, Python, and compiler/linker (builder) based—C/C+ (machine code is generated and linked with libraries through compiler and linker). There are two types of computer instruction-set architecture (ISA): RISC (reduced instruction-set computer) and CISC (complex instruction-set computer). RISC is simpler as it executes one instruction per clock cycle, whereas CISC instructions need multiple clock cycles. Microcontrollers use RISC-type ISA.

© The Author(s), under exclusive license to Springer Nature Switzerland AG 2023 B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_10

265

266

10.2

10 Microcontroller Programming and Interfacing

Arduino Microcontroller Development Boards

Arduino Uno R3 is one of the widely used affordable and accessible microcontroller development boards containing an 8-bit microcontroller ATmega328P as the main processor and an ATmega16U2 as the USB-serial processor, both at clock speed of 16 MHz. The microcontroller has a memory of 2KB SRAM (static RAM), 32KB flash memory, and 1 KB EEPROM. Arduino Uno R3 can be interfaced with external peripheral devices/modules through I/O pins that include two pins for serial in and serial out (pin 0:RX, pin 1: TX), 12 pins for digital input/output (pins 2–13: DIO) of which six pins (pins 3, 5, 6, 9–11) marked with tilde (~) can be used for pulse width modulated (PWM) outputs, and six pins for analog inputs (A0–A5). The board can be powered through a USB-B port or an external DC power supply (7–12 V) through a barrel jack. An Arduino Uno board is shown in Fig. 10.1a (https://arduino.cc). The pins are identified on the board. Another popular Arduino microcontroller development board is the Arduino Mega 2560 based on the 8-bit ATmega2560 as the main processor with more I/O pins and higher memory compared to Arduino Uno. These two boards are shown in Fig. 10.1a, b for easier comparison. Arduino Mega 2560 board is configured with 54 DIO pins (0–53) of which 15 pins (2–13, 44–46) can be used as PWM outputs, 16 analog inputs (A0–A15), four serial ports, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. The memory of Mega 2560 is with 8 KB SRAM, 256 KB flash (of which 8 KB can be used by the bootloader), and 4 KB EEPROM; these are considerably higher than Uno (https:// arduino.cc).

Fig. 10.1 Arduino microcontroller development boards. (a) Uno R3, (b) Mega 2560 R3 (https:// arduino.cc)

10.3

10.3

Arduino Programming Environment

267

Arduino Programming Environment

An Arduino microcontroller board can be programmed using Arduino Integrated Development Environment (IDE) (https://arduino.cc). Arduino IDE provides user interface for connecting the Arduino board to the computer and developing, editing, compiling, debugging, and uploading the compiled code to the Arduino board. A snapshot of the Arduino IDE 2.0 is shown in Fig. 10.2 with different functional keys/areas marked 1–11. 1. Verify: To compile the code 2. Upload: To upload the code to the Arduino board 3. Select Board & Port: To select from the automatically detected Arduino boards along with the port number 4. Sketchbook: To see all sketches locally stored on the computer 5. Boards Manager: To browse through Arduino and third-party packages that can be installed 6. Library Manager: To browse through Arduino libraries 7. Debugger: To test and debug programs in real time 8. Search: To search for keywords in the code 9. Open Serial Monitor: To open the Serial Monitor tool, as a new tab in the console 10. Open Serial Plotter: To open the Serial plotter for graphs of data from the Arduino board 11. Serial Monitor Output: Area to see the serial monitor outputs

Fig. 10.2 A snapshot of Arduino IDE 2.0 (arduino.cc)

268

10.4

10 Microcontroller Programming and Interfacing

Arduino Programming Language

An Arduino program is called a sketch. The language for Arduino is based on C/C++ with some restrictions. The Arduino programming language consists of three main groups: functions, values (variables and constants), and structure. Some basic commands from each of these groups are briefly discussed in this section. The details can be accessed from the Arduino website (https://www.arduino.cc/ reference/en/).

10.4.1

Functions

There are several functions for performing computations and controlling Arduino operations. The functions include different categories like input/output, math, trigonometry, time, and communication. Input/Output The pinout diagram is used for interfacing the board with external peripherals. The power pins can provide 3.3 V and 5 V at a few milliamperes (mA). The DIO pins (0–13) can be used as input or output of 0–5 V, interpreted as 0 (0 V) or 1 (5 V), through commands digitalRead() and digitalWrite(), respectively. Of these, six pins (3, 5, 6, 9–11) can be programmed to output 8-bit PWM square waves using analogWrite(). Analog input pins (A0–A5) can be programmed to input 0–5 V through a 10-bit ADC using analogRead() with a resolution of 4.9 mV

5V 210 - 1

.

The input voltage can be changed through an external analog reference input at the AREF pin and analogReference() command. The DIO pins can be programmed as input or output pins using pinMode(). Examples of digitalRead(), digitalWrite(), analogRead(), and analogWrite() are briefly presented. Example Code: Example of digitalRead() and digitalWrite() _________________________________________________________________ // Example of digitalRead() and digitalWrite() int ledPin = 3; // LED connected to digital pin 3 int pbPin = 4; // pushbutton connected to digital pin 4 int pbStatus = 0; // variable to store the read value (pushbutton status) void setup() { pinMode(ledPin, OUTPUT); // set the digital pin 10 as output pinMode(pbPin, INPUT); // set the digital pin 5 as input Serial.begin(9600); // set serial monitor baud rate at 9600 bits/s } void loop() { pbStatus = digitalRead(pbPin); // read the input pin Serial.print("PB status= "); // print PB Status= Serial.println(pbStatus); // print pbStatus value digitalWrite(ledPin, pbStatus); // sets the LED to the pbStatus value } _________________________________________________________________

10.4

Arduino Programming Language

269

Example Code: Example of analogRead() and analogWrite() _________________________________________________________________ // Example of analogRead() and analogWrite() // LED intensity is proportional to potentiometer value int ledPin = 5; // LED connected to digital pin 5 int analogPin = 2; // potentiometer connected to analog pin A2 int val = 0; // variable to store the read value int ledVal = 0; // variable to store led value void setup() { pinMode(ledPin, OUTPUT); // set the pin as output Serial.begin(9600); // set serial monitor baud rate at 9600 bits/s } void loop() { val = analogRead(analogPin); // read the input analogPin [0-1023] Serial.print("Sensor val="); Serial.print(val); // print analogPin reading ledVal = val/4; // ledVal [0-255] Serial.print(" Led val="); Serial.println(ledVal); analogWrite(ledPin, ledVal); // send ledVal to ledPin } _________________________________________________________________

Math Math functions include abs(), constrain(), max(), min(), pow(), sq(), and sqrt() that are used for basic operations for getting the absolute value, constraining a number within a range, finding the larger of two numbers, the smaller of two numbers, calculating the value of a number raised to a power, the square of a number, and the square root of a number, respectively. Trigonometry Three trigonometric functions, namely, sin(), cos(), and tan() are available for calculating, respectively, sine, cosine, and tangent of an angle in radians. Time Time functions include delay(), delayMicroseconds(), micros(), and millis() to pause operations for a time in milliseconds, microseconds, or getting the time since starting the current program in microseconds and milliseconds, respectively. Communication One of the most commonly used communication modes between an Arduino board and the computer or other devices is done using Serial with other functionalities, like Serial.begin(), Serial.print(), and Serial.println(). These functions are used for beginning the serial communication, printing a value on the serial monitor (same line), and printing a value on the serial monitor followed with a carriage return (new line), respectively.

270

10.4.2

10 Microcontroller Programming and Interfacing

Variables

The constants and data types are covered under variables. Constants The constants include INPUT, OUTPUT, HIGH, LOW, true, and false. Data Types Data types include int, float, double, bool, byte, char, and string to represent data type as integers, floating-point numbers, double-precision floating-point numbers, Boolean value of true or false, 8-bit unsigned number, a character value (ASCII), and a string of characters, respectively. Data type void is used only in the declaration of a function like void funtionName(){. . .}, indicating that the functionName() does not return any value to the function where it is called. An example of using data types, delay, and serial communication is presented next. Example Code: Example of Data Type, Time, and Serial Communication _________________________________________________________________ // Example of data type, time, and Serial communication const int ledPin = 3; // set digital pin 3 as ledPin int ledStatus; // declare ledStatus as an integer void setup() { pinMode(ledPin, OUTPUT); // set the ledPin as output Serial.begin(9600); // set serial monitor baud rate at 9600 bits/s } void loop() { ledStatus = HIGH; // set ledStatus as HIGH digitalWrite(ledPin, ledStatus); // set the ledPin on Serial.print(ledStatus); // print on Serial Monitor delay(2000); // wait for 2 seconds ledStatus = LOW; // set ledStatus as LOW digitalWrite(ledPin, ledStatus); // set the ledPin off Serial.println(ledStatus); // print on Serial Monitor with carriage return (new line) delay(2000); // wait for 2 seconds } _________________________________________________________________

Variable Scope and Qualifiers The commonly used variable qualifiers include const and static that are used to treat a variable as constant and to keep the value of a static variable within a function between function calls. The scope of a variable depends on its place of definition. A global variable is declared outside a function, whereas a local variable is declared within a function. A scope of a variable within braces in a function like in a for loop is within the for loop. An example code snippet of variable scope is presented next.

10.4

Arduino Programming Language

271

Example Code: Example of Variable Scope _________________________________________________________________ // Example of variable scope int ledVal; // this variable is accessible to any functions (global) void setup() { // ... } void loop() { int i; // variable i is accessible inside function loop() float f; // variable f is accessible inside function loop() // ... for (int k = 0; k < 10; k++) { // variable k is accessible inside the for-loop } } _________________________________________________________________

10.4.3

Structure

Sketch Each Arduino program (sketch) must have two functions setup() and loop(). The setup() function is required to set up the communication between the board and the computer and to assign the input/output status to the Arduino digital input/output (DIO) pins. It is placed at the beginning of the sketch, after the global variables are declared. The loop() function is the main code where the actual operations are carried out. Both these functions are declared as type void as none of these functions returns a value. Control Structure The sketch includes common C++ control structures like do. . .while, while, for, if else, and switch(). . .case. The structure do. . .while and while are used in a similar way with one exception, the condition is checked at the end of the do. . .while loop, whereas the condition is checked at the beginning of a while loop. In a for loop, the statements within the scope of the for loop are executed with the number of times specified in the for loop. If. . .else structure is used to test a condition and the statements within the scope of if are executed if the condition is true, otherwise the statements within the scope of the else are executed. Switch. . .case statement is to control the flow of programs to specify different group of code that should be executed in various conditions. In particular, a switch statement compares the value of a variable to the values specified in case statements. When a case statement

272

10 Microcontroller Programming and Interfacing

is found whose value matches that of the variable, the code in that case statement is executed. The break keyword exits the switch statement and is typically used at the end of each case. Example code snippets are presented next. Example Code Snippets: Examples of Do. . . While, While, If... Else, Switch. . . Case Structures _________________________________________________________________ //Example of do. . .while int x = 0; do { delay(20); // wait for input to stabilize x = analogRead(4); // read the analog input pin 4 } while (x < 50); // continue the while loop if x < 50 ---------------------------------------------------------------– // Example of while var = 0; while (var < 100) { //continues the loop while var= 30) { // add statements to be executed when val >=30 } else if (val >= 20) { // add statements to be executed when 20 = (greater than or equal to). Boolean Operators Boolean operators include ! (logical not), || (logical or), and && (logical and). Pointer Access Operators The pointer access operator ampersand & (reference operator) and &x is used to reference to the address of the variable (x) and the operator * (dereference operator); *p is used to represent the value contained in the address pointed by the pointer (p). Bitwise Operators Bitwise operators include & (bitwise and), > (bit shift right), ^ (bitwise xor), | (bitwise or), and ~ (bitwise not). Compound Operators Compound operators include %= (compound remainder), &= (compound bitwise and), *= (compound multiplication), ++ (increment), += (compound addition), %2 D%2D (decrement), -= (compound subtraction), /= (compound division), ^= (compound bitwise xor), and |= (compound bitwise or).

10.5

An Example Code

A simple code for blinking built-in LED pin (13) and plotting the LED status on the serial monitor is presented next. The LED status as seen on the serial monitor using serial plotter feature of Arduino IDE 2.0 is shown in Fig. 10.3.

274

10 Microcontroller Programming and Interfacing

Fig. 10.3 Blinking LED status plot on serial monitor plotter (Arduino IDE 2.0) // Example of blinking LED and seeing the ledStatus on Serial Monitor Plotter // set global variable ledPin as an integer constant const int ledPin = 13; // built-in LED Pin int ledStatus; // sets global variable ledStatus as an integer // setup the pinMode and serial connection void setup() { pinMode(ledPin, OUTPUT); // sets ledPin as output Serial.begin(9600); // sets baud rate for serial monitor } // Main code void loop() { ledStatus = HIGH; digitalWrite(ledPin, ledStatus); // sets ledPin to HIGH (ON) Serial.println(ledStatus); // prints on Serial Monitor delay(1000); // delay for 1 second ledStatus = LOW; digitalWrite(ledPin, ledStatus); // resets ledPin to LOW (OFF) Serial.println(ledStatus); // prints on Serial Monitor delay(1000); // delay for 1 second }

10.6

Virtual Simulation on Tinkercad

Arduino-based systems can be simulated using the open-access virtual simulation environment of Tinkercad for circuits. The simulation environment supports basic circuit elements, diodes, transistors, breadboards, power supplies, multimeter, oscilloscope, Arduino Uno R3 model, and digital logic gates. The circuits can be

10.7

Simulation of Example Codes on Tinkercad

275

constructed virtually that resemble the actual physical circuits. Tinkercad simulation provides an excellent opportunity to create the circuits, connect the Arduino pins, and develop and verify the code in virtual environment. The actual physical circuits using physical circuit elements, components, power supplies, and Arduino boards can be constructed from the virtual simulation models, and the verified Arduino codes can be downloaded or copied and pasted to Arduino IDE for real-time physical implementation. Open-access simulation environment of Tinkercad can be accessed creating a personal account on Tinkercad website (https://www.tinkercad.com) or using a Google account.

10.7

Simulation of Example Codes on Tinkercad

Example codes of Arduino language features discussed in Sect. 10.4 and tested on Tinkercad are presented along with results.

10.7.1

Simulation of digitalRead and digitalWrite on Tinkercad

The example code of digitalRead() and digitalWrite() simulated on Tinkercad is shown in Fig. 10.4. In this simulation, a push button is connected to digital pin 4 (pbPin) as input, and a LED is connected to pin 3 (ledPin) as output. The status of push button is read using digitalRead() and stored in an integer variable pbStatus. The push-button status is printed on serial monitor using Serial.println(pbStatus), and it is also sent to ledPin using digitalWrite(ledPin, pbStatus). The serial monitor display and the LED status (on or off) are shown in the simulation environment of Tinkercad. The code is also listed for quick reference.

Fig. 10.4 Simulation of example code of digitalRead and digitalWrite on Tinkercad

276

10 Microcontroller Programming and Interfacing

// Example of digitalRead and digitalWrite int ledPin = 3; // LED connected to digital pin 3 int pbPin = 4; // pushbutton connected to digital pin 4 int pbStatus = 0; // variable to store the read value (pushbutton status) void setup() { pinMode(ledPin, OUTPUT); // set the digital pin 10 as output pinMode(pbPin, INPUT); // set the digital pin 5 as input Serial.begin(9600); // set serial monitor baud rate at 9600 bits/s } void loop() { pbStatus = digitalRead(pbPin); // read the input pin Serial.print("PB status= "); // print Serial.println(pbStatus); // print pbStatus value digitalWrite(ledPin, pbStatus); // sets the LED to the pbStatus value }

10.7.2

Simulation of analogRead and analogWrite on Tinkercad

The example code of analogRead() and analogWrite() simulated on Tinkercad is shown in Fig. 10.5. In this simulation, a potentiometer output is connected to analog pin A2 (analogPin), and a LED is connected to pin 5 (ledPin) as output. The value of potentiometer reading is read using analogRead() in the range [0, 1023] and stored in an integer variable val. This value is divided by 4 and stored in an integer variable ledVal in the range of [0, 255]. The output pin 5 is PWM enabled so that a value in the range [0, 255] can be sent using analogWrite() command. The value of potentiometer reading and its scaled value (ledVal) are printed on serial monitor using Serial.print(). The variable ledVal is also sent to ledPin using analogWrite(ledPin, ledVal). The intensity of the LED is proportional to the potentiometer reading (val). The serial monitor display and the LED intensity are shown in the simulation environment of Tinkercad. For the potentiometer reading (val) of 491, ledVal is 122. The code is also listed for quick reference.

Fig. 10.5 Simulation of example code of analogRead and analogWrite on Tinkercad

10.7

Simulation of Example Codes on Tinkercad

277

// Example of analogRead and analogWrite // LED intensity is proportional to potentiometer value int ledPin = 5; // LED connected to digital pin 5 int analogPin = 2; // potentiometer connected to analog pin A2 int val = 0; // variable to store the read value int ledVal = 0; // variable to store led value void setup() { pinMode(ledPin, OUTPUT); // sets the pin as output Serial.begin(9600); // set serial monitor baud rate 9600 } void loop() { val = analogRead(analogPin); // read the input analogPin [0-1023] Serial.print("Sensor val="); Serial.print(val); // print analogPin reading ledVal = val/4; // ledVal [0-255] Serial.print(" Led val="); Serial.println(ledVal); analogWrite(ledPin, ledVal); // send ledVal to ledPin }

10.7.3

Simulation of Data Type, Time, and Serial Communication on Tinkercad

The example code of data type, time, and serial communication simulated on Tinkercad is shown in Fig. 10.6. This example is similar to the example code of digitalRead and digitalWrite with usage of data type (int), variable qualifier (const), time (delay), and serial communication (Serial.begin, Serial.print, Serial.println). The digital pin numbers 3 and 4 are assigned to constant integers ledPin and pbPin, respectively. The variables pbStatus and ledStatus are declared as integers. The baud rate for serial communication between the computer and the Arduino board is set at

Fig. 10.6 Simulation of an example code of data type, time, and serial communication on Tinkercad

278

10 Microcontroller Programming and Interfacing

9600 (bits per second) using Serial.begin(9600). The values are displayed on serial monitor using Serial.print() and Serial.println(), the last one with new line character. A pause for 1 s (1000 ms) is implemented using delay(1000). // Example of data type, time, and Serial communication const int ledPin = 3; // set digital pin 3 as ledPin const int pbPin = 4; // set digital pin 4 as pbPin int ledStatus; // declare ledStatus as an integer int pbStatus; // declare pbStatus as an integer void setup() { pinMode(ledPin, OUTPUT); // set the ledPin as output pinMode(pbPin, INPUT); // set pbPin as input Serial.begin(9600); // set baud rate at 9600 for serial communication } void loop() { pbStatus = digitalRead(pbPin); // read pbPin ledStatus = pbStatus; // make ledStatus as pbStatus digitalWrite(ledPin, ledStatus); // set the ledPin on Serial.print("LED status= "); // print LED status= Serial.println(ledStatus); // print on Serial Monitor delay(2000); // wait for 2 seconds }

10.7.4

Simulation of Compound Operators on Tinkercad

The example code of compound operators simulated on Tinkercad is shown in Fig. 10.7. The variables x and y are declared as integer variables. The baud rate is set at 9600 bits per second. The variable x is initially 57. The compound remainder operator %= using x %=5 gives the remainder as 2. The compound multiplication operator x *=4 gives x as 8. The increment operator y= x++ makes x = 9 and y = 9. Next y=++x makes x = 10; y remains at 9. Compound addition x +=5 makes

Fig. 10.7 Simulation of an example code of compound operator on Tinkercad

10.7

Simulation of Example Codes on Tinkercad

279

x = 15; y remains 9. The decrement operator y=--x makes x = 14 and y = x. The decrement operator y= x -- makes x = 13 and y = 14. Compound subtraction x -=5 makes x = 8 and y = 14. Compound division x /=2 makes x = 4; y remains 14. These values are displayed on serial monitor. // Examples of compound operators int x; // set x as an integer variable int y; // set y as an integer variable void setup() { Serial.begin(9600); // set baud rate as 9600 for serial communication } void loop() { // Example of %= x = 57; x %= 5; // x equals to 2 Serial.print("x=57 x %=5 ="); Serial.println(x); // Example of *= x *= 4; // x now equals to 8 Serial.print("x=2 x *=4 ="); Serial.println(x); // Example of ++ y = ++x; // x equals 9, y equals 9 Serial.print("y = ++x , x, y "); Serial.print(x); Serial.print(" "); Serial.println(y); // Example of ++ y = x++; // x equals 10, y equals 9 Serial.print("y = ++x , x, y "); Serial.print(x); Serial.print(" "); Serial.println(y); // Example of += x += 5; // x equals 15 Serial.print("x += 5 , x, y "); Serial.print(x); Serial.print(" "); Serial.println(y); // Example of -y = --x; // x equals 14, y equals x Serial.print("y= --x , x, y "); Serial.print(x);

280

10 Microcontroller Programming and Interfacing

Serial.print(" "); Serial.println(y); y = x--; // x equals 13, but y still equal 14 Serial.print("y = x-- , x, y "); Serial.print(x); Serial.print(" "); Serial.println(y); // Example of -= x -= 5; // x equal 8 Serial.print("x -= 5 , x, y "); Serial.print(x); Serial.print(" "); Serial.println(y); // Example of /= x /= 2; // x equals 4 Serial.print("x /= 2 , x, y "); Serial.print(x); Serial.print(" "); Serial.println(y); delay(1000); // wait for 1000 millisecond(s) }

10.8 10.8.1

Arduino Programming and Interfacing Examples Simulation of 3-Bit Binary Patterns (000-111) Using an Arduino and Three LEDs

The objective of this example is to create a circuit for representing 3-bit binary patterns 000-111 using three digital outputs and three LEDs (RED, GREEN, and BLUE) through an Arduino microcontroller. For example, to represent 000, all three LEDs should be OFF, and to represent 111, all three LEDs should be ON. A snapshot of Tinkercad simulation is presented in Fig. 10.8. A resistor (220 Ω) is connected to each LED. The LEDs are connected to Arduino digital pins 4, 3, and 2 (A, B, and C). First, the pins (pinA, pinB, and pinC) are declared as constant integers. In the setup() block, the pins are set as OUTPUT using pinMode(). The baud rate is set at 9600 bits/s for serial communication between the Arduino and the computer. In the loop() block, the bit patterns (000-111) are generated using nested for loops, one for each integer variable A, B, and C with values 0 and 1. Each variable is sent to the corresponding output pin using digitalWrite(). The generated bit patterns are displayed on serial monitor using Serial.print() and Serial.println(), as shown in the code listing.

10.8

Arduino Programming and Interfacing Examples

281

Fig. 10.8 Simulation of 3-bit binary patterns using an Arduino and three LEDs on Tinkercad

_________________________________________________________________ // Code for LED patterns 000-111 // Inputs (to the circuit) A, B, C // declare pins as constant integers const int pinA = 4; const int pinB = 3; const int pinC = 2; // start of setup void setup() { // setup pins for output (from Arduino) pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); // setup baud rate to 9600 for Serial Monitor Serial.begin(9600); } // end of setup // start of loop void loop() { for (int A=0; A