Professional Documents
Culture Documents
Biswanath Samanta - Introduction to Mechatronics. an Integrated Approach-Springer (2023)
Biswanath Samanta - Introduction to Mechatronics. an Integrated Approach-Springer (2023)
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
© 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
vii
viii Preface
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.
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
Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
About the Author
xxi
Chapter 1
Introduction
1.1 Mechatronics
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.
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,
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
Accurate Inaccurate
(systematic error)
Precise
Imprecise
(reproducibility error)
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
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Þ
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
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:
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
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
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Þ
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
Y = Y 0 ΔY abs ð1:13Þ
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
Y = Y 0 ΔY rss ð1:15Þ
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
ΔY abs
Δxi,abs = ð1:17Þ
∂f
n ∂xi
12 1 Introduction
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
ΔY
Δxi,rss = pffiffiffi rss ð1:19Þ
∂f
n ∂x i
Partial derivatives: ∂R
∂ρ
= L ∂R
πr2 , ∂L = πrρ2 , ∂R
∂r
= - 2ρL πr3
∂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
Δ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 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.
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
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
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.
Value Unit
Color Code
Nominal value
Expected max, min
Exercises 17
Exercises
Bibliography
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.
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
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):
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
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
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
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):
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 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.
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
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
1
ReqP = Pn 1
ð2:17Þ
i=1 Ri
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
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Þ
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
The voltage drop across a resistance is given by Ohm’s law, as in Eq. (2.1), V = IR.
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.
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
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.
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
R1 R2
RTh = :
R1 þ R2
V OC V
I SC = = s
RTh R1
V ðt Þ = V m sinðωt þ ϕÞ ð2:27Þ
2.7 AC Circuit Analysis 31
1 ω
f= = ð2:28Þ
T 2π
V = V m ejðωtþϕÞ = V m ∠ϕ ð2:29Þ
2.7.2 Impedance
V =Z I ð2:32Þ
V =R I ð2:33Þ
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
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
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.
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 °
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):
2.9 Transformer
NS
α= ð2:49Þ
NP
V PIP = V SI S ð2:50Þ
NS V I
α= = S = P ð2:51Þ
NP V P IS
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 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
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
% 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
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
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 Ω.
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 Ω.
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 Ω.
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.
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.
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.
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.
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
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.
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
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.
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
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Þ
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.
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Þ
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
Δ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
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Þ
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
ð12 V Þ2
20 V - 12 V
1W= ð12 V Þ -
R 200 Ω
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.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
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
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.
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:
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
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:
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
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.
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
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.
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.
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
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.
Both conditions are satisfied. Hence, the original assumption that the npn BJT is
operating in active mode is valid.
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
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
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.
Both conditions are satisfied. Hence, the original assumption that the pnp BJT is
operating in active mode is valid.
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
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),
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.
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:
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.
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
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
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.
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
Both conditions are satisfied. Hence, the modified assumption that the PMOS is
operating in triode mode is valid.
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
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
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.
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.
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.
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.
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.
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.
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
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 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):
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):
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):
0 = Ce - τ þ KA, C = - KA,
0
ð4:9Þ
yðt Þ = KA 1- e - τ
t
ð4:10Þ
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 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
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
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
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
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.
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):
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):
The characteristic Eq. (4.24) for the system is obtained from Eq. (4.23) as
s2 þ 2ζωn s þ ωn 2 = 0 ð4:24Þ
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Þ
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Þ
C3 = Y 0 ð4:33Þ
ζ
C 4 = pffiffiffiffiffiffiffiffiffiffiffiffi :Y 0 ð4:34Þ
1 - ζ2
e - ζωn t
yðt Þ = Y 0 pffiffiffiffiffiffiffiffiffiffiffiffi cosðωd t - φÞÞ ð4:35Þ
1 - ζ2
C1 = Y 0 ð4:37Þ
C 2 = Y 0 ωn ð4:38Þ
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):
C 3 = - KA ð4:46Þ
ζ
C4 = - KA pffiffiffiffiffiffiffiffiffiffiffiffi ð4:47Þ
1 - ζ2
4.3 Second-Order Systems 77
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):
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 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
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
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 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
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
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
2π
ωn = pffiffiffiffiffiffiffiffiffiffiffiffi ð4:70Þ
T d 1 - ζ2
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
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Þ
-/
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
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.
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.
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
0 0 0
4.6 Experimental Validation 91
fc-10
fc
fc+10
10 fc
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
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.
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Þ
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Ω
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Þ
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Ω
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Þ
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Þ
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
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
5.8 Integrator
V out ðt Þ = f ðV in ðt Þ, R, CÞ ð5:36Þ
5.8 Integrator 105
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Þ
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
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
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
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Þ
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
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
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:
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
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
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Þ
V 3 - V 1 = IR2 ð5:59Þ
V 2 - V 4 = IR2 ð5:60Þ
5.13 Instrumentation Amplifier 113
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
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.
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
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.
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
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.
The op-amp configurations considered in this chapter are summarized in Table 5.1
for quick reference.
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.3 Comparison of theoretical and experimental gains for op-amp circuits
a
Use measured values of R1 and R2 from Table 5.2
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.
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.
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
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
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
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.
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.
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Ω.
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
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.
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
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.
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
9. Assuming ideal op-amp behavior for the op-amp circuit shown in Fig. P5.9,
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
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
© 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).
Fig. 6.2 An example of an analog signal (red) and its alias (blue) sampled at fs < 2f
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,
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
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,
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:
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.
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
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.
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:
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().
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)
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
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Þ
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
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
ðV in - V min Þ ð2 - ð - 5ÞÞ
x = ð2n- 1Þ = 210- 1 = 716:1 ≈ 716
ðV max - V min Þ ð5 - ð - 5ÞÞ
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
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
1 1
V out1 = - V 1 = - n-1 V s ð6:16Þ
2 2
1 1
V outðn-1Þ = - V = - Vs ð6:17Þ
2 n-1 2
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
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
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.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
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
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
Exercises
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.
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
eo = k x x ðtranslationÞ ð7:2aÞ
eo = kθ θ ðrotationÞ ð7:2bÞ
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
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
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
ρ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):
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
V in
I1 = I4 = ð7:17Þ
R1 þ R4
V in
I2 = I3 = ð7:18Þ
R2 þ R3
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 Þ
R2 R4 - R1 R3 = 0 ð7:22Þ
Alternatively,
R1 R2
= ð7:23Þ
R4 R3
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 Þ
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
V in
V out,A = A ðΔR1 - ΔR2 þ ΔR3 - ΔR4 Þ ð7:26Þ
4R
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.5 Schematic diagram of a load measurement system (axial loading) using a strain gage, a
Wheatstone bridge, and a difference amplifier
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
V in
V out,A = A ð2ΔRÞ ð7:29Þ
4R
7.3 Stress and Strain Measurement Using Strain Gages 171
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
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
V in
V out,A = A ð3ΔRÞ ð7:33Þ
4R
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
Δ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
xr ðt Þ = xo ðt Þ - xi ðt Þ ð7:37Þ
m €xr ðt Þ þ c x_ r ðt Þ þ k xr ðt Þ = - m €xi ðt Þ ð7:38Þ
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
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).
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
ω
r= ð7:46Þ
ωn
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
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.,
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):
Minimum of the given speed range is 3000 rpm ωmin = 60 ð2π Þ = 314:16
3000
rad=s
ω 282:86 rad=s
r= = = 3:3496
ωn 84:4106 rad=s
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
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.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.,
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):
Maximum of the given speed range is 10,000 rpm ωmax = 60 ð2π Þ = 1047:2
10000
rad=s
180 7 Sensors
ω 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
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
ω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
V - = V þ = 0, or V A = 0 ð7:54Þ
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
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
V o ðsÞ τs
= - kq ð7:60Þ
X r ðsÞ 1 þ τs
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.
ω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
1 τω
qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi = 1 α ð7:64Þ
1 - r2
1 þ ðτωÞ2
τωL
1: qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
ffi =1-α ð7:64Þ
1 þ ðτωL Þ2
1 1-α
ωL = qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð7:65Þ
τ
1 - ð1 - αÞ2
1
:1 = 1 þ α ð7:66Þ
1 - r2
rffiffiffiffiffiffiffiffiffiffiffi
α
ωH = ωn ð7:67Þ
1þα
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
T K = T C þ 273:15 ð7:68Þ
9
TF = T þ 32 ð7:69Þ
5 C
T R = T F þ 459:67 ð7:70Þ
RT = R0 ð1 þ αðT- T 0 ÞÞ ð7:71Þ
7.5.2 Thermistors
R = R0 e ð7:72Þ
7.5.3 Thermocouples
V 0 = k ðT 1- T 2 Þ ð7:73Þ
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Þ
PN PN
i = 1V i i = 1 k:ðT i - T ref Þ
Vo = = ð7:77Þ
N N
mV
V 0 = k ðT- T ref Þ = 0:054 ð698:15 - 0Þ ° C = 37:7 mV
°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
Vo 88:5 mV
V o = k:N ðT- T ref Þ, N = = =4
k:ðT - T ref Þ 0:079 mV
° C ð300 - 20Þ ° C
%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
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.
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
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.
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
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
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.
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
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
(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
(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
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
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).
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
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Þ
R = P ∙ Q ∙ ðP þ Q Þ
= P þ Q ∙ ðP þ QÞ using De Morgan’ s Law 2
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
The simplified expression can be implemented using one inverter and two
two-input AND gates, as shown in Fig. 8.8.
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 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
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
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
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
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
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).
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).
The digital circuit corresponding to the simplified Boolean expression of Eq. (8.19)
is shown using logic gates (AND, OR) in Fig. 8.12.
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
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
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 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
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
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
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.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
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).
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
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
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
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
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.
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;
}
_________________________________________________________________
Exercises
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:
(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
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
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
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 )
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.
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.
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.
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
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.
© 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
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
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
d
La ði ðt ÞÞ þ Ra ia ðt Þ = V a ðt Þ - eb ðt Þ ð9:2Þ
dt a
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
d
Jm ωðt Þ þ cωðt Þ = T ðt Þ - T L ðt Þ ð9:5Þ
dt
eb ðt Þ = k e ωðt Þ ð9:6Þ
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Þ
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).
Ra I a = V a - E b ð9:9Þ
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
Va
T s = kt ð9:15Þ
Ra
and ωmax represents the maximum (or no load) speed of the motor:
Va
ωmax = ð9:16Þ
ke
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
1
ω= ω ð9:19Þ
2 max
(a) (b)
Fig. 9.7 PM DC Motor characteristics (a) torque speed, (b) power speed
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
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
9.6.2 H-Bridge
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
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
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.
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
void loop() {
motorDirectionControl();
delay(1000);
motorSpeedControl();
delay(1000);
}
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.
40
20
Speed (rpm)
0
0 1 2 3 4 5 6 7 8 9 10
-20
-40
-60
time (s)
_________________________________________________________________
// Motor A connections
int enA = 9;
int in1 = 8;
int in2 = 7;
void setup() {
// Set all the motor control pins to outputs
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
// Turn off motors - Initial state
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
}
void loop() {
delay(1000);
// move motor CW
motorMotionCW();
motorProfile();
// move motor CCW
motorMotionCCW();
motorProfile();
}
// function to control direction of rotation of motors
void motorMotionCW() {
// set motor motion direction CW
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
}
void motorMotionCCW() {
// set motor motion direction CCW
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
}
void motorProfile() {
// Accelerate from zero to maximum speed over 1 s
for (int i = 0; i < 251; i++) {
analogWrite(enA, i);
delay(4);
}
delay(1000);
// Decelerate from maximum speed to zero
for (int i = 250; i >= 0; --i) {
analogWrite(enA, i);
delay(4);
}
// Turn off motors and wait for 1 s
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(1000);
}
_________________________________________________________________
254 9 Actuators
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.
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.
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
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.
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);
}
________________________________________________________________
% 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
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
________________________________________________________________
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.
40
Motor speed (rpm)
20
0
0 5 10 15 20 25 30
-20
-40
-60
Time (s)
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);
void loop() {
directionCW();
speedControl();
directionCCW();
speedControl();
}
// Turn on motor A
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
}
9.9 Laboratory Experiments 261
________________________________________________________________
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
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
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
© 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
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
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
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
void setup() {
// ...
}
void loop() {
int i; // variable i is accessible inside function loop()
float f; // variable f is accessible inside function 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
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).
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
}
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.
Example codes of Arduino language features discussed in Sect. 10.4 and tested on
Tinkercad are presented along with results.
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
}
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).
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
}
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);
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);
// 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);
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
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.
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)
}
}
}
}
_________________________________________________________________
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;
// 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)
}
_________________________________________________________________
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.
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.
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.
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
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.
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).
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.
© 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
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:
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
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.
The open loop system transfer function is represented for the system of Fig. 11.1, in
open loop, as
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
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.
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
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 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.
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.
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
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
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
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Þ
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
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
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Þ
8
ωgc = rad=s ð11:29Þ
t set tanðϕm Þ
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Þ
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
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Þ
r = js1 j = ωn , ð11:38Þ
The desired pole s1 must be on the root locus of the control system, i.e.,
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
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
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,
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);
%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)
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)
Fig. 11.7 Closed loop step response of the system with the PID controller
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Þ
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
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
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
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 :
π
θ = ðϕm ± 180 ° Þ - ψ = 6:9981 rad
180 °
1
KP = cos θ = 6:2269
M
1 K
KD = sin θ þ I 2 = 0:2706
Mωgc ωgc
Fig. 11.9 Bode plots of the control system: (a) without controller, (b) with PID controller
11.5 Controller Design Method 319
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
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
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)
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
K 34:45
Gp ðsÞ = =
sðτs þ 1Þ sð0:064s þ 1Þ
Fig. 11.18 Simulated closed loop step response of DC motor with controller (a) P, (b) PI, (c) PD,
(d) PID
Controller Implementation 327
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
Exercises
(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
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).
(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).
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.
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)
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.
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.
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 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
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.
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)
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
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.
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.
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
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.
Fig. 12.7 Line following with proportional control: case structure (a) true, (b) false
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
_________________________________________________________________
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
Fig. 12.8 Obstacle avoidance block diagram panel: case structure (a) true, (b) false
344 12 Mechatronic Systems
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
} // end of Sequence 1
} // end of Else
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
_________________________________________________________________
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
© 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
Bibliography
https://www.nist.gov/pml/owm/metric-si/si-units
Index
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