Download as pdf or txt
Download as pdf or txt
You are on page 1of 368

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 (eBook)


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

© 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 engi-


neering 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 Measure-
ment 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 measure-
ment principles, basic circuits and electronics, instrumentation and data acquisition,
signal processing—analog and digital, sensors, actuators, digital circuits, and micro-
controller 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” learn-
ing 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, funda-
mentals 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, non-
inverting amplifier, adder, buffer, comparator, integrator, and differentiator are
presented.
In Chap. 6, number systems, analog-to-digital conversion (ADC), digital-to-
analog 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 hands-
on 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 Engi-
neering (MSME) at Georgia Southern.
The content of the book, though primarily used in undergraduate- and graduate-
level 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 lab-
oratory 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 con-
structive 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 simu-
lations 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 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Mechatronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 An Integrated Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Organization of Book Chapters . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Measurement Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4.1 Basic Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4.2 Excel and Matlab Commands for Basic Statistics . . . . . 7
1.4.3 Example Problems: Basic Statistics . . . . . . . . . . . . . . . 8
1.4.4 Uncertainty Analysis . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.4.5 Estimation of Allowable Uncertainty of Individual
Measured Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.4.6 Example Problems: Uncertainty Analysis . . . . . . . . . . . 12
1.4.7 Computer-Aided Analysis of Basic Statistics
and Uncertainty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.4.8 Experiment on Basic Statistics . . . . . . . . . . . . . . . . . . 15
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2 Basic Electrical Circuit Elements and Circuit Analysis . . . . . . . . . . 21
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.2 Basic Electrical Circuit Elements . . . . . . . . . . . . . . . . . . . . . . . 21
2.2.1 Resistor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.2.2 Capacitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2.3 Inductor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3 Basic Electrical Circuit Elements in Series
and in Parallel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.3.1 Resistors in Series and in Parallel . . . . . . . . . . . . . . . . 25
2.3.2 Capacitors in Series and in Parallel . . . . . . . . . . . . . . . 26
2.3.3 Inductors in Series and in Parallel . . . . . . . . . . . . . . . . 27

xiii
xiv Contents

2.4 DC Circuit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28


2.4.1 Ohm’s Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.4.2 Kirchhoff’s Current Law . . . . . . . . . . . . . . . . . . . . . . 28
2.4.3 Kirchhoff’s Voltage Law . . . . . . . . . . . . . . . . . . . . . . 28
2.5 Ideal Voltage and Current Sources and Measuring
Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.6 Equivalent Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.6.1 Thevenin Equivalent Circuit . . . . . . . . . . . . . . . . . . . . 29
2.6.2 Norton Equivalent Circuit . . . . . . . . . . . . . . . . . . . . . . 29
2.7 AC Circuit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.7.1 AC Signal and Phasor Representation . . . . . . . . . . . . . 30
2.7.2 Impedance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.8 Power in Electrical Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.9 Transformer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.10 Impedance Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.11 Computer-Aided Analysis of Basic Circuits . . . . . . . . . . . . . . . 35
2.11.1 Analysis Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . 36
2.11.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . 36
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3 Basic Electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.2 Introduction to Junction Diodes . . . . . . . . . . . . . . . . . . . . . . . . 41
3.2.1 Ideal Diode Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.2.2 Nonlinear Current-Voltage Characteristics
of Junction Diodes . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.2.3 Zener Diode and Voltage Regulation . . . . . . . . . . . . . . 44
3.2.4 Analysis of Diode Circuits . . . . . . . . . . . . . . . . . . . . . 47
3.2.5 Rectifier Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.3 Bipolar Junction Transistors . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.3.1 Example Problem of npn BJT . . . . . . . . . . . . . . . . . . . 54
3.3.2 Example Problem of pnp BJT . . . . . . . . . . . . . . . . . . . 55
3.4 Metal Oxide Semiconductor Field Effect Transistors . . . . . . . . . 57
3.4.1 NMOS Example Problem . . . . . . . . . . . . . . . . . . . . . . 59
3.4.2 PMOS Example Problem . . . . . . . . . . . . . . . . . . . . . . 60
3.5 Computer-Aided Analysis of Basic Electronic
Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.5.1 Analysis Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . 62
3.5.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . 63
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Contents xv

4 Dynamic System Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . 67


4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.2 First-Order Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.2.1 Time Domain Analysis . . . . . . . . . . . . . . . . . . . . . . . . 68
4.2.2 Frequency Domain Analysis . . . . . . . . . . . . . . . . . . . . 69
4.2.3 Experimental Determination of System
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.3 Second-Order Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.3.1 Time Domain Analysis . . . . . . . . . . . . . . . . . . . . . . . . 72
4.3.2 Frequency Domain Analysis . . . . . . . . . . . . . . . . . . . . 79
4.3.3 Experimental Determination of System
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.4 Fourier Series Representation of Periodic Signals . . . . . . . . . . . 82
4.4.1 Fourier Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.4.2 Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
4.4.3 Examples of Fourier Transform of Signals
Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
4.5 Computer-Aided Analysis and Simulation of Dynamic
System Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.5.1 Analysis Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . 87
4.5.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . 88
4.6 Experimental Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
5 Analog Signal Processing and Operational Amplifiers . . . . . . . . . . . 95
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.2 Operational Amplifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.3 Ideal Operational Amplifier Model . . . . . . . . . . . . . . . . . . . . . . 96
5.4 Inverting Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
5.5 Noninverting Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
5.6 Summing Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
5.7 Difference Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
5.8 Integrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
5.9 Differentiator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
5.10 Voltage Follower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
5.11 Comparator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
5.12 Sample and Hold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
5.13 Instrumentation Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
5.14 The Real Operational Amplifier . . . . . . . . . . . . . . . . . . . . . . . . 114
5.15 Computer-Aided Analysis and Simulation
of Operational Amplifier Circuits . . . . . . . . . . . . . . . . . . . . . . . 114
5.15.1 Analysis Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . 114
5.15.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . 115
xvi Contents

5.16 Summary of Operational Amplifier Configurations . . . . . . . . . . 116


5.17 Simulation and Experimental Validation . . . . . . . . . . . . . . . . . . 116
5.17.1 Basic Operational Amplifier Configurations . . . . . . . . . 116
5.17.2 Integrator, Differentiator, and Modified Versions . . . . . 124
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
6 Data Acquisition and Digital Signal Processing . . . . . . . . . . . . . . . . 139
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
6.2 Analog and Discrete Signals . . . . . . . . . . . . . . . . . . . . . . . . . . 139
6.3 Number Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
6.3.1 Decimal Number System . . . . . . . . . . . . . . . . . . . . . . 141
6.3.2 Binary Number System . . . . . . . . . . . . . . . . . . . . . . . . 141
6.3.3 Octal and Hexadecimal Number Systems . . . . . . . . . . . 142
6.3.4 Decimal to Binary Conversion . . . . . . . . . . . . . . . . . . 142
6.3.5 Binary to Octal Conversion . . . . . . . . . . . . . . . . . . . . . 143
6.3.6 Binary to Hexadecimal Conversion . . . . . . . . . . . . . . . 143
6.4 Analog-to-Digital Conversion . . . . . . . . . . . . . . . . . . . . . . . . . 144
6.4.1 Successive Approximation Register
(SAR) ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
6.4.2 Flash ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
6.4.3 ADC Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
6.5 Digital-to-Analog Conversion . . . . . . . . . . . . . . . . . . . . . . . . . 149
6.5.1 Digital-to-Analog Converters . . . . . . . . . . . . . . . . . . . 149
6.5.2 DAC Relation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
6.6 Virtual Instruments, Data Acquisition, and Digital
Signal Processing Using LabVIEW . . . . . . . . . . . . . . . . . . . . . 151
6.6.1 Virtual Instruments . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
6.6.2 Signal Simulation and Analysis . . . . . . . . . . . . . . . . . . 152
6.6.3 Data Acquisition and Digital Signal Processing . . . . . . 154
6.7 LabVIEW Experimentation . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
7 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
7.2 Position, Displacement, and Velocity Measurement . . . . . . . . . . 163
7.2.1 Proximity Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
7.2.2 Potentiometers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
7.2.3 Ultrasonic Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
7.2.4 Tachogenerators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
7.3 Stress and Strain Measurement Using Strain Gages . . . . . . . . . . 165
7.3.1 Electrical Resistance Strain Gage . . . . . . . . . . . . . . . . . 165
7.3.2 Wheatstone Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
7.3.3 Member with Axial Load . . . . . . . . . . . . . . . . . . . . . . 170
7.3.4 Member with Transverse Load . . . . . . . . . . . . . . . . . . 171
Contents xvii

7.4 Vibration and Acceleration Measurement . . . . . . . . . . . . . . . . . 173


7.4.1 Vibration Pickups for Displacement
Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
7.4.2 Accelerometers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
7.4.3 Piezoelectric Accelerometers . . . . . . . . . . . . . . . . . . . . 180
7.4.4 Charge Amplifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
7.4.5 A Piezoelectric Accelerometer with
a Charge Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
7.5 Temperature Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
7.5.1 Resistance Temperature Detectors . . . . . . . . . . . . . . . . 185
7.5.2 Thermistors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
7.5.3 Thermocouples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
7.6 Computer-Aided Analysis and Simulation
of Wheatstone Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
7.6.1 Analysis Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . 191
7.6.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . 192
7.7 Experimental Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
7.7.1 Data Acquisition and Analysis Using LabVIEW
and a Thermocouple . . . . . . . . . . . . . . . . . . . . . . . . . . 192
7.7.2 Measurement Using a Strain Gage Under Static
Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
7.7.3 Data Acquisition and Analysis Using LabVIEW
and a Strain Gage Under Dynamic Condition . . . . . . . . 198
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
8 Digital Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
8.2 Combinational Logic Devices . . . . . . . . . . . . . . . . . . . . . . . . . 207
8.3 Boolean Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
8.4 De Morgan’s Laws . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
8.5 Truth Table and Simplified Boolean Expression from
a Given Boolean Expression . . . . . . . . . . . . . . . . . . . . . . . . . . 213
8.6 Simplified Boolean Expression and Digital Circuit
from a Given Truth Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
8.7 Design of Digital Logic Networks . . . . . . . . . . . . . . . . . . . . . . 218
8.7.1 Define the Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
8.7.2 Write the Quasi-Logic Statement . . . . . . . . . . . . . . . . . 219
8.7.3 Write the Boolean Expression . . . . . . . . . . . . . . . . . . . 219
8.7.4 Simplify the Boolean Expression . . . . . . . . . . . . . . . . . 219
8.7.5 Construct the Digital Logic Circuit . . . . . . . . . . . . . . . 220
8.7.6 Convert to an all-NAND Circuit . . . . . . . . . . . . . . . . . 220
8.7.7 Convert to an All-NOR Circuit . . . . . . . . . . . . . . . . . . 221
8.8 Karnaugh Map (K-Map) for Simplification
of Boolean Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
xviii Contents

8.9 Sequential Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225


8.9.1 SR Flip-Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
8.9.2 Edge-Triggered SR Flip-Flop . . . . . . . . . . . . . . . . . . . 226
8.9.3 D Flip-Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
8.9.4 JK Flip-Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
8.9.5 T Flip-Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
8.10 Computer-Aided Analysis and Simulation
of Digital Logic Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
8.10.1 Analysis Using Excel . . . . . . . . . . . . . . . . . . . . . . . . . 229
8.10.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . 230
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
9 Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
9.2 Types of Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
9.3 Electromechanical Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . 237
9.4 DC Motor Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
9.4.1 Dynamic Model of an Armature
Controlled DC Motor . . . . . . . . . . . . . . . . . . . . . . . . . 239
9.4.2 Steady-State Characteristics . . . . . . . . . . . . . . . . . . . . 241
9.5 Selection of DC Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
9.6 Electronic Control of DC Motor Speed and Direction . . . . . . . . 246
9.6.1 Pulse Width Modulation (PWM) . . . . . . . . . . . . . . . . . 246
9.6.2 H-Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
9.6.3 L293D Motor Driver IC . . . . . . . . . . . . . . . . . . . . . . . 248
9.6.4 L298N Motor Driver Module . . . . . . . . . . . . . . . . . . . 249
9.6.5 DC Motor Speed and Direction Control
Using an Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
9.7 Stepper Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
9.7.1 Stepper Motor Characteristics . . . . . . . . . . . . . . . . . . . 254
9.7.2 Driving a Bipolar Stepper Motor Using
a Dual H-Bridge and an Arduino . . . . . . . . . . . . . . . . . 254
9.8 Computer-Aided Analysis and Simulation of DC Motors . . . . . . 257
9.8.1 Analysis Using Matlab . . . . . . . . . . . . . . . . . . . . . . . . 257
9.8.2 Simulation Using Tinkercad . . . . . . . . . . . . . . . . . . . . 259
9.9 Laboratory Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
9.9.1 Driving a DC Motor Using an H-Bridge
(L293N) and an Arduino . . . . . . . . . . . . . . . . . . . . . . 261
9.9.2 Driving a Bipolar Stepper Motor Using a Dual
H-Bridge and an Arduino . . . . . . . . . . . . . . . . . . . . . . 262
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Contents xix

10 Microcontroller Programming and Interfacing . . . . . . . . . . . . . . . . 265


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

11 Basic Control Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295


11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
11.2 Control System Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
11.2.1 Mathematical Modeling . . . . . . . . . . . . . . . . . . . . . . . 296
11.2.2 Open and Closed Loop System Characteristics . . . . . . . 297
11.3 Stability Analysis of Control Systems . . . . . . . . . . . . . . . . . . . . 300
11.3.1 Closed Loop Poles on S-Plane . . . . . . . . . . . . . . . . . . 300
11.3.2 Routh-Hurwitz Criterion . . . . . . . . . . . . . . . . . . . . . . . 301
11.3.3 Root Locus Technique . . . . . . . . . . . . . . . . . . . . . . . . 301
11.3.4 Bode Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
11.4 Control System Specifications . . . . . . . . . . . . . . . . . . . . . . . . . 305
11.4.1 Design Specifications . . . . . . . . . . . . . . . . . . . . . . . . . 306
11.4.2 Types of Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . 307
11.5 Controller Design Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
11.5.1 PID Controller Design Using Time Domain
Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
11.5.2 PID Controller Design Using Frequency
Domain Specifications . . . . . . . . . . . . . . . . . . . . . . . . 314
11.5.3 Experimental Method: Ziegler-Nichols Method . . . . . . 320
11.6 Controller Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
12 Mechatronic Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
12.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
12.2 Robotics Project Using Lego Mindstorms EV3 . . . . . . . . . . . . . 333
12.3 EV3 Intelligent Brick . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
12.4 EV3 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
12.5 EV3 Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
12.6 EV3 Sensor Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
12.6.1 Light Sensor Calibration . . . . . . . . . . . . . . . . . . . . . . . 336
12.6.2 Touch Sensor Calibration . . . . . . . . . . . . . . . . . . . . . . 337
12.6.3 Ultrasonic Sensor Calibration . . . . . . . . . . . . . . . . . . . 338
12.6.4 Gyro Sensor Calibration . . . . . . . . . . . . . . . . . . . . . . . 338
12.7 EV3 Motor Speed Calibration . . . . . . . . . . . . . . . . . . . . . . . . . 339
12.8 EV3 Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
12.8.1 Line Following . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
12.8.2 Obstacle Avoidance . . . . . . . . . . . . . . . . . . . . . . . . . . 342
12.8.3 Line Following While Avoiding Obstacle . . . . . . . . . . 344
12.8.4 Following a Moving Target . . . . . . . . . . . . . . . . . . . . 345
12.9 Project Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347

Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
About the Author

Biswanath Samanta received B.Tech. (Honors) and Ph.D. in Mechanical Engi-


neering from Indian Institute of Technology (IIT), Kharagpur. He is an Associate
Professor in the Department of Mechanical Engineering at Georgia Southern Uni-
versity (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 intelli-
gence (AI) and deep learning, and applications of AI in engineering and biomedi-
cine. 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 pub-
lishers including Elsevier and Springer. The papers are regularly cited by indepen-
dent 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 inter-
national 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 Neuroimag-
ing); 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 educa-
tion 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 span-
ning 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 infor-
mation 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 1


B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_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 sub-


systems 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 condi-
tioning 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. Abun-
dance 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 microcon-
troller 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-information-


knowledge-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 simula-
tion; 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 con-
cepts 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, val-
idation 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 ampli-
fier, adder, buffer, comparator, integrator, and differentiator are presented in Chap. 5.
Number systems, analog-to-digital conversion (ADC), digital to analog conver-
sion (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, vibra-
tion 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 program-
ming 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 intro-
duced, 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 Introduction

Accurate Inaccurate
(systematic error)

Precise

Imprecise
(reproducibility error)

Fig. 1.4 Accuracy and precision

Table 1.1 Accuracy and precision comments

Accurate Inaccurate
(systematic error)
Precise Can be corrected
Desired 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 7

1.4.1 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
i=1 xi
μ= ð1:1Þ
n
Pn
- μÞ2
i=1 ðxi
v= ð1:2Þ
n-1
sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
Pn
pffiffiffi i=1 ðxi - μÞ
2
s= v= ð1:3Þ
n-1

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

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

x-μ
z= ð1:5Þ
s
x=μ þ s z ð1:6Þ

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.

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


Pðμ - 2σ ≤ X ≤ μ þ 2σ Þ ≈ 95:45% ð1:8Þ
Pðμ - 3σ ≤ X ≤ μ þ 3σ Þ ≈ 99:7% ð1:9Þ

1.4.2 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-μ
PðX ≤ xÞ = 1 - PðX ≥ xÞ = normcdf
s
 
x-μ
PðX ≥ xÞ = 1 - PðX ≤ xÞ = 1 - normcdf
s

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 devi-
ation, z-score, and probabilities P(Z ≤ z), P(X ≤ x), and P(X > x).
1.4 Measurement Fundamentals 9

Table 1.2 Statistical parame- Statistical parameter Value (Ω)


ters for Example 1.1
Maximum 122.1
Minimum 116.9
Mode 119.8
Median 119.8
Mean (μ) 119.98
Variance (sample) 2.3484
Variance (population) 2.1136
Standard deviation (sample) (s) 1.5324
Standard deviation (population) (σ) 1.4538

Table 1.3 Probability distribution for Example 1.1


x - μ P (Z < = z) = P(X < = x) = P(X > x) =
x-value z= s norm . s. dist(z, true) norm . dist(x, μ, s, true) 1 - P(X < = x)
116.9 -2.0098 0.0222 0.0222 0.9778
118.9 -0.7047 0.2405 0.2405 0.7595
119.3 -0.4437 0.3286 0.3286 0.6714
119.5 -0.3132 0.3771 0.3771 0.6229
119.8 -0.1175 0.4532 0.4532 0.5468
119.8 -0.1175 0.4532 0.4532 0.5468
120.4 0.2741 0.6080 0.6080 0.3920
121.3 0.8614 0.8055 0.8055 0.1945
121.8 1.1876 0.8825 0.8825 0.1175
122.1 1.3834 0.9167 0.9167 0.0833

Solution Using Excel commands, basic statistical parameters for the set of mea-
sured 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 Introduction

1.4.4 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
∂xi
, i=1, 2, 3, . . . , n, and individual measurement uncertainties Δxi (assuming Δxi as
very small) as follows:

Xn  ∂f 
ΔY = i=1 ∂xi
Δx i ð1:11Þ

1.4.4.1 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 ð1:12Þ
i=1 ∂xi

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 root-
sum-square (rss) as follows:
sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
2ffi
Xn  ∂f
ΔY rss = i=1 ∂xi
Δ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

Xn ∂f
ΔY abs = Δxi ð1:12Þ
i=1 ∂xi

Assuming equal error contribution from each measured variable, Eq. (1.12) can
be rewritten as (1.16)

∂f
ΔY abs = n Δxi ð1:16Þ
∂xi

Equation (1.16) can be rearranged to express allowable uncertainty of individual


measured variables as

ΔY abs
Δxi,abs = ð1:17Þ
∂f
n ∂xi
12 1 Introduction

1.4.5.2 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
ΔY rss = i=1 ∂xi
Δxi ð1:14Þ

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

Equation (1.18) can be rearranged to express allowable uncertainty of individual


measured variables as

ΔY
Δxi,rss = pffiffiffi rss ð1:19Þ
∂f
n ∂x i

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 uncer-
tainty 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Þ


Nominal value of resistance R = = 0:2165 Ω
π ð0:5 × 10 - 3 mÞ
2

Partial derivatives: ∂R
∂ρ
= L ∂R
πr2 , ∂L = πrρ2 , ∂R
∂r
= - 2ρL πr3

Error contributions from individual measured variables:

∂R ð10 mÞ  -9

ΔRρ = Δρ =  2 1:7 × 10 Ω:m = 0:0216 Ω
∂ρ π 0:5 × 10 m-3

 
∂R 1:7 × 10 - 8 Ω:m -5
ΔRL = ΔL =  2 ð0:001 mÞ = 2:1645 × 10 Ω
∂L π 0:5 × 10 - 3 m
 
∂R 2 1:7 × 10 - 8 Ω:m ð10 mÞ
ΔRr = Δr = -  3 ð0:0001 mÞ = - 0:0866 Ω
∂r π 0:5 × 10 - 3 m

Maximum possible uncertainty ΔRabs = |ΔRρ| + |ΔRL| + |ΔRr| = 0.1082 Ω


Percentage uncertainty pΔRabs = ΔRRq
abs
× 100% = 50:01% ffi
ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
Most probable uncertainty ΔRrss = ΔRρ 2 þ ΔRL 2 þ ΔRr 2 = 0:0892 Ω
ΔRrss
Percentage uncertainty pΔRrss = R × 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
Allowable uncertainty in measurement of resistivity Δρ = pffiffiffi
n ∂R
= 4:9075 ×
∂ρ

10 - 10 Ω.m. This is less than the current uncertainty for resistivity; the current
measuring instrument uncertainty needs to be improved.
ΔR
Allowable uncertainty in measurement of length ΔL = pffiffiffi
n ∂R
= 0:2887 m. This
∂L
is higher than the current uncertainty for length; the current measuring instrument
uncertainty is adequate, ΔL = 1 mm.
ΔR
Allowable uncertainty in measurement of radius Δr = pffiffiffi n ∂R
= 7:2169 ×
∂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 =
 ffiffiffiffiffiffiffiffiffiffiffiffiffi
rffiffiffiffiffiffiffiffi 2 ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
∂R
∂R 2 ∂R 2
∂ρ
Δρ þ ∂L ΔL þ ∂r Δr = 0:0088 Ω:
ΔRrss
Percentage uncertainty pΔRrss = R × 100% = 4:08%:

1.4.7 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 mea-
surements 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 Unit
Color Code
Nominal value
Expected max, min
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 uncer-
tainty 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 fol-
lows: E = 210.0 GPa,  ν = 0.30  0.001. Estimate the vessel internal pressure
p = rð1 tE
- ν2 Þ ε x þ ν ε y : Estimate the maximum possible percentage error and the
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, Engi-
neering). 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 exer-
cise problems are provided to help consolidate problem-solving skills and under-
standing of materials covered.

2.2 Basic Electrical Circuit Elements

The basic electrical circuit elements include passive elements—resistors (R), capac-
itors (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 relation-
ships. The ideal electrical energy sources are assumed to be without any internal
resistance, capacitance, or inductance. The schematic symbols of these basic elec-
trical 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 21


B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_2
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)

ρL
R= ð2:2Þ
A

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):

V2
P = I 2R = ð2:3Þ
R

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-orange-


gold, 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 uncer-
tainty as a percentage of the color-coded value of the resistor.
2.2 Basic Electrical Circuit Elements 23

Table 2.1 Four-band color a, b, and c bands Tolerance (d) band


codes for resistors
Color Value Value
Black 0
Brown 1 1%
Red 2 2%
Orange 3
Yellow 4
Green 5
Blue 6
Violet 7
Gray 8
White 9
Gold 5%
Silver 10%
None 20%

2.2.2 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 propor-
tionality is called capacitance (C), as given in Eq. (2.5).

Q
Q = C V or V = ð2:5Þ
C

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):

dqðt Þ dvðt Þ
iðt Þ = =C ð2:6Þ
dt dt

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):
Z
1 t
qð t Þ
vð t Þ = iðt Þdt = ð2:7Þ
C 0 C
24 2 Basic Electrical Circuit Elements and Circuit Analysis

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


Z V
CV 2 Q2
E=C v dv = = ð2:8Þ
0 2 2C

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))

dλðt Þ
vð t Þ = ð2:10Þ
dt

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 25

diðt Þ
vð t Þ = L ð2:12Þ
dt

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


Z t
1
iðt Þ = vðt Þdt ð2:13Þ
L 0

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


Z I
LI 2
E=L i di = ð2:14Þ
0 2

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 combi-
nations 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).
Xn
ReqS = 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).

V Xn V
I= = ð2:16Þ
ReqP i=1 Ri

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

1
ReqP = Pn 1
ð2:17Þ
i=1 Ri

2.3.2 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).

Q Xn Q
V= = ð2:18Þ
C eqS i=1 C i

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


2.3 Basic Electrical Circuit Elements in Series and in Parallel 27

Fig. 2.5 Capacitors in


parallel

Fig. 2.6 Inductors in series

1
C eqS = Pn 1
ð2:19Þ
i=1 C i

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).
Xn
Q = VCeqP = i=1
ðVC i Þ ð2:20Þ

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


Xn
C eqP = i=1
Ci ð2:21Þ

2.3.3 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).
Xn
LeqS = 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
ð2:23Þ
i=1 Li
28 2 Basic Electrical Circuit Elements and Circuit Analysis

Fig. 2.7 Inductors in


parallel

2.4 DC Circuit Analysis


2.4.1 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 XN in XN out
i
I i = 0 or i
I in,i - 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 29

2.5 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 Equivalent Circuits

2.6.1 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.

V OC
I SC = ð2:26Þ
RTh

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

R2
V oc = V s
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

R1 R2
RTh = :
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

V OC V
I SC = = s
RTh R1

Norton equivalent circuit is shown in Fig. 2.10.

2.7 AC Circuit Analysis

2.7.1 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

1 ω
f= = ð2:28Þ
T 2π

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.

ð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Þ

2.7.2 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 ð2:35Þ


 
1
V= I = ZC I ð2:36Þ
jωC
1 -j 1
ZC = = = ∠ - 90 ° ð2:37Þ
jωC ωC ωC

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 + ϕ)
dt with I = Ime
In case of an inductor in an AC circuit, V = L dI

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 Ω.
Equivalent impedance for the circuit Z eq = Z 1 þ ZZ22þZ
Z3
3
= 1000þ
ð2000þj226:19Þð3000 - j6631:5Þ
2000þj226:19þ3000 - j6631:5 = 2788:7 - j 225:39 Ω = 2797:8 Ω∠ - 4:62 ° .

V 20 V∠0 °
Currents I1 = = = 7:1 þ j0:6 mA = 7:15 mA∠4:62 °
Z eq 2797:8 Ω∠ - 4:62 °
Z3 ð3000 - j6631:5ÞΩ
I2 = I1 = ð7:1 þ j0:6 mAÞ
Z2 þ Z3 ð2000 þ j226:19 þ 3000 - j6631:5ÞΩ
= 6:3 - j1 mA = 6:40 mA∠ - 9:01 °
Z2 ð2000 þ j226:19ÞΩ
I3 = I1 = ð7:1 þ j0:6 mAÞ
Z2 þ Z3 ð2000 þ j226:19 þ 3000 - j6631:5ÞΩ
= 0:8 þ j1:6 mA = 1:77 mA∠63:1 °

2.8 Power in Electrical Circuits

Power in a purely resistive circuit can be obtained as

V2
P = VI = I 2 R = ð2:41Þ
R

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
Z T
1
Pavg = V m sinðωt ÞI m sinðωt - ϕÞdt ð2:42Þ
T 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
Z T Z T 
V mI m
Pavg = sin2 ðωt Þ cosðϕÞdt - sinðωt Þ cosðωt Þ sinðϕÞdt ð2:43Þ
T 0 0
34 2 Basic Electrical Circuit Elements and Circuit Analysis

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

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

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 ð2:47Þ
T 0 m 2
sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
Z T
1 I
I rms = I 2 sin 2 ðωt Þdt = pmffiffiffi ð2:48Þ
T 0 m 2

2.9 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
α= ð2:49Þ
NP

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 ð2:50Þ
NS V I
α= = S = P ð2:51Þ
NP V P IS

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

ZS
Z eqP = Z P þ ð2:52Þ
α2
Z eqS = Z S þ α2 Z P ð2:53Þ

The equivalent impedances can be used to analyze an AC circuit with a trans-


former, 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

ðV s - V A Þ V VA
I1 = , 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 = 0.1955 A, i3 = 0.1700 A, V4 = 13.9377 V

2.11.2 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/software-
products/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 41


B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_3
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 condi-
tion, 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 temper-
ature. 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 current-


voltage 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

kT
VT = ð3:2Þ
q

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
 
i
v = nV T ln ð3:4Þ
IS

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 forward-
bias 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 char-
acteristics 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

ΔV
ΔI = ð3:6Þ
RZ

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 current-
limiting 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

V S - V Z0
IZ = ð3:8Þ
R þ RZ
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

ΔV S
ΔI Z = ð3:9Þ
R þ RZ

The change in regulator output voltage (ΔVo = ΔVZ) can be expressed as

ΔV S RZ
ΔV o = ΔV Z = ΔI Z RZ = ð3:10Þ
R þ RZ

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
IL = ð3:11Þ
RL

The unregulated source current I is

VS - VZ
I= ð3:12Þ
R

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 = I- ð3:14Þ
RLmax

The power dissipated in the Zener diode can be expressed as

 
VS - VZ V 2Z
PZmax = I Zmax V Z = VZ - ð3:15Þ
R RLmax

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):

 
VS - VZ V 2Z
PZmax = I Zmax V Z = VZ -
R RLmax

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

  ð12 V Þ2
20 V - 12 V
1W= ð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 ΩÞ
ΔV o = ΔV Z = ΔI Z RZ = ΔV S RZ
RþRZ = 240 Ωþ10 Ω = 40 mV. Line regulation
ΔV o
ΔV S = 40 mV=V.
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

V - 0:7 - V a 30 - 0:7 - V a
I1 = =
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
1 × 10 3
0:5 × 10 3
1 × 103
30 - 0:7 - V a - 2V a - ðV a- 0:7Þ = 0
30
Va = = 7:5 V
4

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


 
V - 0:7 - V a 30 - 0:7 - 7:5 V
I1 = = = 21:8 × 10 - 3 A = 21:8 mA
R1 1 × 10 3 Ω
 
V 7:5 V
I2 = a = = 15 × 10 - 3 A = 15 mA
R2 0:5 × 10 Ω
3
 
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
I R1 = = 3 Ω
= 9:3 × 10 - 3 A = 9:3 mA
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 8:3 V
I R3 = b = = 2:77 × 10 - 3 A = 2:77 mA
R3 3 × 103 Ω

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
 
Va 9:3 V
I R1 = = 3 Ω
= 9:3 × 10 - 3 A = 9:3 mA
R1 1 × 10

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


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

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 Bipolar Junction Transistors 53

3.3 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 ð3:16Þ

Fig. 3.14 Models of BJT (a) npn, (b) npn, (c) pnp, (d) pnp
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 validat-
ing 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
V BB - V BE
IB =
RB þ RE ð1 þ βÞ
6:8 - 0:7 V
IB = 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

R1 R2 ð12Þð42Þ
RTh = = kΩ = 9:333 kΩ
R1 þ R2 12 þ 42
R2 42
V OC = V 1 = ð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
V EE - V EB - V OC
IB =
RTh þ RE ð1 þ βÞ
8:5 - 0:7 - 5:833 V
IB =
ð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 sub-
strate 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Þ ð3:23Þ


 
I D = K 2 V SG- V tp - V SD V SD ðPMOSÞ ð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Þ ð3:25Þ
2
I D = K V SG - V tp ðPMOSÞ ð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 59

V GS = V tn þ V OV ðNMOSÞ ð3:27Þ
V SG = V tp þ jV OV j ðPMOSÞ ð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 :

8:5 - V GS
Equating ID from both K ðV GS - V tn Þ2 = 2:5 × 10 - 3

8:5 - V GS
or 0:4 × 10 - 3 ðV GS - 2Þ2 = × 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 drain-
source 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
V D - V DD 4:5 - 0 V
ID = = = 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 manipula-
tion 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 determina-
tion of these characteristics are covered. Examples including computer-aided anal-
ysis and simulation are presented. Experimentation using the 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.

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 Þ ð4:1Þ
dt

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 67


B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_4
68 4 Dynamic System Characteristics

4.2.1 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 steady-
state 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.

1
yPI ðt Þ = Kxðt Þ ð4:5Þ
ð1 þ τDÞ

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 þ . . . ð4:6Þ
ð1 þ τDÞ

1
yPI ðt Þ = Kxðt Þ
ð1 þ τDÞ
 
= 1- τD þ ðτDÞ2 - ðτDÞ3 þ . . . KAuð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,
0
ð4:9Þ
 
yðt Þ = KA 1- e - τ
t
ð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 is shown in Fig. 4.1. The normalized output (y(t)/KA) at normalized time
(t/τ)
τt = 1 is 0:632:
 The normalized output (y(t)/KA) is 0.9 at normalized time
τ = 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 Þ ð4:13Þ
dt
1 ð1 - τDÞ
yðt Þ = KA sinðωt Þ = KA sinðωt Þ
1 þ τD ð1 þ τDÞð1 - τDÞ
 
ð1 - τDÞ d 2
= KA sinðωt Þ D  , D  - ω 2
1 þ ðτωÞ2 dt
1
= KAðsinðωt Þ - τω cosðωt ÞÞ
1 þ ðτωÞ2
KA
= qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi sinðωt - φÞ ð4:14Þ
1 þ ðτωÞ2

The amplitude ratio (AR = Y/KA) and phase lag (φ) are obtained as shown in
Eqs. (4.15) and (4.16).

1
AR = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð4:15Þ
1 þ ðτωÞ2

φ = 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ω.
At τω = 1 or ω = 1/τ, AR = pffiffiffiffiffiffi1
1þ1
= p1ffiffi2 = 0:707, ωc = 1τ rad
s is termed corner or
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
 
yð t Þ
= e-τ
t
1- ð4:17Þ
KA

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


 
yð t Þ t
- ln 1- = ð4:18Þ
KA τ
 
yð t Þ
It means that time constant is equal to the reciprocal of the slope of - ln 1- 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, second-


order ordinary differential Eq. (4.19):

d2 yðt Þ dyðt Þ
2
þ 2ζωn þ ωn 2 yðt Þ = Kxðt Þ ð4:19Þ
dt dt

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 steady-
state 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 ð4:22Þ


2 
s þ 2ζωn s þ ωn 2 Cest = 0 ð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.
pffiffiffiffiffiffiffiffi
The roots are complex conjugates, as shown in Eq. (4.26), where j = - 1:
qffiffiffiffiffiffiffiffiffiffiffiffi
s1,2 = - ζωn  jωn 1 - ζ2 ð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):
 pffiffiffiffiffiffiffiffi2ffi  pffiffiffiffiffiffiffiffi2ffi
- ζωn þjωn 1-ζ - ζωn - jωn 1-ζ
yCF ðt Þ = C 1 e t
þ C2 e t
ð4:27Þ
yCF ðt Þ = e - ζωn t ðC 3 cosðωd tÞ þ C4 sinðωd tÞÞ ð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:
qffiffiffiffiffiffiffiffiffiffiffiffi
ω d = ωn 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):
 ffi
pffiffiffiffiffiffiffiffi  ffi
pffiffiffiffiffiffiffiffi
- ζþ ζ - 1 ωn t
2
-ζ- ζ - 1 ωn t
2
yCF ðt Þ = C1 e þ C2 e ð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 con-
stants of integration can be obtained as given in Eqs. (4.33) and (4.34):

C3 = Y 0 ð4:33Þ
ζ
C 4 = pffiffiffiffiffiffiffiffiffiffiffiffi :Y 0 ð4:34Þ
1 - ζ2

The transient response can be expressed in the form of Eq. (4.35):

e - ζωn t
yðt Þ = Y 0 pffiffiffiffiffiffiffiffiffiffiffiffi cosðωd t - φÞÞ ð4:35Þ
1 - ζ2

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


!
-1 ζ
φ = tan pffiffiffiffiffiffiffiffiffiffiffiffi ð4:36Þ
1 - ζ2
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 con-
stants 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 con-
stants of integration can be obtained as given in Eqs. (4.40) and (4.41):
pffiffiffiffiffiffiffiffiffiffiffiffi
ζ þ ζ2 - 1
C1 = pffiffiffiffiffiffiffiffiffiffiffiffi Y 0 ð4:40Þ
2 ζ2 - 1
pffiffiffiffiffiffiffiffiffiffiffiffi
- ζ þ ζ2 - 1
C2 = pffiffiffiffiffiffiffiffiffiffiffiffi Y 0 ð4:41Þ
2 ζ2 - 1

The transient response can be expressed in the form of Eq. (4.42):


 qffiffiffiffiffiffiffiffiffiffiffiffi  pffiffiffiffiffiffiffiffiffi
1
ζ þ ζ2 - 1 e - ζ - ζ - 1 ω n t
2
Y 0 pffiffiffiffiffiffiffiffiffiffiffiffi
yð t Þ =  2 ζ -
2
1 ð4:42Þ
qffiffiffiffiffiffiffiffiffiffiffiffi  pffiffiffiffiffiffiffiffiffi
þ - ζ þ ζ2 - 1 e - ζþ ζ - 1 ωn t ÞÞ
2

The transient response for a second-order system with normalized initial condi-
tions (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
 (t), can
The particular integral, yPI  be obtained for the particular input x(t). Here, an
operator approach using D≜ dtd is presented.

1
yPI ðt Þ =   Kxðt Þ ð4:43Þ
D2 þ 2ζωn D þ 1

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

1
yPI ðt Þ =   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 ð4:47Þ
1 - ζ2
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 - φÞ ð4:48Þ
1 - ζ2

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


!
-1 ζ
φ = tan pffiffiffiffiffiffiffiffiffiffiffiffi ðð4:49Þ
1 - ζ2

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 con-


stants 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):
 ffi
pffiffiffiffiffiffiffiffi  ffi
pffiffiffiffiffiffiffiffi
- ζþ ζ - 1 ωn t
2
-ζ- 2
ζ - 1 ωn t
yð t Þ = C 1 e þ C2 e þ KA ð4:54Þ

Applying initial conditions, at t = 0, yðt Þ = 0, dydtðtÞ = 0, to Eq. (4.54), the con-


stants of integration can be obtained as given in Eqs. (4.55) and (4.56):
pffiffiffiffiffiffiffiffiffiffiffiffi
ζ þ ζ2 - 1
C 1 = - KA pffiffiffiffiffiffiffiffiffiffiffiffi ð4:55Þ
2 ζ2 - 1
78 4 Dynamic System Characteristics

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

pffiffiffiffiffiffiffiffiffiffiffiffi
- ζ þ ζ2 - 1
C 2 = - KA pffiffiffiffiffiffiffiffiffiffiffiffi ð4:56Þ
2 ζ2 - 1

The step response of an overdamped system can be expressed in the form of


Eq. (4.57):
 qffiffiffiffiffiffiffiffiffiffiffiffi  pffiffiffiffiffiffiffiffiffi
1
ζ þ ζ2 - 1 e - ζ - ζ - 1 ω n t
2
KA 1 - pffiffiffiffiffiffiffiffiffiffiffiffi
yð t Þ =  2 ζ -1
2
ð4:57Þ
qffiffiffiffiffiffiffiffiffiffiffiffi  pffiffiffiffiffiffiffiffiffi
þ - ζ þ ζ2 - 1 e - ζþ ζ - 1 ωn t ÞÞ
2

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 79

4.3.2 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Þ ð4:58Þ

Y ðsÞ
The transfer function (GðsÞ = X ðsÞ ) of the second-order system is obtained as
Eq. (4.59):

Y ðs Þ K
GðsÞ = = ð4:59Þ
X ðsÞ s2 þ 2ζωn s þ ωn 2

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):

K
GðjωÞ = 2
ðjωÞ þ 2ζωn ðjωÞ þ ωn 2
K
=    ð4:60Þ
ω2
ωn 2 1- ωn 2 þ j2ζ ωωn

ωn 2 Y 0
The normalized amplitude ratio (AR = KX 0 ) can be obtained from the
magnitude

 
ωn 2 Y ðsÞ 1
mag =   ð4:61Þ
KX ðsÞ 1- ω2
þ j2ζ ωωn
ωn 2

1
ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
AR = r 2  2 ð4:62Þ
1 - ωωn 2 þ 2ζ ωωn
2

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.
!
2ζ ωωn
φ = - tan - 1 ω2
ð4:64Þ
1- ωn 2

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,
pe -ffiffiffiffiffiffiffiffi
ζωn t
e -ffiffiffiffiffiffiffiffi
ffi2 cosðωd t - φÞ = p
ζωn t
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:
 
 pffiffiffiffiffiffiffiffiffi
An e - ζωn t ζωn 2π
ζ= 1-ζ 2
=   =e ωd
=e 2π
ð4:65Þ
Anþ1 - ζωn tþω2π
e d

Taking the logarithm of both sides, Eq. (4.65) can be written as


   qffiffiffiffiffiffiffiffiffiffiffiffi
An
ln = = ζ= 1 - ζ2 2π ð4:66Þ
Anþ1
82 4 Dynamic System Characteristics

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


 
An
ln Anþ1
δ= ð4:67Þ

δ
ζ = pffiffiffiffiffiffiffiffiffiffiffiffiffi ð4:68Þ
1 þ δ2

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

2π 2π
Td = = pffiffiffiffiffiffiffiffiffiffiffiffi ð4:69Þ
ωd ωn 1 - ζ 2

ωn = pffiffiffiffiffiffiffiffiffiffiffiffi ð4:70Þ
T d 1 - ζ2

4.4 Fourier Series Representation of Periodic Signals

4.4.1 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):
X/   X/  
2nπt 2nπt
f ðt Þ = C 0 þ A cos
n=1 n
þ n=1
Bn sin ð4:71Þ
T T

The coefficients An and Bn of cosine and sine terms are obtained as shown in
Eqs. (4.72) and (4.73):
Z T  
2 2nπt
An = f ðt Þ cos dt ð4:72Þ
T 0 T
Z T  
2 2nπt
Bn = f ðt Þ sin dt ð4:73Þ
T 0 T

The DC component C0 represents the average value of the signal over the period,
and it can be obtained as in Eq. (4.74):
Z T
1 A0
C0 = f ðt Þdt = ð4:74Þ
T 0 2
4.4 Fourier Series Representation of Periodic Signals 83

 
The fundamental frequency ω0 = 2π T and its integer multiples appear in the
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):
X/  
2nπt
f ðt Þ = C 0 þ C
n=1 n
cos þ ϕn ð4:75Þ
T

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 ð4:76Þ
 
B
ϕn = - tan - 1 n ð4:77Þ
An

4.4.2 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 Þ = F ðωÞeiωt dω ð4:79Þ
-/

4.4.3 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, respec-
tively, 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 three-
digit code for the capacitor, and complete Table 4.1. Calculate the expected values of
4.6 Experimental Validation 89

Table 4.1 Codes for R and C


R Color code
C code

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

Based on Nominal Based on % Difference


Values of R and C Measured Values
of R and C
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 dual-
channel 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).  
V out ðt Þ
2. Complete Table 4.3 and plot - ln 1- 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) Vout(t) ( )


− ln 1 −
,

0 0 0
4.6 Experimental Validation 91

Table 4.4 Frequency response of RC circuit

Estimated Actual Input Amplitude Output Log10 (f) Amplitude Ratio


frequency Vin (V) Amplitude AR=Vout/Vin
Frequency
f (Hz) Vout (V)
(Hz)
fc/10

fc-10
fc
fc+10

10 fc

Table 4.5 Characteristic parameters: Comparison of theoretical and experimental values


Experimental
Frequency
Time response response Comments
Characteristic Theoretical % %
parameters valuesa Valuesb Errorc Valuesd Errorc
τ (ms)
tR = 2.303 τ (ms)
ωc = (1/ τ) ×103
(rad/s)
fc = ωc/(2π) (Hz)
a
Based on measured values of R and C (column 3 of Table 4.2)
b
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
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 expo-
nentially 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 expo-
nentially decreasing amplitude that finally reduced to zero. The voltage wave-
form, 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
f Beam k =ðmBeam,effectiveÞ mBeam,effective þmTip
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/software-
products/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 95


B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_5
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:

ðV in - V C Þ V in
Ii = ≈ ð5:7Þ
Ri Ri

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:

ðV out - V C Þ V out
If = ≈ ð5:8Þ
Rf Rf

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 ð5:10Þ
Ri Rf
 
Rf
V out = - V in ð5:11Þ
Ri

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:
 
Zf
V out = - V in ð5:12Þ
Zi

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Ω
V out = - V in = - ð3 VÞ = - 6:25 V:
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 ð5:13Þ

Fig. 5.4 Schematic


diagram of a noninverting
amplifier
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:

ð0 - V C Þ V
Ii = ≈ - in ð5:17Þ
Ri Ri

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:

ðV out - V C Þ ðV out - V in Þ
If = ≈ ð5:18Þ
Rf Rf

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 ð5:20Þ
Ri Rf
 
Rf
V out = 1 þ V in ð5:21Þ
Ri

 (5.21), the output voltage (Vout) is the amplified input voltage (Vin) with a
In Eq.
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 out = 1 þ V in = 1 þ ð2:5 VÞ = 5:19 V:
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

Xn V i 
V out = - Rf i=1 Ri
ð5:22Þ

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


Xn
V out = - i=1
Vi ð5:23Þ

Fig. 5.5 Schematic diagram of a summing amplifier


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,
Xn
V out = i=1
Vi ð5:24Þ

5.7 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:

Rf
Vþ = V2 ð5:26Þ
R þ Rf

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.,

Rf
V - ≈ Vþ = V2 ð5:27Þ
R þ Rf

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

Rf
VC ≈ V2 ð5:28Þ
R þ Rf

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:

ðV 1 - V C Þ
Ii = ð5:29Þ
R

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:

ðV out - V C Þ
If = ð5:30Þ
Rf

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 1 - V C Þ ðV out - V C Þ
þ =0 ð5:32Þ
R Rf
   
V out 1 1 1
= VC þ - V ð5:33Þ
Rf R Rf R 1
    
V out Rf 1 1 1
= V2 þ - V ð5:34Þ
Rf R þ Rf R Rf R 1

After simplification, the output voltage Vout can be obtained:


 
Rf
V out = ðV 2- V 1 Þ ð5:35Þ
R

 (Vout) is the difference of input voltages


In Eq. (5.35), the output voltage
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
   
Rf 5:6 kΩ
V out = ðV 2- V 1 Þ = ð4:5 V - 2:5 VÞ = 4:15 V
R 2:7 kΩ

5.8 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:

ðV in ðt Þ - V C Þ V in ðt Þ
Ii = ≈ ð5:40Þ
R R

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

dqðt Þ d d
If = = C ðV out ðt Þ - V C Þ ≈ C V out ðt Þ ð5:41Þ
dt dt dt

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 ð5:43Þ
R dt
106 5 Analog Signal Processing and Operational Amplifiers

Fig. 5.9 Schematic


diagram of a modified
integrator

Z t
1
V out ðt Þ = - V in ðτÞdτ ð5:44Þ
RC 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 ð5:45Þ
A
R
Rs þ ðRCωÞ2

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

1
ωci = ð5:45aÞ
Rs C

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
A = - R , and for frequency ω > ωci, the modified integrator acts as an integrator.
B Rs

Example 5.4 For the modified integrator circuit of Fig. 5.9, find the corner fre-
quency ω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 = 1


Rs C = 200 rad=s
ωci
using Eq. (5.45a) with f ci = 2π = 31:82 Hz: The output voltage amplitude can be
obtained from Eq. (5.45) as

1 1V
ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
B = r 2 A = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
  2 ffi
10 kΩ 2 -6
R
þ ðRCωÞ 2
50 kΩ þ 10 × 10 3
× 0:10 × 10 × 200
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:

dqðt Þ d d
Ii = = C ðV in ðt Þ - V C Þ ≈ C V in ðt Þ ð5:50Þ
dt dt dt

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:

ðV out ðt Þ - V C Þ V out ðt Þ
Ii = ≈ ð5:51Þ
R R

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:

d V ðt Þ
C V ðt Þ þ out = 0 ð5:53Þ
dt in R
d
V out ðt Þ = - RC V in ðt Þ ð5:54Þ
dt

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 ð5:55Þ
A
R
s
þ RCω

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

1
ωcd = ð5:55aÞ
Rs C

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

1 1V
B = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
R 2  1 2ffi A = rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
 2 = 7:070 V:

R
s
þ RCω
1 kΩ 2
þ 1
-6
10 kΩ 10 × 10 × 0:10 × 10
3
× 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
8 9
< þV sat V in > V ref =
V out = ð5:56Þ
: ;
- V sat V in < V ref
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 voltage-
holding 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:58Þ

5.13 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 ð5:62Þ
R1 R1

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
V4 = 1 þ V - 2V ð5:63Þ
R1 2 R1 1

Assuming R5 = R4, the output voltage Vout can be expressed in terms of the input
voltages V1 and V2:
 
R4 R
V out = 1 þ 2 2 ðV 2- V 1 Þ ð5:64Þ
R3 R1
114 5 Analog Signal Processing and Operational Amplifiers

5.14 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 charac-
teristics 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 V-
i1=(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 Simulation and Experimental Validation

5.17.1 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.
Table 5.1 Summary of op-amp configurations
5.17

Serial Op-amp
number configuration Fig Relation
 
1 Inverting amplifier Rf
V out = - Ri V in

 
2 Noninverting R
Simulation and Experimental Validation

V out = 1 þ Rfi V in
amplifier

(continued)
117
Table 5.1 (continued)
118

Serial Op-amp
number configuration Fig Relation
3 Summing amplifier n  
P Vi
V out = - Rf Ri
i=1
5

 
4 Difference amplifier Rf
V out = R ðV 2- V 1 Þ
Analog Signal Processing and Operational Amplifiers
1
Rt
5 Integrator V out ðtÞ = - 0 V in ðτÞdτ
5.17

RC

6 Modified integrator 1 ffi
τ = RC, BA ðωÞ = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
2
ðRRs Þ þðτωÞ2
Rs ≥ 10R
Simulation and Experimental Validation

(continued)
119
Table 5.1 (continued)
120

Serial Op-amp
number configuration Fig Relation
7 Differentiator d
V out ðtÞ = - RC dt V in ðt Þ
5

8 Modified 1 ffi
τ = RC, BA ðωÞ = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
2 2
differentiator ðRRs Þ þðτω1 Þ
Rs ≤ R/10
Analog Signal Processing and Operational Amplifiers
9 Voltage follower Vout = Vin
5.17

8 9
10 Comparator < þV sat V in > V ref =
V out =
: ;
- V sat V in < V ref
Simulation and Experimental Validation

h  i
11 Instrumentation V out = R4
R3 1 þ 2 RR21
amplifier
[V2 - V1]
121
122 5 Analog Signal Processing and Operational Amplifiers

Table 5.2 Nominal and measured values of resistance


Color Nominal value from color code Measured value %
Resistance code (kΩ) (kΩ) Difference
R1
R2

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

Op-Amp Vin p-p Vout p-p Amplifier Gain (G) Waveforms to


Configuration Theoretical Experimental % include from
Expression Gaina Gain (Vout / Difference Oscilloscope
Vin) p-p Vin,(t), Vout(t)
Inverting 1V Square wave
Amplifier Triangular wave

Sinusoidal (50 Hz)
Sinusoidal (10 kHz)
Non-inverting 1V Square wave
Amplifier Triangular wave
1+
Sinusoidal (50 Hz)
Sinusoidal (10 kHz)
Voltage 1V Square wave
Follower Triangular wave
Sinusoidal (50 Hz)
Sinusoidal (10 kHz)
Comparator Vin (Triangular) and
Vout

a
Use measured values of R1 and R2 from Table 5.2

Fig. 5.20 Schematic of an inverting amplifier circuit on Tinkercad


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 ampli-


fier 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 Color Code Nominal value from Color code Measured value
R 10 kΩ
Rsi 100 kΩ
Rsd 1 kΩ
Capacitance code Nominal value from code Measured value
C 104 0.10 μF
Time constant
= ∗ (s)
= (Hz)

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 integra-


tor 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).
5.17

Table 5.5 Results of integrating and differentiating amplifiers


1
Amplifier gain (G) at f = 2πRC Hza
Expected gain
(based on
Op-amp Vin Vout measured values) Experimental gain (Vout/ % Waveforms to include from oscilloscope, Vin,
configuration p-p p-p Expression Gain Vin)p-p Difference Vout
Simulation and Experimental Validation

Integrator Observe and record input and output waveforms Square


Triangular
1/(RC2πf) Sinusoidal
Differentiator Observe and record input and output waveforms Square
Triangular
- RC2πf Sinusoidal
a 1
Get amplifier gain with sinusoidal wave as input at f = 2πRC Hz
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


Table 5.8 Results of modified integrating and differentiating amplifiers

Corner freq. fc Amplifier gain (G) at f c = 2πR1 s C Hza


Op-amp Vin Vout Expected gain Experimental Gain (Vout/ % Waveforms to include from
Simulation and Experimental Validation

configuration Expected Actual p-p p-p Expression Gain Vin)p-p Difference oscilloscope
 
Modified Rsi p1ffiffi Vin, Vout (sinusoidal)
R 2
integratorb
 
Modified R p1ffiffi Vin, Vout (sinusoidal)
differentiatorc Rsd 2

a 1
Get amplifier gain with sinusoidal wave as input at f c = 2πRs C Hz
 
b p1ffiffi
Estimate fc from Table 5.6 (modified integrator) at which AR is close to expected value RRsi
2 
c
Estimate fc from Table 5.7 (modified integrator) at which AR is close to expected value RRsd p12ffiffi
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/software-
products/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 139
B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_6
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:2Þ

6.3.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 Successive division Remainder


decimal to binary
135/2 1 LSB
conversion
67/2 1
33/2 1
16/2 0
8/2 0
4/2 0
2/2 0
1/2 1 MSB
Result (10000111)2
6.3 Number Systems 143

6.3.5 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:6Þ

6.3.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 Decimal Binary Octal Hexadecimal


in different number systems
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
144 6 Data Acquisition and Digital Signal Processing

6.4 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

0.75
Vin and Vout (V)

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 Data Acquisition and Digital Signal Processing

6.4.2 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 com-
binational 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 decreas-
ing 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 Comparator output (C2C1C0) ADC output (B1B0)
0 ≤ V in ≤ V4 000 00
4 ≤ V in ≤ 4
V 2V 001 01
4 ≤ V in ≤ 4
2V 3V 011 10
4 ≤ V in ≤ V
3V 111 11

6.4.3 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

ðV max - V min Þ
R= ð6:10Þ
2n - 1

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):
 
ðV max - V min Þ
log 10 R þ1
n= ð6:11Þ
log 10 2

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

ðV in - V min Þ
x = ð2n- 1Þ ð6:12Þ
ðV max - V min Þ

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

ðV max - V min Þ 5—V 10


Resolution R = = 8 = V=bit
2n - 1 2 -1 255
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

ðV in - V min Þ  ð2:1 - ð - 5ÞÞ


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

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

ðV max - V min Þ
R=
2n - 1
0:10 5 - ð - 5Þ V
ð5- ð- 5Þ V Þ =
100 2n - 1
6.5 Digital-to-Analog Conversion 149

2n = 1000 þ 1
log 10 ð1001Þ
n= = 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

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

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

1 1 1
V n-1 = V s , V n-2 = V , . . . , V 1 = V 2, V 0 = V 1 ð6:13Þ
2 n-1 2 2
1
V 0 = n-1 V s ð6:14Þ
2
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

1 1
V out0 = - V = - n Vs ð6:15Þ
2 0 2

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 ð6:16Þ
2 2

Similarly with MSB bn-1 = 1, the corresponding switch is connected to the


op-amp circuit, the output.

1 1
V outðn-1Þ = - V = - Vs ð6:17Þ
2 n-1 2

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
is from 0 to - ð2 2-n 1Þ V s :
n

For the example of 4-bit R-2R ladder DAC with 4 bits changing 0000–1111, the
output ranges from 0 to - 12 þ 14 þ 18 þ 16
1
V ref = - 15
16 V ref :
6.6 Virtual Instruments, Data Acquisition, and Digital Signal Processing. . . 151

6.5.2 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 max - V min Þ
V out = x þ V min ð6:19Þ
ð 2 n - 1Þ

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 max - V min Þ ð7:5 - ð - 7:5ÞÞV


V out = x þ V min = ð1263Þ   þ ð- 7:5 V Þ =
ð2n - 1Þ 212 - 1
- 2:874 V

6.6 Virtual Instruments, Data Acquisition, and Digital


Signal Processing Using LabVIEW
6.6.1 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 dis-
plays. 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 Func-
tions palette. Wiring tool is used to connect the block diagram objects for transfer-
ring data between objects and communicating with the front panel objects for the
desired functional objectives.
152 6 Data Acquisition and Digital Signal Processing

6.6.2 Signal Simulation and Analysis

LabVIEW provides built-in template VIs that include the sub-VIs, functions, struc-
tures, and front panel objects that are used to build common measurement applica-
tions. 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 157

6.7 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 double-
clicking 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 spec-
trum 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 Vis Front panel display
Multiple signals displayed together on a graph, Front panel and Sine, square, triangle,
sum of signals, and its frequency spectrum block diagram sawtooth
Sum of two sine signals with frequencies of 30 Hz Front panel and Waveform of input signal
and 80 Hz and amplitudes of 1 and 0.4, respec- block diagram and frequency spectrum
tively, and its frequency spectrum
Sum of two square signals with frequencies of Front panel and Waveform of input signal
30 Hz and 80 Hz and amplitudes of 1 and 0.4, block diagram and frequency spectrum
respectively, and its frequency spectrum
Sum of two sine signals with frequencies of 30 Hz Front panel and Waveform of input signal
and 80 Hz and amplitudes of 1 and 0.4, respec- block diagram and frequency spectrum
tively (with Gaussian noise of standard deviation
of 1), frequency of filtered signal
160 6 Data Acquisition and Digital Signal Processing

Exercises

1. Convert decimal number (125)10 to binary, octal, and hexadecimal numbers.


2. Convert hexadecimal number (25D)16 to binary, octal, and decimal numbers.
3. Convert octal number (756)8 to binary, hexadecimal, and decimal numbers.
4. 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.
5. 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.
6. 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.
7. 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.
8. 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.
9. 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.
10. 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).
11. 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 Position, Displacement, and Velocity Measurement


7.2.1 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 ð7:1Þ

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

7.2.2 Potentiometers

For potentiometers—translational and rotational—the output voltage (e0) is propor-


tional to the displacement (x, translation) or angle of rotation (θ), with the constant of
proportionality as kx, kθ:

eo = k x x ðtranslationÞ ð7:2aÞ
eo = kθ θ ðrotationÞ ð7:2bÞ

7.2.3 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 
d = V sound 102 = 10 t cm ð7:3Þ
s 2 m 2

7.2.4 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 165

7.3 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 measure-
ment 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

h
PLbeam PLbeam
σ= 2
=6 ð7:5Þ
bh3
12
bh2

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:

σ PL
E= = 6 beam ð7:6Þ
E Ebh2

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):

ρL
R= ð7:7Þ
wt

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
= þ - - ð7:9Þ
R ρ L w t
 
ΔtApplying Poisson’s ratio(ν), the relative changes in width Δw w and thickness
ΔL
t can be related to strain L for the strain gage, in Eqs. (7.10) and (7.11) as

Δw ΔL
= -ν ð7:10Þ
w L
7.3 Stress and Strain Measurement Using Strain Gages 167

Δt ΔL
= -ν ð7:11Þ
t L

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
= þ þν þν ð7:12Þ
R ρ L L L
 ΔL

Using the definition of strain E = L , the Eq. (7.12) can be written as

ΔR Δρ
= þ E ð1 þ 2ν Þ ð7:13Þ
R ρ
ΔR
The ratio of relative change in resistance R and strain (E) can be written as

ΔR Δρ
ρ
R
= 1 þ 2ν þ ð7:14Þ
E 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
ΔR constant over the normal operating range of the strain gage. The ratio
E is specified for commercially available strain gages. The ratio is known as gage
R

factor (GF):

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

ΔR
= ðGF Þ E ð7:16Þ
R

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
resistance ΔRR is quite small assuming the strain is in general quite small in the
range of 1–100 μStrain (microstrain).
168 7 Sensors

7.3.2 Wheatstone Bridge


 
The small change of resistance ΔR R of the strain gage can be detected using the
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

V in
I1 = I4 = ð7:17Þ
R1 þ R4
V in
I2 = I3 = ð7:18Þ
R2 þ R3

The output voltage (Vout) can be expressed as

V out = V C - V D ð7:19Þ
V out = ðV in- I 1 R1 Þ - ðV in- I 2 R2 Þ = I 2 R2 - I 1 R1 ð7:20Þ
   
R2 R1 R2 R4 - R1 R3
V out = V in - = V in ð7:21Þ
R2 þ R3 R1 þ R4 ðR1 þ R4 ÞðR2 þ R3 Þ

For the balanced bridge, Vout = 0,

R2 R4 - R1 R3 = 0 ð7:22Þ

Alternatively,

R1 R2
= ð7:23Þ
R4 R3

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:
 
ðR2 þ ΔR2 ÞðR4 þ ΔR4 Þ - ðR1 þ ΔR1 ÞðR3 þ ΔR3 Þ
V out = V in ð7:24Þ
ðR1 þ ΔR1 þ R4 þ ΔR4 ÞðR2 þ ΔR2 þ R3 þ ΔR3 Þ

In general, initial resistances are equal, Ri = R, i = 1, . . . , 4, and the relative


changes ΔR ΔRi
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
i
ΔR 2
involving R asi

V in
V out = ðΔR1 - ΔR2 þ ΔR3 - ΔR4 Þ ð7:25Þ
4R

In Eq. (7.25), the changes in resistances (ΔRi, i = 1, . . . , 4) appear with alter-


nating 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 in
V out,A = A ðΔR1 - ΔR2 þ ΔR3 - ΔR4 Þ ð7:26Þ
4R

where the difference amplifier gain (A) is given:

R6
A= ð7:27Þ
R5

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 Strain Gage Wheatstone Difference
member bridge amplifier

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


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 in
V out,A = A ðΔRÞ ð7:28Þ
4R

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 in
V out,A = A ð2ΔRÞ ð7:29Þ
4R
7.3 Stress and Strain Measurement Using Strain Gages 171

7.3.4 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 in
V out,A = A ðΔRÞ ð7:30Þ
4R

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 in
V out,A = A ð2ΔRÞ ð7:31Þ
4R

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 in
V out,A = A ð2ΔRÞ ð7:32Þ
4R

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 in
V out,A = A ð3ΔRÞ ð7:33Þ
4R

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 in
V out,A = A ð4ΔRÞ ð7:34Þ
4R

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 Wheat-
stone 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

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

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


E = 2:6198 × 10 - 4:
ΔR
Relative change in resistance ΔR
R can be obtained from Eq. (7.15) GF =
R
E as

ΔR
= E GF = 2:6198 × 10 - 4 ð2:15Þ = 5:6326 × 10 - 4
R
ΔR
Change in resistance of the strain gage ΔR = R R = ð120 ΩÞ5:6326 ×
10 - 4 = 0:0676 Ω
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
V out =ðΔR1 - ΔR2 þ ΔR3 - ΔR4 Þ
4R
 
V ΔR 10V
= in = 5:6326 × 10 - 4 = 0:00141 V = 1:41 mV
4 R 4

Amplified voltage output can be obtained from Eq. (7.26) as

V out,A = A V out = 14:1 mV


V out,A 14:1 mV
Sensitivity can be obtained as k = = = 0:2687 mV=MPa
σ 52:397 MPa

7.4 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 Þ ð7:35Þ
- kð xo ðt Þ - xi ðt ÞÞ - cð x_ 0 ðt Þ - x_ i ðt ÞÞ = m €x0 ðt Þ ð7:36Þ

Fig. 7.6 Schematic


diagram of a mass-spring-
damper system on a
vibrating object
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

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

Substituting mc = 2ζωn k
m = ω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 = ð7:41Þ
m

And the damping ratio is given as

c
ζ = pffiffiffiffiffiffi ð7:42Þ
2 km

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 ð7:45Þ
Xi
ð1 - r2 Þ2 þ ð2ζ rÞ2
7.4 Vibration and Acceleration Measurement 175

where r is termed as the frequency ratio:

ω
r= ð7:46Þ
ωn

and ϕ is the phase lag given as


 
2ζ r
ϕ = tan - 1 ð7:47Þ
1 - r2

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

Xr r2
AR = = 1  α = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð7:48Þ
Xi
ð1 - r 2 Þ2 þ ð2ζ rÞ2

Fig. 7.7 Frequency response of a vibrometer


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
u - 4ζ - 2  2
4ζ - 2 - 4 1 - ð1þα 1
u Þ2

r 1,2 = t   ð7:49Þ
2 1 - ð1þα 1
Þ2

 2  
where it is assumed 4ζ2 - 2 > 4 1- 1
ð1þαÞ2
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
u 4ζ - 2 þ 4ζ - 2 þ 4 ð1 -1αÞ2 - 1
u
r3 = t   ð7:50Þ
2 ð1 -1 αÞ2 - 1

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 instru-
ment (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
2700 rpm. Use the sensitivity of the instrument k = X r as 10 mm
V mV
.

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 = 60 ð2π Þ = 314:16
3000
rad=s

ωmin ω 314:16 rad=s


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

(b) Given ζ =0.4, ωn = 84:4106 rad


s , ω = 2700 rpm = 60 ð2π Þ = 282:86
2700
rad=s

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

Substituting r = 3.3496 in Eq. (7.45), XXri = pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi


ffi = 1:0620
2
r
2 2 2
ð1 - r Þ þð2ζ rÞ

V mV 15 mV
From V = 15 mV, k = = 10 , Xr = = 1:5 mm:
Xr mm 10 mV=mm
Xr Xr 1:5 mm
Input amplitude = 1:0620, X i = = = 1:4125 mm:
Xi 1:062 1:062

7.4.2 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

ω2n X r 1
AR = = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð7:54Þ
Ai
ð1 - r Þ2 þ ð2ζ rÞ2
2

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 7 Sensors

Fig. 7.8 Frequency response of an accelerometer

Fig. 7.9 Variation of phase angle over frequency ratio for an accelerometer
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

ω2n X r 1
AR = = 1 þ α = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð7:55Þ
Ai
ð1 - r 2 Þ2 þ ð2ζ rÞ2

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

r 1,2 = ð7:56Þ
2

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
 the machine
 is operating at ω =11,000 rpm. Use the sensitivity of
the instrument k = X r ωn 2 as 10 mm=s
V mV
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 = 60 ð2π Þ = 1047:2
10000
rad=s
180 7 Sensors

ωmax ω 1047:2 rad=s rad


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

(b) Given ζ =0.4, ωn = 3897:5 rad


s , ω = 11000 rpm = 60 ð2π Þ = 1151:9
11000
rad=s

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

ω2n X r
Substituting r = 0.2956 in Eq. (7.54), Ai = pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
1
2 2
ffi = 1:0607.
2
ð1 - r Þ þð2ζ rÞ

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

ω2n X r ω2 X r 1:5 mm=s2


Input amplitude = 1:0607, Ai = n = = 1:4142 mm=s2 :
Ai 1:0607 1:0607

7.4.3 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

ω2n X r 1
AR = = ð7:51Þ
Ai 1 - r2

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

ω2n X r 1
AR = =1 þ α= ð7:52Þ
Ai 1 - r2
rffiffiffiffiffiffiffiffiffiffiffi
α
r= ð7:53Þ
1þα

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 181

7.4.4 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:

ð V o ðt Þ - V A Þ V o ðt Þ
i1 ðt Þ = ≈ ð7:56Þ
Rf Rf

Fig. 7.10 Schematic of a


charge amplifier connected
to the output of a
piezoelectric accelerometer
182 7 Sensors

d d
i 2 ðt Þ = C f ðð V o ðt Þ - V A ÞÞ ≈ Cf V o ðt Þ ð7:57Þ
dt dt

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 displace-
ment xr(t) in Eq. (7.59):

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

where τ = RfCf is termed time constant of the charge amplifier and k q =


kq
Cf is the
modified charge constant for the charge amplifier.
In s-domain, the Eq. (7.59) can be represented as a transfer function:

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

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

V0 τω
AR = = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð7:61Þ
kq X r
1 þ ðτωÞ2

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

7.4.5 A Piezoelectric Accelerometer with a Charge Amplifier

The characteristics of a piezoelectric accelerometer and a charge amplifier combi-


nation can be expressed by cascading the individual characteristic Eqs. (7.51) and
(7.61):

ω2n X r V 0 1 τω
: = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð7:62Þ
Ai k q X r 1 - r2
1 þ ðτωÞ2
7.4 Vibration and Acceleration Measurement 183

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

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

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 combina-
tion 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
of the accelerometer is close to 1, i.e., kA V0
i
≈ 1: τω
1 = τω. Whereas for frequency range
τω ≫ 1, the behavior is dominated by the accelerometer as the AR of the charge
V0
amplifier is close to 1, i.e., kA i
≈ 1 -1 r2 : τω
τω = 1 - r 2 . The amplitude ratio of Eq. (7.63)
1

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 Sensors

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

For finding the lower limit of the frequency ωL, kAV0


i
= 1 - α with accelerometer
part in Eq. (7.64) can be approximated close to 1 as

τωL
1: qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
ffi =1-α ð7:64Þ
1 þ ðτωL Þ2
1 1-α
ωL = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð7:65Þ
τ
1 - ð1 - αÞ2

Similarly, for finding the upper limit of the frequency ωH, kA V0


i
= 1 þ α with
charge amplifier part in Eq. (7.64) can be approximated close to 1 for τω ≫ 1 as

1
:1 = 1 þ α ð7:66Þ
1 - r2
rffiffiffiffiffiffiffiffiffiffiffi
α
ωH = ωn ð7:67Þ
1þα

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

1 1-α 1 1 - 0:05 rad


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

Applying the values in Eq. (7.67), the upper limit of the frequency range is
obtained as
rffiffiffiffiffiffiffiffiffiffiffi rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
α 0:05
ωH = ωn = ð100 kHzÞ = 21:812 kHz
1þα 1 þ 0:05

The frequency range of the piezoelectric accelerometer-charge amplifier combi-


nation is 48.4 Hz–21.812 kHz.
7.5 Temperature Measurement 185

7.5 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), thermis-
tors, 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):

T K = T C þ 273:15 ð7:68Þ
 
9
TF = T þ 32 ð7:69Þ
5 C
T R = T F þ 459:67 ð7:70Þ

7.5.1 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):
 
β T - T0
1 1

R = R0 e ð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 ther-
mocouples 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 thermo-
couples 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 thermo-


couple 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 (A-
C, 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 thermo-


couple 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 (A-
C, C-B) are kept at the same temperature (T1 = T3) (Fig. 7.17).

4. Law of intermediate temperatures. The thermoelectric voltage of a thermocou-


ple 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 thermo-


couple 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):
XN
Vo = 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 Sensors

PN PN
i = 1V i i = 1 k:ðT i - T ref Þ
Vo = = ð7:77Þ
N N

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 thermocou-
ple 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


35
T= þ 50 ° C = 698:15 ° C
0:054
For T ref = 0 ° C, T = 698:15 ° C

mV
V 0 = k ðT- T ref Þ = 0:054 ð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
° C , T = 300 ° C, T ref = 20 ° C
(a) N = 50, k = 0:054 mV
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

Vo 75:6 mV
V o = k:N ðT- T ref Þ, N =  = mV  =5
k: T - T ref 0:054 ° C ð300 - 20Þ ° C

° C , T = 300 ° C, T ref = 0 ° C
(c) N = 5, k = 0:054 mV

 
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

Vo 88:5 mV
V o = k:N ðT- T ref Þ, N = =   =4
k:ðT - T ref Þ 0:079 mV
° C ð300 - 20Þ ° C

7.6 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 = 0.0676 Ω,
Vout,A = 0.0141 V =14.1 mV, k = 0.2687 mV/MPa
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 origi-
nally 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 Experimental Validation

7.7.1 Data Acquisition and Analysis Using LabVIEW


and a Thermocouple

Objectives The objectives are to introduce temperature measurement with thermo-


couples 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 temper-
ature 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 Sensors

Table 7.1 Time response  


T ðt Þ - T 0 T ðt Þ - T 0
characteristics of Time t (sec) T(t) Tf - T0 - ln 1- Tf - T0
thermocouple 0 T0 0 0

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).
T ðt Þ - T 0
(c) Complete Table 7.1 and plot— ln 1- 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 Temperature, T (°C) Voltage, Vo (mV)
Ice
Room
Hand (P1)
Hand (P2)

Table 7.3 Summary of thermocouple characteristics

Time Rise % Sensitivity, k Expected % Difference for


Constant, time, Difference (mV/°C) Range of k k from mid-
(s) (s) for (mV/ °C) range 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 Color code Nominal value Measured value R % Difference


Rn (Ω) (Ω)
Strain gage (R4 or Rg) 120
WB R1 120
WB R2 120
WB R3 120
R5 1k
R5 1k
R6 10 k
R6 10 k

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 Wheat-
stone 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


Difference voltage,
Sl. No. Tip deflection, d (mm) Output voltage, Vout (mV) ΔVout = Vout – V0 (mV)
0 0 V0 0
1 2.54
2 5.08
3
4
5
6
7
8
9
10 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


Estimated
voltage Experimental % Estimated Estimated
Tip output voltage Difference change in change in
deflection Vout1E output Vout1 in voltage resistance Estimated length ΔL
δtip1 (mm) (mV) (mV) output ΔRg1 (Ω) strain ε1 (mm)
10.16

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 config-
ured 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 canti-
lever. 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).
200

Table 7.7 Undamped natural frequency and damping ratio from time response graph

Logarithmic Damping
Time ratio ζ =
Sl. Amplitude of Amplitude of next period T Decrement
  Undamped natural frequency Undamped natural
An ωn
No. peak An (mV) peak An + 1 (mV) (sec) δ = ln Anþ1 =2π δ ffi
pffiffiffiffiffiffiffi ωn rad/s ωn = p2π
ffiffiffiffiffiffiffiffi2ffi frequency fn Hz f n = 2π
1þδ2 T 1-ζ
1
2
Average
7
Sensors
7.7 Experimental Validation 201

Table 7.8 Comparison of natural frequency of cantilever beam without tip mass

Frequency from power Average frequency % Difference Comment


spectrum, f1 (Hz) from time response
fn Hz

Table 7.9 Comparison of tip mass

Frequency Frequency Measured Effective Measur Calculated % Difference


from power from power beam mass beam mass ed tip tip mass of tip mass
spectrum, spectrum, Mbeam = mass ,
without tip with tip mass (kg)
mass, f2 (Hz) 0.2357 (kg) =
f1 (Hz)

(kg) −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 spec-
imen, 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 ampli-
fier 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 maxi-
mum 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 function-
ing 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 mea-
sured 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 amplifier-
accelerometer 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/software-
products/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 instanta-
neous 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 207
B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_8
208 8 Digital Circuits

Table 8.1 Summary of commonly used combinational logic gates


Serial Mathematical Truth
number Logic gate Logic operation Schematic symbol expression table
1 Buffer Increase the Q=A A Q
output current 0 0
1 1
2 Inverter Invert (comple- Q=A A Q
(NOT, INV) ment) signal 0 1
1 0
3 AND gate AND logic Q=A∙B A B Q
0 0 0
0 1 0
1 0 0
1 1 1
4 NAND gate Inverted AND Q=A∙B A B Q
logic 0 0 1
0 1 1
1 0 1
1 1 0
5 OR gate OR logic Q=A+B A B Q
0 0 0
0 1 1
1 0 1
1 1 1
6 NOR gate Inverted OR Q=A þ B A B Q
logic 0 0 1
0 1 0
1 0 0
1 1 0
L
7 XOR Exclusive OR Q=A B A B Q
logic 0 0 0
0 1 1
1 0 1
1 1 0
L
8 XNOR gate Exclusive NOR Q=A B A B Q
logic 0 0 1
0 1 0
1 0 0
1 1 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 manufac-
turers’ 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 iden-
tities. In these, the variables A, B, and C are all logic variables.
Basic Boolean Algebra Laws

OR AND NOT

+0= ∙0=0

+1 = 1 ∙1= ̿=

Commutative Laws

A þ B=B þ A ð8:2Þ
A∙B=B∙A ð8:3Þ

Associative Laws

ðA þ B Þ þ C = A þ ðB þ C Þ ð8:4Þ
ðA ∙ BÞ ∙ C = A ∙ ðB ∙ C Þ ð8:5Þ

Distributive Laws

A ∙ ðB þ C Þ = ðA ∙ BÞ þ ðA ∙ CÞ ð8:6Þ

Useful Identities

A þ ðA ∙ BÞ = A ∙ 1 þ A ∙ B = A ∙ ð1 þ BÞ = A ∙ 1 = A ð8:7Þ
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
A þ ðA  ∙ B Þ = A ∙ 1 þ ðA þ A
 Þ ∙ B = A þ 1 ∙ B = A þ B ð8:9Þ
 
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
ð8:12Þ
     
ð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
= ðA ∙ BÞ ∙ 1 þ 1 ∙ ðB  ∙ CÞ ð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 implementa-
tion 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 L


P Q P∙Q Q∙P R P Q
R=P∙Q þ Q∙P
0 0 0 0 0 0
0 1 1 0 1 1
1 0 0 1 1 1
1 1 0 0 0 0

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 B C A∙B A∙B∙C (A + B) ðA þ BÞ ∙ C X X1
0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
0 1 0 1 0 1 1 1 1
0 1 1 1 1 1 0 1 1
1 0 0 0 0 1 1 1 1
1 0 1 0 0 1 0 0 0
1 1 0 0 0 1 1 1 1
1 1 1 0 0 1 0 0 0

Fig. 8.9 Schematic of


digital logic circuit
for X = A ∙ B þ A ∙ C

 8.4 Truth
Table  table for X Y Z X ∙Y ∙Z X ∙Y ∙Z X∙Y ∙Z P
P= X ∙Y ∙Z þ X ∙Y ∙Z
  0 0 0 0 0 0 0
þ X ∙Y ∙Z
0 0 1 0 0 0 0
0 1 0 0 0 0 0
0 1 1 1 0 0 1
1 0 0 0 0 0 0
1 0 1 0 1 0 1
1 1 0 0 0 1 1
1 1 1 0 0 0 0

8.6 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 Y Z XþY þZ XþY þZ XþY þZ P
0 0 0 1 1 1 1
0 0 1 0 1 1 0
0 1 0 1 0 1 0
0 1 1 1 1 1 1
1 0 0 1 1 0 0
1 0 1 1 1 1 1
1 1 0 1 1 1 1
1 1 1 1 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 consid-
ered as inputs
 to an AND gate. For row 3, (X = 0, Y = 1, Z = 1), the AND-edterm
 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-of-
products 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 X Y Z P


P = ∑ ( m3, m5, m6)
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 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  þ Z results
þ Y  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 Digital Circuits

Table 8.7 Truth table for X Y Z P


P = ∏ (M1, M2, M4)
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1

8.7 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 S State
0 1 Sleeping
1 0 Away
0 0 Normal
1 1 Not used

8.7.2 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 8 Digital Circuits

R S R∙S R∙S
0 1 1 0
1 0 0 1
0 0 0 0
1 1 Don’t care Don’t care

A = P ∙ S þ ðP þ Q Þ ∙ R ð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 221

Table 8.8 Truth table for


∙ ( + )∙
home security system
0 0 0 0 0 0 0
0 0 0 1 0 0 0
0 0 1 0 0 0 0
0 0 1 1 X X 0
0 1 0 0 0 0 0
0 1 0 1 0 0 0
0 1 1 0 0 1 1
0 1 1 1 X X 0
1 0 0 0 0 0 0
1 0 0 1 1 0 1
1 0 1 0 0 1 1
1 0 1 1 X X 0
1 1 0 0 0 0 0
1 1 0 1 1 0 1
1 1 1 0 0 1 1
1 1 1 1 X X 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 223

Table 8.9 Truth table for  


X Y Z X∙Y∙Z X ∙Y ∙Z X∙ Y þZ A
A=X ∙Y ∙Z þ X∙Y ∙Z þ
  0 0 0 0 0 0 0
X∙ Y þZ
0 0 1 0 0 0 0
0 1 0 0 0 0 0
0 1 1 0 1 0 1
1 0 0 0 0 1 1
1 0 1 0 0 1 1
1 1 0 0 0 1 1
1 1 1 1 0 0 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 P Q R S X Row


four-variable system
0 0 0 0 0 0
0 0 0 1 0 1
0 0 1 0 0 2
0 0 1 1 1 3
0 1 0 0 0 4
0 1 0 1 0 5
0 1 1 0 0 6
0 1 1 1 1 7
1 0 0 0 0 8
1 0 0 1 0 9
1 0 1 0 0 10
1 0 1 1 1 11
1 1 0 0 1 12
1 1 0 1 1 13
1 1 1 0 1 14
1 1 1 1 1 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 11 10

00 0 1 3 2
1

01 4 5 7 6
1

11 12 13 15 14
1 1 1 1

10 8 9 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 Inputs Outputs


SR flip-flop
S R Q Q
0 0 Q0 Q0
1 0 1 0
0 1 0 1
1 1 NA

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 S R CK Q Q


positive edge-triggered SR
flip-flop 0 0 " Q0 Q0
1 0 " 1 0
0 1 " 0 1
1 1 " NA
X X 0, 1, # Q0 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 D CK Q Q


positive edge-triggered D flip-
flop 0 " 0 1
1 " 1 0
X 0 Q0 Q0
X 1 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 229

Table 8.15 Truth table for a CK J K Q Q


negative edge-triggered JK
flip-flop # 0 0 Q0 Q0
# 0 1 0 1
# 1 0 1 0
# 1 1 Q0 Q0
0,1 X X Q0 Q0

Fig. 8.21 T flip-flop, (a) schematic, (b) internal design

Table 8.16 Truth table for T CK T Q Q


flip-flop
" 0 Q0 Q0
" 0 Q0 Q0
" 1 Q0 Q0
" 1 Q0 Q0

8.10 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 Digital Circuits

Table 8.17 Truth table for X Y Z X.Y.Z X’.Y.Z X.(Y′+Z’) A


Example 8.6 using Excel
0 0 0 FALSE FALSE FALSE FALSE
0 0 1 FALSE FALSE FALSE FALSE
0 1 0 FALSE FALSE FALSE FALSE
0 1 1 FALSE TRUE FALSE TRUE
1 0 0 FALSE FALSE TRUE TRUE
1 0 1 FALSE FALSE TRUE TRUE
1 1 0 FALSE FALSE TRUE TRUE
1 1 1 TRUE FALSE FALSE 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 combi-


national 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<=1; X++){


digitalWrite(pinX, X);
for (int Y=0; Y<=1; Y++){
digitalWrite(pinY, Y);
for (int Z=0; Z<=1; Z++){
digitalWrite(pinZ, Z);
A=digitalRead(pinA);
// display on serial monitor
Serial.print("XYZ= ");
Serial.print(X);
Serial.print(Y);
Serial.print(Z);
Serial.print(" A= ");
Serial.println(A);

delay(1000); // Wait for 1000 millisecond(s)


}
}
}

}
_________________________________________________________________

Exercises

1. A digital logic circuit is to be designed to implement the Boolean expression:

X = P ∙ Q þ ðP þ Q þ RÞ ∙ ðP ∙ RÞ:

(a) Use Boolean algebra to simplify the expression for X, and draw the sche-
matic of the logic circuit for the simplified version.
(b) Obtain the truth table for the original expression for X, and verify the output
of its simplified version.
2. A digital logic circuit is to be designed to implement the Boolean expression:

X =A∙B þ A∙B þ A∙B

(c) Use Boolean algebra to simplify the expression for X, and draw the sche-
matic of the logic circuit for the simplified version.
(d) Obtain the truth table for the original expression for X, and verify the output
of its simplified version.
Exercises 233

3. A digital logic circuit is to be designed to implement the Boolean expression:

X = A ∙ B þ ðB þ C Þ ∙ ðB ∙ C Þ

(e) Use Boolean algebra to simplify the expression for X, and draw the sche-
matic of the logic circuit for the simplified version.
(f) Obtain the truth table for the original expression for X, and verify the output
of its simplified version.

4. Find the Boolean expression for the output (P) in terms of the inputs (A, B, C) for
the combinational logic circuit shown in Fig. P8.1. Using Boolean algebra,
obtain the simplified expression (PS) of the output for its implementation
using the minimum number of two-input logic gates. Draw the combinational

Fig. P8.1 Combinational logic circuit for problem 1

logic circuit for implementation of the simplified expression (PS), and identify
the gates (type and number).

5. Find the Boolean expression for the output (Q) in terms of the inputs (G, H ) for
the combinational logic circuit shown in Fig. P8.2. Using De Morgan’s laws and
Boolean algebra obtain the simplified expression (QS) of the output for its

Fig. P8.2 Combinational


logic circuit for problem 2
234 8 Digital Circuits

implementation using the minimum number of two-input logic gates. Draw the
combinational logic circuit for implementation of the simplified expression
(QS), and identify the gates (type and number).

6. Find the Boolean expression for the output (R) in terms of the inputs (L, M, N )

Fig. P8.3 Combinational


logic circuit for problem 3

for the combinational logic circuit shown in Fig. P8.3. Using De Morgan’s laws
and Boolean algebra, obtain the simplified expression (RS) of the output for its
implementation using the minimum number of two-input logic gates. Draw the
combinational logic circuit for implementation of the simplified expression (RS),
and identify the gates (type and number).

7. Construct truth table and Karnaugh map for the Boolean expression. Simplify
the expression, and construct digital circuits for both the original and the
simplified expressions.

Y =A∙B þ A∙C þ B∙C

8. Construct a truth table and Karnaugh map for the Boolean expression. Simplify
the expression, and verify using Boolean algebra. Construct digital circuit for
the simplified expression.

Y =A∙B∙C þ A∙B∙C þ A∙B∙C

9. Construct a truth table and Karnaugh map for the Boolean expression. Simplify
the expression, and verify using Boolean algebra. Construct digital circuit for
the simplified expression.

Y =A∙B∙C þ A∙B∙C þ A∙B∙C þ A∙B∙C


Exercises 235

10. Construct a truth table and Karnaugh map for the Boolean expression. Simplify
the expression, and verify using Boolean algebra. Construct digital circuits for
both the original and the simplified expressions.
     
Y= AþBþC ∙ AþBþC ∙ AþBþC

11. It is required to design an alarm system using a digital logic circuit for an
experimental machining platform. In the machining platform, three sensors will
be installed to measure cutter vibration (V ), cutter temperature (T ), and the
product surface roughness (S). Each of the sensors generates a HIGH signal
(1) if the measured value is higher than its preset threshold value; otherwise, the
signal is LOW (0).
(a) Design a logic circuit that will generate an alarm (A) if the cutter vibration is
HIGH and the cutter temperature (T ) is HIGH and the surface roughness is
HIGH, or if the cutter vibration is HIGH and either the cutter temperature is
HIGH or the surface roughness is HIGH, or if the cutter temperature is
HIGH and the surface roughness is HIGH.
(b) Obtain the Boolean expression and the truth table. Simplify the Boolean
expression, and draw the logic schematic for realization of the circuit using
minimum number of two-input combinational logic gates.
12. It is required to design a combinational logic system for a process tank for which
four variables’ level (L ), pressure (P), flow rate (Q), and temperature (T ) are
monitored. The signal-conditioning circuit for each of the monitored variables
(L, P, Q, and T ) generates a logic HIGH (1) when the sensor output exceeds the
corresponding threshold value; otherwise, the output is logic LOW (0).
The following conditions are considered unsafe and warrant the initiation of
an alarm (A):
(i) If the liquid level and flow rate are low and the temperature is high and
pressure is low
(ii) If the liquid level is high and flow rate is low and the temperature is low
and the pressure is high
(iii) If the liquid level or flow rate is low and the temperature is high and the
pressure is high
(iv) If the liquid level is low or pressure is high and the temperature is high or
flow rate is low
(a) Construct a Boolean expression for the alarm output (A) in terms of
logic outputs of the sensors.
(b) Obtain the corresponding truth table.
236 8 Digital Circuits

(c) Construct the Karnaugh map and simplify the Boolean expression.
(d) Draw the logic schematic for realization of the simplified circuit using
two-input logic gates.
(e) Convert the simplified logic circuit to an equivalent one using only
NOT and two-input NOR gates for its implementation with minimum
number of logic gates.

Bibliography

Alciatore DG (2019) Introduction to mechatronics and measurement systems, 5th edn. McGraw
Hill, New York
Arduino (2022) Arduino. https://www.arduino.cc
Boolean-algebra.com (2022a) Boolean algebra simplifier. https://www.boolean-algebra.com/kmap/
Boolean-algebra.com (2022b) K-map simplifier. https://www.boolean-algebra.com/kmap/
Texas Instruments (2022) Logic gates. https://www.ti.com/logic-voltage-translation/logic-gates/
overview.html
Stanford University (2022) Truth table generator. https://web.stanford.edu/class/cs103/tools/truth-
table-tool/
Tinkercad (2022) Learn circuits. https://www.tinkercad.com/learn/circuits
Chapter 9
Actuators

9.1 Introduction

In mechatronic systems, actuators are devices2 that facilitate generation of actions


based on information received from sensors and desired objectives for specific
applications. The actuators are to be selected along with other driving interfaces.
In this chapter, an overview of actuators is provided with primary focus on electro-
mechanical actuating devices for mechatronics applications.

9.2 Types of Actuators

There are several types of actuators spanning over different energy domains. These
include electromechanical devices like solenoids, relays, and DC and AC motors,
used in low- to medium-power applications. There are hydraulic actuators that use
high-pressure fluid for high-power applications. Electrohydraulic systems (EHS) are
used to combine advantages of hydraulic and electric systems in terms of high power
and better controllability. Pneumatic actuators using compressed air are primarily
suited for low-power applications.

9.3 Electromechanical Actuators

Electromechanical actuators are primarily used in low- to medium-power applica-


tions. These devices include solenoids, electromechanical relays, and DC and AC
motors. Solenoids are mainly constructed with a coil and a moveable iron core to
produce small motion with current energizing the coil. Solenoids are primarily used
in small motion applications like latching, locking, and triggering.

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

Electromechanical relays are solenoids to make or break mechanical contacts using a


small input voltage to control large current in relay contacts. Relays are mainly used
as power switches. Electric motors are most commonly used electromechanical
actuators. Electric motors can be classified in two broad groups—DC and AC
motors. DC motors are mainly grouped in two: brushed and brushless. AC motors
are grouped primarily as single-phase and multi-phase motors. Each of these groups
is further classified into induction and synchronous motors. In this chapter, the
primary focus is on DC motors and stepper motors as these motors are very common
in mechatronics applications.

9.4 DC Motor Characteristics

Direct current (DC) motors are widely used in mechatronic systems because of the
ease of control, direction reversibility, high torque-to-inertia ratio, fast response, and
reasonably achievable torque-speed characteristics. DC motors are categorized
mainly in four groups based on the type of stator magnetic fields. These are
permanent magnet, series wound, shunt wound, and compound wound, as shown
in Figs. 9.1, 9.2, 9.3 and 9.4. In permanent magnet (PM) DC motors, the magnetic

Fig. 9.1 Permanent magnet


DC motor

Fig. 9.2 Series wound DC


motor

Fig. 9.3 Shunt wound DC


motor
9.4 DC Motor Characteristics 239

Fig. 9.4 Compound wound


DC motor

Fig. 9.5 Electromechanical modeling of a permanent magnet armature controlled DC motor

field is produced by permanent magnets requiring no external power supply for


magnetization. PM DC motors are characterized by linear torque-speed relation and
mainly used in low-power applications. In series wound DC motors, the field and
armature windings are in series. The series wound DC motors are characterized by a
hyperbolic torque-speed relation with a high starting torque and a nearly constant
power. It is important to keep a series wound DC motor loaded to avoid runaway
speed. In shunt wound DC motors, the field and armature windings are in parallel.
The shunt DC motors are characterized by a flat torque-speed relation over a range of
speed with nearly a constant speed over a wide range of torque (load). In compound
wound DC motors, the field winding is in both series and parallel with the armature
winding, resulting in characteristics that combine that of series and shunt wound DC
motors.

9.4.1 Dynamic Model of an Armature Controlled DC Motor

The dynamic model of an armature controlled DC motor can be obtained considering


the electrical and mechanical subsystems and the electromechanical coupling
between the two subsystems. The schematic diagram is shown in Fig. 9.5. The
electrical circuit for the armature is shown (assuming an independent electrical
circuit for field magnetization) where Ra is the armature resistance (Ω), La is the
armature inductance (H), Va(t) is the applied armature voltage (V ), ia(t) is the
armature current (A), eb(t) is the back electromotive force (emf) (V ) due to the
240 9 Actuators

generator effect in the motor, and t is time (s). The mechanical subsystem is shown
with Jm as an equivalent rotor-load inertia (kg. m2), and c, an equivalent viscous
damping coefficient (N. m. s/rad), T(t) as the motor generated torque (N. m), and ω(t)
is the motor speed (rad/s). The conventional units for the mechanical subsystem
Jm, c, and T(t) can be written as ug. ft2, lb. ft. s/rad, and lb. ft, respectively.
Electrical Subsystem Dynamic Model
Applying Kirchhoff’s voltage law (KVL) to the armature loop, Eq. (9.1) can be
written as

d
Ra ia ðt Þ þ ðL i ðt ÞÞ þ eb ðt Þ - V a ðt Þ = 0 ð9:1Þ
dt a a

Assuming La as constant, Eq. (9.1) can be rewritten as

d
La ði ðt ÞÞ þ Ra ia ðt Þ = V a ðt Þ - eb ðt Þ ð9:2Þ
dt a

Mechanical Subsystem Dynamic Model


Applying equation of motion for the mechanical subsystem (rotational motion),
Eq. (9.3) can be written as

X d
Mo = Jm ωðt Þ ð9:3Þ
dt

where ∑Mo represents the sum of external moments acting on the rotational system
about the axis of rotation. Taking into account all moments (torques) acting on the
rotor, Eq. (9.3) can be rewritten as

d
T ðt Þ - T L ðt Þ - cωðt Þ = J m ωðt Þ ð9:4Þ
dt

Equation (9.4) can be rewritten, with rearrangement of terms, as

d
Jm ωðt Þ þ cωðt Þ = T ðt Þ - T L ðt Þ ð9:5Þ
dt

Electromechanical (E-M) Coupling


The electromechanical coupling can be described relating the electrical variable
eb(t), the back emf, to the mechanical variable ω(t), the motor speed, as

eb ðt Þ = k e ωðt Þ ð9:6Þ

where ke is called the electrical constant (V. s/rad) of the motor.


9.4 DC Motor Characteristics 241

The mechanical variable T(t), the generated motor torque, can be related to the
electrical variable ia(t), the armature current, as

T ðt Þ = k t i a ðt Þ ð9:7Þ

where ktis the torque constant (N. m/A) of the motor.


The electromechanical (E-M) coupling can be considered as a process of power
conversion from electrical to mechanical domain. In the SI system of units, assuming
lossless conversion
 of power
 from electrical to mechanical domain, the two motor
s
constants k e , V: rad and k t , N: mA are numerically the same, i.e., k:

ke = kt = k ð9:8Þ

The dynamic model of the DC motor is represented in the form of Eqs. (9.2),
(9.5), (9.6), and (9.7).

9.4.2 Steady-State Characteristics

Under steady-state condition, the variations of electrical and mechanical variables


with respect to time can be neglected. Representing the time-dependent variables in
lower case to time-independent upper case variables, i.e., ia(t) as Ia and eb(t) as Eb,
Eq. (9.2) can be written as

Ra I a = V a - E b ð9:9Þ

Similarly, Eqs. (9.6) and (9.7) can be written, under steady-state, as

Eb = ke ω ð9:10Þ
T = kt I a ð9:11Þ

Substituting Ia and Eb in terms of T, motor torque, and ω, motor speed, Eq. (9.9)
can rewritten as

Ra T
= V a - ke ω ð9:12Þ
kt

Rearranging the terms, the motor torque can be expressed in terms of motor
voltage and motor speed as

kt k
T = Va - ke t ω ð9:13Þ
Ra Ra
242 9 Actuators

Equation (9.13) can be rewritten as the motor torque-speed characteristics:


 
ω
T ð ωÞ = T s 1- ð9:14Þ
ωmax

where Ts represents the stall or starting torque for the motor:

Va
T s = kt ð9:15Þ
Ra

and ωmax represents the maximum (or no load) speed of the motor:

Va
ωmax = ð9:16Þ
ke

Equation (9.14) can be represented as a straight line in torque-speed (T - ω)


curve starting at ω = 0, T = Ts, and ending at ω = ωmax, T = 0.
The instantaneous power of the motor P(ω) can be expressed as a product of
torque T(ω)and motor speed (ω):
 
ω
PðωÞ = T s 1- ω ð9:17Þ
ωmax

The power at the end points of the torque-speed curve is zero. The maximum
dP
power can be obtained taking dω = 0:
 
dP 2ω
= Ts 1- =0 ð9:18Þ
dω ωmax

The motor speed at which the power is maximum can be obtained as

1
ω= ω ð9:19Þ
2 max

The maximum power can be expressed as


 ωmax

1- ωmax ωmax
2
ωmax
Pmax = T s = Ts ð9:20Þ
2 4

The motor torque-speed and power-speed characteristics curves in normalized


form are shown in Fig. 9.6:
These characteristics can be used for separately excited armature controlled DC
motor as well as a permanent magnet (PM) DC motor. The DC motor specification
includes starting or stall torque (Ts), the armature voltage (Va), the maximum
armature current (Iamax), the maximum motor speed (ωmax), and the maximum
power(Pmax).
9.4 DC Motor Characteristics 243

Fig. 9.6 Normalized motor torque-speed and power-speed characteristics

Example 9.1 A permanent magnet DC motor is with armature resistance Ra = 2Ω,


armature voltage Va = 12 V, motor electric constant ke = 0.20 V. s/rad, motor torque
constant kt = 0.20 N. m/A, and motor rotary inertia Jm = 9 × 10-3 kg. m2. Find the
maximum armature current, stall torque, maximum speed, maximum power, speed at
maximum power, and maximum acceleration.
Solution Given armature resistance Ra = 2Ω, armature voltage Va = 12 V, motor
electric constant ke = 0.20 V. s/rad, motor torque constant kt = 0.20 N. m/A, and
motor rotary inertia Jm = 9 × 10-3 kg. m2.
Maximum armature current I a, max = VRaa = 12V 2Ω = 6 A:
 
Stall torque T s = k t VRaa = 0:2 N: mA ð6AÞ = 1:2 N:m
ð60rads Þð60 mins Þ
Maximum motor speed ωmax = Va
12V
ke =
0:2 V:s=rad = 60 s =
rad
2π rad
= 572:73 rpm
rev
ωmax ð1:2 N:mÞð60rad Þ
Maximum motor power Pmax = T s 4 = 4
s
= 18 W
ð 60rad
Þ
Motor speed at maximum power ω = 2 ωmax = 2 = 30 s = 572:732 rpm = 286:36 rpm
1 s rad
133:33rad
Maximum motor acceleration αmax = TJ ms = 9 ×ð10 1:2 N:mÞ
-3
kg:m2
= 133:33 rad s2 = 2π rad
s2
rev
= 21:21 rev
s2
The motor torque-speed and power-speed characteristics are shown in
Fig. 9.7a, b.
244 9 Actuators

(a) (b)

Fig. 9.7 PM DC Motor characteristics (a) torque speed, (b) power speed

9.5 Selection of DC Motors

The selection of DC motors for a particular application will be based on desired


characteristics.
Maximum Armature Current For a PM DC motor, the maximum armature current
(Ia) can be expressed in terms of armature voltage (Va) and the armature resistance
(Ra) as I a = VRaa .

Starting or Stall Torque The starting or stall torque (Ts) of a PM DC motor can be
expressed in terms of motor constant (k) and maximum armature current (Ia), as in
Eq. (9.15):

Va
Ts = k = kI a :
Ra

Motor and Load Inertia The effective rotary inertia (Jeff) can be considered taking
into account the inertia of motor rotor (Jm) and the load (JL) through the gear pair
with gear ratio of n = ωωmL as
9.5 Selection of DC Motors 245

JL
J eff = J m þ ð9:21Þ
n2

where ωm and ωL represent the rotational speed of the motor and the load,
respectively.
Starting Acceleration of the Motor The starting angular acceleration (α) of the
motor can be expressed in terms of motor torque (Ts), load torque (TL), and the
effective rotary inertia (Jeff) as

 
T s - TnL
α= ð9:22Þ
J eff

Maximum Speed of the Motor For a PM DC motor, the maximum speed of the
motor (ωmax) can be expressed in terms of motor constant (k) and armature voltage
(Va), as in Eq. (9.16):

Va
ωmax =
ke

Power Rating of the Motor For a PM DC motor, the maximum power (Pmax) can be
expressed in terms of stall torque (Ts) and maximum motor speed (ωmax), as in
Eq. (9.20):

ωmax
Pmax = T s
4

Operating Speed of the Motor For a PM DC motor, the operating speed of the
motor should be within β% of the speed at maximum power (ωmax/2) as

 β
  β

1- ωmax 1 þ 100 ωmax
100
≤ω≤ ð9:23Þ
2 2

Matching of load torque with motor torque-speed characteristics: The load torque
and the motor torque should match near the operating speed range of the motor.
Example 9.2 It is necessary to select a DC servomotor such that its maximum speed
(ωmax) is at least 550 rev/min, the maximum armature current (Ia,max) is less than 5A,
the starting torque (Ts) is at least 0.9 N.m, the starting acceleration (αmax) is at least
30 rev/s2, and the power (Pmax) is at least 13.5 W. A DC servomotor is available with
an input voltage of 12.5 V, armature resistance of 2.8 Ω, motor constant of
0.22 N.m/A, and equivalent rotor inertia of 5.5 × 10-3 kg.m2. Find the maximum
246 9 Actuators

armature current, the starting torque, the maximum rotational speed, the starting
acceleration, and maximum power of the available DC servomotor. Verify if the
available DC servomotor meets the required specifications.
Solution Given armature resistance Ra = 2.8 Ω, armature voltage Va = 12.5 V,
motor electric constant ke = 0.22 V. s/rad, motor torque constant kt = 0.22N. m/A,
motor rotary inertia Jm = 5.5 × 10-3 kg. m2.
Desired specifications: Ia, max ≤ 5A, Ts ≥ 0.90 N. m, ωmax ≥ 550 rpm, αmax≥30
rev/s2, Pmax ≥13.5W
Maximum armature current I a, max = VRaa = 12:5
2:8 Ω = 4:46 A < 5 A √
V
 
Stall torque T s = k t Ra = 0:22 N: A ð4:46 AÞ = 0:9821 N:m > 0:9 N:m √
Va m

ð56:8182rads Þð60 mins Þ


Maximum motor speed ωmax = Vkea = 0:2212:5 V:s=rad = 56:8182 s =
V rad
2π rad rev
= 542:57 rpm < 550 rpm X
ð0:9821 N:mÞð56:8182rad

Maximum motor power Pmax = T s ω4max = 4 = 13:95 W > 13:5 W √
ð0:9821 N:mÞ 178:5714rad2
Maximum motor acceleration αmax = Ts
Jm = 5:5 × 10 - 3 kg:m2 = 178:5714 rad
s2 = 2π rad
s
rev
= 28:42 rev
s2 < 30 s2 X
rev

The available DC motor meets the specifications on maximum armature current,


starting torque, and maximum power but does not meet specifications on maximum
speed and starting acceleration.

9.6 Electronic Control of DC Motor Speed and Direction

In this section, electronic control of a PM DC motor speed and direction of rotation


control is discussed. An Arduino microcontroller can be used to control the speed
and the direction of rotation of a DC motor through an H-bridge. Pulse width
modulation (PWM) is used to control the DC motor speed, and an H-bridge is
used to control the direction of the DC motor rotation.

9.6.1 Pulse Width Modulation (PWM)

The speed of a DC motor can be controlled by varying its input voltage through
PWM. PWM is a technique where average value of the input voltage is adjusted by
sending a series of ON-OFF pulses with the average voltage being proportional to
the ratio of the pulses (ON) known as duty cycle. Illustration of PWM technique with
various duty cycles (0%, 25%, 50%, 75%, and 100%) is presented in Fig. 9.8 where
average voltages over the cycles are presented in red. The PWM signals can be
generated through analogWrite() command from Arduino with argument of the
command being 0, 64, 127, 191, and 255 corresponding to 0%, 25%, 50%, 75%,
and 100% duty cycle (arduino.cc). With these values, the DC motor speed can be
varied to 0%, 25%, 50%, 75%, and 100% of full speed, respectively.
9.6 Electronic Control of DC Motor Speed and Direction 247

Fig. 9.8 PWM signals generated using Arduino analogWrite() (arduino.cc)

9.6.2 H-Bridge

The direction of rotation of the DC motor can be controlled using an H-bridge. An


H-bridge consists of four power transistors with the motor at the center forming an
H-like arrangement (Fig. 9.9). The motor can be run in a desired direction (clockwise
or counter clockwise) by selectively turning on a pair of transistors of the H-bridge.
Turning on the pair of transistors, upper left (Q1) and lower right (Q4), at the same
time, with other pair of transistors, upper right (Q3) and lower left (Q2) off, allows
the DC motor to rotate in one direction (e.g., clockwise). Similarly turning on the
pair of transistors, upper right (Q3) and lower left (Q2), at the same time, with other
pair, upper left (Q1) and lower right (Q4) off, allows the DC motor to rotate in the
other direction (counterclockwise).
248 9 Actuators

Fig. 9.9 Schematic of an


H-bridge for DC motor
direction control

Fig. 9.10 Pinout diagram


of L293D driver
IC. (Adapted from www.
tinkercad.com)

Table 9.1 Signal combina- Low (0) Low (0) Motor OFF
tions to control DC motor
High (1) Low (0) Clockwise
direction
Low (0) High (1) Counterclockwise
High (1) High (1) Motor OFF

9.6.3 L293D Motor Driver IC

The L293D is a dual-channel H-bridge motor driver IC that can be used to run a pair
of DC motors or one stepper motor. The pinout diagram can be obtained from
datasheet on the manufacturer’s website (e.g., www.ti.com). An adapted version of
L293D IC is presented in Fig. 9.10. There are a total of 16 pins—eight on either side
of the driver IC. The power supply (5 V) is connected to pins 8 (Vcc2) and 16 (Vcc1)
on the IC. The common ground terminals (GND) are pins 4, 5, 12, and 13. One DC
motor (Motor A) can be connected to pins 3 and 6 (OUT 1 and OUT 2), and the other
motor (Motor B) can be connected to pins 11 and 14 (OUT 3 and OUT 4). The
control pins 2 and 7 (IN 1 and IN 2) can be used to control the direction of rotation of
Motor A, and pins 10 and 15 (IN3 and IN4) can be used to control direction of
rotation of Motor B. The direction of rotation can be controlled using digital signals
(HIGH or LOW) to these four control pins as shown in Table 9.1. The speed of the
DC motors can be controlled by using PWM signals to enable pin 1 (EN 1, 2) for
Motor A, and pin 9 (EN 3, 4) for Motor B.
9.6 Electronic Control of DC Motor Speed and Direction 249

9.6.4 L298N Motor Driver Module

L298N motor driver board is based on L298N dual full-bridge driver IC. The details
of L298N IC can be from datasheet on manufacturer’s website (e.g., www.st.com).
The motor driver board is convenient to interface and drive two DC motors simul-
taneously with an external DC power supply in the recommended range of 5–12 V.
There are 11 pins that can be used to connect the driver module with external
components like power supply, motors, and driving signals from a microcontroller
like Arduino. The details of motor driver L298N module can be readily accessed
from internet (e.g., create.arduino.cc/projecthub). The module can be powered
through three-pin screw terminal that includes one pin (marked +12 V) with
recommended DC supply range of 5–12 V to drive the motors, one pin (marked
+5 V) with recommended range of 5–7 V to drive the logic circuits of L298N IC, and
one pin (marked GND) to provide common ground. The external +5 V supply is not
needed if the onboard 5 V regulator is enabled through a jumper. The motors can be
connected to the driver module through each pair of screw terminals marked OUT1
and OUT2 for one motor (A) and OUT3 and OUT4 for the other motor (B). The
direction of motors can be controlled through each pair of pins marked IN1 and IN2,
for motor A, and IN3 and IN4, for motor B. These pins can be connected to digital
I/O pins to receive digital outputs (HIGH or LOW) from Arduino using digitalWrite
() command. The speed of the motors can be controlled through enabled pins marked
ENA for motor A and ENB for motor B. The enabled pins can be connected to PWM
output pins of Arduino (digital I/O pins marked with ~) to receive values in the range
of 0–255 using analogWrite() command.

9.6.5 DC Motor Speed and Direction Control Using


an Arduino

The schematic of driving two DC motors using a L298N motor driver module and an
Arduino Uno board is shown in Fig. 9.11. 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. Two DC motors are connected to the driver module
using screw terminals on the sides. The upper right corner DC motor (Motor A) is
driven by ENA and IN1 and IN2 on the L298N motor driver module. These pins are
connected to Arduino Uno digital input/output (DIO) pins 9, 8, and 7, respectively.
Of these, pin 9 is a PWM-enabled output pin required to control the speed of Motor
A. Similarly, the other motor (Motor B) is driven by ENB, IN4, and IN3 on the
motor driver module. These pins are connected to Arduino DIO pins 3, 4, and
5, respectively. Of these, pin 3 is a PWM-enabled output pin required to control
the speed of Motor B.
250 9 Actuators

Fig. 9.11 Connection diagram for driving a pair of DC motors using L298N driver module

The Arduino code for driving the DC motors is listed. First, the pins 9, 8, 7, 5,
4, and 3 are defined as enA, in1, in2, in3, in4, and enB, respectively. Next, all these
pin modes are assigned as OUTPUT in setup() block. There are two functions called
within loop() block. The function motorDirectionControl() is used to control the
direction of rotation of the motors by setting outputs to in1, in2 for Motor A and in3,
in4 for Motor B as per Table 9.1. The function motorSpeedControl() is used to
control the speed of the motors by changing PWM value to pins enA for Motor A
and enB for Motor B. For accelerating the motors, PWM values are increased
gradually from 0 to 255 in steps of 1. For decelerating the motors, PWM values
are decreased from 255 to 0 in steps of 1.

// Motor A connections
int enA = 9;
int in1 = 8;
int in2 = 7;
// Motor B connections
int enB = 3;
int in4 = 4;
int in3 = 5;

void setup() {
// Set all the motor control pins to outputs
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
9.6 Electronic Control of DC Motor Speed and Direction 251

// Turn off motors - Initial state


digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}

void loop() {
motorDirectionControl();
delay(1000);
motorSpeedControl();
delay(1000);
}

// function to control direction of rotation of motors


void motorDirectionControl() {
// Set motors to maximum speed
// For PWM maximum possible values are 0 to 255
analogWrite(enA, 255);
analogWrite(enB, 255);

// Turn on motor A & B


digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
delay(2000);

// Now change motor directions


digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay(2000);

// Turn off motors


digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}

// function to control speed of the motors


void motorSpeedControl() {
// Turn on motors
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
252 9 Actuators

// Accelerate from zero to maximum speed


for (int i = 0; i &lt; 256; i++) {
analogWrite(enA, i);
analogWrite(enB, i);
delay(20);
}

// Decelerate from maximum speed to zero


for (int i = 255; i >= 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

40

20
Speed (rpm)

0
0 1 2 3 4 5 6 7 8 9 10
-20

-40

-60
time (s)

Fig. 9.12 Speed profile of DC motor (Example 9.3)


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 &lt; 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 Actuators

9.7 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 IN1 IN2 IN3 IN4 CW CCW
1 High (1) Low (0) Low (0) High (1) # "
2 High (1) Low (0) High (1) Low (0) # "
3 Low (0) High (1) High (1) Low (0) # "
4 Low (0) High (1) Low (0) High (1) # "

Fig. 9.14 Connection diagram for a bipolar stepper motor using L298N driver module
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 <Stepper.h>

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 <Stepper.h>

// 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 Computer-Aided Analysis and Simulation of DC


Motors
9.8.1 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 Actuators

(a) (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

40
Motor speed (rpm)

20

0
0 5 10 15 20 25 30
-20

-40

-60
Time (s)

Fig. 9.16 Speed profile of DC motor (Example 9.5)


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 &lt; 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 Actuators

9.9.2 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 acceler-
ation (α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 char-
acteristics 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
dynamics G1 ðsÞ = V ðsÞI a-ðsEb
Þ ωðsÞ
ðsÞ = 0:28sþ2500 , rotor dynamics G2 ðsÞ = T ðsÞ = 6sþ2,
1000 1000

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 periph-
erals, 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 265
B. Samanta, Introduction to Mechatronics, https://doi.org/10.1007/978-3-031-29320-7_10
266 10 Microcontroller Programming and Interfacing

10.2 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 Arduino Programming Environment 267

10.3 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 Microcontroller Programming and Interfacing

10.4 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, trig-
onometry, 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
5V
through a 10-bit ADC using analogRead() with a resolution of 4.9 mV 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 Microcontroller Programming and Interfacing

10.4.2 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<100

// do something repetitive 100 times


var++;
}
-----------------------------------------------------------------
// Example of if. . .else
if (val >= 30) {
// add statements to be executed when val >=30
}
else if (val >= 20) {
// add statements to be executed when 20 <= val < 30
}
else {
// add statements to be executed when val < 20
}
-----------------------------------------------------------------
// Example of a switch. . .case structure
switch (val) {
case L1:
// statements to be executed when val equals L1
break;
case L2:
// statements to be executed when val equals L2
break;
default:
// if nothing else matches, statements under default to be executed
// default is optional
break;
}
_________________________________________________________________
10.5 An Example Code 273

Further Syntax
Further syntax statement #define is used to define a variable as a constant. However,
const is preferred for Arduino. The #include statement is used to include external
libraries in a sketch. This is very convenient to make use of existing libraries, both
standard C and Arduino specific, in developing codes (sketches) for specific
applications.
/* */ (block comment) is used to comment a block of lines starting with /* and
ending with */. The double slashes (//) are used to comment a single line following //.
A semicolon (;) is used to end a statement. Curly braces {. . .} are used to define the
scope of a function like void funcName() {. . .}, a loop structure like while (. . .)
{. . .}, do {. . .} while(), for (. . .){. . .}, and conditional statements if (){. . .}, if ()
{. . .} else {. . .}.
Arithmetic Operators
The arithmetic operators include % (remainder), * (multiplication), + (addition), -
(subtraction), / (division), and = (assignment operator).
Comparison Operators
Comparison operators include != (not equal to), < (less than), <= (less than or
equal to), == (equal to), > (greater than), >= (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 left), >> (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, oscil-
loscope, 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 poten-
tiometer 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 Arduino Programming and Interfacing Examples

10.8.1 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<=1; A++){
digitalWrite(pinA, A);
for (int B=0; B<=1; B++){
digitalWrite(pinB, B);
for (int C=0; C<=1; C++){
digitalWrite(pinC, C);

// display on serial monitor


Serial.print("ABC= ");
Serial.print(A);
Serial.print(B);
Serial.println(C);
282 10 Microcontroller Programming and Interfacing

delay(1000); // Wait for 1000 millisecond(s)


} // end of for C
} // end of for B
} // end of for A
} // end of loop
// end of code
_________________________________________________________________

10.8.2 Simulation of Setting LEDs On/Off Based


on the Status of Push Buttons

The objective of this example is to create a circuit to put an RGB LED on/off
depending on the state (pressed/not pressed) of two push buttons and test it using
Arduino code.
A snapshot of simulation on Tinkercad is shown in Fig. 10.9. A resistor (470 Ω) is
connected to each LED. The LEDs are connected to Arduino digital pins 5, 4, 3, and
2 (A, B, C, and D), and the push buttons are connected to digital pins 7 and 6 (X and
Y). First, the pins (pinA, pinB, pinC, pinD, pinX, and pinY) are declared as constant
integers. In the setup() block, the LED pins, pinA-pinD, are set as OUTPUT and
push-button pins, pinX and pinY, are set as INPUT 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 status of each push button is read using digitalRead(). Based
on the status of the push button (pressed = 1, not pressed = 0), LEDs are selectively
put on or off by setting corresponding output pin HIGH or LOW using digitalWrite
(). The status of each pushbutton is displayed on serial monitor using Serial.print()
and Serial.println(), as shown in the code listing.

Fig. 10.9 Simulation of LEDs on/off based the status of push buttons using an Arduino on
Tinkercad
10.8 Arduino Programming and Interfacing Examples 283

_________________________________________________________________
// Code for LED_PB
// Inputs (to the circuit) A, B, C, D (LEDs)
// Outputs from the circuit X, Y (Push buttons)
const int pinA = 5;
const int pinB = 4;
const int pinC = 3;
const int pinD = 2;
const int pinX = 7;
const int pinY = 6;

void setup()
{
// setup pins for output (from Arduino)
pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
// setup pin for input (to Arduino)
pinMode(pinY, INPUT);
pinMode(pinX, INPUT);
// setup baud rate to 9600 for Serial Monitor
Serial.begin(9600);
}

void loop()
{ int Y = 0;
int X = 0;
// read circuit outputs
Y = digitalRead(pinY);
X = digitalRead(pinX);
digitalWrite(pinA, LOW);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, HIGH);

if (X == 0 && Y == 0){
digitalWrite(pinA, LOW);
digitalWrite(pinB, LOW);
digitalWrite(pinC, HIGH);
digitalWrite(pinD, HIGH);
}
else if(X == 0 && Y == 1){
digitalWrite(pinA, LOW);
digitalWrite(pinB, HIGH);
digitalWrite(pinC, LOW);
digitalWrite(pinD, HIGH);
}
else if(X == 1 && Y == 0){
digitalWrite(pinA, HIGH);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, HIGH);
}
284 10 Microcontroller Programming and Interfacing

else if(X == 1 && Y == 1){


digitalWrite(pinA, HIGH);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, LOW);
}
Serial.print("X, Y= ");
Serial.print(X);
Serial.print(" ");
Serial.println(Y);
delay(1000); // Wait for 1000 millisecond(s)

}// end of code


_________________________________________________________________

10.8.3 Simulation of a Digital Logic Circuit for a Multiplexer

The objective of this simulation is to create a digital logic circuit using gates (inverter
or NOT, AND, OR gates) and test it using an Arduino for a two-input multiplexer
with the output X represented in terms of inputs A and B and the control input P,

X=A  P þ B  P

The output X is the same as A when P is LOW and X is the same as B when P is
HIGH. It is necessary to generate the 3-bit input patterns 000-111 for PAB and
monitor the output via an input to the Arduino and a LED. The truth table for the
digital logic circuit, as shown in Table 10.1, needs to be verified.
A snapshot of simulation on Tinkercad is shown in Fig. 10.10. An inverter (NOT
gate) IC 7404, an AND gate IC 7408, and an OR gate IC 7432 are used to construct
the logic circuit. Each of these IC is powered at pin 14 through 5 V from Arduino and
grounded at pin 7 to the Arduino ground (GND). Arduino digital pins 5, 4, and 3 are
used to output digital signals P, A, and B, respectively. Digital pin 2 is used as input
(Y ) to Arduino to monitor the output of the digital logic circuit. The output of the
logic circuit is also connected to a LED through a 470 Ω resistor to display the logic
circuit output status.

Table 10.1 Truth table for P A B PA PB X


multiplexer X = A  P þ B  P
0 0 0 0 0 0
0 0 1 0 0 0
0 1 0 1 0 1
0 1 1 1 0 1
1 0 0 0 0 0
1 0 1 0 1 1
1 1 0 0 0 0
1 1 1 0 1 1
10.8 Arduino Programming and Interfacing Examples 285

Fig. 10.10 Simulation of a digital logic circuit for a multiplexer using an Arduino on Tinkercad

The signal P is connected to pin 1 of inverter (IC 7404), and the output (P) from
pin 2 (IC 7404) is connected to pin 1 of AND gate (IC 7408) as one of the inputs. The
signal A is connected to pin 2 of the AND gate (IC 7408), and the output (P  A) from
pin 3 (IC 7408) is passed to pin 1 of the OR gate (IC 7432). The signal P is also
connected to pin 4 of the AND gate (IC 7408). The signal B is connected to pin 5 of
the AND gate (IC 7408), and the output (P  B) from pin 6 (IC 7408) is connected to
pin 2 of the OR gate (IC 7432). The output from pin 3 of the OR gate is the output of
the logic circuit. It is connected to Arduino digital pin 2 and also to the LED.
First, the pins (pinP, pinA, pinB, and pinY) are declared as constant integers. In
the setup() block, the signal pins, pinP, pinA, and pinB are set as OUTPUT (from
Arduino), and logic circuit output pinY is set as INPUT (to Arduino) 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 P, A, and B with values 0 and 1. Each
variable is sent to the corresponding output pin using digitalWrite(). The logic circuit
output is read at pinY using digitalRead(). The generated bit patterns (PAB) and the
circuit output (Y ) are displayed on the serial monitor using Serial.print() and Serial.
println(), as shown in the code listing. The serial monitor display matches with the
truth table (Table 10.1) and confirms the validity of the simulation.

_________________________________________________________________
// Code for Ch10_8_3 2-input Multiplexer : X=P'A+PB
// Inputs (to the circuit) P, A, B
// Output from the circuit Y
const int pinP = 5;
const int pinA = 4;
const int pinB = 3;
const int pinY = 2;

void setup()
{
// setup pins for output (from Arduino)
pinMode(pinP, OUTPUT);
286 10 Microcontroller Programming and Interfacing

pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
// setup pin for input (to Arduino)
pinMode(pinY, INPUT);
// setup baud rate to 9600 for Serial Monitor
Serial.begin(9600);
}

void loop()
{ int Y = 0;
for (int P=0; P<=1; P++){
digitalWrite(pinP, P);
for (int A=0; A<=1; A++){
digitalWrite(pinA, A);
for (int B=0; B<=1; B++){
digitalWrite(pinB, B);
// read circuit output
Y = digitalRead(pinY);
// display on serial monitor
Serial.print("PAB= ");
Serial.print(P);
Serial.print(A);
Serial.print(B);
Serial.print(" Y= ");
Serial.println(Y);
delay(1000); // Wait for 1000 millisecond(s)
}
}
}
}
_________________________________________________________________

10.8.4 Simulation of Ultrasonic Sensor for Distance


Measurement with an Arduino

The objective of this example is to use an ultrasonic sensor for measuring a distance
in the range of 0–98 cm and to display the coded value of the measured distance in
bit patterns 000-111 using an Arduino.
A snapshot of simulation on Tinkercad is shown in Fig. 10.11. In this, a three-pin
ultrasonic sensor (also known as ping sensor) with GND, 5 V, and signal (SIG) is
used. The other version of the sensor with four pins (GND, 5 V, trigger, echo) is also
available. In the three-pin version, SIG pin is used as trigger and echo pin alternately.
The sensor is powered with 5 V from the Arduino and grounded through GND of
Arduino. The SIG is connected to Arduino digital pin 7. Three LEDs are connected
to Arduino digital pins 4, 3, and 2 (ledPin2, ledPin1, and ledPin0). Variables cm,
cm1, and inches are declared as integers. LED pins ledPin0, ledPin1, and ledPin2 are
declared as constant integers. In setup() block, the ledPin0, ledPin1, and ledPin2 are
set as OUTPUT using pinMode().
10.8 Arduino Programming and Interfacing Examples 287

Fig. 10.11 Simulation of distance measurement using an ultrasonic sensor and Arduino on
Tinkercad

There are two functions used in this code. One of these readPingTime (int
triggerPin, int echoPin) is used to measure time elapsed between the signal trigger
and reception at echo pin. The ultrasound signal is triggered at triggerPin set as
OUTPUT for 10 μs, and the echopin set as INPUT is read to return the ultrasound
wave travel time in μs. This time is used to calculate the distance in cm using a factor
344:6 × 10 - 4
2 = 0:01723. The distance in cm is converted to inches. Next, the distance is
capped at 98 cm for this example. If the distance is larger than 98 cm, all three
ledPins are set to HIGH. Otherwise, the distance in cm is divided by 14 to bring it
(cm1) to 0–7 that can be converted to a 3-bit pattern 000-111 using a function
dec2Bin(int n). This function converts values 0–7 to 3-bit pattern 000-111, binVal
[2], binVal[1], and binVal[0] using decimal to binary conversion. The bit pattern is
output to ledPin2, ledPin1, and ledPin0, respectively, putting corresponding LEDs
on or off depending on the bit value. The distance is also displayed on serial monitor
in both cm and inches as shown in the snapshot. For a distance of 46 cm, 18 in,
ledPin0 and ledPin1 are 1 and ledPin2 as 0, as indicated by the LEDs.

_________________________________________________________________
// Ch10_8_4: Distance measurement using a Ping Sensor
// Display distance inches and cm
// Display scaled value of distance 0-98 cm as 000-111 on LEDs
int distanceThreshold = 0;
int cm = 0;
int cm1 = 0;
int inches = 0;
const int ledPin0 = 2;
const int ledPin1 = 3;
const int ledPin2 = 4;

long readPingTime(int triggerPin, int echoPin)


{
pinMode(triggerPin, OUTPUT); // Clear the trigger
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
288 10 Microcontroller Programming and Interfacing

// Sets the trigger pin to HIGH state for 10 microseconds


digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
pinMode(echoPin, INPUT);
// Reads the echo pin, and returns the sound wave travel time in
microseconds
return pulseIn(echoPin, HIGH);
}

// set binVal[3]
int binVal[3];
// function dec2Bin
void dec2Bin(int n)
{ // initialize bits
binVal[0] = 0;
binVal[1] = 0;
binVal[2] = 0;
int i =0;
while (n > 0){
binVal[i] = n % 2;
n = n / 2;
i++;
}// end of while
}// end of dec2Bin

void setup()
{
Serial.begin(9600);
pinMode(ledPin0, OUTPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}

void loop()
{
// set threshold distance to activate LEDs
distanceThreshold = 98;
// measure the ping time in cm
cm = 0.01723 * readPingTime(7, 7);
// convert to inches by dividing by 2.54
inches = (cm / 2.54);
Serial.print(cm);
Serial.print("cm, ");
Serial.print(inches);
Serial.println("in");
cm1 = cm /14;
if (cm > distanceThreshold) {
cm = distanceThreshold;
digitalWrite(ledPin0, HIGH);
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
}
10.9 Simulation on Tinkercad and Physical Validation in Laboratory 289

dec2Bin(cm1);
digitalWrite(ledPin0, binVal[0]);
digitalWrite(ledPin1, binVal[1]);
digitalWrite(ledPin2, binVal[2]);
delay(200); // Wait for 200 millisecond(s)
}
_________________________________________________________________

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

Follow the example of Sect. 10.8.1 to simulate 4-bit patterns (0000-1111) using an
Arduino and four LEDS on Tinkercad. Modify the circuit in Fig. 10.8 for 4-bit
patterns (0000-1111) using four LEDs and update the code to test it. Include the
circuit, the code, and the results as displayed on the serial monitor.
This can be assigned for implementation on real hardware using physical Arduino
Uno board and physical circuit in laboratory.

10.9.2 Simulation of Setting Four LEDs On/Off Based


on the Status of Two Push Buttons

Follow the example of Sect. 10.8.2 to simulate setting on/off 4 LEDs based on the
status of two push buttons using an Arduino and four LEDS on Tinkercad. Modify
the circuit in Fig. 10.9 for four LEDs to be put ON/OFF based on the state of two
push buttons and the scaled decimal values as in Table 10.2 and update the code to
verify it.
Include the circuit, the code, and the results as displayed on the serial monitor.
This can be assigned for implementation on the real hardware using physical
Arduino Uno board and physical circuit in laboratory.

Table 10.2 Status of PBs and LEDs


PB2 PB1 Scaled Decimal value LED3 LED2 LED1 LED0
0 0 0 0 0 0 0
0 1 5 0 1 0 1
1 0 10 1 0 1 0
1 1 15 1 1 1 1
290 10 Microcontroller Programming and Interfacing

10.9.3 Simulation of a Digital Logic Circuit for Implementing


X = A  B þ ðA þ BÞ  C

Follow the example of Sect. 10.8.3 to create a digital logic circuit for implementing
X = A  B þ ðA þ BÞ  C using gates (inverter or NOT, AND, OR gates), similar to
Fig. 10.12, and test it using Arduino on Tinkercad. Generate the 3-bit input patterns
000-111, and monitor the output via an input to the Arduino and a LED. Verify that
the input-output combinations match the truth table of Table 10.3.
Include the circuit diagram, the code, and the results as displayed on the serial
monitor.
This can be assigned for implementation on real hardware using physical digital
logic gate ICs (7404, 7408, 7432), Arduino Uno board, and physical circuit in
laboratory.

Fig. 10.12 Simulation of a digital logic circuit for X = A  B þ ðA þ BÞ  C using an Arduino on


Tinkercad
10.9 Simulation on Tinkercad and Physical Validation in Laboratory 291

Table 10.3 Truth table for A B C AB (A + B) ðA þ BÞ  C X


X = A  B þ ðA þ BÞ  C
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 1 0 1 1 1 1
0 1 1 1 1 0 1
1 0 0 0 1 1 1
1 0 1 0 1 0 0
1 1 0 0 1 1 1
1 1 1 0 1 0 0

10.9.4 Simulation of Ultrasonic Sensor for Distance


Measurement with Arduino

The objective of this assignment is to use an ultrasonic sensor for measuring a


distance in the range of 0–105 cm and to display the coded value of the measured
distance in bit patterns 0000-1111 using an Arduino and four LEDs.
Follow the example of Sect. 10.8.4 to simulate the distance measurement using an
ultrasonic sensor, an Arduino, and four LEDS on Tinkercad. Modify the circuit in
Fig. 10.11 for 4-bit patterns (0000-1111) using 4 LEDs and update the code to test
it. Include the circuit, the code, and the results as displayed on the serial monitor.
This can be assigned for implementation on real hardware using a physical
ultrasonic sensor, an Arduino Uno board, and physical circuit in laboratory.

10.9.5 Simulation of a Home Security System Using Digital


Logic Gates and an Arduino on Tinkercad

The objective is to simulate a home security system, similar to that presented in Sect.
8.7. Here, the example is briefly presented for completeness. The objective is to
implement a home security system to activate an alarm (Y = 1) if there is a break-in
(A = 1) while the occupants are sleeping (C = 1 and D = 0), or if there is a break-in
(A = 1) or motion is detected (B = 1) while the occupants are away (C = 0 and
D = 1). There should not be any false alarm during regular household activities of
the occupants (C = 0 and D = 0). In this, one state of sensors with both sensors
(C and D high, i.e., C = 1 and D = 1) is not used. Under this condition, the Boolean
expression for the alarm can be represented, similar to Eq. (8.19), as
Y = A  C + (A + B)  D.
Create a digital logic circuit (similar to Fig. 10.13) for simulating the home
security system

Y = A  C þ ðA þ BÞ  D:
292 10 Microcontroller Programming and Interfacing

Fig. 10.13 Simulation of a circuit for home security system using an Arduino on Tinkercad

Table 10.4 Truth table for home security system Y = A  C + (A + B)  D

A B C D + ( + )∙ ∙
0 0
0 1
1 0
1 1 0
0 0
0 1
1 0
1 1 0
0 0
0 1
1 0
1 1 0
0 0
0 1
1 0
1 1 0

(a) Use the virtual Tinkercad simulation environment to create the digital logic
circuit, develop Arduino code, and test the circuit.
(b) Complete truth table for home security system (Table 10.4). Note that the rows
with C = 1 and D = 1 have been blocked off with Y = 0 as this condition is
not used.
(c) Include the circuit, the code, and the results as displayed on the serial monitor.
Verify your results with that of the truth table (Table 10.4).
10.9 Simulation on Tinkercad and Physical Validation in Laboratory 293

This can be assigned for implementation on real hardware using physical digital
logic gate ICs (7404, 7408, 7432), Arduino Uno board, and physical circuit in
laboratory.

10.9.6 Simulation of a Car Safety System Using Digital Logic


Gates and Arduino on Tinkercad

Create a digital logic circuit for implementing the car safety system that produces an
alarm (Y = 1) when the seat belts are not fastened (A = 0) or the doors are not closed
(B = 0) while the ignition switch is on (C = 1), i.e., Y = C  A þ B :
(a) Use the virtual Tinkercad simulation environment to develop Arduino code and
test the circuit.
(b) Modify the Boolean expression to implement it using only NAND and AND
gates:

Y =C  A  B

(c) Complete the truth table for the car security system (Table 10.5).

Table 10.5 Truth table    


A B C AþB C AþB AB C AB
for car securitysystem 
Y =C  A þ B =C  A  B 0
1
0
1
0
1
0
1

Fig. 10.14 A circuit for a car safety system using NAND and AND gates and an Arduino on
Tinkercad
294 10 Microcontroller Programming and Interfacing

(d) Include the circuit with digital logic gate ICs (7400, 7408) (similar to
Fig. 10.14), the code, and the results as displayed on the serial monitor. Verify
your results with that of the truth table (Table 10.5).
This can be assigned for implementation on real hardware using physical digital
logic gate ICs (7400, 7408), Arduino Uno board, and physical circuit in laboratory.

Bibliography

Alciatore DG (2019) Introduction to mechatronics and measurement systems, 5th edn. McGraw
Hill, New York
Arduino (2022a). https://www.arduino.cc/
Arduino (2022b) Arduino Hardware. https://www.arduino.cc/en/hardware
Arduino (2022c) Arduino Software. https://www.arduino.cc/en/software
Arduino (2022d) Arduino language reference. https://www.arduino.cc/reference/en/
Tinkercad (2022) Learn circuits. https://www.tinkercad.com/learn/circuits
Chapter 11
Basic Control Systems

11.1 Introduction

The concepts of basic circuits and electronics, sensors, data acquisition, analog and
digital signal processing, digital logic, actuators, and microcontroller programming
and interfacing are integrated to design mechatronic systems. These mechatronic
systems are also enhanced with capabilities to control the system performance. There
is a wide range of control architectures that can be designed and implemented in
analog or digital domains. In this chapter, basic control system concepts are intro-
duced covering control system characteristics, stability analysis, controller design
specifications, types of controllers, and design methods of a popular type of con-
troller, namely, proportional integral derivative (PID). Most of the analysis, design,
and simulation are carried out in Matlab environment. The design of a PID controller
for a physical DC motor module using Matlab and the real-time implementation of
the controller using LabVIEW are also presented.

11.2 Control System Structure

A basic control system is composed of different functional components or sub-


systems, namely, a plant or the system to be controlled, the sensor, the comparator,
and the controller. The schematic of an example closed loop control system is shown
in Fig. 11.1 where the objective is to make the output of the system, c(t), follow the
reference input, r(t), as closely as possible satisfying the desired performance
specifications. The control system needs to be analyzed for system characteristics
like disturbance rejection, sensitivity, closed loop response, steady-state errors, and
stability. In this chapter, the basics of these concepts are briefly introduced.

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

Fig. 11.1 Schematic of a closed loop control system

11.2.1 Mathematical Modeling

The first step of analysis of control systems starts with the modeling of components
like the plant or the system to be controlled and the sensor. The plant of the physical
system that needs to be controlled or the sensor can be modeled mathematically in
form of an n-th order ordinary differential equation:

d n yðt Þ d n-1 yðtÞ d m xðtÞ d m-1 xðt Þ


an þ an-1 þ . . . þ a 0 yð t Þ = b m þ bm -1 þ . . . þ b0 xðt Þ
dt n dt n-1 dt m dtm -1
ð11:1Þ

where y(t) and x(t) represent, respectively, the output and the input of the system,
coefficients ai, i = 0, . . . , n and bj, j = 0, . . . , m are constants, and in general, n ≥ m.
For example, a first-order system can be represented in standard form as

dyðt Þ
τ þ yðt Þ = Kxðt Þ ð11:2Þ
dt

where τ and K are termed, respectively, as time constant and static gain of the
system. Similarly, a second-order system is represented in standard form as

d 2 yð t Þ dyðt Þ
2
þ 2ζωn þ ωn 2 yðt Þ = Kωn 2 xðt Þ ð11:3Þ
dt dt

where ζ, ωn, and K are termed, respectively, as damping ratio, undamped natural
frequency, and static gain of the system.
Applying Laplace transform and assuming zero initial conditions, Eqs. (11.2) and
(11.3) can be transformed to algebraic equations as

ðτs þ 1ÞY ðsÞ = KX ðsÞ ð11:4Þ


11.2 Control System Structure 297

Fig. 11.2 Block diagram

and

Shivayanama@41
 
s2 þ 2ζωn s þ ωn 2 Y ðsÞ = Kωn 2 X ðsÞ ð11:5Þ

Equations (11.4) and (11.5) can be expressed in the form of transfer functions as

Y ð sÞ K
GðsÞ = = ð11:6Þ
X ðsÞ τs þ 1

and

Y ðs Þ Kωn 2
GðsÞ = = 2 ð11:7Þ
X ðsÞ s þ 2ζωn s þ ωn 2

The Eqs. (11.6) and (11.7) can be represented in the form of block diagram, as
shown in Fig. 11.2:
Laplace transforms for some common time functions are presented in
Appendix B.

11.2.2 Open and Closed Loop System Characteristics

The open loop system transfer function is represented for the system of Fig. 11.1, in
open loop, as

Go ðsÞ = Gc ðsÞGP ðsÞH ðsÞ ð11:8Þ

The open system transfer function Go(s) can be represented in zero-pole form
Qm
ðs - zi Þ
Go ðsÞ = K t Qi=1   ð11:9Þ
s n-tj=1 s - pj

where K is the static gain, zi, i = 1, . . . , m are zeros; pj, j = 1, . . . , (n - t) are nonzero
poles; and t is the number of poles at s = 0 of the open loop system. The order and
the type of the open loop system are n and t, respectively.
298 11 Basic Control Systems

The closed loop system transfer function T(s) can be obtained from the schematic
of the closed loop control system, Fig. 11.1, as

C ðsÞ Gc ðsÞGP ðsÞ


T ðs Þ = = ð11:10Þ
RðsÞ 1 þ Gc ðsÞGP ðsÞH ðsÞ

The denominator of the closed loop system transfer function T(s) leads to the
characteristic equation of the closed loop system. The roots of the characteristic
equation are the closed loop poles of the system.

1 þ Gc ðsÞGP ðsÞH ðsÞ = 0 ð11:11Þ

Steady-State Errors
For a closed loop system, the error, E(s), the output of the comparator, can be
obtained as

1
EðsÞ = RðsÞ - C ðsÞH ðsÞ = R ðsÞ ð11:12Þ
1 þ Gc ðsÞGP ðsÞH ðsÞ

Steady-state error can be obtained applying the final value theorem to Eq. (11.11)
with the reference input represented as the Laplace transform of the input function
r(t). For example, in case of unit step input, rðt Þ = uðt Þ, RðsÞ = 1s , the steady-state
error can be expressed as

1
ess,step = lim sE ðsÞ = lim s ð1=sÞ
s→0 s→01 þ Gc ðsÞGP ðsÞH ðsÞ
ð11:13Þ
1 1
= lim =
s → 0 1 þ Gc ðsÞGP ðsÞH ðsÞ 1 þ kp

where

k p = lim ðGc ðsÞGP ðsÞH ðsÞÞ ð11:14Þ


s→0

kp is termed as position error constant. For a type zero (t = 0) system, kp is a finite


value and the steady-state error due to a unit step input is a finite value. For type
1 (t = 1) and type 2 (t = 2) systems, kp approaches infinity making the steady-state
error due to step input as zero.
For a unit ramp input, rðt Þ = t uðt Þ, RðsÞ = s12 , the steady-state error can be
expressed as
11.2 Control System Structure 299

1  2
ess,ramp = lim sEðsÞ = lim s 1=s
s→0 s → 0 1 þ Gc ðsÞGP ðsÞH ðsÞ
ð11:15Þ
1 1
= lim =
s → 0 sð1 þ Gc ðsÞGP ðsÞH ðsÞÞ kv

where

kv = lim ðsGc ðsÞGP ðsÞH ðsÞÞ ð11:16Þ


s→0

kv is termed as velocity (or rate) error constant. For a type zero (t = 0) system, kv is
zero, and the steady-state error due to a unit ramp input is infinite. For a type 1 (t = 1)
system, kv is a finite value, and the steady-state error due to a ramp input is a finite
value. For type 2 (t = 2) systems, kv approaches infinity making the steady-state error
due to ramp input as zero.
For a unit parabolic input, r ðt Þ = 2t 2 uðt Þ, RðsÞ = s13 , the steady-state error can be
expressed as

1  3
ess,par = lim sEðsÞ = lim s 1=s
s→0 s → 0 1 þ Gc ðsÞGP ðsÞH ðsÞ
ð11:17Þ
1 1
= lim 2 =
s → 0 s ð1 þ Gc ðsÞGP ðsÞH ðsÞÞ ka

where
 
ka = lim s2 Gc ðsÞGP ðsÞH ðsÞ ð11:18Þ
s→0

ka is termed as acceleration (or rate of rate) error constant. For a type zero (t = 0)
and type 1 (t = 1) systems, ka is zero and the steady-state error due to a unit ramp
input is infinite. For a type 2 (t = 2) system, ka is a finite value, and the steady-state
error due to a ramp input is a finite value. The steady-state error for different types
(t = 0, 1, 2) of systems and different inputs (step, ramp, and parabolic) is summa-
rized in Table 11.1. The desired situation should be on the upper diagonal of
Table 11.1 or on the main diagonal and the lower diagonal should be avoided as
much as possible.

Table 11.1 Steady-state error depending on type of system and input signal
Type 0 (t = 0) Type 1 (t = 1) Type 2 (t = 2)
Step, r(t) = u(t), R(s) = 1/s 1
1þk p
0 0
Ramp, r(t) = tu(t), R(s) = 1/s2 / 1
kv
0
Parabolic, r ðt Þ = t2
uðt Þ, R(s) = 1/s 3 / / 1
ka
2
300 11 Basic Control Systems

Sensitivity
Sensitivity of a closed loop control system can be expressed as a ratio of relative
change in a system of closed loop transfer function T(s) to the relative change in the
parameter K, using partial derivative as
 
∂T ðsÞ K
STK = ð11:19Þ
∂K T ðsÞ

The closed loop control system should be insensitive (low sensitivity) to the changes
in the system parameters, whereas the system should be sensitive (high sensitivity) to
the changes in controller parameters.
Disturbance Rejection
The closed loop control system should be able to maintain the output close to its
desired value in spite of the presence of disturbance, if properly designed.

11.3 Stability Analysis of Control Systems

The stability of a control system is defined as the ability of the system to have a finite
(bounded) output when a finite (bounded) input is applied to the system—it is
commonly known as bounded-input bounded-output (BIBO) system. The stability
of a control system is a very important characteristics that needs to be analyzed using
several techniques. The stability analysis techniques include direct method of
explicitly finding closed loop poles as roots of the closed loop system characteristic
equation. There are indirect methods that can be used to analyze the stability of the
closed loop system without explicitly solving for roots of the closed loop system
characteristic equation.

11.3.1 Closed Loop Poles on S-Plane

One direct way of analyzing the stability of a closed loop system is to obtain
analytically the roots of the closed loop system (termed as closed loop poles), and
the system is stable if all closed loop poles are on the left-hand side (LHS) of s-plane
with negative real parts, as the system response for any finite input remains finite. If
any of the closed loop pole is on the right-hand side (RHS) of s-plane with positive
real part, the closed loop system is unstable, as the system response for a finite input
grows exponentially with time. If any of the closed loop poles are purely imaginary
(on the imaginary axis of s-plane with zero real part), the system is termed margin-
ally stable, as the system response for a step input remains oscillatory with
undamped amplitude.
11.3 Stability Analysis of Control Systems 301

Table 11.2 Routh table


Power of
s 1st column 2nd column 1st column sign
s3 1 11 +
s2 6 (6 + K ) +
s1 6ð11Þ - 1ð6þK Þ 0 60 - K > 0 or K < 60
6
s 0
(6 + K ) 0 6 + K > 0 or K > - 6

11.3.2 Routh-Hurwitz Criterion

Routh-Hurwitz criterion uses a tabular method to determine the number of closed


loop poles on RHS of s-plane as the number of sign changes in the first column of the
Routh-Hurwitz table (Table 11.2).
Example 11.1 Use Routh-Hurwitz criterion to examine the stability of the closed
loop system with G(s) = K/(s + 2)(s + 3), H(s) = 1/(s + 1).
The closed loop transfer function of the system can be expressed as

GðsÞ K=ðs þ 2Þðs þ 3Þ


T ðs Þ = =
1 þ GðsÞH ðsÞ 1 þ K=ðs þ 2Þðs þ 3Þðs þ 1Þ

The characteristic equation of the closed loop system is 1 þ ðsþ2ÞðsþK3Þðsþ1Þ = 0


Characteristic polynomial: s3 + 6s2 + 11s + 6 + K
For stability (with no change of sign on the 1st column), the range of
K: -6 < K < 60.

11.3.3 Root Locus Technique

Root locus technique is used to study the locus of each closed loop pole of a system
using the open loop transfer function of the system as the positive gain K is varied in
the range 0 < K < 1 .
Example 11.2 Use root locus technique to examine the stability of the closed loop
system with G(s) = K/(s + 2)(s + 3), H(s) = 1/(s + 1).
The open loop transfer of the system GðsÞH ðsÞ = ðsþ2Þðsþ3K
Þðsþ1Þ. Root locus starts
at open loop poles s = - 1, - 2, - 3, two of the loci approach + 1 , and the other
approaches -1. The root locus obtained using Matlab command rlocus() is shown
in Fig. 11.3. The gain K = 60, the root locus crosses the imaginary axis, implying for
positive gains, the closed loop poles remain on the left half of an s-plane with
negative real part for K < 60, i.e., the closed loop system is stable for K < 60. The
closed loop system is unstable for K > 60, and the system is marginally stable at
K = 60. This is also confirmed from Routh-Hurwitz criterion. The closed loop pole
302 11 Basic Control Systems

Fig. 11.3 An example root locus for GðsÞH ðsÞ = K


ðsþ2Þðsþ3Þðsþ1Þ

at
 the critical rad  K = 60 can be shown to the imaginary part of the closed loop pole
gain
ωosc = 3:32 s . This value is obtained from the auxiliary pffiffiffiffiffipolynomial
pffiffiffiffiffifrom the
 
Routh table AðsÞ = 6s2 þ ð6 þ 60Þp=ffiffiffiffiffi
6ðs2 þ 11Þ = 6 s þ j 11 s- j 11 . So the
closed loop pole at K = 60, s = ± j 11 = ± j3:32:
The closed loop system poles and step responses for the three values of K are
presented next to confirm the results of root locus.
Case I: K < 60
The closed loop poles for K = 10 are obtained as -4.3089, -0.8455 + 1.7316i, and
-0.8455 – 1.7316i, all with negative real parts, so the closed loop system is stable,
which is also confirmed by the closed loop step response in Fig. 11.4a.
Case II: K = 60
The closed loop poles for K = 60 are obtained as -6.0000, 3.3166i, and – 3.3166i,
with two as imaginary, so the closed loop system is marginally stable; it is also
confirmed by the sustained oscillatory closed loop step response in Fig. 11.4b.
The period of oscillation T = (4.88–2.99) = 1.89 s, and the frequency of
oscillation ωosc = 2π
T = 3:32 s :
rad

Case III: K > 60


The closed loop poles for K = 65 are obtained as -6.1036, 0.0518 + 3.4102i, and
0.0518 – 3.4102i, two with positive real parts, so the closed loop system is unstable;
it is also confirmed by the growing amplitude closed loop step response in
Fig. 11.4c.
11.3 Stability Analysis of Control Systems 303

Fig. 11.4 Closed loop


step response
GðsÞH ðsÞ = ðsþ2Þðsþ3
K
Þðsþ1Þ.
(a) K = 10, (b) K = 60,
(c) K = 65
304 11 Basic Control Systems

11.3.4 Bode Plot

The variation of magnitude (M) and phase angle ϕ of the open loop transfer function
G(s)H(s) with frequency (s = jω), i.e., M = |G( jω)H( jω)|, ϕ = ∠ G( jω)H( jω) can
be plotted as bode plot. There are two frequencies of interest, gain crossover
frequency, ωgc and phase crossover frequency ωpc.
    
At gain crossover frequency, ωgc , M = G jωgc H jωgc  = 1 ð11:20Þ
   
At phase crossover frequency ωpc , ϕ = ∠G jωpc H jωpc = ± 180 ° ð11:21Þ

The phase margin (ϕm) is defined at gain crossover frequency,


   
ϕm = ∠G jωgc H jωgc þ 180 ° ð11:22Þ

The gain margin (GM) is defined at phase crossover frequency,


    
GM = 1=G jωpc H jωpc  ð11:23Þ

It should be mentioned that phase angle and phase margin are defined in degrees,
and magnitude and gain margin are defined as numbers or in decibel (dB) scale. For
stability, both gain margin and phase margin should be positive.
Example 11.3 An example bode plot for the open loop system GðsÞH ðsÞ =
ðsþ2Þðsþ3Þðsþ1Þ is shown in Fig. 11.5a with K = 1. The gain margin (GM) is 35.6 dB
K

or approximately 60 = 10ð 20 Þ at phase crossover frequency ω = 3.32 rad/s. The
35:6
pc

gain margin in normal scale is 60 which is the same as the critical gain obtained

Fig. 11.5 Bode plot for GðsÞH ðsÞ = K


ðsþ2Þðsþ3Þðsþ1Þ. (a) K = 1, (b) K = 10
11.4 Control System Specifications 305

using Routh-Hurwitz criterion as well as the root locus technique. The phase
crossover frequency (ωpc = 3.32 rad/s) is the same as the frequency of oscillation
at critical gain. The phase margin (ϕm) is infinite as the magnitude stays 1 or below
for K = 1. The bode plot with K = 10 is shown in Fig. 11.5b. The phase margin (ϕm)
is 90° at gain crossover frequency ωgc = 1 rad s , and the gain margin is 15.6 dB of

approximately 6 = 10 20 ð 15:6
Þ at phase crossover frequency ω = 3.32 rad/s.
pc

The Matlab code snippet for generating the root locus, closed loop poles, step
response, and the bode plot is presented.
Matlab Code for Examples 11.1, 11.2 and 11.3

_____________________________________________________________________________________
%RL Example 11_1_RL_stepResonse_BodePlot

clear all; close all;clc

ngs=1; dgs=poly([-1 -2 -3])% G(s)H(s)=1/(s+1)(s+2)(s+3)


G=tf(ngs,dgs)
% Root locus
figure
rlocus(G);[k,p]=rlocfind(G)
% k<60
K=10;[nts,dts]=cloop(K*ngs,dgs);
p=roots(dts) %closed loop poles
figure
step(nts,dts) %closed loop step response
title('Closed loop step response K<60')
%K=60
K=60;[nts,dts]=cloop(K*ngs,dgs);
p=roots(dts) %closed loop poles
figure
step(nts,dts) %closed loop step response
title('Closed loop step response K=60')
%K=65
K=65;[nts,dts]=cloop(K*ngs,dgs);
p=roots(dts)
figure
step(nts,dts,10) %closed loop step response
title('Closed loop step response K>60')
% Bode plot
figure
bode(G);margin(G)
gm=10^(35.563/20)
figure
bode(10*G);margin(10*G)
gm=10^(15.6/20)
_____________________________________________________________________________________

11.4 Control System Specifications

The design of a controller for a control system involves specification of control


system performance characteristics: steady-state error, transient response, and
frequency domain; determination of types of controller: PID, PI, PD, phase lag,
306 11 Basic Control Systems

phase lead, or phase lag-lead; and design methodology: analytical, empirical, or


experimental. For analytical design, the model of the system to be controlled should
be available. The empirical or experimental method of designing controllers does not
need an analytical model of the system; the controller gains are tuned empirically
from the response of the system. In this section, these aspects are discussed briefly.

11.4.1 Design Specifications

Design specifications include steady-state error, transient response characteristics,


and frequency domain characteristics.
Steady-State Error Specifications
The steady-state error specifications include allowable steady-state error of the
closed loop system response due to a step input, ess,step, a ramp input, ess,ramp,
and/or a parabolic input ess,par. These steady-state error limits are used to determine
error constants kp, kv, and/or ka, defined in Sect. 11.2.2. These in turn are used to
determine the steady-state gain of the controller.
Transient Response Characteristics
Specifications on transient response characteristics include percentage overshoot (α)
and settling time (tset), that is the time by which the system response settles down
within a specified percentage (β) of the steady-state value. The control system
response can be approximated by that of a second-order system model
ðsÞ = XY ððssÞÞ = s2 þ2ζω
ωn 2
n sþωn
2 , using the concept of dominant poles. The overshoot can

be expressed as
 pffiffiffiffiffiffiffiffi2ffi
α
= e- πζ= 1-ζ
ð11:24Þ
100

The damping ratio can be obtained in terms of overshoot from Eq. (11.24) as
α
- ln 100
ζ= q ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
  α 2 ð11:25Þ
π 2 þ ln 100

The settling time (tset),in terms of error limit (β%), can be expressed as
β
ln 100
t set = - ð11:26Þ
ζωn
11.4 Control System Specifications 307

The undamped natural frequency can be obtained in terms of damping ratio and
settling time as
β
ln 100
ωn = - ð11:27Þ
ζ t set

The desired pole to satisfy the transient response specifications can be obtained in
terms of damping ratio and undamped natural frequency as
qffiffiffiffiffiffiffiffiffiffiffiffi
s1 = - ζωn þ jωn 1 - ζ2 ð11:28Þ

Frequency Domain Specifications


Frequency domain specifications include desired gain margin (GM), phase margin
(ϕm), and at times the gain crossover frequency (ωgc). The gain crossover frequency
can be expressed in terms of settling time (tset) and phase margin (ϕm) as

8
ωgc = rad=s ð11:29Þ
t set tanðϕm Þ

11.4.2 Types of Controllers

PID Controllers
The proportional (P)-integral (I)-derivative (D) or PID controllers are one of the most
commonly used type of controllers. A PID controller consists of three parts—the
proportional part that represents the current state of error (difference between the
desired and the actual response), the integral part that takes into account the past
history of error, and the derivative part that incorporates the trend or future state of
error. In other words, a PID controller takes into account past, present, and future of
the system error in keeping the error as close to zero as possible.
The transfer function of a PID controller is given as

KI
GcPID ðsÞ = K P þ þ KDs ð11:30Þ
s

where KP, KI, and KD are proportional, integral, and derivative gains, respectively.
To limit the high frequency gain, the derivative part is modified with a pole at the
cutoff frequency ωc

KI KDs
GcmPID ðsÞ = K P þ þ ð11:31Þ
s 1 þ s=ωc
308 11 Basic Control Systems

For lower frequency ω ≪ ωc,the last part (D) acts as the ordinary derivative
component with gain of KD. For higher frequencies ω ≫ ωc, the derivative part acts
as a simple amplifier with a constant gain KDωc. At times, two of three parts of PID
are used as PI or PD controller

KI
GcPI ðsÞ = K P þ ð11:32Þ
s
GcPD ðsÞ = K P þ K D s ð11:33Þ

Phase Lag, Phase Lead, and Phase Lag-Lead Controllers


The other group of controllers include phase-lag, phase-lead, and phase lag-lead
controllers. The phase-lag controller transfer function is given as

1 þ a1 s
GcLag ðsÞ = a0 ð11:34Þ
1 þ b1 s

where pole -1/b1 is nearer to the origin of the s-plane than the zero -1/a1 giving a
net phase lag, and a0 is the steady-state gain of the controller. In general, the phase
lag angle (ϕlag) is limited to 5–10° and (1/b1) < (1/a1). A phase lag controller is
similar to a PI controller as these improve the steady-state (low frequency) response
of the control system.
The phase lead controller transfer function is given as

1 þ c1 s
GcLead ðsÞ = c0 ð11:35Þ
1 þ d1 s

where zero -1/c1 is nearer to the origin of the s-plane than the pole -1/d1 giving a
net phase lead, and c0 is the steady-state gain of the controller. In general, the phase
lead angle (ϕlead) is around 35–50° and (1/c1) < (1/d1). A phase lead controller is
similar to a PD controller as these improve the transient (high frequency) response of
the control system.
The phase lag-lead controller combines the phase lag and the phase lead:

1 þ a1 s 1 þ c 1 s
GcLag-Lead ðsÞ = a0 c ð11:36Þ
1 þ b1 s 0 1 þ d 1 s

The phase lag part is used to improve low-frequency response, and the phase lead
part is used to improve high-frequency response of the control system. A phase
lag-lead controller is similar to a PID controller as these controllers are used to
improve both steady-state and transient response of the control system.
11.5 Controller Design Method 309

11.5 Controller Design Method

In this section, analytical methods of designing PID controllers using specifications


in time and frequency domains are presented first. Next, the experimental method of
tuning PID controller gains is presented.

11.5.1 PID Controller Design Using Time Domain


Specifications

The PID controller can be designed using root locus technique for the desired time
domain specifications of percentage overshoot (α), and settling time (tset), within a
specified percentage (β) of the steady-state value. The desired pole s1 can be
obtained from the given time domain specifications as shown in Eqs. (11.25),
(11.27), and (11.28). The desired pole s1 can be expressed in polar form as

s1 = re jθ ð11:37Þ

where the magnitude is

r = js1 j = ωn , ð11:38Þ

and the angle is


pffiffiffiffiffiffiffiffiffiffiffiffi!
-1 ωn 1 - ζ2
θ = ∠s1 = tan ð11:39Þ
- ζωn

The desired pole s1 must be on the root locus of the control system, i.e.,

1 þ Gc ðs1 ÞGðs1 ÞH ðs1 Þ = 0 ð11:40Þ

For a PID controller, Gc ðsÞ = K P þ KsI þ K D s, the PID controller must satisfy at
s = s 1,

KI 1
KP þ þ K D s1 = - ð11:41Þ
s1 Gðs1 ÞH ðs1 Þ

The open loop system transfer function at s = s1 can be expressed in polar form as

Gðs1 ÞH ðs1 Þ = Me jψ ð11:42Þ


310 11 Basic Control Systems

where the magnitude is

M = jGðs1 ÞH ðs1 Þj ð11:43Þ

and the angle is

ψ = ∠ðGðs1 ÞH ðs1 ÞÞ ð11:44Þ

Equation (11.41) can be written as

KI 1
KP þ jθ
þ K D re jθ = - jψ ð11:45Þ
re Me

Expressing exponential terms in the form of sine and cosine, Eq. (11.45) can be
rewritten as

KI 1
KP þ ðcos θ - j sin θÞ þ K D ωn ðcos θ þ j sin θÞ = - ðcos ψ - j sin ψÞ
ωn M
ð11:46Þ

Equating real and imaginary terms of both sides of Eq. (11.46), the following
equations can be obtained:

KI 1
KP þ ðcos θÞ þ K D ωn ðcos θÞ = - ðcos ψÞ ð11:47Þ
ωn M
KI 1
ð- sin θÞ þ K D ωn ðsin θÞ = ðsin ψÞ ð11:48Þ
ωn M

There are three unknown parameters, KP, KI, and KD and two Eqs. (11.47) and
(11.48). In general, one of the unknown parameters, mainly, the integral gain KI is
assumed, and then, the derivative gain KD and the proportional gain KP are obtained
in terms of KI as

M ðsin ψÞ þ ωKnI ðsin θÞ


1
KD = ð11:49Þ
ωn ðsin θÞ
1 K
KP = - ðcos ψÞ - I ðcos θÞ - K D ωn ðcos θÞ ð11:50Þ
M ωn

In general, to start, KI = 0 is assumed, then KD and KP are obtained from


Eqs. (11.49) and (11.50). Next, KI is assumed in the range
11.5 Controller Design Method 311

KI
0:01 ≤ ≤ 0:10 ð11:51Þ
KP

The lower bound is assumed for relatively high KP, and the higher bound is used
for relatively low KP. The values of controller gains are expected to converge in a
few iterations. The obtained values of gain can be adjusted to satisfy the desired time
domain specifications as closely as possible.
Example 11.4 Design a PID controller for a control system with an open loop
transfer function GðsÞ = ðsþ130
Þðsþ2Þ such that the overshoot is 10% and the settling
time is 0.35 s for a step input.
Solution Matlab code was developed and used for analysis, design, and simulation
of the control system. The code is listed at the end of the example.
Given α = 10 % , tset = 0.35 s, β = 2%.
Using Eqs. (11.25), (11.27), and (11.28), the damping ratio, undamped natural
frequency, and the desired pole are obtained as ζ = 0.5912, ωn = 18.9074 rad/s,

s1 = - 11:1721 þ j15:2499 rad=s, r = 18:9074, θ = 2:2033 rad:M = jGðs1Þj


= 0:0919,

ψ = ∠ (G(s1) = 2.0114 rad. Assuming KI = 0.1, the derivative and proportional


gains are obtained from Eqs. (11.49) and (11.50), respectively,

M ðsin ψÞþ ωKnI ðsin θÞ


1
KD = = 0:6454,
ωn ðsin θÞ
1 K
KP = - ðcos ψÞ - I ðcos θÞ - K D ωn ðcos θÞ = 11:8559:
M ωn

The transfer function of the PID controller is Gc ðsÞ = K P þ KsI þ K D s =


0:6454 s2 þ11:8559 sþ0:1
s
Root locus plots of the system without and with the PID controller are shown in
Fig. 11.6a, b, respectively. From the root locus of the original system, it is clear that
the desired specifications cannot be achieved by a simple gain. The desired pole (s1)
is shown on the root locus of the system with the PID controller.
The closed loop step response of the system with the PID controller is shown in
Fig. 11.7. The overshoot of about 20% is higher than the desired value, but the
settling time of 0.39 s is close to the desired value of 0.35 s.
312 11 Basic Control Systems

Fig. 11.6 Root locus plots of the control system: (a) without controller, (b) with PID controller
11.5 Controller Design Method 313

The bode plots of the system without and with the PID controller are shown in
Fig. 11.8a, b. The phase margin increases from 31.7° to 59.9° with the PID
controller.
Matlab Code for Example 11.4

___
%Ex-11.4 design of PID controller using time domain specs
clear all; close all; clc
% plant TF G(s)
ngs=30; dgs=[1 3 2];
G =tf(ngs,dgs);

% desired pole location s1

%input %overshoot(alpha) & settling time(ts)


alpha=0.10; ts=0.35; beta=0.02;
zeta=abs(log(alpha))/sqrt(pi^2+log(alpha)^2)
wn=abs(log(beta))/(zeta*ts)
s1=-zeta*wn+j*wn*sqrt(1-zeta^2);
r=abs(s1)
theta=angle(s1)

%evaluate G(s1)
nv=polyval(ngs,s1); dv=polyval(dgs,s1);
gv=nv/dv; % G(s1)
%gv=polyval(sysg,s1)
m=abs(gv)
psi=angle(gv)

% pid controller gains kp, kd, ki

ki=0.1;
kd=sin(psi)/(m*r*sin(theta))+ki/(r^2)
kp=-cos(psi)/m - kd*r*cos(theta) -ki*cos(theta)/r
%Gc(s)
ngc=[kd kp ki]; dgc=[0 1 0];
printsys(ngc,dgc)
% Closed loop system TF
[nc,dc]=series(ngc,dgc,ngs,dgs);
GcG=tf(nc,dc)
% RL of uncompensated G(s)
figure
rlocus(G)
% RL of compenasted system Gc(s)G(s)
figure
axis([-40, 40, -40, 40]); hold on
rlocus(GcG)

%CLTF: System Step Response


[ncl,dcl]=cloop(nc,dc)
figure
step(ncl,dcl,2)

% bode plot of uncompensated system


figure
bode(G)
margin(G)
% bode plot of the compensated plant
figure
bode(GcG)
margin(GcG)
314 11 Basic Control Systems

Fig. 11.7 Closed loop step response of the system with the PID controller

11.5.2 PID Controller Design Using Frequency Domain


Specifications

The PID controller can be designed for the frequency domain specifications of
desired gain margin (GM) and phase margin (ϕm) at the desired gain crossover
frequency (ωgc). At gain cross-over frequency, the characteristic equation of the
closed loop system must satisfy

     
1 þ Gc jωgc G jωgc H jωgc = 0 ð11:52Þ

The magnitude of Gc( jωgc) can be expressed as

  
Gc jωgc  = 1=M ð11:53Þ

where
    
G jωgc H jωgc  = M ð11:54Þ
11.5 Controller Design Method 315

Fig. 11.8 Bode plots of the control system: (a) without controller, (b) with PID controller
316 11 Basic Control Systems

7The angle of Gc( jωgc) can be expressed as


 
∠Gc jωgc = ϕm ± 180 ° - ψ = θ ð11:55Þ

where
    
∠ G jωgc H jωgc = ψ ð11:56Þ

Taking both magnitude and angle, the complex form of Gc( jωgc) can be
expressed as

  1
Gc jωgc = e jθ ð11:57Þ
M

Replacing Gc ðsÞ = K P þ KsI þ K D s, Eq. (11.57) can be rewritten as

KI 1
KP þ þ K D jωgc = e jθ ð11:58Þ
jωgc M

Expanding exponential term in form of sine and cosine, Eq. (11.58) can be written
as

KI 1
KP - j þ j K D ωgc = ðcos θ þ j sin θÞ ð11:59Þ
ωgc M

Equating real and imaginary parts of both sides, the following can be opened as

1
KP = cos θ ð11:60Þ
M

KI 1
- þ K D ωgc = sin θ ð11:61Þ
ωgc M

Equation (11.61) can be rearranged to get KD as

1 K
KD = sin θ þ I 2 ð11:63Þ
Mωgc ωgc
11.5 Controller Design Method 317

Here again, there are three unknown variables KP, KI, and KD and two equations.
In general, one of gains KI is assumed, and the other gains are obtained in terms of
KI. As a guideline, the ratio of KKPI is kept within

KI
0:01 ≤ ≤ 0:10 ð11:64Þ
KP

Example 11.5 Design a PID controller for a system with transfer function
GðsÞ = sðsþ5
50
Þ such that the gain margin is 10 dB and the phase margin is at 55° at
the gain crossover frequency ωgc = 20 rad/s.
Solution Given GðsÞ = 50
sðsþ5Þ, desired gain margin GM = 10 dB, phase margin
ϕm = 55 °, ωgc = 20 rad
s :

At gain crossover frequency M = |G( jωgc)| = 0.1213, ψ = ∠ (G( jωgc))


= - 2.8966 rad.

π
θ = ðϕm ± 180 ° Þ - ψ = 6:9981 rad
180 °

Assuming KI = 0.10, the gains are obtained as

1
KP = cos θ = 6:2269
M

1 K
KD = sin θ þ I 2 = 0:2706
Mωgc ωgc

The PID controller transfer function Gc ðsÞ = K P þ KsI þ K D s = 0:2706s þ6:2269sþ0:1


2
s .
The bode plots of the system without and with the PID controller are shown in
Fig. 11.9a, b. The phase margin improves from 38.7° at 6.25 rad/s to 55° at 20 rad/s.
The closed loop step response of the system is shown in Fig. 11.10. The overshoot is
about 20%, and the settling time is 0.42 s. Though these are not part of the desired
specifications, the closed loop step response is reasonably satisfactory. The root
locus of the system with the PID controller is shown in Fig. 11.11.
318 11 Basic Control Systems

Fig. 11.9 Bode plots of the control system: (a) without controller, (b) with PID controller
11.5 Controller Design Method 319

Fig. 11.10 Closed loop step response with PID controller

Fig. 11.11 Root locus of the system with PID controller


320 11 Basic Control Systems

Matlab Code for Example 11.5 Is Presented Here

%EX.11.5 design of pid controller - frequency domain


clear all; close all; clc
%G(s)
ngs=[50]; dgs=[1 5 0 ];
G=tf(ngs,dgs)
%Frequency domain specs
dpm=55; wgc=20.0;dgm=10;
% m and psi
nv=polyval(ngs,j*wgc);dv=polyval(dgs,j*wgc);
g=nv/dv;
m=abs(g) %value of the G(S) at wgc
psi=angle(g) % psi
% Controller design
ki=.10
theta=(180+dpm)*pi/180-psi
kp=cos(theta)/m
kd=sin(theta)/(m*wgc)+ki/(wgc^2)
%Gc(s)
ngc=[kd kp ki]; dgc=[0 1 0];
Gc=tf(ngc,dgc)
%Gc(s)G(s)
[nc,dc]=series(ngc,dgc,ngs,dgs);
GcG=tf(nc,dc)
% bode plot
figure
bode(G)
margin(G)
figure
bode(GcG)
margin(GcG)
% closed loop step response
figure
[ncl,dcl]=cloop(nc,dc);
step(ncl,dcl);
% Root Locus
figure
rlocus(G)
figure
rlocus(GcG)

11.5.3 Experimental Method: Ziegler-Nichols Method

Ziegler-Nichols method is used to design empirically a PID controller from the


response of the system under open loop and closed loop configurations. In this
section, the closed loop configuration is discussed. The procedure consists of the
following steps:
11.5 Controller Design Method 321

Table 11.3 PID controller gains using Ziegler-Nichols method


Integral Derivative
Controller Proportional Integral action gain Derivative action gain
type gain KP time T I = KKPI K I = KT PI time T D = KKDP KD = TDKP
P 0.5Kcr – – – –
PI 0.45Kcr Tcr/1.2 0.54Kcr/Tcr – –
PID 0.6Kcr Tcr/2 1.2Kcr/Tcr 0.125Tcr 0.075KcrTcr

Fig. 11.12 Simulink model of example system GðsÞ = 1


sðsþ1Þðsþ2Þ

1. Set up the system in closed loop configuration with a variable gain K.


2. Give a step input to the system and observe the system response (output).
3. Increase the gain K gradually till the output starts oscillating.
4. Note the gain (Kcr) and the period of oscillation (Tcr) of the system output.
5. Set up the controller gains as per Table 11.3.
In general, the system transfer function will not be known. Here, an example is
presented using a transfer function for the system to illustrate the Ziegler-Nichols
procedure of PID gain tuning through Matlab/Simulink simulation environment.
Example 11.6 Apply Ziegler-Nichols method for a system given by transfer func-
tion GðsÞ = sðsþ11Þðsþ2Þ through Matlab/Simulink simulation environment.

A Matlab/Simulink model as shown in Fig. 11.12 is created with a step input and
a scope to observe the system response. The gain K is increased gradually, and the
system response is observed. The system response starts oscillating at K = 6. The
oscillating response at Kcr = 6 is shown in Fig. 11.13. The period of oscillation (Tcr)
is found to be 4.5 s. The PID gains are computed using the values of Kcr, Tcr and are
presented in Table 11.4. The closed loop system response with P, PI, PD, and PID
322 11 Basic Control Systems

Fig. 11.13 Closed loop system response of example system GðsÞ = 1


sðsþ1Þðsþ2Þ at K = 6

Table 11.4 PID controller gains using Ziegler-Nichols method for GðsÞ = 1
sðsþ1Þðsþ2Þ

Integral Derivative
Controller Proportional Integral action gain Derivative action gain
type gain KP time T I = KKPI K I = KT PI time T D = KKDP KD = TDKP
P 3 – – – –
PI 2.7 3.75 0.72 – –
PID 3.6 2.25 1.6 0.563 2.027

controllers are presented in Figs. 11.14, 11.15, 11.16 and 11.17. Out of all combi-
nations, the performance of PD controller is the best in terms of overshoot
(α = 25.8%) and settling time (tset = 6 s), next are PID with overshoot
(α = 58.8%) and settling time (tset = 12.7 s), P with overshoot (α = 55.4%) and
settling time (tset = 19.5 s), and PI controller with overshoot (α = 92.3%) and
settling time (tset = 72.9 s).
11.5 Controller Design Method 323

P Controller

Fig. 11.14 Closed loop system response with P controller (KP = 3)

PI Controller

Fig. 11.15 Closed loop system response with PI controller (KP = 2.7, KI = 0.72)
324 11 Basic Control Systems

PD Controller

Fig. 11.16 Closed loop system response with PD controller (KP = 3.6, KD = 2.027)

PID Controller (Table 11.5)

Fig. 11.17 Closed loop system response with PID controller (KP = 3.6, KI = 1.6, KD = 2.027)
Controller Implementation 325

Table 11.5 Comparison of Type of controller Overshoot α (%) Settling time tset (s)
performance of controllers,
P 55.4 19.5
for example, system GðsÞ =
1
PI 92.3 72.9
sðsþ1Þðsþ2Þ PD 25.8 6
PID 58.8 12.7

11.6 Controller Implementation

In this section, the procedure of controller implementation on a physical DC motor


control module from National Instruments with NI ELVIS II board (NI Engineering
Virtual Instrumentation Suite II) board (National Instruments 2022) is discussed.
The speed dynamics model for the DC motor was identified using bump test, and
steady-state gain (K ) and the time constant (τ) for a module were found as 34.45
(rad/s.V) and 0.064 s, respectively. The position dynamics model of the DC motor
module is represented as

K 34:45
Gp ðsÞ = =
sðτs þ 1Þ sð0:064s þ 1Þ

A PID controller was designed with time-domain specifications of overshoot


(α) as15% and a settling time (tset) as 0.25 s using the procedure presented in Sect.
11.5.1. The PID controller gains were obtained as KI = 0.10, KP = 1.706, and
KD = 0.0292. The simulated closed loop step responses for the following
controller configurations—proportional (P), proportional integral (PI), proportional
derivative (PD), and proportional integral and derivative (PID)—are presented in
Fig. 11.18a–d.
As expected, the performance of P and PI controllers are similar, and the
performance of PD and PID controllers are similar. The results of overshoot and
settling time for the controllers are summarized in Table 11.6.
The controller gains were put in the front panel of the position control VI for the
NI-ELVIS II DC motor module for PI (KD = 0), PD (KI = 0), and PID. The actual
motor responses (in red) for a square wave input (reference in blue) for these
controllers are presented in Fig. 11.19a–c. The response of PI is worse with higher
overshoot and settling time than PD and PID controllers.
326 11 Basic Control Systems

Fig. 11.18 Simulated closed loop step response of DC motor with controller (a) P, (b) PI, (c) PD,
(d) PID
Controller Implementation 327

Fig. 11.18 (continued)


328 11 Basic Control Systems

Table 11.6 Comparison of Type of controller Overshoot α (%) Settling time tset (s)
performance of controllers for
P 43 0.464
DC motor Gp ðsÞ = sð0:064sþ1
34:45
Þ
PI 43 0.463
PD 18 0.249
PID 18 0.247

Fig. 11.19 Actual closed loop step response of DC motor with controller (a) PI, (b) PD, (c) PID
Exercises 329

Fig. 11.19 (continued)

Exercises

1. The position control system of an extender robot is represented as a system shown


in Fig. P11.1. The actuator dynamics is given as G(s) = sð2sþ1Þð80:05sþ1Þ : The
controller is a P-type controller with a transfer function Gc(s) = K.

Fig. P11.1 Schematic of a closed loop control system

(a) Obtain the closed loop transfer function, T(s) = Y(s)/R(s). Obtain the char-
acteristic polynomial P(s).
(b) Use Routh-Hurwitz criteria to find the range of gain K for stability.
(c) Obtain the critical value of K for which the closed loop system step response
will be oscillatory. Find theoretically the frequency of such oscillatory
response for the critical value of K from auxiliary polynomial A(s).
(d) Obtain step response of the closed loop system for different values of
K (stable, unstable, marginally stable), to confirm the results obtained in
steps (b) and (c). Show the closed loop response for each case. Verify the
frequency of response of the oscillatory response from the closed step
response time period at the critical value of K.
330 11 Basic Control Systems

2. The closed loop control system of a process is represented in Fig. P11.2. The
process dynamics is given as a transfer function GðsÞ = ðsþ1Þ1ðsþ4Þ and the PI

Fig. P11.2 Schematic of a closed loop control system

0:1sþ1
controller, Gc ðsÞ = K s .
(a) Obtain the root locus of the system for positive gain K. Show the details of
root locus. Show break-in/breakaway points. Comment on the closed loop
system stability.
(b) On the root locus of the system in (a), show the point where the closed loop
step response is expected to be oscillatory. Find the corresponding gain
K and the closed loop poles. Verify the value of gain (Kcritical) using Routh-
Hurwitz criterion. Estimate the frequency of oscillation.
(c) For the system, obtain the closed loop step response of the system with the
gain (Kcritical) found in (c). Verify the frequency of oscillation from the step
response.
(d) Draw bode plot of the system. Obtain gain margin, phase margin, gain
crossover frequency, and phase crossover frequency of the system. Com-
ment on the gain margin and the critical gain of step (b). Comment on the
phase crossover frequency and the frequency of oscillation of step (b).

3. The position control system of a mobile robot using a vision system is


represented as shown in Fig. P11.2 with the plant transfer function
G(s) = ð2sþ1Þ19ð3 sþ1Þ.
It is required to design a PID controller such that the system steady error due
to step input is limited to 5%, the overshoot due to step input is limited to 5%,
and the settling time (within 2% error) is limited to 0.5 s.
(a) Obtain desired poles. Obtain PID controller gains.
(b) Verify if the desired poles are met using the root locus of the system.
Bibliography 331

(c) Verify if closed loop step response of the compensated system meets the
desired specifications.
(d) Obtain gain and phase margin of the compensated system.
4. The control system of an experimental robot is represented as shown in
Fig. P11.2 with the dynamics of leg and actuator given as G(s) = ðs2 þ0:5sþ2
20
Þ.
It is required to design to design a PID controller such that the gain margin is
10 dB and phase margin is 60° at gain crossover frequency of 6.9 rad/s.
(a) Obtain the PID controller gains. Use suitable integral gain.
(b) Verify if the design specifications are met on gain margin, phase margin, and
the gain crossover frequency for the compensated system using Bode plot.
(c) Obtain closed loop step response of the compensated system and estimate
overshoot and settling time.
(d) Comment on the role of the controller on system stability using the root
locus of the system without and with the controller.

Bibliography

Dorf RC, Bishop RH (2022) Modern control systems, 14th edn. Pearson Education, Harlow
Mathworks (2022) Matlab and Simulink. https://www.mathworks.com/products/matlab.html
National Instruments (2022) NI ELVIS II. https://www.ni.com/en-us/support/model.ni-elvis-ii.html
Nise NS (2019) Control systems engineering, 8th edn. Wiley, New York
Ziegler JG, Nichols NB (1942) Optimum settings for automatic controllers. Trans ASME 64:
759–768
Chapter 12
Mechatronic Systems

12.1 Introduction

In this chapter, 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, and 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 South-
ern, programming language Python is introduced and EV3 project is carried out in
MicroPython environment using the libraries for EV3 (EV3 brick).

12.2 Robotics Project Using Lego Mindstorms EV3

The robotics project integrates application of knowledge gained for the different
types of sensors and DC servo motors and programming an educational robotics
module (Lego Mindstorms EV3) to perform specific tasks. Each robot is required to
follow a path, following a moving target at a safe distance while running a basic
obstacle avoidance program. The knowledge of graphical programming language
LabVIEW is consolidated for programing each robot. The project requirements
include the following:
• Each major component of EV3, namely, the brick; the sensors—touch, light,
ultrasonic, and gyro; and the DC servo motors, should be studied and tested. Each
of the sensors and drive motors should be calibrated.
• Each robot should have the basic capability of (i) following a path, (ii) avoiding
an obstacle, (iii) following a moving target while keeping a safe distance.

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

• Robots may use any available sensors necessary for the completion of this
project.
• Robots will operate autonomously.
• Following robots will maintain a fixed (safe) distance from the leading robot/
moving target.

12.3 EV3 Intelligent Brick

The heart and brain of an EV3 is the central processing block, commonly called the
intelligent brick. The full details of an EV3 intelligent brick can be obtained from
LEGO Education (https://education.lego.com/en-us/). Some necessary details are
presented here for quick reference.
An EV3 intelligent brick consists of the following:
• 300 MHz ARM 9 processor with Linux-based operating system
• Onboard storage of 16 MB flash memory, 64 MB RAM
• Mini SDHC card reader of 32 GB expanded memory
• Four input ports (marked 1–4) for data acquisition at 1000 samples/s (for sensors)
• Four output ports (marked A–D) for execution of commands (for motors)
• A high-resolution 178 × 128 pixel display
• Computer-to-brick communication through on-board USB or external Wi-Fi or
Bluetooth dongles
• A speaker
• A rechargeable battery pack (6 AA)

12.4 EV3 Sensors

There are four types of sensors in each EV3. The sensors are (1) color or light sensor,
(2) touch sensor, (3) ultrasonic sensor, and (4) gyro sensor. The details of the sensors
can be obtained from LEGO Education (https://education.lego.com/en-us/). Here,
some necessary details are presented.
Light or Color Sensor
EV3 color or light sensor is a digital sensor that can be used in three modes: color,
reflected light intensity, and ambient light intensity mode. In color mode, the sensor
can be used to detect seven colors (black, blue, green, yellow, white, red, and brown)
and no color. In reflected light intensity mode, the sensor is used to emit red light
from a bulb and measure the intensity of reflected light from the surface in front of it
in the scale of 0 (least reflection) to 100 (most reflection). The reflected light intensity
mode is used in line following applications. In ambient light intensity mode, the
sensor is used to measure the intensity of ambient light in the scale of 0 (very dark) to
100 (very bright). In color or reflected light intensity modes, the sensor should be
placed at right angles and close to the surface of interest.
12.6 EV3 Sensor Calibration 335

Touch Sensor
EV3 touch sensor can be used to detect the status of its front button: pressed or
released. The touch can also be used to count the number of times the front button is
pressed. The touch can be used to stop the robot and reverse its motion when the
touch sensor comes in contact with an obstacle.
Ultrasonic Sensor
EV3 ultrasonic sensor is a digital sensor that can be used to send ultrasound wave
from the transmitter (TX) and detect and measure the distance of an object in front of
it using the time taken by the reflected ultrasound wave to reach the receiver (RX).
The usual range of distance is 3–250 cm with an accuracy of ±1 cm (~1–100 in,
±0.394 in). The ultrasonic sensor can be used for following a moving object at a safe
distance.
Gyro Sensor
EV3 gyro is a digital sensor that can be used to measure angle of rotation (angle
mode) or rate of angular motion (gyro mode) about the axis of motion indicated by
arrows on the sensor. The angular accuracy is ± 3°, and the maximum angular rate is
440°/s. The gyro can be used to turn the robot by a specific angle or by a specific
angular rate.

12.5 EV3 Motors

Each EV3 kit is equipped with three DC servo motors, each with a rotation sensor of
1° resolution. Two of these DC motors are called large motors that are slower but
stronger, and the other motor called medium motor is faster and lighter. The details
of the large and the medium motors are obtained from LEGO Education (https://
education.lego.com/en-us/). Here, some necessary details are presented. The large
motors are typically used as drive motors, each with a maximum speed range of
160–170 rpm, an operating torque of 20 N.cm, and a stall torque of 40 N.cm. The
medium motor is with a maximum speed range of 240–250 rpm, an operating torque
of 8 N.cm, and a stall torque of 12 N.cm.

12.6 EV3 Sensor Calibration

For proper operation of EV3 robot, it is necessary to calibrate each sensor. The
calibration of each sensor involves creating a VI for each sensor, uploading it to EV3
target, running the program on EV3, and recording the readings displayed on EV3.
Details of these sensor calibrations are discussed in this section. The programming of
EV3 is done through LabVIEW (EV3 is supported on LabVIEW 2015/2016). To use
LabVIEW for EV3 sensor calibration, the following sequence needs to be followed:
336 12 Mechatronic Systems

Launch LabVIEW
→File → New NXT/EV3 → Targeted VI → Function Palette
→Mindstroms Robotics → I/O → Sensors

To calibrate any of EV3 sensors, it is necessary to create a new VI with a STOP


button on the panel and a while loop on the block diagram panel. In the block
diagram panel, place the STOP subVI within the while block and connect the STOP
subVI to the while block conditional terminal.

12.6.1 Light Sensor Calibration

To calibrate the light/color sensor, place a color sensor subVI by selecting Read EV3
Color → Reflected from the sensors panel. The port to which the light/color sensor is
connected is assigned next by right-clicking to the blue terminal at the top-corner of
the sensor block and selecting Create → Constant. Select the actual port from the
drop-down menu. To display the sensor reading on the EV3 display screen, select
I/O → Display and place it within the while block, and connect the output terminal of
the sensor block to the input of the display block. The block diagram panel should
look like the one shown in Fig. 12.1a.
To deploy this program to the EV3, first turn the EV3 on by pressing the center,
dark grey button. Once the EV3 has booted, connect it to the computer by connecting
the mini-USB port labeled “PC” on the EV3 to the USB port on the PC. Before
deploying the program to the EV3, it is a good idea to save the VI. It is a good idea to
save the file on EV3. When the VI is saved, click the deploy button (the downward
facing arrow adjacent to the run arrow). If the EV3’s volume is not muted, it will
emit two beeps to signify that it has received a new program file. The LCD on the
EV3 should display a list of programs that currently reside on the robot, with the

Light sensor calibration -Reflected light


intensity
100
Sensor reading

80
60
40
20
0
Black Green Blue Floor Red Yellow White
Color/surface

(a) (b)

Fig. 12.1 EV3 color sensor calibration (a) block diagram panel, (b) bar chart
12.6 EV3 Sensor Calibration 337

most recently downloaded program currently selected. Disconnect the EV3 from the
computer and press the dark grey button to start the light calibration program. In the
top-left corner of the LCD screen, single- or double-digit values should be displayed
indicating the current signal value from the color sensor. Put blocks or surface of
different colors in front of the color sensor, record the sensor readings, and plot a bar
chart of sensor reading versus color/surface. A representative bar chart is presented
in Fig. 12.1b for reference.

12.6.2 Touch Sensor Calibration

To calibrate the touch sensor, place within the while loop a touch sensor subVI by
selecting it from Function Palette → Mindstroms Robotics → I/O → Sensors → Read
NXT/EV3 Touch → Pressed. The port to which the touch sensor is connected is
assigned next by right-clicking to the blue terminal at the top-corner of the sensor
block and selecting Create → Constant. Select the actual port from the drop-down
menu. The output of the touch sensor will be logic true (1) when the sensor button is
pressed and logic false (0) otherwise. The output of the touch sensor is connected to
the input of a case structure with two cases (true and false). To display the sensor
status on EV3 display screen, select I/O → Display and place it within each case
block and create and connect the constant text terminal of the display Text block.
Text to display will be pressed in case the sensor output is true and released in case
the sensor output is false. The block diagram panels for two-case structure should
look like the ones shown in Fig. 12.2a, b.
The program is uploaded to EV3 brick and run to check the touch sensor button
status on EV3 display, and results are recorded for two conditions of the button:
pressed and released. The representative touch sensor calibration table is presented
in Table 12.1.

Fig. 12.2 EV3 touch sensor calibration block diagram panel (a) true, (b) false
338 12 Mechatronic Systems

Table 12.1 Touch sensor Actual button status Sensed button status
calibration
Pressed True (pressed)
Released False (released)

Ultrasonic sensor calibration


120

Measured distance
100 y = 1.0125x - 0.12
80

(cm)
60
40
20
0
0 20 40 60 80 100
Actual distance (cm)

(a) (b)

Fig. 12.3 EV3 ultrasonic sensor calibration (a) block diagram panel, (b) calibration graph

12.6.3 Ultrasonic Sensor Calibration

To calibrate the ultrasonic sensor, place within the while loop the ultrasonic sensor
subVI by selecting it from Function Palette → Mindstroms Robotics → I/O → Sen-
sors → Read EV3 Ultrasonic → CM. The port to which the ultrasonic sensor is
connected is assigned next by right-clicking to the blue terminal at the top corner of
the sensor block and selecting Create → Constant. Select the actual port from the
drop-down menu. To display the sensor reading on EV3 display screen, select
I/O → Display and place it within the while block and connect the output terminal
of the sensor block to the input of the display block. The block diagram panel should
look like the one shown in Fig. 12.3a.
The VI is uploaded to EV3 brick and run. The measured distance reading on EV3
screen is recorded when a flat wide object is placed at a known distance (using a
meter ruler) in front of the ultrasonic sensor, and the process is repeated at a regular
interval (say 10 cm) over the entire range (10–100 cm). A representative calibration
graph for an ultrasonic sensor is presented in Fig. 12.3b.

12.6.4 Gyro Sensor Calibration

To calibrate the gyro sensor, place within the while loop the gyro sensor subVI by
selecting it from Function Palette → Mindstroms Robotics → I/O → Sensors → Read
EV3 Gyro → Angle. The port the gyro is connected to is assigned following the
same procedure as for other sensors. A similar process is followed to display the
sensor reading on EV3 display. The block diagram panel should look like the one
shown in Fig. 12.4a.
12.7 EV3 Motor Speed Calibration 339

Gyro calibration
200

Measured angle
y = 0.9733x
150

(degrees)
100

50

0
0 50 100 150 200
Actual angle (degrees)

(a) (b)

Fig. 12.4 EV3 Gyro sensor calibration (a) block diagram panel, (b) calibration graph

The VI is uploaded to EV3 brick and run. The measured angle reading on EV3
screen is recorded when EV3 is placed at a known angle with a reference (using a
protractor), and the process is repeated at a regular interval (say 45°) over the entire
range (0–180°). A representative calibration graph for gyro sensor is presented in
Fig. 12.4b.

12.7 EV3 Motor Speed Calibration

Speed of each large motor can be controlled through the power input (0–100%) to
the motor. Though the large motors are with the same specifications, it is important
to calibrate the motors individually to verify if there is any difference and to take that
into account in programming the motors for specific EV3 motion profile or specific
tasks.
The move motor subVI can be placed within the while loop by selecting from
Function Palette → Mindstroms Robotics → I/O → Move Motors. The port to which
the left motor is attached can be assigned by right-clicking on the top node of the
Motor subVI, using Create → Constant, and selecting the actual one from the drop-
down menu Lego port A–D. The power to the motor can be controlled by right-
clicking on the lower left node, using Create → Constant, and by assigning the
numerical value (0–100%) in steps of 25%. The motor can be run at a specific power
level for a specific time (say 10 s) using a stacked sequence structure and delay time
(10,000) in milliseconds. The next sequence is to stop the motor by assigning power
as 0% to the motor followed with a delay. The following sequence (0..3) can be
adopted.
Run the motor with power at x% → wait (10,000) → Stop the motor setting
power at 0 → wait (10,000).
The block diagram panel with sequence structure is shown in Fig. 12.5a–c.
Sequence 1 and 3 are identical. Here, both motors are run simultaneously, but the
number of revolutions can be monitored independently.
340 12 Mechatronic Systems

Fig. 12.5 EV3 Large motor calibration sequence structure VI (a) Seq 0, (b) Seq 1, (c) Seq 2

Motor Speed Calibration - Left Motor Speed Calibration - Right


140 140
120 120
Motor speed (rpm)

Motor speed (rpm)


100 100
80 80
60 60
40 40
20 20
0 0
-20 0 20 40 60 80 100 -20 0 20 40 60 80 100
Motor power (%) Motor power (%)
(a) (b)

Fig. 12.6 EV3 Large motor calibration graphs (a) left motor, (b) right motor

The VI is uploaded to EV3 brick and run. The number of revolutions of the motor
is recorded for the specific time of 10 s for each power level in steps of 25% in the
range of 0–100%. The recorded number of revolutions is converted to rpm, and the
speed (rpm) vs power (%) graph is plotted for each of two large motors. Represen-
tative speed calibration graphs are shown in Fig. 12.6a, b for left and right motors,
respectively.

12.8 EV3 Programming

The graphical programming environment of LabVIEW can be used to program EV3


for completion of desired tasks. The individual tasks include (1) following a line,
(2) avoiding an obstacle, and (3) following a moving target while maintaining a safe
distance. These individual tasks can be combined to create composite tasks like
(1) following a line and avoiding an obstacle and (2) following a randomly moving
target from a safe distance while avoiding a collision with any stationary object.
There may be various options to get each of these tasks completed. The basic
individual tasks are discussed in terms of pseudocode and the corresponding
LabVIEW implementation on EV3 for reference.
12.8 EV3 Programming 341

Fig. 12.7 Line following with proportional control: case structure (a) true, (b) false

12.8.1 Line Following

The pseudocode for line following using a proportional control is presented. The
implementation of the pseudocode is presented in Fig. 12.7. The pseudocode can be
implemented using graphical programming language LabVIEW with Mindstorms
EV3 module installed. The outer Do. . .While loop can be implemented by the While
structure from functions palette with condition (touch sensor not pressed) for
continuing. The inner if. . .else can be implemented using case structure from
functions palette with two cases: true and false. The values may need to be adjusted
for particular applications.
Pseudocode for Line Following Using Proportional Control
________________________________________________________________-
_________________
Start
Initialize Inputs
Light sensor reading on Black Tape: lightB
Light sensor reading on Floor: lightF
Tolerance Tol
Fixed power (%) to motors: P
Proportional gain: Kp
342 12 Mechatronic Systems

Do {
Get reference value for light sensor lightRef = lightB + (lightB
+lightF)/2
Get upper limit for light sensor lightRefU = lightRef + Tol
Get lower limit for light sensor lightRefL = lightRef - Tol
Read light sensor reading x
If (x > lightRefU or x < lightRefL) {
// Turn to line
Get error = lightRef – x
Get motor powerVal = Kp*error
Set powerLeftMotor = - powerVal
Set powerRightMotor = powerVal
}
Else {// move straight
Set powerLeftMotor = P
Set powerRightMotor = P
}
} while (Touch sensor button is not pressed)
End
_________________________________________________________________

12.8.2 Obstacle Avoidance

The pseudocode for obstacle avoidance is presented. The implementation of the


pseudocode is presented in Fig. 12.8. The pseudocode can be implemented using
LabVIEW with Mindstorms EV3 module installed. The outer Do. . .While loop can
be implemented by the While structure from functions palette with condition (touch
sensor not pressed) for continuing. The inner if. . .else can be implemented using
case structure from functions palette with two cases: true and false based on the
ultrasonic sensor reading in relation to the safe distance. The values may need to be
adjusted for particular applications.
Pseudocode for Obstacle Avoidance
_________________________________________________________________
Start
Initialize Inputs
Safe distance from an object (cm): xSafe
Fixed power (%) to motors: P
Fraction of power: fP

Do {
Read ultrasonic sensor reading x

If (x > xSafe) {
// Move forward
Get motor powerVal = fP*P
Set powerLeftMotor = powerVal
Set powerRightMotor = powerVal
}
12.8 EV3 Programming 343

Else {// Turn right


Get motor powerVal = fP*P
Set powerLeftMotor = powerVal
Set powerRightMotor = -powerVal
}

} while (Touch sensor button is not pressed)


End
_________________________________________________________________

Fig. 12.8 Obstacle avoidance block diagram panel: case structure (a) true, (b) false
344 12 Mechatronic Systems

12.8.3 Line Following While Avoiding Obstacle

The features of stand-alone line following and obstacle avoidance modules are
combined for line following while line following. The pseudocode can be
implemented using LabVIEW with Mindstorms EV3 module installed. In this
application, all four sensors are used: light/color sensor for line following, ultrasonic
sensor for obstacle detection, gyro sensor for angle of detour, and touch sensor for
detection of direct contact. Sequence structure with two sequences, each with a
Do. . .While built-in, is used for detour around the obstacle in the robot path and
continue following the line.
Pseudocode for Line Following While Avoiding Obstacle
_________________________________________________________________
Start
Initialize Inputs
Light sensor reading on Black Tape: lightB
Light sensor reading on Floor: lightF
Tolerance on light sensor value: Tol
Fixed power (%) to motors: P
Proportional gain: Kp
Angle of turn: Theta
Default Left Motor Power (%): LmP
Default Right Motor Power (%): RmP
Safe distance from an object (cm): xSafe
Time elapsed in turning back to line dTime

Do {
Read ultrasonic sensor value x
If (x > xSafe) {// Follow the line

Get reference value for light sensor lightRef =lightB+(lightB


+lightF)/2
Get upper limit for light sensor lightRefU=lightRef+Tol
Get lower limit for light sensor lightRefL=lightRef-Tol
Read light sensor value x

If (x > lightRefU or x<lightRefL) {


// Turn to line
Get error =lightRef – x
Get motor powerVal = Kp*error
Set powerLeftMotor = - powerVal
Set powerRightMotor = powerVal
}

Else {// move straight


Set powerLeftMotor = P
Set powerRightMotor = P
}
}
Else {// Avoid obstacle using flat sequence structure (0..1)
12.8 EV3 Programming 345

Sequence 0 {// sequence 0 turn sharply away from the object in


front
Reset gyro angle to 0

Do {// Turn right sharply for Theta


Set powerLeftMotor = LmP
Set powerRightMotor= -LmP
Read gyro sensor angle theta
} while (theta < Theta) // end of sharp turn
} // end of sequence 0

Sequence 1{// sequence 1 move back towards the line in a detour


Start timer t0
Do {// Move back towards the line
Set powerLeftMotor = LmP
Set powerRightMotor= RmP
Start timer t1
Get timeElasped =t1 – t0
} while (timeElasped < dTime)

} // end of Sequence 1
} // end of Else

} while (Touch sensor button is not pressed)


End
_________________________________________________________________

12.8.4 Following a Moving Target

Pseudocode for following a moving object within the robot field of view is
presented. Implementation of the pseudocode can similarly be done using LabVIEW
with EV3 module supported. The objective for the robot is to look for an object in the
vicinity of its field of view to start with. Once an object is detected within the robot
field of view, the robot is supposed to move forward to the object before stopping at a
predefined safe distance. The robot should move forward with the moving object. If
the object moves toward the robot, the robot should move backward to maintain the
safe distance with the object. If the object moves out of field of view of the robot, the
robot should continue searching for an object in its field of view till one is found.
Pseudocode for Following a Moving Target
_________________________________________________________________
Start
Initialize Inputs
Object detection distance (cm): xDetect
Safe distance from an object (cm): xSafe
Waiting period for spinning (ms): dT
Fixed power (%) to motors: P
Fraction of power: fP
Proportional gain: Kp
346 12 Mechatronic Systems

Do {
Read ultrasonic sensor value x
If (x > xDetect) {
// Spin around and search for an object
Do {
Get motor powerVal = fP*P
Set powerLeftMotor = powerVal
Set powerRightMotor = -powerVal
Wait for dT
Read ultrasonic sensor reading x
} while (x < xDetect)
}
Else {// Object detected in range
Read ultrasonic sensor value x
Get xDiff = x – xSafe
Get xDiffP = Kp*xDiff
If (| xDiffP | < P) {
If (xDiff > 0) {// Move forward
Set powerLeftMotor = fP*P
Set powerRightMotor = fP*P
}
Else {// Move backward (back down)
Set powerLeftMotor = - fP*P
Set powerRightMotor = - fP*P
}
Else {// Limit the power to motors
Set powerLeftMotor = P
Set powerRightMotor = P
}
}
} while (Touch sensor button is pressed)
End
_________________________________________________________________

12.9 Project Ideas

1. Develop an algorithm to follow a boundary wall while avoiding obstacle on its


way in a maze. Implement the algorithm on EV3 and demonstrate.
2. Develop a pseudocode for a mobile EV3 to follow a path (created using black
tape on a bright floor) and track a wall. The robot should be able to avoid any
obstacle on its way. The robot should be equipped with all necessary sensors and
motors for achieving the goal in the shortest time.
3. Assemble EV3 to create a mobile base and an arm. The robot is required to follow
a path, stop at a station, pick up a light package, deliver the package to another
station, and move itself to a parking area. The robot should be able to avoid any
obstacle on its way. The robot should be equipped with all necessary sensors and
motors for achieving the goal in the shortest time.
Bibliography 347

Bibliography

https://education.lego.com/en-us/
https://education.lego.com/en-us/products/lego-mindstorms-education-ev3-intelligent-brick/45500
https://education.lego.com/en-us/products/lego-mindstorms-education-ev3-color-sensor/45506
https://education.lego.com/en-us/products/lego-mindstorms-education-ev3-touch-sensor/45507
https://education.lego.com/en-us/products/lego-mindstorms-education-ev3-ultrasonic-sensor/4
5504
https://education.lego.com/en-us/products/lego-mindstorms-education-ev3-gyro-sensor-/45505
https://www.depts.ttu.edu/coe/stem/gear/ev3/documents/Ev3-Brick-Details.pdf
https://www.depts.ttu.edu/coe/stem/gear/ev3/documents/EV3-Motors-Sensors.pdf
National Instruments (2015) LEGO MINDSTORMS® Module for LabVIEW 2016. https://www.ni.
com/en-us/support/downloads/software-products
National Instruments (2022) LabVIEW fundamentals. https://www.ni.com/docs/en-US/bundle/
labview/page/lvconcepts/labview_fundamentals.html
Pybricks.com (2020) Getting started with LEGO® MINDSTORMS Education EV3 MicroPython.
https://pybricks.com/ev3-micropython/
Appendices

Appendix A (Tables A.1, A.2, A.3, A.4 and A.5)

Table A.1 SI base units Quantity Name Symbol


Time Second s
Length Meter m
Mass Kilogram kg
Electric current Ampere A
Thermodynamic temperature Kelvin K
Amount of matter Mole mol
Luminous intensity Candela cd

Table A.2 Derived SI units


Derived quantity Derived name Symbol
Area Square meter m2
Volume Cubic meter m3
Speed, velocity Meter per second m/s
Acceleration Meter per second squared m/s2
Mass density Kilogram per cubic meter kg/m3
Specific volume Cubic meter per kilogram m3/kg
Current density Ampere per square meter A/m2
Magnetic field strength Ampere per meter A/m
Luminance Candela per square meter cd/m2
Concentration Mole per cubic meter mol/m3

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

Table A.3 SI derived units with special names and symbols


Quantity Name Symbol Expression
Frequency Hertz Hz s-1
Force Newton N kg. m. s-2
Pressure, stress Pascal Pa N. m-2 = kg. m-1. s-2
Energy, work Joule J N. m = kg. m2. s-2
Power, radiant flux Watt W J. s-1 = kg. m2. s-3
Electric charge Coulomb C A. s
Voltage, electric potential Volt V W. A-1 = kg. m2. s-3. A-1
Capacitance Farad F C. V-1 = s4. A2. m-2. kg-1
Electric resistance Ohm Ω V. A-1 = kg. m2. s-3. A-2
Electric conductance Siemens S A. V-1 = kg-1. m-2. s3. A2
Magnetic flux Weber Wb V. s = kg. m2. s-2. A-1
Magnetic flux density Tesla T Wb. m-2 = kg. s-2. A-1
Inductance Henry H Wb. A-1 = kg. m2. s-2. A-2

Table A.4 SI unit prefixes Prefix Symbol Scientific notation Name


Yotta Y 1024 Septillion
Zetta Z 1021 Sextillion
Exa E 1018 Quintillion
Peta P 1015 Quadrillion
Tera T 1012 Trillion
Giga G 109 Billion
Mega M 106 Million
Kilo k 103 Thousand
Hecto h 102 Hundred
Deca da 10 Ten
Deci d 10-1 Tenth
Centi c 10-2 Hundredth
Milli m 10-3 Thousandth
Micro μ 10-6 Millionth
Nano n 10-9 Billionth
Pico p 10-12 Trillionth
Fempto f 10-15 Quadrillionth
Atto a 10-18 Quintillionth
Zepto z 10-21 Sextillionth
Yocto y 10-24 Septillionth
Appendices 351

Table A.5 Conventional system to SI unit conversion factors


Physical quantity Conventional unit SI unit
Length 1 in 2.540 cm
1 ft 0.3048 m
1 mile 1.609 km
Mass 1 lbm (pound mass) 0.4536 kg
Force 1 lbf (pound force) 4.448 N

Temperature Fahrenheit (°F) T K = 59 ðT F- 32Þ þ 273:15 K
Pressure 1 lb/in2 6.895 × 103 Pa
1 atm 1.013 × 105 Pa
Power 1 BTU/h 0.2929 W
1 hp 745.7 W
Magnetic field 1 gauss 1.000 × 10-4 T

Appendix B (Table B.1)

Table B.1 Laplace transform of time functions


f(t) F(s)
δ(t) 1
u(t) 1
s
t 1
s2
tk 1
k! k ≥ 0 skþ1
at 1
e s-a
cos ωt s
s2 þω2
ω
sinωt s2 þω2
df ðt Þ sF(s) - f(0)
dt
 
d k f ðt Þ  k-1 
dt k sk F ðsÞ - sk - 1 f ð0Þ - sk - 2 dfdtðtÞ - . . . - d dtk -f ð1tÞ
t=0 t=0
Rt F ðsÞ
0 f ðτ Þdτ s
f(αt), α > 0 αF(s/α)
eatf(t) F(s - a)
dF ðsÞ
tf(t) - ds
k
ð - 1Þk d dsF ðksÞ
k
t f(t)
f ðtÞ
R1
t s F ðsÞds
n -ST
gðt Þ = 0 0≤t<T
,T ≥0 G(s) = e F(s)
f ðt - T Þ t ≥ T

Bibliography

https://www.nist.gov/pml/owm/metric-si/si-units
Index

A Combinational logic, 146, 207–211, 222–224,


Accelerometers, viii, 5, 177–184, 204 229, 230, 233–235
Accuracy, 6, 335 Comparators, viii, 5, 95, 96, 111, 116,
Actuators, vii–ix, 3–5, 41, 237–238, 295, 329, 121, 123, 124, 144, 146, 147,
331, 333 295, 298
Analog signal processing, viii, 4, 5, 95–136 Control systems, vii, viii, 1, 4, 5, 295–331
Analog-to-digital converter (ADC), viii, 5, 139, Critically damped, 73, 75, 77, 78
144–149, 160, 268
Arduino, 230, 246, 247, 249–257, 259–262,
266–275, 277, 280–294 D
Arduino Uno, 230, 249, 254, 259, 261, 262, Data acquisition system, 2, 160
266, 274, 289–292, 294 Data to knowledge, 3
DC motors, 238–254, 257–262, 295,
325, 326, 328, 335
B De Morgan’s laws, 211–213, 223, 233, 234
Basic circuits, vii, viii, 3, 4, 21, 35–37, 62, Design of experiment, 4
274, 295 Difference amplifier, 92, 93, 102–104, 112,
Basic statistics, viii, 4, 7–9, 14–16 165, 168–170, 172, 191, 192, 195, 196,
Binary number, 141–142, 148, 149 198, 202, 203
Bipolar junction transistor (BJT), viii, 4, 41, Differentiators, viii, 5, 95, 96, 107–110, 120,
53–57, 64, 65 124–131
Bode plots, 304, 305, 313, 315, 317, 318, Digital logic, viii, 5, 146, 207, 210, 212–223,
330, 331 225, 229–233, 235, 274, 284–286,
Boolean algebra, 209–212, 223, 229, 232–235 290–295
Buffers, viii, 5, 95, 96, 111, 124, 207, 208 Digital-to-analog converter (DAC), viii, 2, 5,
139, 144, 145, 149–151, 160

C
C++, vii, 4, 230, 252, 260, 265, 268, 271 E
Capacitances, 21, 23–27, 37, 104, 108, 181, 350 Equivalent circuits, viii, 4, 21, 29–30, 39, 56
Charge amplifiers, 181–184, 204 Ev3, viii, 5, 333–346
Circuit analysis, viii, 4, 21, 28–33, 35 Experimental determination, 71–72, 80–82
Color sensor, 334, 336, 337

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

F M
Filter, 71, 88, 92, 156, 157 Maximum power, 47, 242, 243, 245, 246,
First order system, 71, 72, 296 257, 262, 263
Flip-flop, 225–229 Measurement devices, 6
Following a moving target, 333, 340, 345–346 Measurement fundamentals, viii, 4–16
Frequency response, 71, 87, 88, 91, 92, 107, Mechatronics, vii–ix, 1–5, 41, 67, 80, 95, 139,
110, 125, 126, 129, 130, 175, 177, 178, 149, 237, 238, 262, 265, 295, 333–346
182, 183, 204, 308 Mega, 266, 350
Metal oxide semiconductor field effect
transistor (MOSFET), viii, 4, 41, 57–62
G Microcontroller programming, vii–ix, 3–5, 265,
Gain margin (GM), 304, 305, 307, 314, 317, 295, 333
330, 331
Graphical programming, viii, 5, 151, 333,
340, 341 N
Gyro sensor, 334, 335, 338–339, 344 NMOS, 57–60, 65
Noninverting amplifiers, viii, 5, 95, 99–101,
110, 115–117, 123
H Npn transistor, 53
H-bridge, 246–248, 254–257, 259, 261, 262 Number systems, viii, 5, 140–143, 147–149,
Hexadecimal numbers, 142, 143, 148, 149, 160 160

I O
Impedances, 31–33, 35, 39, 40, 97, 99, 106, Obstacle avoidance, 333, 342–344
109, 114, 136 Octal number, 142, 143, 148, 149, 160
Inductances, 21, 24, 25, 27, 239, 262, 350 Operational amplifier (op-amp), 95–100,
Integrated development environment (IDE), 102–105, 108, 111, 112, 114–126, 130,
267, 273–275 132–136, 146, 149, 150, 169, 181, 182,
Integrators, viii, 5, 95, 104–107, 119, 124–131 185, 186, 203
Inverting amplifiers, viii, 5, 95, 97–99, 101, Overdamped system, 74, 75, 77, 78
102, 104, 106, 107, 116, 117, 122 Overshoot, 78, 306, 309, 311, 317, 322, 325,
328, 330, 331

J
Junction diodes, viii, 4, 41–52 P
Phase lag, 70, 175, 305, 308
Phase lag-lead controller, 308
K Phase lead, 305, 308
Karnaugh map (K-map), 223–225, 229, Phase margin, 304, 305, 307, 313, 314, 317,
234–236 330, 331
PID controllers, 295, 307–322, 324, 325,
330, 331
L PMOS, 57, 58, 60–62, 66
Labview, vii, viii, 4, 5, 92, 93, 139, 151–157, Pnp transistor, 53
192–195, 198–201, 295, 333, 335, Poles, 297, 298, 300–302, 305–309, 311, 330
340–342, 344, 345 Power, viii, 3, 4, 21, 22, 24, 31, 33–35, 44–46,
Light/color sensor, 336, 344 63, 88, 97, 99, 116, 125, 140, 157, 168,
Light sensor, 334, 336–337 199, 224, 230, 237–239, 241–249, 257,
Line following, 273, 334, 341–342, 344–345 258, 262, 266, 268, 269, 274, 275, 301,
Logic gates, 210, 212, 213, 220, 223, 233, 339, 340, 350, 351
234, 236 Power-speed characteristics, 242, 243, 257, 262
Index 355

Precision, 6, 63, 96, 112, 149, 192 Thermocouples, viii, 5, 154, 155, 185,
Programming languages, viii, 5, 265, 187–195, 198, 204, 205
268–273, 333 Thermopile, 189–191, 204, 205
Time constant, 67, 71, 72, 86, 89, 90, 92,
182–184, 194, 195, 204, 296, 325
R Time responses, 78, 87, 90, 91, 194, 195,
Resistance temperature detectors (RTD), viii, 199, 200
5, 185, 186 Touch sensor, 334, 335, 337, 338, 341,
Resolution, 147, 148, 160, 268, 334, 335 342, 344
Rise time, 69, 89, 92, 194
Root locus, 301–303, 305, 309, 311, 312, 317,
319, 330, 331 U
Ultrasonic sensors, 164, 286–289, 291, 334,
335, 338, 342, 344
S Uncertainty analysis, viii, 4, 10–11, 14
Second order system, 74–81, 296, 306 Undamped natural frequency, 72, 80, 82, 92,
Sensors, vii–ix, 2–5, 41, 154, 160, 163, 164, 174, 200, 204, 296, 307, 311
185, 194, 218, 219, 222, 235, 237, 286, Under damped, 73, 74, 76–78, 80, 81, 174
291, 295, 296, 333–339, 344, 346
Sequential logic, 207, 225–228
Servo motors, viii, 5, 333, 335 V
Settling time, 78, 306, 307, 309, 311, 317, 322, Vibration pick up, 174–177
325, 330, 331 Voltage followers, 110–112, 116, 123, 124
Stability analysis, 295, 300–305 Voltage regulators, 44, 45
Stall torque, 242–246, 262, 263, 335
Stepper motors, viii, 5, 238, 248, 254–257,
261, 262 W
Step responses, 70–72, 75–78, 90, 92, 194, 302, Wheatstone bridge, 92, 93, 165, 168–172, 191,
303, 305, 311, 314, 317, 319, 325, 326, 192, 195, 196, 198, 202, 203
328–331
Strain gages, viii, 5, 92, 93, 165–173, 192,
195–203 Z
Zener diodes, viii, 44–47
Zero, 7, 25, 28, 29, 32, 41, 71, 79, 92, 93,
T 97, 98, 105, 108, 242, 296, 298–300,
Thermistors, viii, 5, 185, 186 307, 308

You might also like