You are on page 1of 158

TOLERANCE

ANALYSIS
OF ELECTRONIC
CIRCUITS
"USI:NG
IVIATLAB®

Robert R. Boyd

0 CRC Press
Taylor & Francis Group
Boca Raton London New York

CRC Press is an imprint of the


Taylor & Francis Group, an informa business
Library or Coqrest Cataloging·ln-PubUcadon Data
Boyd, Robert {Robert R.)
Tolerance analysis of electronic circuits using MATI.AB I by
Robert Boyd.
p. em.
ISBN 0-8493-2276-6
I. Electronic circuits--Data processing. 2. Tolerance
(Engineering)--Data processing. 3. Electric circuit analysis-Data
processing. 4. MATI.AB. I. Title.
TK7867.B65 1999
621.3815-dc21 99-26898
CIP

This book contains infonnation obtained from authentic and higb]y


regarded sources. Reprinted material is quoted with pennission, and sources
are indicated. A wide variety of references are listed. Reasonable efforts have
been made to publish reliable data and information, but the author and the
publisher cannot assume responsibility for the validity of all materials or for
the consequences of their use.
Neither this book nor any part may be reproduced or transmitted in any
form or by any means, electronic or mechanical, including photocopying,
microfilming, and recording, or by any infonnation storage or retrieval sys-
tem, without prior permission in writing from the publisher.
The consent of CRC Press U.C does not extend to copying for general
distribution, for promotion, for creatinJ new worb, or for resale. Specific per-
mission must be obtained in writing from CRC Press U.C for such copying.
Direct all inquiries to CRC Press U.C, 2000 Corporate Blvd., N.W., Boca
Raton, Florida 33431.

Trademark Notice: Product or corporate names may be trademarks or


registered trademarlts, and are only used for identification and explanation,
without intent to infringe.

C 1999 by CRC Press UC

No claim to original U.S. Government works


International Standard Book Number 0-8493-2276-6
Library of Congress Card Number 99-26898
Preface
This book is written for the practicing electronics professional.
Knowledge of the capabilities and limitations of tolerance analysis
is a valuable asset to both the engineer and senior technician.
Tolerance analysis is necessary in several phases of the design
task, primarily to show that a circuit card, and a system of circuit
cards, will meet requirements over production life. Methods are
shown which can be used in the design process to perform worst-
case analysis, determine manufacturing yields, calculate limits for
production testing, determine if a design meets specification limits,
and for component stress analysis.
Topics include rxtreme value analysis and root-sum-square anal-
ysis using symmetric and asymmetric tolerances, Monte Carlo anal-
ysis using normal and uniform component distributions, Spice com-
parisons, sensitivity formulas, and ratiometric tolerances. Also
included are tolerance analyses of opamp offsets and anomalies of
high-Q and high-gain circuits.
Much ofthis material is not found in textbooks. 1be information
will benefit those involved in the following areas of engineering:
analog design/analysis, RF design/analysis, test, system, reliability,
and quality assurance. The book will also be of value to specification
writers, programmers, and senior technicians.
It is the author's hope that this work will fulfill the maxim of
Richard. W. Hamming:

"The purpose of computing is insight, not numbers."

iii
About the Author
Robert R. Boyd was a technical instructor in the United States
Air Force for 19 years. Upon his retirement from the Air Force in
1971, he enrolled at the University of New Mexico and obtained a
BSEE degree with honors in 1974. Mr. Boyd was employed in the
aerospace industry in anlog circuit design until 1996. He is presently
a consultant in analog circuit design and analysis and teaches a course
in the tolerance analysis of electronic circuits at the University of
California Extension (Irvine, CA).

v
Contents

PART I
Root-Sum-Square and Extreme Valuue Analysis
Derivatives and Sensitivities.....•......•.••...................••.••....•.••••...•••••..• I
Approximate Derivatives and Sensitivities ...................................... 2
Tolerance Analysis of a DC Differential Amplifier •••••••••.••••••••.•••..• 3
MATLAB M-file diffamp.m ........................................................... ll
Nominal Output = Zero.................................................................. 14
Combined Gain and Offset Analysis..••..••••..••••..•••.••••.••••..••••••••••••• 17
More Complicated Circuits ............................................................ 19
Tolerance Analysis of AC Circuits ................................................. 26
Tolerance Analysis of Bandpass Filter........................................... 29
Bandpass Filter with Asymmetric Tolerances •.•.............••.•••.....•.•.. 39
Lowpass Filter ................................................................................41
Spice Results Compared•••••••••••••••••••••••.••.•••••••••••••••••••••••••••••••••••••• 4S
Tolerance Analysis of Stability ••••.•.••.•..••..••••••••.•••.•••••.•••.••.•.••..•.•.•46

PART2
Monte Carlo Analysis
General Comments Concening RSS .............................................. 65
Uniform vs. Gaussian Distribution..•..••............•.•.....•.•••.••.•.•..•.....•• 66
Ratiometric Tolerances ····-······················································-· ·66
MCA of Opamp de Offsets ............................................................ 70
MCA of RTD Circuit ....•...•••••...••••••••.•.•.•.•.••...•.••.•..•••••••.•••••••...••••. 75
MCA of Bandpass Filter (BPF) Circuit •••.•.••••••.•.••••••••.••••••••••.•••••• 78
Fast Monte Carlo Analysis ......•...•.•.•..•..•.•...••..••••••••..•.•.•.•...••••.••.... 85
Sallen and Key BPF ....................................................................... 92

vii
viii Tolerance Analysis of Electronic Circuits

More MCAIFMCA Examples ........................................................ 99


Delyiannis BPF•.....•.••.•..•.•.•••..•.....•...•.••••....•..•.•••.•..•..•.•..•••.....•. 100
Twin-T Passive Notch Filter..•...•..•..........••.........•••.••..•..•.••.•••... l02
LTC 1562 BPF.............................................................................. 103
MFB All-Pass Filter...................................................................... I 05
NS MF10 Switched Capacitor Filters .......................................... 106
Buffered 60-Hz Notch Filter ........................................................ 109

APPENDIX
Derivation of the RSS Equation ................................................... 113
BPF Sensitivity Expressions......................................................... 115
Confidence Intervals ..................................................................... 119
Percent Yield ................................................................................. l20
Mathematical Curios..................................................................... l22
An "Accurate" Cancer Test ...................................................... 122
Easter Dates .............................................................................. 123
Number of Weekdays Between Two Datcs.............................. l24
M-file Listings .............................................................................. 125

REFERENCES............................................................................ 147
Introduction
There are three well-known tolerance analysis methods. The first two
are covered in Part 1:
1. Root-Sum-Square analysis (RSS)
2. Extreme Value Analysis (EVA) (sometimes called worst-case
analysis)
The third is covered in Part 2:
3. Monte Carlo Analysis (MCA)
The author has added a fourth method that is an application of an
old idea:
4. Fast Monte Carlo Analysis (FMCA).
As will be shown, this method exposes several weaknesses in methods
I and 2 above.
The treatment of asymmetric tolerances is neglected in what few
existing publications there are on the subject. (See References.)
Asymmetric tolerances can occur when performing design verifica-
tion analyses where the specification temperature extremes, and
hence the temperature variation of the components are most always
asymmetric. For example: -55°C to +85°C. The worst-case methods
used in circuit analysis packages derived from Spice cannot acco-
modate asymmetric tolerances. In addition, for ac circuits the sensi-
tivity portion and the resulting output of the present-day
Spice .WCASE analyses is incorrect as will be shown.
In ac analyses, especially in high-Q, high-gain filter circuits,
there are some pitfalls that the analyst must be aware of. These
anomalies will be illustrated by several examples.

ix
X Tolerance Analysis of Electronic Circuits

The fonnulas and equations given in the text are written in


MA1LAB•• 5.2 M-tiles. The M-files follow the procedural text for
about the first half of the book and the remainder are listed in the
Appendix to improve readability. TheM-tiles can be accessed at The
Mathworks FfP site: ftp://ftp.mathworks.com/pub/books/boyd.

This material is based on class notes for a course developed by


the author at the University of California Extension, Irvine, CA.

• MATLAB is a registen:d trademarlc of The MathWorts, IDe.


1 Root-Sum-Square (RSS)
and Extreme Value
Analysis (EVA)

DERIVATIVES AND SENSITIVITIES


Component sensitivities, and the required derivatives, are an integral
part of the tolerance analysis process. The component sensitivities
contain important design information for any circuit and valuable
economic information for circuits that are mass produced.
We begin with a simple voltage divider as the first example: Let
Rl = 1K3, R2 = 3K3, and the input voltage E1 = 10V. Then the
circuit output is:

Vo= El ·R2 = 10·3 =?.5


Rl+R2 1+3

We take the partial derivative of this function with respect to R2:

avo =6.25 ·10-4


oR2
The units are volts per ohm (V/n). The normalized sensitivity is
defined as:

SY =~ dy
• y dx

1
2 Tolerance Analysis of Electronic Circuits

Hence the normalized sensitivity of this circuit with respect to R2 is:

S t 2R2
='iJVo (3000)
- - = - - ·6.25·10 =0.25 _.
Vo 'iJR2 7.5

The units here are%/%, since (nN) times (V/n) = 1, i.e., dimen-
sionless. Hence if R2 increases by +1%, the output voltage will
increase by 0.25% or 7.5 ( 1.0025) = 7 .519V. Note that the normalized
sensitivity is independent of the component tolerance.

APPROXIMATE DERIVATIVES AND SENSITIVITIES


For programming purposes, the following sensitivity approximation
is developed. First, the constant dpf =0.0001
is used as a perturbation
factor as part of the derivative and normalized sensitivity approxi-
mations. The component R2 is perturbated, i.e., increased by a very
small amount:

Vr2= El·R2{l+dpf) =7.5002


R1 + R2{1 +dpf)

The approximate derivative with respect to R2 is then:

dR2 = Vr2 - Vo- 6.2495·10_.


der·R2

The quantity dR2 above is equivalent to the approximate derivative


definition:

l!t.y = f(x+l!t.x}-f(x)
l!t.x l!t.x
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 3

where ~ = dpf·R2 = 0.3Q. Now we can multiply dR2 by R2/Vo to


closely approximate the sensivity:

Sen 2 = R2. Vr2- Vo =(Vr2 -l)·-t-= 0.25


Vo der·R2 Vo der

Note that the component values cancel. However, this does not mean
the sensitivity is independent of the component value. It can be
shown that the sensitivity for R2 is:

Vo Rl
Sen2=1--=---
El Rl+R2

Using a larger number of decimal places, the relative error of St2


and Sen2 is 0.0075% and hence Sen2 is sufficiently accurate and
can be iterated with ease as will be shown later.

TOLERANCE ANALYSIS OF A DC
DIFFERENTIAL AMPLIFIER

E1

The general procedure for RSS and EVA tolerance analysis of this
simple de circuit is as follows:
4 Tolerance Analysis of Electronic Circuits

Step 1: We first define the component and input voltage values:


El =IV, E2 =-lV, Rl =ton, R2 = 1000., R3 =ton, R4 = 1000..

Step 2: The circuit output is given in functional notation as:

Step 3: The nominal value of the function is assigned to the variable


Vo:

Vo = G(Rl,R2,R3,R4,El,E2); Vo = 20V

Step 4: Since there are six components to be toleranced (4 resistors


and 2 input voltages), a component counter p is next created with
N= 6; p= l...N.

Step 5: A square perturbation matrix Q is then created by multiply-


ing anN x N identity matrix by dpf and adding 1, or Q = dpf ·I+
1. The Q matrix will then be:

1.0001
1 1.0001
1 1 1.0001
Q=
1 1 1.0001
1 1.0001 1
1 1 1.0001

(The Q matrix is displayed for tutorial purposes, and need not be


shown again.)
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 5

The Q matrix will always:

1. Have 1.0001 = 1 + dpf on the main diagonal.


2. Be of dimension N x N (number of components x number
of components), i.e., square.
3. Have l's in every position but the main diagonal.

Step 6: Together with component counter p, we perturbate each


component of the circuit one at a time while the remaining compo-
nents remain unchanged in value. This is accomplished as follows:

For example, when p = 2, R2 is multiplied by Qu = 1.0001, while


the other components are multiplied by 1.0 and unchanged in value.
When counter p has cycled through to N, Vr then is the
N-element vector:

Vr = [19.9981 20.0019 19.9999 20.0001 20.0010 20.0010)

Note that the 1st and 3rd elements are less than the nominal value
of Vo = 20, and that the relt'aining elements are greater than Vo. In
other words, R 1 and R3 have a negative sensitivity sign, while the
remaining components have a positive sensitivity sign.

Step 7: Using the previously given equation for the approximate


sensitivities:

Vr ) 1
Sen, = ( V~ - 1 · dpf
6 Tolerance Analysis of Electronic Circuits

which gives:

Sen= [-o.9S4 0.955 -0.045 0.045 0.5 0.5]

The sensitivities of R 1 and R2 are over an order of magnitude larger


than those for R3 and R4. This should not be surprising as Rl and
R2 appear twice in the circuit function, while R3 and R4 appear only
once in the first denominator. Hence it is feasible to use less precise
resistors for R3 and R4, thereby yielding a manufacturing cost sav-
ings.

Step 8: The next task is to determine the component tolerances


which are obtained from the component data sheet. In this example,
the resistor tolerances will be ±1% (Tr = 0.01), while the input
voltages are assigned a ±5% tolerance (Te = 0.05). A 2 x N array of
tolerances is created:

-Tr -Tr -Tr -Tr -Te -Te]


T= [
Tr Tr Tr Tr Te Te

Note that the column order is Rl, R2, R3, R4, El, E2 and that the
tolerances are symmetric.

Step 9: Create a new tolerance array M with the tolerance rows


swapped only if the sensitivity is < 0. In MATI.AB• script this is:

for p=l:N
i f Sen(p)>O
M(l,p)=l+T(l,p);M(2,p)=l+T(2,p);
else
M(l,p)=l+T(2,p);M(2,p)=l+T(l,p);
end
end
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 7

If the sensitivity is < 0, this block of code will replace the negative
tolerance with the corresponding positive tolerance plus 1. The result
is stored in array M. If the sensitivity is > 0, it merely copies the
tolerance + I into M. The result is:

l+Tr 1-Tr l+Tr 1-Tr 1-Te 1-Te]


M= [
I-Tr I+Tr 1-Tr I+Tr I+Te 1+Te

1.01 0.99 l.OI 0.99 0.95 0.95]


= [ 0.99 l.OI 0.99 l.OI 1.05 l.OS

Step 10: Now create a low-high row counter k = 1,..2, and plug the
M elements into the circuit function as follows:

The extreme values are contained in the 2 x I column vector Vev:

Vev= [ 18.624] !J.Vev=Vev-Vo= [-1.376]


21.424 1.424

Step 11: Before computing the RSS values, some definitions are in
order.

Definition or RSS: The variance of any function (linear or non-


linear) is defined (Ref. 7) as follows:
8 Tolerance Analysis of Electronic Circuits

where the~ denotes components such as R 1, R 2, <;,etc., and Var


(XJ is the squared standard deviation. This equation assumes the
components are statistically independent; i.e., uncorrelated. A normal
(Gaussian) distribution of components is assumed so that the stan-
dard deviation of a resistor R1 is:

QIU = R(T
3
1

(This assumption of component normality may at times be unjusti-


fied.) For a circuit with three resistors R 1, R 2, and R 3, the variance
of the output voltage is:

The first term above can be approximated by:

(
AYo·R1
3·AR
·1j) 2 2
=(AVo ·T1 ) =(AYo ·T1)
3·A 3·dpf
2

Using AVrs as the variable name for~ (the three sigma value of
the output), the expression for AVrs is:

The sensitivities are:

AVo, AVo,
Sen = , Sen = , etc.
' Yo · dpf • Yo · dpf
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 9

Then solving for the /!No's, !Nrs becomes:

This equation shows that RSS analysis is strongly dependent on the


sensitivity-tolerance products.
Now we can calculate the RSS value since we have all the
required inputs. There are two equation forms that will provide the
same answers for synrmetric tolerances.

~Yrst =(-1)k·Yo·~(
' Sen,-Tt.p)2 (1~ ~Yrs= [-{).757]
.
0 757

~Yrs and ~Yrss are then added to Yo to get the -3o and +30 values
of 19.243 and 20.757.
The (-l)k is added as a convenience so that both elements can be
added to Yo.
To show where form (2) is used, we change the tolerance array
T to asymmetric tolerances Ta:

-Tr -Tr -Tr -Tr -Te -Te]


Ta= [
0.03 Tr O.Q3 Tr Te Te

We modify the if statement for array M as

for p=l:N
i f Sen(p)>O
Ma(l,p)=l+Ta(l,p);Ma(2,p)=l+Ta(2,p);
else
Ma(l,p)=l+Ta(2,p);Ma(2,p)=l+Ta(l,p);
end
end
10 Tolerance Analysis of Electronic Circuits

and Ma-l is:

0.03 - Tr 0.03 - Tr - Te - Te]


Ma-l=
[ -Tr Tr -Tr Tr Te Te

since Sen(l) and Sen(3) are< 0. J!Vrs and J!Vrss now become:

i!V~ =(-1)t ·Vo·~(


' Sen,-Tat.p )1 (1~ J!Vrs= [....0.757]
0. 30
9

The error in J!Vrs with asymmetric tolerances is because the squaring


process prevents the sensitivity signs from exerting any influence on
the answers, which implies that all sensitivities are > 0. This is
obviously incorrect. Hence by swapping the tolerances rows prior to
squaring in the RSS formula, the negative signed sensitivities and
tolerances can properly affect the calculation.
To corroborate that !J.Vrss is correct, we recalculate the extreme
values using the new asymmetric tolerances:

This gives new values of:

18.262] [-1.738]
Veva= [ 1. J!Veva=Veva-Vo= 1.
2 424 424
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 11

Hence the swapped 3% tolerances cause the low side (-1.738) to be


pulled down farther than the high side is increased (+1.424). Thus,
it makes sense that the RSS values should be similarly skewed as ll.Vrss
is. This will be further verified in Part 2, "Monte Carlo Analysis."
When specifying test limits, the tolerance of the measuring
device (DVM, scope, etc.) must be included. A de measurement of
the differential amplifier would be done with a DVM and we assign
a 2% tolerance (Tm = 0.02) to this device. Either the RSS or EVA
limits should be widened by multiplying by 1 ± Tm. For example
= =
Veva1 18.262 becomes 18.262(0.98) 17.897, and Veva2 21.424 =
becomes 21.424(1.02) = 21.852.
It has been the author's experience that some circuit designers,
due to time and schedule constraints, will specify ±5% or ±10% test
limits and be done with it. If 5% is too tight, the engineer must deal
with marginal failures with time spent troubleshooting good circuit
cards. If 10% is used and it is too wide, then what sometimes happens
is that the card fails at system level when it should have failed at
card level. Hence time spent doing tolerance analysis, using valid
system specification limits, is time well spent.

MATLAB M-FILE DIFFAMP.M


In order to exploit the extensive matrix capabilities of MA'ILAB,
the nodal equations for the differential amplifier are used to create
matrix A and column vector B as follows:

I 1 E1
-+-
Rl R2
0 0
R2
-R1
I -I 0 0 0
A= B=
1 1 E2
0 0 -+- -
R3 R4 R3
0 Ao -Ao 0
12 Tolerance Analysis of Electronic Circuits

where Ao = the opamp open-loop gain= 1Q6. ln MA1LAB script


notation, this is easily solved using C = A\B. The output voltage
node 4 is then obtained from row 4 of the C solution vector.

The M-file diffamp.m is given below:


' File diffamp.m
' de differential amplifier
clear;clc
'' Step 1 Assign component values
'
R1=10;R2=100;R3=10;R4=100;E1=-l;E2=1;Ao=1e6;
'' Step 2 Create A matrix & B input vector
'
A=zeros(4);
A=[1/R1 + 1/R2 0 0 -1/R2; .•.
1 -1 0 0; 0 0 1/RJ + 1/R4 0; • ••
0 Ao -Ao 1);
B=[E1/R1;0;E2/R3 ; 0);
'' Step 3
'
C=A\B;Vo=C(4) ;
'' Steps 4 & 5
'
N=6;dpf=0.0001;Q=dpf•eye(N)+l;

'' Step 6 Perturbate circuit function with diagonal


elements of Q

for p=1:N
A=(1/(R1*Q(p,1))+1/(R2*Q(p,2)) 0 0
-1/(R2*Q(p,2));1 -1 0 0; 0 0 .•.
1/(R3*Q(p,3))+1/(R4*Q(p,4)) 0; .•.
0 Ao -Ao 1);
B=[E1*Q(p,5)/(R1*Q(p,1));0; ...
E2*Q(p,6)/(R3*Q(p,3));0);
C=A\B;Vr=C(4);
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 13

'II
'II Step 7 Calculate normalized sensitivities
'II
Sen(pl=CVr/Vo-1)/dpf;
end
'II
'II Step 8 Create tolerance array T
'II
Tr=0.01;Te=O.OS;
T=[-Tr -Tr -Tr -Tr -Te-Te; ...
Tr Tr Tr Tr Te Tel;

'II Step 9 Create new tolerance array M per


sensitivity signs

for p=1:N
i f Sen(p)>O
M(1,p)=1+T(1,p);
M(2,p)=1+T(2,p);
else
M(1,p)=1+T(2,p);
M(2,p)=1+T(1,p);
end
end
'II
'II Step 10 Calculate EVA values
'for k::1:2
A=[1/(R1*M(k,1))+1/(R2*M(k,2)) 0 0 ...
-1/(R2*M(k,2));1 -1 0 0; ...
0 0 1/(R3*M(k,3))+1/(R4*M(k,4)) 0; .•.
0 Ao -Ao 1]; B=[E1*M(k,5)/(R1*M(k,1));0; ...
E2*M(k,6)/(R3*M(k,3));0];
C=A\B;Vev(k)=C(4);
end
'II
' Step 11 Calculate RSS values
'II
swn1=0;swn2=0;
for p=1:N
swn1=swn1 + (Sen(p)*(M(1,p)-1))A2;
swn2=swn2 + (Sen(p)*(M(2,p)-1))A2;
end
14 Tolerance Analysis of Electronic Circuits

Vrss(1)=Vo*(1- sqrt(sum1));
Vrss(2)=Vo*(l + sqrt(sum2));
Von=[Vo Vo);V1=[Vrss;Von;Vev);

'
% Send output to text file 'Output.txt'

'
fid=fopen('Output.txt', 'w');
fprintf(fid, 'Differential Amplifier\r\n');
fprintf(fid,'RSS NOM EVA\r\n');
fprintf(fid,'%3.3£ %3.3£ %3.3f\r\n',V1);
status=fclose(fid);

'% Send output to screen


'
format compact
Title=sprintf('Differential Amplifier\r •..
RSS NOM EVA \n' )
Output=sprintf('%3.3£ %3.3f %3.3f\n',V1)

The output file Output.txt is:

Differential Amplifier
RSS NOM EVA
19.243 20.000 18.624
20.757 20.000 21.424

NOMINAL OUTPUT= ZERO


It sometimes happens that a circuit is designed for a nominal output
=
ofVo 0. For example: if the above differential amplifier (diff amp)
was used for common-mode rejection (CMR), it would be handy to
know what the worst-case CMR was using 1% resistors and then
using 0.1% resistors.
We soon discover is that we cannot calculate the normalized
=
sensitivities because this entails dividing by Yo 0. The following
MA1LAB M.file diffamp2 shows the slightly modified sequence.
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 15

t File diffamp2.m
t de differential amplifier with Vo = 0
t function DA2.m used to decrease required code
clear;clc
'
Rl=l0;R2=100;R3=10;R4=100;El=l;E2=l ; Ao=le6;
'
Vo=DA2(Rl,R2,R3,R4,El,E2,Ao);
'
Nc=6;dpf=O.OOOl;Q=dpf*eye(Nc)+l;

'forVr(p)=DA2(Rl*Q(p,l),R2*Q(p,2),
p=l:Nc
. ..
R3*Q(p,3),R4*Q(p,4), ...
El*Q(p,5),E2*Q(p,6),Ao);
end
t Sensitivities cannot be calcuated; Vo=O
'
Tr=O.Ol;Te=O;
T=[ -Tr -Tr -Tr -Tr -Te-Te; ...
Tr Tr Tr Tr Te Tel;

for p=l:Nc
i f Vr(p)>O
M(l,p)=l+T(l,p);M(2,p)=l+T(2,p);
else
M(l,p)=l+T(2,p);M(2,p)=l+T(l,p);
end
end
%
for k=l:2
Vev(k)=DA2(Rl*M(k,l),R2*M(k,2), ...
R3*M(k,3),R4*M(k,4), . . .
El*M(k,5),E2*M(k,6),Ao);
end
'suml=O;sum2=0;
for p=l:Nc
suml=suml + (Vr(p)*(M(l,p)-l))A2;
sum2=sum2 + (Vr(p)*(M(2,p)-l))A2;
end
Vrss(l)=-sqrt(suml)/dpf;
16 Tolerance Analysis of Electronic Circuits

Vrss(2)=sqrt(sum2)/dpf;
Von=[Vo Vo);V1=[Vrss;Von;Vev);
'fid=fopen('OUtput.txt', 'w');
fprintf(fid, 'Diff Amp, Vo = 0\r\n');
fprintf(fid, 'RSS NOM EVA\r\n');
fprintf(fid,'%3.2e %3.2e %3.2e\r\n',V1);
status=fclose(fid);
s1='Diff Amp Vo = 0\';
s2='r RSS NOM EVA';
s3=strcat(s1,s2);
Title=sprintf(s3)
0Utput=sprintf('%3.2e %3.2e %3.2e\n',V1)

Function DA2.m file is:

function y = DA2(R1,R2,R3,R4,E1,E2,Ao);
% function for de diffamp
A=[1/R1 + 1/R2 0 0 -1/R2;1 -1 0 0; ...
0 0 1/R3 + 1/R4 0; .•.
0 Ao -Ao 1);
B=[El/R1;0;E2/R3;0);
C=A\B;y=C(4);

Note the equation fonn used to calculate Vrss.

The output file 'Output.txt' is:

Diff Amp, Vo = 0
RSS NOM EVA
-1. 82e-003 O.OOe+OOO -3.64e-003
1.82e-003 O.OOe+OOO 3.63e-003

When 1% resistors are used the output becomes:

Diff Amp, Vo = 0
RSS NOM EVA
-1.82e-002 O.OOe+OOO -3.70e-002
1.82e-002 O.OOe+OOO 3.57e-002
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 17

an order of magnitude increase. From these numbers the CMR due


to the component tolerances in dBV can be calculated.

COMBINED GAIN AND OFFSET ANALYSIS


Another situation that arises is having to contend with opamp or
other device offsets in addition to the gain variation of the circuit.
1be following example uses a voltage divider with some offset volt-
age Vos, followed by a gain ratio of two resistors: R3 and R4.

The input voltage is 15V. The offset is 4mV and the nominal
circuit output is 4.396V.
For Step 11, when Vos is non-zero, and comparing with the RSS
term:

Note where counters p = 1,Nc and q = 1, Nc-1 are used.


M-file diffamp3 showing the calulation sequence is:

\File diffamp3.m
\ Combined gain and offset analysis
\ function not used
clear;clc
\ Step 1
R1=75000;R2=1000;R3=20000 ; R4=898;E1=15;Vos=0.004;
\ Step 2 & 3
Vo=(E1*R2/(R1+R2)+0)*R3/R4;
'15 Step 4 & 5
Nc=6;dpf=0.0001;Q=dpf*eye(Nc)+l;
\ Step 6
for p=1:Nc
Vr(p)=(El*Q(p,l)*R2*Q(p,3)/ ...
(R1*Q (p, 2) +R2*Q (p, 3)) +Vos* ( (Q (p, 6) -1) /dpf)) ...
*R3*Q(p,4)/(R4*Q(p,S));
end
18 Tolerance Analysis of Electronic Circuits

c'No=Vr(Nc)-Vo;
% Step 7
for q=1:Nc-1;Sen(q)=((Vr(q}/Vo)-1)/dpf;end
% step 8
Tr=0.01;
T=[-Tr -Tr -Tr -Tr -Tr -vos;Tr Tr Tr Tr Tr Vos];
% Step 9
for q=1:Nc-1
i f Sen(q)>O
M(1,q)=1+T(1,q);M(2,q)=1+T(2,q);
else
M(1,q)=1+T(2,q);M(2,q)=1+T(1,q);
end
end
% step 10
for k=1:2
Vev(k)=(E1*M(k,1}*R2*M(k,3}/ ••.
(R1*M(k,2)+R2*M(k,3))+T(k,Nc)) ...
*R3*M(k,4}/(R4*M(k,5));
end
% Step 11
sum1=0;sum2=0;
for q=1:Nc-1
sum1=sum1 + (Sen(q)*(M(1,q)-1))A2;
sum2=sum2 + (Sen(q}*(M(2,q)-1))A2;
end
sum1=sum1+(c'No/Vo)A2;sum2=sum2+(c'No/Vo)A2;
Vrss(1)=Vo*(1-sqrt(sum1));
Vrss(2)=Vo*(1+sqrt(sum2));
Von=[Vo Vo];V1=[Vrss; Von; Vev];
% output to text file and command window
fid=fopen ('Output. txt', 'w');
fprintf(fid,'Combined gain & offset\r\n');
fprintf(fid,'RSS NOM EVA\r\n};
fprintf(fid,'%3.3f %3.3f %3 .3f\r\n' ,Vl);
status=fclose(fid);
s1='Combined gain & offset';
s2='\rRSS NOM EVA';
s3=strcat(sl,s2);
Title=sprintf(s3)
Output=sprintf('%3.3£ %3.3f %3.3f\n',Vl)
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 19

The output is:

Combined gain & offset


RSS NOM F:VA
4.263 4.396 4.095
4.528 4.396 4 . 711

MORE COMPLICATED CIRCUITS


The worst-case analysis steps are now fairly straightforward, given
that a mathmatical description of circuit output is available. If the
transfer function is too complicated due to the large order of the
circuit, then the analysis is no more difficult using matrices. The
matrices (the square A coefficient matrix and the B column vector)
just become bigger.
As has been alluded to previously, there is a circuit-analysis
method that is given in just about every undergraduate text on circuit
or network analysis. It is a mnemonic method used for passive
circuits derived from the nodal analysis method. No controlled
sources could be used as this would destroy the symmetry of the
coefficient matrix and presumably the utility of the method.
The method entails creating the coefficient matrix by inspection
of the circuit. On the main diagonal of the matrix, all the reciprocal
impedances (admittances) are added together if they are connected
to that particular node represented by the row-column of the matrix.
All off-diagonal elements are the negative reciprocals of impedances
connected between the nodes.
The following example is given of a circuit the author was
required to analyze while working for a company on the International
Space Station project. Management did not want an extreme value
analysis (EVA) since, they believed, that went out with the cold war.
They desired RSS only. In addition, the temperature extremes of the
space station environment, +35°C to -80°C, created asymmetric
tolerances for the resistors. This eliminated Spice-derived analysis
20 Tolerance Analysis of Electronic Circuits

packages on two counts: (l) only EVA can be performed (.WCASE)


and (2) asymmetric tolerances were involved.
The circuit was an RTD (resistive-temperature-detector) temper-
ature sensing circuit with an output of -SV when the RTD resistor
was IK (0°C), and +5V when the RID was 2K (+260°C). The
following gives an overview of the circuit and requirements:

Component values: Rl = 4.53K, R2 = 34.81(, R3 = l32K, R4


= 9.09K, R5 = 9.09K, R6 = 4.53K, R7 = 27.41(, RT = 191.5 (RTD
sensor), El = S, E2 = -.5 (precision references).

Tolerance analysis task requirements:

1. No transfer function available


2. Can use Spice for EVA
3. However, requires RSS analysis (which rules out Spice)
4. Component tolerances asymmetric (again rules out
Spice)
S. Accuracy spec: ±5°C.

RJ
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 21

Task requires a relatively simple circuit analysis method other than


Spice. The somewhat cumbersome transfer function obtained from
a shareware program is:

81 = R~R4 · R7 · R2 + R3{R4(Rl + R5 + 2R7)+ R5{Rl- R2)}]

82 = Rl[R4{R5·R3-R7 ·R2)+R5· R2· R3] N2 = Bl +82

02 = R~R4{Rl(R6+ R5+ R7)+ R6(R5+ R7)}+ Rl· R6 · R5]

Al=R3{(Rl+R4)(RS+R6)]-R2[R7(Rl+R4)+R3(RS+R6+2R7)]

A2 = R2{(Rl+R4)(RS+R6+R7))

2 2
Nl=RT·Al Dl=RT·A2 Vo= E (Nl+N ) Vo=4.326V(242°C)
01+02

Since the circuit has five nodes, a 5th order matrix is required. By
inspection of the circuit diagram above, the creation of the first four
rows, corresponding to nodes VI through V4, is a simple book-
keeping task. We start with node V 1 and main diagonal element
A(l,l) in the upper left-hand comer and proceed down to the lower
right comer:

and so forth. For the off-diagonal elements, we see from the diagram
that RT is connected between nodes VI and V2, R4 is connected
between nodes VI and V3. Hence the A coefficient matrix will be
as follows:
22 Tolerance Analysis of Electronic Circuits

1 1
-+-+-
1
Rl R4 RT
-RT
-1 -1
R4
0 0

-1 1 1 1 -1
-+-+- 0 0
Rt RT R5 R6 RS

A= -1 1 1 1 -1
- 0 -+-+- 0
R4 R2 R3 R4 R3
-1 1 1
0 0 -+- 0
RS RS R7

0 0 Ao -Ao

Note what symmetry there is, e.g., A(l,2) =-1/RT =A(2,1).


=
For the last row, the equation for the output node is VS Ao
=
(V4- V3) Ao·Y4- Ao·Y3, where Ao is the open loop gain of the
opamp and is on the order of 120 dBV or 1()6 VN. With unknowns
on the LH side, the equation is V5 - Ao·V4 + Ao·V3 =0. Hence the
coefficient +Ao in the 3rd column for V3, the -Ao in the 4th column
for V4, and the 1 in the 5th column for VS.
The partial input currents from the precision references E1 and
E2 are E21Rl for node 1 (the first row), El/R6 for node 2, and El/R2
for node 3. Hence the input column vector (transposed to a row
vector for printing) is:

B=[E2 !!_E.!_ 0
Rl R6 R2
o]T

Cramer's Rule can be used to solve for V5 only. Hence the B 1 matrix
below is created by replacing the last column of the A matrix with
the B vector.
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 23

1 1 1 -1 -1 E2
-+-+- 0
Rl R4 RT RT R4 Rl
-1 1 1 1 -1 El
-+-+- 0
RT RT R5 R6 R5 R6

81= -1 1 1 1 El
0 -+-+- 0
R4 R2 R3 R4 R2
-1 1 1
0 0 -+- 0
R5 R5 R7

0 0 Ao -Ao 0

The nominal output is then the detenninant of 8 1 over the detenni-


nant of A and= 4.326V for an RT value of 1.915K.
In using Cramer's Rule, two large matrices must be created
which can be somewhat cumbersome. Using MATLAB's agility with
solving simultaneous equations, we use instead the MATLA8
expression C=A\8.
Once we have a means of solving the circuit, either by matrices
or by circuit functions, the tolerance analysis step-by-step procedure
is the same and is summarized below:

Step 1: Define the nominal component values.

Step 2: Create the circuit function or matrices.

Step 3: Calculate the nominal output.

Step 4: Create component counter p = l...N, with N the number of


component and inputs to be toleranced.

Step 5: Create the perturbation matrix Q = dpf·identity(N) + 1.


24 Tolerance Analysis of Electronic Circuits

Step 6: Using the Q matrix elements and the circuit function or


matrices, perturbate each component separately, i.e., get Vr(p).

Step 7: Determine the sensitivities Sen(p).

Step 8: Determine component tolerances and create the 2 x N tol-


erance array T.

Step 9: Create the tolerance array M with rows of T swapped if


S~<O.

Step 10: Get the EVA output Vev by using the circuit function or
matrices multiplied by elements of array M.

Step 11: Get the RSS output Vrss.

The following MA11..AB file analyzes the RTD circuit. Note that
once the initial A matrix and 8 vector is formed, the formation of
the subsequent matrices can be facilitated by using MATI..AB func-
tions, which are much like subroutines and hence save rewriting the
large matrices. The following M-file uses a function named G2.m.

'II File rtdrss.m


'II Tolerance analysis of RTD circuit
' uses MATLAB function G2.m
clear;clc
'II Step 1
Rl=4.53;R2=34.8;R3=132;R4=9.09;R5=9.09;R6=4.53;
R7=27.4;RT=1.915;
El=S;E2=-5;Ao=le6;
'II Step 2 & 3
Vo=G2(Rl,R2,R3,R4,RS,R6,R7,RT,El,E2,Ao);
'II Step 4 and Step 5
N=9;der=0.0001;Q=der*eye(N)+l;
'II Step 6
for p=l:N
VS(p)=G2(Rl*Q(p,l),R2*Q(p,2),R3*Q(p,3), .•.
R4*Q(p,4),R5*Q(p,5),R6*Q(p,6),R7*Q(p,7), •.•
RT*Q(p,8),El*Q(p,9),E2*Q(p,9),Ao);
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 25

% Step 7
Sen(p)=((VS(p)/Vo)-1)/der;
end
% Step 8
Tinit=0.001;Tlife=0.002;ppm=1e-6;TC1=50*ppm;
TC2=25*ppm;
Thi=Tinit+Tlife+3S*TC1;T1o=-Tinit-Tlife-80*TC1;
Trhi=8.1e-4;Trlo=-Trhi;Treflo=-0.02-80*TC2;
Trefhi=0 . 02+3S*TC2;
T=[ Tlo Tlo Tlo Tlo Tlo Tlo Tlo Trlo Treflo; ...
Thi Thi Thi Thi Thi Thi Thi Trhi Trefhi);
% Step 9
for p=l:N
if Sen(p)>O
M(l,p)=l+T(l,p);M(2,p)=l+T(2,p);
else
M(l,p)=1+T(2,p);M(2,p)=l+T(l,p);
end
end
% Step 10
for k=1:2
Vev(k)=G2(Rl*M(k,l),R2*M(k,2),R3*M(k,3), ...
R4*M(k,4),RS*M(k,S),R6*M(k,6), ...
R7*M(k,7),RT*M(k,8),El*M(k,9),E2*M(k,9),Ao);
end
% Step 11
suml=O;sum2=0;
for p=l:N
suml=suml + (Sen(p)*(M(l,p)-l))A2;
sum2=sum2 + (Sen(p)*(M(2,p)-1))A2;
end
Vrss(1)=Vo*(l-sqrt(suml));
Vrss(2)=Vo*(l+sqrt(sum2));
Von=[Vo Vo);Vl=[Vrss;Von; Vev);
% output to text file and command window.
fid=fopen('Output.txt', 'w');
fprintf(fid, 'RTD Circuit\r\n');
fprintf(fid, 'RSS NOM EVA\r\n');
fprintf(fid, '%3.3£ %3.3£ %3.3f\r\n',Vl);
st~tus=fclose(fid);
Title=sprintf('RTD Circuit\rRSS NOM EVA')
Output=sprintf( ' %3 . 3£ %3 . 3£ ,3.3£\n',Vl)
26 Tolerance Analysis of Electronic Circuits

The function G2.m called in the above file is:

function y = G2(Rl,R2,R3,R4,RS,R6,R7,RT,El,E2,Ao)
' mea for rtd function
A=zeros(5);
A(l,l)=l/Rl+l/R4+1/RT;A(l,2)=-l/RT;A(l,3)=-l/R4;
A(2,l)=A(l,2);A(2,2)=1/RS+l/R6+1/RT;A(2,4)=-l/RS;
A(3,l)=A(l,3);A(3,3)=1/R2+1/R3+1/R4;A(3,5)=-l/R3;
A(4,2)=A(2,4);A(4,4l=l/RS+l/R7;
A(5,3)=Ao;A(S,4l=-Ao;A(5,5)=1;
B=(E2/Rl;El/R6;El/R2;0;0];C=A\B;y=C(5);

The output is:

RTD Circuit
RSS NOM EVA
4.139 4.326 3.869
4.527 4.326 4.841

Tile accuracy specification was ±S°C which converts to I 0/26 =


0.385V. Tile RSS spread is /l.Vrss = 4.527-4.139 = 0.388V, which
is only slightly out of specification. The EVA spread is of course
larger. The RSS numbers above will be verified when MCA tech-
niques are covered.

TOLERANCE ANALYSIS OF AC CIRCUITS


Prior to any tolerance analysis of ac circuits, a simple circuit will be
analyzed using MATI.AB to illustrate the general method. The circuit
used is a bandwidth limited differentiator.
In this circuit, the inverse of a series RC circuit (admittance) is
developed as follows:

Z(s)=R+_!_= sRC+l, I Y() sC


sC sC Z{s) = s = sRC+l
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 27

The circuit schematic and M-file:


% Bandwidth Limited Differentiator
% File: bwdiff.m
clear;clc
% Component values
Rl=l000;R2=10000;Cl=10e-9;
BF=3; % beginning log frequency lOABF
ND=4; % number of decades
PD=20; % points per decade
wl=2*pi*lOO;w2=2*pi*le6;Ao=le5 ;
% oppamp characteristics
FM=linspace(BF,BF+ND,ND*PD+l);
% log Freq linear scale
for i=-l:ND*PD+l
F(i)=l0AFM(i);s=0+2*pi*F(i)*j;
% s = jw
Aol=Ao/((l+s/wl)*(l+s/w2));
% opamp open loop gain
Op(i)=20•log10(abs(Aol));
% dBV

'% create A matrix and


% B input column vector

'
A=[({s*Cl)/(s*Rl*Cl+l)+l/R2) -l/R2;Aol 1];
B=[s*Cl/(s*Rl*Cl+l);O];
Va=A\B;Vo(i)=20*log10(abs(Va(2)));
% output in dBV
end
'% plot results
'
h=plot(FM,Vo,'k',FM,Op, 'k');
set(h,'LineWidth ' ,2)
grid on
axis([BF BF+ND -20 80))
xlabel('Log Freq (Hz) ');ylabel('dBV')
title('Fig.l BW Limited Diff Amp')
% Option - print to graphics file
\print -dlneta bwlim
\print -dhpgl bwlim
\print -dbitmap bwlim
28 Tolerance Analysis of Electronic Circuits

C1 R1 Vn R1
E~~~~~~~~--~

Vo

The results are plotted in Figure 1 which shows the opamp open loop
gain and the closed loop opamp output. The bandwidth limiting effect
of the opamp rolloff can clearly be seen.

1:~7 ~-
-10

-20L;-----~----......l-;-------'-;-----.Ji
1~ 1~ 1~
FAOQ fliz,l
1f
""\" 1~

FIGURE 1 BW Limited Diff Amp.


Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 29

TOLERANCE ANALYSIS OF BANDPASS FILTER


With this background in MATI..AB ac analyis methods, we are ready
to perform a RSS and EVA analysis of a bandpass filter (BPF) shown
below. This type of BPF is known as multiple feedback BPF since
there are two feedback paths via R3 and C2.

Step 1: The filter has a center frequency of fo = 500 Hz and a pole


Q = 20. The component values then are R 1 =6.34K, R2 = 80.63,
=
R3 =127K. The capacitor values are C 1 C2 =0.1uF. The MA1LAB
setup uses a linear frequency sweep instead of a log sweep as in the
previous example:

BF = 400 (Beginning frequency in Hz)


DF = 2 (Frequency increment in Hz)
LF = 600 (Last frequency in Hz)

Increment counter:

· =l .. •(LF-BF)
I DF +l
30 Tolerance Analysis of Electronic Circuits

Frequency in Hz:

F1 =BF+DF(i-1}

Laplace transform:

Step 2: In setting up the following A coefficient matrix, the opamp


characteristics are ignored and V2 (virtual ground node) is assumed
zero at all frequencies. Then the equation for node VI is:

El-Vl VI
- - = - + ( V I - V3}·s C2+ Vl ·s Cl
Rl R2 I I

Rearranging for insertion into the A coefficient matrix:

l 1
V ( -+-+sCl+sC2) -V3 ·sC2=-
ffi
Rl R2 I I I Rl

and similarly for node V2; El is set= to 1 + jO. Matrix A is then:

and the 8 column vector is


Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 31

The nominal output Yo will be shown along with the RSS and EVA
plots.

Step 4: N = 5 p = l...N dpf= 0.0001

Step 5: Q = dpf.identity(N) + 1

Step 6: New matrices A and 8 are created for perturbation by


elements of Q.

·+·~~]
C =A\8, Yr~.p =C(2);

Step 7: Get sensitivities:

Sen
t.p
=( ~-1-
Yr
1
Yo
1
dpf
)

Step 8: Resistor tolerances 2%; Tr = 0.02; capacitor tolerances I 0%;


Tc = 0.1 (symmetric tolerances).

T= [
-Tr -Tr -Tr -Tc -Tc]
Tr Tr Tr Tc Tc
32 Tolerance Analysis of Electronic Circuits

Step 9: In de analysis, this is the point where tolerances are swapped


if Sen < 0. With ac analysis, a slight modification of this step is
necessary because of the 3rd frequency dimension k, p, and i. Hence
the M array is separated into a L (for low) array and a H (for high)
array as follows:

Step lOa: EVA low:

·+:L,l
Step lOb: To get EVA high, we replace the L's in the above matrices
with H's. See the following M-file.

Step 11: The RSS output is, using both Land H:

Vml, =vo.[1-P,:[s.a._{L.. -l)f]

Vm2, = Vo.[I+P,:ts.a._(H.. -l)r l


Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 33

The M-file that does all this is shown below:

\ MFB Bandpass Filter RSS & WCA


\File: b.Pfrss3.m using function Gl.m
clear;clc
Rl=6340;R2=80.6;R3=127000;Cl=O.l*le-6;C2=Cl;
BF=400;LF=600;DF=l;
Nc=S;dpf=O.OOOl;Q=dpf*eye(Ncl+l;
\ Form symmetric tolerance array T
Tr=0.02;Tc=O.l;
T=[-Tr -Tr -Tr -Tc -Tc;Tr Tr Tr Tc Tc];
\ Start ac analysis
F=linspace(BF,LF, (LF-BF)/DF+l);
for i=l: (LF-BF)/DF+l
s=0+2*pi*F(i)*j;
D=Gl(Rl,R2,R3,Cl,C2,s);
Vo(i)=D;
for p=l:Nc
F(i)=BF+OP*(i-l);s=0+2*pi*P(i)*j;
D=Gl(Rl*Q(p,l),R2*Q(p,2),R3*Q(p,3), ...
Cl*Q(p,4),C2*Q{p,S),s);
Vr(i,p)=D;
Sen(i,p)=(Vr(i,p)/Vo(i)-1)/dpf;
i f Sen(i,pl>O
L(i,p)=l+T(l,p);H(i,p)=l+T(2,p);
else
L(i,p)=l+T(2,p);H(i,p)=l+T(l,p);
end
end

Ill get EVL & EVH


for k=1:2
for p=l:Nc
if k==l
M(i,p) =L{i,p);
else
M(i,p)=H(i,p);
end
end
D=Gl(Rl*M(i,l),R2*M{i,2),R3*M(i,3), ...
Cl*M(i,4),C2*M(i,S),s);
34 Tolerance Analysis of Electronic Circuits

if k==l
VL(i) =D;
else
VH(il=D;
end
end
'\ get rss
' suml(i)=O;sum2(il=O;
for p=l:Nc
suml(il=suml(i)+(Sen(i,p)*(L(i,p)-l))A2;
sum2(il=sum2(i)+(Sen(i,p)*(H(i,p)-l))A2;
end
Vrssl(il=Vo(i)*(l-sqrt(suml(i)));
Vrss2(i)=Vo(il*(l+aqrt(sum2(illl;
end

'
aubplot(2,2,1)
h=plot ( F, Sen ( : , 1 l , 'k' , F, Sen ( : , 2 l , 'm' , ...
F, Sen ( : , 3 l , ' c ' l ;
hold on
g=plot(F,Sen(:, 4), 'r', F, Sen(:, 5), 'g' l;
set(h, 'LineWidth',ll;set(g, 'LineWidth',l)
grid on
axis([BF LF -15 15))
xlabel('Freq (Hz)', 'Fontsize',Sl
ylabel('\/\', 'FontSize',8)
title('Fig 6. Sensitivities', 'FontSize',8)
hold off
'
subplot(2,2,2)
h=plot ( F, Sen ( : , 1 l , 'k' , F, Sen ( : , 2 l , 'k' , .•.
F, Sen ( : , 3 ) , ' k ' ) ;
hold on
g=plot (F, Sen (:, 4 l , 'r' , F, Sen (:, 5 l , 'g' ) ;
set(h, 'LineWidth',l);set(g, 'LineWidth',ll
grid on
axis([500 501 -2 2));
YT=linspace(-2,2,5);set(gca,•ytick',YT)
xlabel('Freq (Hz)','FontSize',8);
ylabel('\/\','FontSize',8)
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 35

title( ' Fig 7. Sensitivities Near fo','FontSize ' ,B);


s1='At 500.6 Hz high to low order is:'
text(500.1,-1.4,s1, 'FontSize',B)
text(500.1,-1.7, 'R3,C1,R2,C2,R1', 'FontSize',B)
hold off
%
subplot(2,2,4)
m=plot(F,VL, 'k' ,F,VH, 'k' ,F,Vo, 'r');
set(m, 'LineWidth',1)
grid on
axis([BF LF -10 20])
xlabel('Freq (Hz) ' ,'Fontsize',B)
ylabel('Volts', 'FontSize',B)
title('Fig 9 . EVA','Fontsize',B)
%
subplot(2,2,3)
m=p1ot(F,Vrss1, 'k',F,Vrss2,'k',F,Vo, 'r');
set(m, 'LineWidth',1)
grid on
axis([BF LF -10 20])
xlabel('Freq(Hz) •, 'FontSize•,B);
ylabel('Volts','Fontsize',B);
title('Fig 8. RSS','FontSize',8)

function y = G1(R1,R2,R3,C1,C2,s)
% bpf function with matrices
A=[1/R1+1/R2+s*Cl+s*C2 -s*C2;s*Cl l/R3];
B=[l/R1;0];C=A\B;
y=abs(C(2));

The output plots are shown on Figures 2 to S.


We see that the sensitivities for R2, R3, Cl, and C2 are almost
overlays (Figure 2), and form an odd function through the center
=
frequency fo 500.6 Hz, with peaks at about +10 and -10. The
almost flat line at -1 is the sensitivity of Rl.
Most textbooks on active filters give the sensitivities at fo only.
Since this type of filter is well documented in the literature, we can
determine these center frequency sensitivities by zooming in on the
plot from 500Hz to 501 Hz in Figure 3.
36 Tolerance Analysis of Electronic Circuits

15r--------,-------,,-------.--------,

10 ...
I
,.
l

I
-10 -·-···t

F1GURE 2 Sensitivities.

$ 0 ....... .

At sor.eHz
I
hlg, to low orctr Ia ;

R3.C . R2 .C2 ,R r ,

-loLo-----5-oo~.2~~5~o~o~.-4---5~oo-L-
_s---=s~o~o-.s~--~501
P'r.q (Hz)

F1GURE 3 Sensitivities near fo .


Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 37

20

l
15

10 ····+

! 5

.. . ...... i. ..

I
-5

- 1 ~oo 450 500 550 600


F.-.q (Hz)

FIGURE 4 RSS.

20,-------.--------,--------.--------,

- 1 ~oo~----~4~5~0~----~5~0~0~----~5~5~0~----6~00
Freq (Hz)

FIGURE 5 EVA.
38 Tolerance Analysis of Electronic Circuits

Here we can see that the sensitivity of Rl is exactly -1, while


that for R2 is 0, R3 is +1, C2 is +'n, and C2 is -'n. Again, this is
only at the center frequency fo. The large sensitivities on both sides
of the center frequency drastically affect the RSS calculation as
shown in Figure 4.
The nominal output Vo in Figure 4 can be seen peaking at l OV
at 500 Hz with a Q of 20 as designed. What is suspicious are the
two upper lobes (Vrss2) that purport to be the Vo + 3o RSS varia-
tions. Note the lobes coincide with the peak sensitivity frequencies,
while the notch coincides with the center frequency sign change of
the sensitivities. The Vo- 3o RSS output (Vrss1,lower trace) is even
worse. It becomes negative on a volts scale, not a dBV scale. Hence
we have ample reason to suspect that something is amiss here.
Recall that the two capacitor tolerances are 10%. With the peak
sensitivities also being 10%/%, we can ignore the resistor contribu-
tions and ballpark the high RSS output as follows:

Vrss2 • v{1 +~(10·0.1} +(10·0.1) ]= V~l +.J2)= 2.41 · Vo


2 2

Hence the peaks are about 2.4 times the nominal output which is
about 8 Vat 490Hz, so that the peaks are 2.4 x 8 = 19.2 V, which
is approximately correct. For Vrss1, we have:

Vrssl• V~t-.J2)= 8 ·(-Q.414)=-3.3l

The problem here is that this calculation is a bad application of a


good idea. As will be shown in the Appendix, the RSS eqJUllion
should not be used with large sensilivity-tolerance pi"'ducts. Hence,
for this circuit at least, the RSS information is bogus and should be
ignored.
The EVA plot in Figure 5 shows that the low center frequency
peak is 447 Hz, while the high is at 568 Hz. The information shown
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 39

this plot shows is correct. The problem is that a lot of information


has been left out. For example: is one to assume that in the neigh-
borhood of 470 Hz, that the output will never exceed 5V? As will
be shown in the Monte Carlo section, this is a bad assumption.
The RSS and EVA plots are shown with the same vertical scale
to emphasize their disparity.

BANDPASS FILTER WITH ASYMMETRIC TOLERANCES


When asymmetric tolerances of -2%, + l% for the resistors, and
-15%, +10% for the capacito~ are used, the RSS and EVA plots
change shape. These are shown in Figures 6 through 9, obtained with
the same M-file previously used with the new tolerances substituted.
Since the tolerances are now asymmetric so is the RSS output.
For EVA, the upper peak center frequency has increased from 568
Hz for the symmetric tolerances, to about 600 Hz due to the increased
negative tolerances of -2% and -15% for the resistors and capacitors,
respectively.

15r------,------~-------,------,

10 ...... .

-5
··········t
i ······················f
!

!
-1 0
···r···
FIGURE 6 Sensitivities.
40 Tolerance Analysis of Electronic Circuits

~ 0

-1r-----1------+------r-----+-~~~

At af.eHz hiO to ojr


10w la o

R3, C , R2,C2 , ~

FlGURE 7 Sensitivities near fo .

*
>

FlGURE 8 RSS.

Again, the RSS output is correct only in the sense the mathe-
matics is correct. It is misleading due to the misuse of the RSS
concept, i.e., the sensitivity-tolerance products are excessive.
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 41

20,------,-------.-------.------,

15
I
·······j..
I
·I······
I
... 1...
i
I

-5 i··· t. . . . . .
I
j··

I
- 1 ~o~o~--~4~5~0----~5~00~--~5~5~0~--~6oo
Freq (Hz)

FIGURE 9 EVA.

LOWPASS FILTER
Of course, not all ac circuit exhibit these somewhat disappointing
results. An example of a "well-behaved" circuit is the multiple feed-
back lowpass filter, the circuit for which is shown below.

R1
E1 V1
42 Tolerance Analysis of Electronic Circuits

= =
The component values are: Rl 1.43K, R2 14.3K, R3 = 9.09K,
= =
Cl 2nF, and C2 O.luF. Component tolerances are chosen as Tr

l [l
= =
0.02 and Tc 0.1 (symmetric).
Ignoring the opamp and setting V2 =0, the A and B matrices are

_!_+_1 +-1 +sC2 __ I I


A = Rl R2 R3 R2 , B = Rl
[ 1
-- -sCI 0
R3

Using the following M-file lpfrss2.m, the sensitivities and RSSIEVA


outputs are plotted and are shown in Figures 10 and 11.

' Lowpass Filter RSS & WCA


' Pile: lpfrss2.m
' Uses function L2.m
clear;clc
R1=1430;R2=14300;R3=9090;Cl=2*1e-9;C2=0.1*le-6;
BP=2;ND=2;PD=40; ' log frequency sweep
Nc=S;dpf=O.OOOl;
Q=dpf*eye(N)+l;
' Form tolerance array T
Tr=0.02;Tc=O.l;
T=(-Tr -Tr -Tr -Tc -Tc;Tr Tr Tr Tc Tc];
' Start ac analysis
P=logspace(BP,BP+ND,ND*PD+l);
for i•l:ND*PD+l
s=0+2*pi*P(i)*j;
Vs(i)=L2(Rl,R2,R3,Cl,C2,s);
Vo(i)220*log10(Vs(i));
for p=l:N
Vr(i,p)=L2(Rl*Q{p,l),R2*Q(p,2), ..•
R3*Q(p,3),Cl*Q(p,4),C2*Q{p,5),s);
Sen(i,p)=(Vr(i,p)/Vs(i)-1)/dpf;
i f Sen(i,p)>O
L(i,p)=l+T(l,p);H(i,p)=l+T(2,p);
else
L(i,p)=l+T(2,p);H(i,p)=l+T(l,p);
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 43

end
end
% get EVL
D=L2(Rl*L(i,1) ,R2*L(i,2) ,R3*L(i,3), .. •
C1*L(i,4),C2*L(i,S),s);
VL(i)=20*log10(D);
% get EVH
D=L2(Rl*H(i,l),R2*H(i,2),R3*H(i,3), ...
C1*H(i,4),C2*H(i,S),s);
VH(i)=20*log10(D);
% get rss
suml(i)=O;sum2(i)=0;
for p=1:N
sum1(i)=sum1(i)+(Sen(i,p)*(L(i,p)-1))A2;
sum2(i)=sum2(i)+(Sen(i,p)*(H(i,p)-1))A2;
end
Vrss1(i)=20*log10(Vs(i)*(1-sqrt(sum1(i))));
Vrss2(i)=20*log10(Vs(i)*(1+sqrt(sum2(i))));
end
'subplot(2,1,1)
h=semilogx(F,Sen(: ,1), 'k' ,F,Sen(:, 2), 'r', ...
F, Sen ( : , 3 ) , • g ' ) ;
hold on
g=plot(F,Sen(:,4), 'c',F,Sen(:,S), 'm');
set(h, 'LineWidth',l);set(g, ' LineWidth',1)
grid on
axis([10ABF 10A(BF+NO) -2 2])
ylabel('%/%', 'FontSize',Bl
title('Fig 10. LPF Sensitivities','FontSize',Bl
hold off
'
subplot(2,1,2)
m=semilogx(F,VL,'g',F,VH,'b ', F,Vrssl, 'k', ...
F, Vrss2, 'k' ) ;
set (m, 'LineWidth' , 1)
grid on
axis([10ABF lOA(BF+NO) -20 20))
xlabel('Freq (Hz)', 'FontSize',B)
ylabel('dBV', 'FontSize',B)
title('Fig 11. LPF EVA', 'FontSize',B)
44 Tolerance Analysis of Electronic Circuits

function y = L2(Rl,R2,R3,Cl,C2,s)
% fen for Butterworth LPF
A=[l / Rl+l / R2+1 / R3+s*C2 -l / R2;-l / R3 -s*Cl] ;
B=[l / Rl; O];C=A\ B;
y=abs ( c (2) ) ;

R1 C1
-1 .5 .. ..................... ······················-

-27---------------------~--------------------~
~ ~ ~
F... (HZ)

FIGURE 10 LPF Sensitivities.

FIGURE 11 LPF EVA.


Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 45

Note in the plots that the maximum sensitivity amplitude is approx-


imately ±1. Hence the RSS and EVA outputs in Figure 11 are what
might be expected; i.e., narrow bands on either side of nominal. With
symmetrical tolerances, the RSS outputs are by definition symmet-
rical. Hence the nominal output is midway between the two RSS
inner traces. As might be expected, the EVA outputs are wider than
the RSS outputs.
Hence the key to worst-case behavior of a circuit is the magni-
tude of the component sensitivity-tolerance products.

SPICE ANALYSIS
While the results of the EVAIRSS analysis for the BPF circuit are
disappointing, the Spice analysis is more so. Most present-day Spice-
derived analysis packages do not correctly calculate the ac sensitiv-
ities for EVA (.WCASE) analysis. ( Spice does not have ac or de
RSS capability.)
To show an example of this, the net-list below describes an
identical BPF circuit and specifies a .WCASE analysis. The output
files (filename.out) generated by this net-list, show that the sensis-
tivities are calculated at only one frequency, which gives incorrect
results. (In the author's version, the MIN run calculated the sensi-
tivities at 400Hz, while 501.01 Hz was used for the MAX run.)
Hence other ac circuits may also be incorrect
The reader should compare the probe plots of each run with that
of Figure 5.

Spice listing for bandpass filter:

Bandpass Filter WCA


Vll OAC 1
Rl I 2 RA 6.34K
R2 2 0 RA 80.6
R3 4 3 RA 127K
Cl 2 3 CA O.luF
Tolerance Analysis of Electronic Circuits

C2 4 2 CA O.luF
E14 0 0 3 1E6
• As in MATI.AB, an ideal VCVS is used.
.MODEL RA RES(R=l DEV/GAUSS=0.667%)
=
• 3 sigma 2%
.MODEL CA CAP(C=l DEV/GAUSS=3.333%)
=
• 3 sigma 10%
.WCASE AC V(4) MIN VARY DEV
*.WCASE AC V(4) MAX VARY DEV
.AC LIN 100 400 600
.PROBEV(4)
.OPTIONS NOECHO NO PAGE
.END

TOLERANCE ANALYSIS OF STABILITY


To show that ac tolerance analysis is not confined to active filters,
the next MATLAB file OmlS8ta.m) is a stability analysis of an
LM1S8 opamp model. The model uses two internal components (Rx
and Cx) to form one of three poles in the opamp open loop gain.
When this model (theoretically representing a real-world opamp) is
combined with external circuitry to form the feedback (beta) path,
it is often prudent for a circuit designer to perform a stability analysis
to ensure there are no surprises when the circuit is bread-boarded or
first-articled. In other words, stability analysis is one of those design
tasks required to make the design ''bullet-proof."
Tolerance analysis of stability shows how near, in terms of phase
margin, the circuit is to becoming unstable and thus exhibiting a
lightly damped (ringing) or un-damped oscillation. As a rule of
thumb, the phase margin should never be less than 45°.
The M-file lml58ta.m given below presents some MATI..AB
techniques for stability analysis. (The step numbers are omitted.)
The circuit analyzed is shown below.
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 47

C2

\ LM158 Stability Analysis


% File: lml58ta.m
\ no functions used
clear;clc;
Rx=101.2433*le6; % internal to IC
Cx=SO*le-12; % internal to IC
%Cx=200*le-12; % 200 pF improves phase margin
R4=1130;R6=2260;R19=10000;C2=0.l*le-6;
\ opamp poles
wl=l/(Rx*Cx);w2=2*pi*1.2*1e6;w3=4*pi*le6;
Ao=le5; \ opamp open loop gain
BF=O;ND=7;PD=20;Lit=ND*PD+l;
Tr=0.02;Tc=O . l;Ta=0.2;Trx=O.l;
T=[-Tr -Tr -Tr -Tc -Ta -Trx;Tr Tr Tr Tc Ta Trx];
Nc=6;dpf=O.OOOl;Q=dpf*eye(Nc)+l;
F=logspace(BF,BF+ND,Lit);
for i=l:Lit
s=2*pi*F(i}*j;
A=Ao/((l+s/wl)*(l+s/w2)*(l+s/w3));
Al(i)=20*logl0(abs(A));
\ inverse Beta
B=(s+(l/Rl9+1/R6+1/R4)/C2)/(s+l/(Rl9*C2));
Bl(i)=20*logl0(abs(B});
% loop gain
Gl=A/B;GH(i)=abs(Gl);
M(i)=20*log10(GH(i});
48 Tolerance Analysis of Electronic Circuits

Ph(i)=(180/pi)*ang1e(G1)+180;
if Ph(i)>180;Ph(i)=Ph(i)-360;end;
for p=l:N
A=Ao*Q(p,5)/((l+s/(wl*Q(p,6)))* .•.
(l+s/w2)*(l+s/wJ));
B=(s+(l/(Rl9*Q(p,3))+1/(R6*Q(p,2))+ •• ,
l/(R4*Q(p,1)))/(C2*Q(p,4))) ...
/(s+l/(R19*Q(p,J)*C2*Q(p,4)));
GHr(i)=abs(A/B);
% sensitivities
SM(i,p)=((GHr(i)/GH(i))-1)/dpf;
end
end
'
subp1ot(2,2,1)
h=semilogx(F,M, 'k',F,Al,'k',F,Bl, 'k');
set(h,'LineWidth',1);grid on;
axis((10ABF 10A(BF+ND) -20 120))
xlabel('Freq(Hz) •, 'FontSize',8);
ylabel('dBV','FontSize',8);
title('Fig. 12, Bode Plot of gains','FontSize',SI
XT=1ogspace(BF,BF+ND,BF+ND+l);
set(gca, •xtick',XTI;

'
subplot(2,2,21
g=semi1ogx(F,Pb,'k');grid on;
set(g, 'LineWidth',1);
axis((10ABF 10A(BF+ND) -100 200))
xlabel('Freq(Hz)','FontSize',8);
ylabel('Phase (deg) •, 'FontSize',8);
title('Fig 13. Phase Angle','FontSize',8);
set(gca, •xtick' ,XT);

'
aubplot(2,2,3)
g=plot(Ph,M, 'k');grid on;
set(g, 'LineWidth',1);
axis((-100 200 -40 80))
xlabel('Phase•, 'FontSize',8);
ylabel('Mag (dBV) •, 'FontSize',8);
title('Fig 14. Mag vs Phase', 'FontSize',8);

'
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 49

subplot(2,2,41
h=semilogx(F,SM(:,l),'k',F,SM(:,2),'k',F,SM(:,3));
set(h, 'LineWidth',l);
hold on;grid on
h=semi logx ( F, SM ( : , 4) , ' k' , F, SM ( : , 5 I , ' k' , F, SM ( : , 6) I ;
set(h, 'LineWidth',l);
hold off
axis([lQABF lQA(BF+ND) -1.5 1.5])
xlabel('Freq (Hz) •, 'FontSize',B);
ylabel('\/\', 'Fontsize',B);
title('Fig. 15 Sensitivities', 'Fontsize',BI
set(gca, •xtick' ,XT);

Figure 12 shows the opamp open loop gain A starting at a de gain


of Ao = 10' = 100 dBV. The next trace down is the loop gain GH
starting at about 77 dBV; and finally inverse beta B = up. Note that
GH + B = A on the plot dBV scale.
Also note the slope of GH where it crosses dBV = 0 unity gain.
For a more than adequate stability phase margin of 90°, the slope
should be about -20 dB/decade (sometimes referred to as a -1 slope).
From the plot it can be seen that the slope is picking up the second
opamp 1.2 MHz pole and is approaching ~ dB/decade, or a -2
slope. A -2 slope is equivalent to 0° phase margin.
The same information can be obtained from the slope angle of
interception of GH and B. For 90° phase margin, this should be a
net slope of 20 dB/decade. Note that this angle in Figure 12 is greater
than 20 dB/decade. When the net slope is 40 dB/decade, this indicates
close to 0° phase margin.
Figure 13 is a plot of GH phase angle vs. frequency. Figure 14
is a plot of phase angle vs. GH magnitude and shows the phase angle
at 0 dB crossover to be very small. (This plot scale can easily be
expanded to get more resolution of the crossover phase angle.)
Figure 15 shows that the component sensitivities are all 1 or less.
The M-file lml58pol.m below creates a Nyquist polar plot to
show the phase margin more clearly at unity gain.
so Tolerance Analysis of Electronic Circuits

% LM158 Stability Analysis - polar plot


% File: lm158pol.m
% no functions used
clear;clc;
Rx=101.2433*1e6; % internal to IC
Cx=SO*le-12; % internal to IC
%Cx=200*le-12; % more stable
R4=1130;R6=2260;R19=10000;C2=0.1*1e-6;
% opamp poles
wl=l/{Rx*Cx);w2=2*pi*l.2*le6;w3=4*pi*le6;
Ao=le5; % opamp de open loop gain
% linear frequency, NP points
NP=200;BF=le6;LF=le7;DF=(LF-BF)/NP;
% tolerances
Tr=0.02;Tc=O.l;Ta=0.2;Trx=O.l;
% Tr resistor tolerances
% Tc = capacitor C2 tolerance
% Ta = Ao tolerance
% Trx = wl tolerance
% Tolerance array T
T=[-Tr -Tr -Tr -Tc -Ta -Trx;Tr Tr Tr Tc Ta Trx];
Nc=6;dpf=0.000l;Q=dpf*eye(Nc)+l;
Lit=(LF-BF)/DF;
F=linspace(BF,LF,Lit);
for isl:Lit
s=2*pi*F(i)*j;
A=Ao/{{l+s/wl)*{l+s/w2)*(l+s/w3));
Al{i)=20*logl0(abs(A));
% inverse Beta
B=(s+{l/R19+1/R6+1/R4)/C2)/(s+l/(Rl9*C2));
Bl(i)=20*log10(abs(B));
Gl=A/B;GH(i)=abs(Gl);
M(i)=20*logl0(GH(i)); %loop gain
Ph(i)=angle(Gl); %radians for polar plot
for p=l:Nc
A=Ao*Q(p,5)/((l+s/(wl*Q(p,6)))• ..•
(l+s/w2)*(l+s/w3));
B=(s+(l/(Rl9*Q(p,3))+1/(R6*Q(p,2))+1/ ...
(R4*Q(p,l)))/(C2*Q(p,4))) ...
/{s+l/(R19*Q(p,3)*C2*Q(p,4)));
GHr(i)=abs(A/B);
SM(i,p)={(GHr(i)/GH(i))-1)/dpf;
Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 51

% SM = sensitivities
i f SM(i,p) >0
L(i,p)=l+T(l,p);H(i,p)=l+T(2,p);
else
L(i,p)=l+T(2,p);H(i,p)=l+T(l,p);
end
end
% get EVL
A=Ao*L(i,5)/((l+s/(wl*L(i,6))) •..
*(l+s/w2)*(l+s/w3));
B=(s+(l/(Rl9*L(i,3))+1/(R6*L(i,2))+1/ ...
(R4*L(i,l)))/(C2*L(i,4))) ...
/(s+l/(R19*L(i,3)*C2*L(i,4)));
GHL(i)=abs(A/B);
% get EVH
A=Ao*H(i,5)/((l+s/(wl*H(i,6)))* ...
(l+s/w2)*(l+s/w3));
B=(s+(l/(Rl9*H(i,3))+1/(R6*H(i,2))+1/ ...
(R4*H(i,l)))/(C2*H(i,4))) ...
/(s+l/(Rl9*H(i,3)*C2*H(i,4)));
GHH (i) =abs (A/B);
Ill get RSS
suml(i)=O;sum2(i)=O;
for p=l:Nc
suml(i)=suml(i)+(SM(i,p)*(L(i,p)-l))A2;
sum2(i)=sum2(i)+(SM(i,p)*(H(i,p)-l))A2;
end
Grssl(i)=GH(i)*(l-sqrt(suml(i)));
Grss2(i)=GH(i)*{l+sqrt(sum2(i)));
end
% create polar plot
h=polar ( [0 2*pi], [0 21);
delete(h);hold on
%g=polar(Ph,GH, 'k');set(g, 'LineWidth',l);
g=polar(Ph,Grssl, 'r');set(g,'LineWidth',l);
g=polar(Ph,Grss2, 'g');set(g, 'LineWidth',l);
g=polar(Ph,GHL, 'c');set(g,'LineWidth',l);
g=polar(Ph,GHH, 'b');set(g,'LineWidth',l);
gtext('Fig 16. RSS/EVA, Cx = 80pF')
hold off
52 Tolerance Analysis of Electronic Circuits

120,---,----.---.----.---.----,---,

60

40

20 ···-·······t··
···

0
I
···········!··········

FIGURE 12 Bode plot of gains.

J ···r····-..-
. . . .J . . !...........!......-..
150 . !

100 ············f···
..

I ~ i I
r······1. 1 ., . .
50

0 ...... ~.. -••

I . J.. 1 I I
- 50
r··· · ······-r ·t·······j·······l
-100L---~--~--~----L---~--~--~
1~ 1~ 1~ 1~ 1~ 1~ 1~ 1~
F.-q(Hz)

FIGURE 13 Phase angle.


Root-Sum-Square (RSS) and Extreme Value Analysis (EVA) 53

EIO ······---~--
4o ·····-···----········--------L
...

,
i 20
l
0 ...................... .. . ........ I..... .

-20 ... ....... . ,


....... ..... .......... . ........ ..

-!~o~o--~------o~---------1~00----------2~00

FIGURE 14 Mag. vs. phase.

1.5r---.----,----,----,----,---,----,

I
0.5 [..........i

-0. 5

-1.5 L-:-----'-----'-::---~---'-----'-=-----'----'
1~ 1~ 1~ 1~ 1~ 1~ 1~ 1~
Fr.q(Hz)

FIGURE 15 Sensitivities.
54 Tolerance Analysis of Electronic Circuits

90

180

270

FIGURE 16 RSS/EVA, Cx = 80pF.

The polar plot output from this M-file shown in Figure 16. The two
outer traces are high and low EVA plots, while the inner traces are
high and low RSS outputs. The phase margin is 180° minus the angle
where these traces cross the unity gain circle. The lowest is about
10°, far below the 45° target value.
The reader is encouraged to change the value of Cx from 80pF
to 200pF and observe the increase in the minimum phase margin.
2 Monte Carlo Analysis

The general Monte Carlo analysis (MCA) procedure is to create


random numbers for each of M components then convert these ran-
dom numbers to M tolerance multipliers. Thus if a decimal tolerance
Tr is given, a random tolerance multiplier between 1 - Tr and 1 + Tr
is calculated. These are applied to the M components in the circuit
and the (random) output is computed in the same manner as the
nominal output. This is repeated a sufficient number of times (N
samples) so that the spread of outputs represents a typical manufac-
turing run of the circuit.
It will be shown later that the number of samples N cannot be
too large; i.e., it should be as large as the memory capacity of the
computer can handle. N = 1000 should be considered a minimum.
For ac circuits, N samples of M components are taken at (LF -
BF)/DF linear frequencies. For example if BF = 400, LF = 600, DF =
2, M = 6, and N = 1000, this in affect creates an array with 6 columns
and 1000 rows at each of (600- 400)/2 = 100 frequencies. Hence
ac MCA taxes computer memory.
It should be stated that there are no ideal random number gen-
erators. Some come close to being ideal, however, virtually all ran-
dom number algorithms depend in some manner upon the previous
random number. A truly random number does not remember the
previous one. For example, the next Keno ball in Las Vegas has no
knowledge of what the previous ball was, and the two little red cubes
at the crap table are similarly heartless and uncooperative.
In general, two types of random numbers will be used: (1)
Gaussian or normal (bell-curve) and (2) uniform (flat). MATLAB
has two functions for this purpose, randn for normal and rand for
uniform.

55
56 Tolerance Analysis of Electronic Circuits

The following MA1LAB file shows how create and use what
should more accurately be called psuedo-random numbers, but will
be referred to as random numbers.

% Generating Gaussian random numbers with MATLAB


% File: genorm.m
clear;clc;
N=6; % number samples
M=3; % number of components
Z=zeros(N,Ml; %increases speed
for k=1:N
for w=1:M
% N*M random normal numbers with
% 0 mean and standard deviation (sigma) of 1.
Z(k,wl=randn;
end
end
% output z to screen
z
% write z to text file output.txt
fid=fopen('output.txt', 'w');
fprintf(fid, '%2.3f %2.3£ %2.3f\r\n',Z);
status=fclose(fid);
% Gaussian random tolerances
for i=1:7
x(il•i-4;
% symmetric tolerances of +/- 2%
T11il=I0.04/6l*(x(il+3)-0.02;
% asymmetric tolerances of +2% & -1%
T2(il=(0.03/6)*(x(i)+3)-0.01;
% asymmetric tolerances of +1% & -2%
T3(i)=(0.03/6)*(x(i)+3)-0.02;
end
% plot Tl, T2, & T3
plot(x,T1, 'k' ,x,T2, 'g' ,x,T3, 'm')
axis([-3 3 -0.02 0.02))
grid on

Output file output.txt showing the N = 6 x M = 3 random normal Z


array:
Monte Carlo Analysis 57

1.521 -0.696 0.587


0 . 668 2.309 0.913
-0 . 038 0.008 -0.251
- 0.078 0.525 0.056
1.227 -0.783 0 . 480
0 . 889 -0.012 -1.107

With a mean of 0 and a standard deviation of l, these numbers will


be limited to a spread of -3 to +3. (Occasionally, outliers < -3 and
> +3 will be encountered simply because the normal curve is not
restricted to -3CJ and +3CJ. Theoretically however, 99.74% of the
numbers will be within the -3 to +3 range.)
To convert these numbers to decimal tolerance multipliers,
choose Z(l,l) = 1.521 for example. Then, for symmetric tolerances
of say ±2%:

0
Tl(z) = ·~ ·(z+3)-0.02+1 =(0.0067)(4.521)+0.98= 1.101

For asymmetric tolerances of +2%, -1%, this would then be:

0 3
T2(z) = ·~ ·(z+3)-0.0l + 1 =(0.005)(4.521)+0.99+1.0126

and for asymmetric tolerances of+ 1%, -2%:

0
T3(z)= ~3 ·(z+3)-0.02+ 1 = (0.005)(4.521)+0.98 = 1.0026

Then a 10000 Q resistor would have values of llOIO n, 10126 n,


and 10026 n, respectively.
Figure 17 shows these decimal tolerance relationships for ran-
dom normal numbers between -3 and +3.
58 Tolerance Analysis of Electronic Circuits

FIGURE 17 Decimal tolerances.

For uniform random numbers zu between 0 and 1, T1 above


would be changed to:

TI(zu) = 0.04(zu)-0.98
and correspondingly for T2 and T3.
We next perform a MCA on the de differential amplifier of Part
1 and compare the results to the RSS and EVA analysis of that simple
circuit. We will use both normal and uniform distributions and com-
pare the histograms for each (see Figures 18 and 19).
The steps outlined below are before the analysis is perfomed:

Step 1: Define the nominal component values.


Step 2: Create the circuit function or matrices.
Step 3: Calculate the nominal output.
Monte Carlo Analysis 59

Step 4: Specify N, the number of samples.


StepS: Generate theN Gaussian (or uniform) random numbers for
the M components.
Step 6: Create the tolerance array T and convert the random num-
bers to random tolerance multipliers.
Step 7: Calculate the N random outputs by multiplying theM com-
ponents in step 2 by the N tolerance multipliers in step 6.
Step 8: Calculate the statistics - mean and standard deviation of
the output.
Step 9: (Optional) Calculate 95% confidence levels (See Appendix).
Step 10: Create histograms of the output voltage.
The M-file figl819.m creating the foregoing histrograms is listed
below:

% File figl819 . m
% de differential amplifier
% functions not used
clear;clc;
% Step 1 - assign component values
R1=10;R2=100;R3=10;R4=100;E1=-1;E2=1;Ao=le6;
% Step 2 - create A matrix & B input vector
A=[l/R1 + l/R2 0 0 -1/R2;
1 -1 0 0; 0 0 l/R3 + 1/R4 0;0 Ao -Ao 1];
B=[El/Rl;O;E2/R3;0];
% Step 3 - optional;
% calculate nominal output
C=A\B;Vo=C(4);
% Step 4 - specify N number of samples
% and M components
N=5000;M=6;
% Step 5 - seed for random numbers
randn('state',sum(lOO*clock));
Tn=zeros (N,M);
% Step 6 - create tolerance array T;
% convert to tolerance multipliers
Tolerance Analysis of Electronic Circuits

% use -1%/+3% for Rl & R3


Tr=0.01;Te=O.OS;
T=[ -Tr -Tr -Tr -Tr -Te -Te;
Tr Tr Tr Tr TeTe);
% do normal first (mc=l) and
% then uniform (mc=2l
nb=25; \ number of histogram bins
for mc=l:2
for k=l:N
for w=1:M
if mc="'1
Tn(k,w)=((T(2,w)-T(1,w))/6)* .•.
(randn+3)+T(1,w)+1;
else
Tn(k,w) =IT (2,w) -T(1,w)) • •.•
rand+T(1,w)+1;
end
end
\ Step 7 - calculate N random outputs
A=[1/(R1*Tn(k,1))+1/(R2*Tn(k,2)) •..
0 0 -1/(R2*Tn(k,2)); .•.
1 -1 0 0; 0 0 1/{R3*Tn{k,3))+1/ ••.
(R4*Tn(k,4)) 0;0 Ao -Ao 1);
B=IE1*Tn(k,5)/(R1*Tn(k,1));0; .••
E2*Tn(k,6)/(R3*Tn(k,3));0);
C=A\B;Vm(k)=C(4);
end
% Step 8 - get statistics
if mc=:o1
Vs1=3*std(Vm);Vavg1=mean(Vm);
h1=hist(Vm,nb);VL1:omin(Vm);VH1=max(Vm);
intvlc(VH1-VL1)/nb;
for qx1:nb;bin1(q)=VL1+intv1*(q-1);end
Vhi1=Vavg1+Vs1;Vlo1=Vavg1-Vs1;
Vsr=aprintf('\2.3f\n',Va1);
Vavgrzsprintf{'\2.3f\n',Vavg1);
else
Vs2=3*std(Vm);Vavg2=mean(Vm);
h2=hist(Vm,nb);VL2=min(Vm);VH2=max(Vm);
intv2=(VH2-VL2)/nb;
for q=1:nb;bin2(q)=VL2+intv2*(q-1);end
Vhi2=Vavg2+Vs2;Vlo2=Vavg2-Vs2;
Monte Carlo Analysis 61

Vsu=sprintf ( '%2 . 3 f \ n' , Vs2) ;


Vavgu=sprintf('%2.3f \ n',Vavg2);
end
end
% Step 9 - confidence levels (see text)
% Step 10 - create histograms
subplot(2,1,1)
bar(bin1 , h1, 'y');
title('Fig 18. Diff Amp MCA, Normal dist');
grid on;
axis([18.5 21.5 0 600]);
text (20 . 7, 400, [ 'Vavg1=', Vavgr]);
text (20.7,300, ['Vs1=',Vsr]);
%
subplot(2,1,2)
bar(bin2,h2, 'y');
title('Fig 19 . Diff Amp MCA, Uniform dist');
xlabel ('Volts de')
grid on;
axis([18 . 5 21.5 0 600]);
text (20 . 7, 400, [ 'Vavg2=', Vavgu]);
text(20.7,300,['Vs2=',Vsu]);

21 .5

FIGURE 18 Diff amp MCA, normal dist.


62 Tolerance Analysis of Electronic Circuits

FIGURE 19 Diff amp MCA, uniform dist.

Some interesting conclusions can be drawn from the two histograms.


The first histogram with normal distribution shows the tails (Vo -
3cr and Vo + 3cr) at 19.999- 0.766 = 19.233V and 20.765V respec-
tively. The EVA numbers from this same circuit were EVL = 18.264
and and EVH = 21.424V. One can see from the histogram that the
likelihood of reaching these extremes is very low. Even the uniform
distribution of Figure 19 with tails 18.691V and 21.341V does not
reach the EVA extremes. One then questions the cost-benefit wisdom
of using EVA.
The EVA values will be attained only when the number of
samples using a normal or uniform distribution is infinite. In other
words, the extreme values will never occur. Hence one can see that
EVA analysis can have an adverse economic impact. In other words,
use of the +1- 3cr limits in a MCA with large N is a reliable predictor
of circuit performance over a large or small production run. It can
then be demonstrated that specification limits can be met without
using ultra-precise and expensive components that an EVA analysis
Monte Carlo Analysis 63

would possibly require. (See Appendix for infonnation on MCA


confidence levels and percent yield.)
Note that the 3a value for Figure 18 is 0.766Y. The RSS analysis
predicted this value to be 0.757Y. Since the sensitivity-tolerance
products for this circuit are very low, the de RSS analysis is also a
reliable predictor of circuit perfonnance.
Referring to Figure 19 with unifonn distribution for compo-
nents, the histogram is quasi-Gaussian in fonn. The standard devia-
tion for a component R1 with a unifonn (rectangular) distribution
and decimal tolerance T1 is:

Then the a ratios of unifonn to nonnal distribution is:

= =
Hence the 3a value for Figure 19 is 31i Ys1 1.732(0.766) 1.327
iH.325. The closer the output approaches Guassian, the better this
approximation is.
Figures 20 and 21 were created with the same M-file, but with
N = 10000 samples and -1%/+3% asymmetric resistor tolerances
used for Rl and R3. (See pages 9 and 10).
Referring to Figure 20 with the asymmetric tolerances, it will
be recalled that the RSS analysis predicted that these limits would be

Yo- Yrss1 = 20-0.930 = 19.070Y and


Yo + Yrs5z = 20 + 0.757 =20.757Y.

This compares with Figure 20 histogram 3a limits of:


Yavg1 - Ysl = 19.797 ± 0.809 = l8.988Y and 20.606Y.
64 Tolerance Analysis of Electronic Circuits

1~r------.-------.-------r------,-------.------.

~~ ················· ..··-·······;
.....................

FIGURE 20 Diff amp MCA, normal dist.

21.5

FIGURE 21 Diff amp MCA, uniform dist.


Monte Carlo Analysis 65

1be EVA numbers for this case were l8.262V and 2l.424V. 1bese
numbers together with % deviation from the MCA numbers are
summarized in the table below for easy comparison.

Category Low Value High Value Low 'Yo High 'Yo

Vrss 19.070 20.757 +{).43 +{).73


Vrs 19.243 20.93 +1.34 +1.57
MCA3a 18.988 20.606
EVA 18.262 21.424 -3.82 +3.97

The conclusion is that Vrss is a better estimator than Vrs and much
better than EVA.

GENERAL COMMENTS CONCERNING RSS


When seeking the 3o value of a function, it is generally assumed
that the function is Gaussian. 1be standard deviation (a) has little
meaning for non-Gaussian distributions when the intent is to consis-
tently visualize where the 3o point is located. Most if not all de
circuits with small sensitivity-tolerance products are approximately
Gaussian with Gaussian or uniform inputs, however, a general proof
of this is not available. Reference 1 states that normality is preserved
only if the (transfer) function is linear. As will be seen, analysis of
high-Q ac circuits have extremely non-Gaussian distributions, hence
their 3o numbers are meaningless.
Thus the RSS method has little value in predicting performance
limits unless it can be shown that the output is Gaussian or quasi-
Gaussian. Further, as has been demonstrated and will be subse-
quently confirmed, the RSS method does not give valid answers
when the component tolerance-sensitivity products are high.
All this is leading up to the fact that MCA is a much better
predictor of worst-case performance of any de or ac circuit providing
the number of samples is large.
66 Tolerance Analysis of Electronic Circuits

UNIFORM VS. GAUSSIAN DISTRIBUTION

=
Uniform: N 5000 k =l..N Tu(k) = 3( 2 ·(rand) -1]

Since the rand function provides a random number between 0 and


1, the maximum value of Th is +3.0 and the minimum value is -3.
How close they come is shown in the example below:

Tmin=min(Tu) Tmin=-2.9993 Tmax=max(Tu) Tmax=2.9993

Hence uniform distribution never exceeds +3a or -3a which implies


components that meet the vendors specifications for tolerance. This
distribution also has the advantage of covering all possible vendor
non-Gaussian distributions such as bi-modal due to pre-screening
for another customer.

Gaussian: z = znorm(N,O,l) Zmin = min(z) Zmin = -3.3763


Zmax = max(z) Zmax = +3.4477

These extremes are called outliers and their use in MCA implies the
analysis is being performed with out-of-spec components which is
unrealistic, especially in a manufacturing yield analysis. Also, MCA
with uniform inputs could serve as a happy compromise between the
EVA and RSS philosophical camps.

RATIOMETRIC TOLERANCES
In integrated circuits, tolerances for ratio tracking components are
expressed in a different manner. There are two tolerances associated
with a ratio of resistors. One is the individual tolerance T1 of either
resistor which may be quite large. The other is the ratio tolerance
T2 of this resistor to another, which is usually much smaller.
Monte Carlo Analysis 67

For example, each resistor in the pair may have a tolerance of


30%, while the ratio tolerance T2 may be on the order of 5% or T2
= 0.05. Then if Rl = 2 and R2 = 10, the ratio

R2 10
K=-=-=5
Rl 2

The minimum value of K is then 0.95(5) = 4. 75, while the maximum


value is 1.05(5) = 5.25.
We generally do not care what the individual values of Rl and
R2 are, since we know that their ratio cannot exceed 1 ± 1'2. For
example, if Rl had a value of 10(1.3) = 13, R1 must have a value
between:

R 1(1+ Tl) 2(1·3) = 2(1.238) = 2.476


l+T2 1.05

and 2.6, so that K does not exceed 5.25 per the advertised ratio
specification.

For the differential amplifier, if we let R2/R1 = K1, and R3/R4 =


K2, the output is:

Vo= El(1+Kl) E2·K1


l+K2

The following MATI..AB file daratio.m, uses a ratio tolerance of 1%,


and performs a MCA of the de diff amp. The histograms are con-
tained in Figures 22 and 23. Step numbers are omitted in this analysis
since the MCA sequence has been previously defined.
68 Tolerance Analysis of Electronic Circuits

\ File daratio.m
\ de differential amplifier
\ - ratiometric
clear;clc;
Rl=l0;R2=100;R3=10;R4=100;El=l;E2=-l;
Kl=R2/Rl;K2=R3/R4;
N=SOOO;M=4;
randn('state',sum(lOO*clock));
Tn=zeros (N,M);
\ Ratio tolerances
Tr=O.Ol;Te=O.OS;
T=[-Tr -Tr -Te -Te;Tr Tr Te Te];nb=25;
for mc=1:2
for k=l:N
for w=l:M
if mc==l
Tn(k,w) =I (T(2,w) -T (l,wl l /6) .•.
*(randn+3)+T(l,w)+l;
else
Tn(k,wl= (T(2,wl -T(l,wl l ..•
*rand+T (l,w) +1;
end
end
A=Kl*(Tn(k,l));B=K2*(Tn(k,2));
vm(k)=El*Tn(k,3)*{l+A)/(l+B)-E2 .••
*Tn(k,4)*A;
end
if mc==l
Vs1=3*atd(vm);Vavgl=meanlvml;
hl=hiat(vm,nbl ;VLl=minlvml;
VHl=max 1vm1 ;
intvl=IVHl-VLll/nb;
for q=l:nb;binl(q)=VLl+intvl*(q-l);end
Vhil=Vavgl+Val;Vlol=Vavgl-Vsl;
Vsrzsprintf('\2.3f\n',Vsl);
Vavgrssprintf ( '\2. 3f\n', Vavgl);
else
Vs2=3*std(vm);Vavg2=mean(vm);
h2=hist(vm,nbl;VL2=min(vm);
VH2=maxlvml;
intv2=1VH2-VL2)/nb;
for q=l:nb;bin2(q)=VL2+intv2*(q-l);end
Monte Carlo Analysis 69

Vhi2=Vavg2+Vs2;Vlo2=Vavg2-Vs2;
Vsu=sprintf('%2.3f\n',Vs2);
Vavgu=sprintf('%2.3f\n',Vavg2);
end
end
subplot(2,1,1)
bar(binl,hl, 'y');
title('Fig 22. Ratiometric MCA, Normal dist');
grid on;
axis([18.5 21.5 0 700]);
text(20.5,450, ['Vavgl=',Vavgr]);
text (20.5,400, ['Vsl=',Vsr]);
%
subplot(2,1,2)
bar(bin2,h2, 'y');
title('Fig 23. Ratimetric MCA, Uniform dist');
xlabel ( 'Volts de' )
grid on;
axis([18.5 21.5 0 700]);
text (20.5, 450, [ 'Vavg2=', Vavgu]);
text (20. 5, 400, [ 'Vs2=' ,Vsu]);

700,------.-------.-------.------.-------.------.

600

21 .5

FIGURE 22 Ratiometric MCA, normal dist


70 Tolerance Analysis of Electronic Circuits

FIGURE 23 Ratiometric MCA, uniform dist.

Note that the 3cr values Vsl and Vs2 are slightly Jess than that shown
in Figures 18 and 19 for non- ratiometric resistors.

MCA OF OPAMP DC OFFSETS


A tolerance analysis of de offsets in an opamp circuit can yield
valuable information about offset drifts and bias currents and their
affect on the overall circuit performance.
The following MATLAB file shows how to do this for a typical
equivalent de circuit shown below.

R1
Monte Carlo Analysis 71

One or more of the four resistors may represent Thevenin equiva-


lents. If one resistor is not present it can be set to a very high
resistance (e.g., 109 Q) for an open or a very low resistance (e.g.,
lo-3 Q) for a short.
With El = E2 = 0, the output can be expressed as:

Vo =(vos+lbl·(RII/R2)-lb2·(R3//R4))(t + ~~)

where the II symbol denotes the parallel combination.


In matrix form:

1 1 El_lbl
-+- 0 0
Rl R2 R2 Rl
-1 0 0 Vos
A= , B=
I I E 2 -lb2
0 0 -+- 0
R3 R4 R3
0 Ao -Ao 0

Note that the initial values of Vos, lbl, and lb2 are one times the
unit (i.e, InA, lmV). Hence these numbers could be lpA and IV.
The tolerances in the last three columns of array T are then the data
sheet max values of Vos, lb and los in which:

lbl =lb+ los lb2 = lb-los


2, 2

In the M-file offsets.m below, example Vos extremes are -IOmV,


+5mV, lbl is -150nA, +lOOnA, and lb2 is -SOnA, +30nA.
72 Tolerance Analysis of Electronic Circuits

\ File offsets.m
\ de opamp offsets
\ uses MATLAB function G6.m
clear;clc;
R1=10000;R2=20000;R3=10000;R4=20000;
El=O;E2=0;Ao=le6;
Vos=0.001;Ib1=1e-9;Ib2=1e-9;
\ Vos in mV; Ib1 • Ib2 in nA
\ must be 1 x tolerance unit,
\i.e., Vos = 2.SmV, etc.
\ Step 2 - create A matrix;
\ add offset sources to B; E1=E2=0
Vo=G6(R1,R2,R3,R4,E1,E2,Vos,Ib1,Ib2,Ao);
N=SOOO;M=7;
randn('state',sum(100*clock));
Tn=zeros (N, Ml ;
Tr=0.01;
T=[ -Tr -Tr -Tr -Tr -10 -150 -50;
Tr Tr Tr Tr 5 100 30];
\ Vos -10mV/+SmV;
\ Ib1 -150na/+100nA;
t Ib2 -50na/+30nA
nb=25;
for mc=1:2
for k=1:N
for w=1:M
if mc==1
Tn(k,w)=((T(2,wl-T(l,w))/6)* ...
(randn+3l+T(1,w)+1;
else
Tn(k,w)=(T(2,w) -T(1,w)) * ...
rand+T(l,wl+l;
end
end
Vm(kl=G6(R1*Tn(k,1),R2*Tn(k,2), •..
R3*Tn(k,3),R4*Tn(k,4), .•.
E1,E2,Vos*Tn(k,S),Ib1*Tn(k,6), ...
Ib2*Tn(k,7),Ao);
end
if mc==l
Vs1=3*std(Vm);Vavg1=mean(Vm);
h1=hist(Vm,nb);VLl=min(Vm);
Monte Carlo Analysis 73

VHl=max (VDI) ;
intvl=(VHl-VLl)/nb;
for q=l:nb;binl(q)=VLl+intvl*(q-l);end
Vhil=Vavgl+Vsl;Vlol=Vavgl-Vsl;
Vsr=sprintf('%2.3f\n',Vsl);
Vavgr=sprintf('%2.3f\n',Vavgl);
else
Vs2=3*std(VDI);Vavg2=mean(vm);
h2=hist(VDI,nb);VL2=min(VDI);VH2=max(VDI);
intv2=(VH2-VL2)/nb;
for q=l:nb;bin2(q)=VL2+intv2*(q-l);end
Vhi2=Vavg2+Vs2;Vlo2=Vavg2-Vs2;
Vsu=sprintf('%2.3f\n',Vs2);
Vavgu=sprintf('%2.3f\n',Vavg2);
end
end
subplot(2,1,1)
bar(binl,hl, 'y');
sl='Pig 24. Opamp offsets MCA, Normal dist•;
title(sl);
grid on;
axis([-0.04 0.04 0 600]);
text(-0.03,450,['Vavgl=',Vavgr]);
text (-0.03,400, ['Vsl=',Vsr]);
'
subplot(2,1,2)
bar(bin2,h2, 'y');
s2='Fig 25. Opamp offsets MCA, Uniform dist';
title(s2);
xlabel('Volts de')
grid on;
axis([-0.04 0.04 0 600]);
text(-0.03,450, ['Vavg2=',Vavgu]);
text(-0.03,400, ['Vs2=',Vsu]);

For Gaussian inputs, the histogram Figure 24 shows that the +3a
= =
output is Vavg + Vsl -SmV + 22mV 18mV. The histogram of
Figure 25 approximates a uniform distribution. The calculated +3a
point is Vavg + Vs2 = -SmV + 40mV = 35mV. Since the output
distribution is non-Gaussian, the calculated 3a number does not
74 Tolerance Analysis of Electronic Circuits

0.03 0.04

FIGURE 24 Opamp offsets amp MCA, normal dist

0.04

FIGURE 25 Opamp offsets amp MCA, uniform dist

mean much. Note however, that the extreme right-hand bin is about
18mV, the same as the extreme right-hand bin for Figure 24. The
same applies to the extreme left-hand bins.
Monte Carlo Analysis 75

MCA OF RTD CIRCUIT


The RTD circuit analyzed on page 19 had RSS values of 4.139 and
4.527V. Before proceeding to ac circuits, it will be interesting to
see how close a Gaussian input MCA will be to these numbers.
The following M-file rtdmca3.m performs a MCA on the RTD
circuit.

'il File rtdmca3.m


\ mea of rtd circuit;
'il normal and uniform distribution
\ uses MATLAB function G2.m, 7th order
clc;clear
Rl=4.53;R2=34.8;R3=132;R4=9.09;R5=9.09;E1=5;
R6=4.53;R7=27.4;R8=20;R9=20;RT=1.915;Ao=le6;
'
Vo=G2(Rl,R2,R3,R4,R5,R6,R7,RB,R9,RT,El,Ao);
Tinit=0.001;Tlife=0.002;ppm=le-6;
TC1=50*ppm;TC2=25*ppm;
Thi=Tinit+Tlife+35*TC1;Tlo=-Tinit-Tlife-BO*TC1;
Trhi=B.l*le-4;Trlo=-Trhi;Trefhi=0.02+35*TC2;
Treflo=-0.02-80*TC2;
'il
T=[ Tlo Tlo Tlo Tlo Tlo Tlo .. .
Tlo Tlo Tlo Trlo Treflo; .. .
Thi Thi Thi Thi Thi Thi • • .
Thi Thi Thi Trhi Trefhi];
N=5000;Nc=ll;nb=25;
randn('state',sum(lOO•clock));
rand('state',sum(lOO•clock));
for mc=1:2
Tn=zeros(N,Nc);vm=zeros(N,l);
for k=l:N
for w=l:Nc
if mc==l
Tn(k,w) = ( (T(2,w) -T(l,w)) /6) • ...
(randn+3)+T(l,w)+l;
else
Tn(k,w)=(T(2,w)-T(l,w))• ...
rand+T(l,w)+l;
16 Tolerance Analysis of Electronic Circuits

end
end
D=G2(Rl*Tn(k,l),R2*Tn(k,2),R3*Tn(k,3), .•.
R4*Tn(k,4),R5*Tn(k,5), •.•
R6*Tn(k,6),R7*Tn(k,7),RB*Tn(k,B), •..
R9*Tn(k,9),RT*Tn(k,10),El*Tn(k,ll),Ao);
Vlll(k)=D;
end
if mc==l
Vsl=3*std(Vlii);Vavgl=mean(Vlll);
hl=hist (VIII, nbl ; VLl=min (VIII) ; VHl=max (VIII) ;
intvl=(VH1-VL1)/nb;q=l:nb;
binl=VLl+intvl*(q-1);
Vhil=Vavgl+Vsl;Vlol=Vavgl-Vsl;
Vsr=sprintfl''2.3f\n',Vs1);
Vavgr=aprintf(''2.3f\n',Vavg1);
else
Va2=3*std(Vlii);Vavg2=mean(VIII);
h2=hiat (Vm, nb) ;VL2zmin (VIII) ;VH2=max (VIII);
intv2=1VH2-VL2)/nb;q=l:nb;
bin2=VL2+intv2*(q-1);
Vhi2=Vavg2+Vs2;Vlo2=Vavg2-Vs2;
Vsu•sprintf(''2.3f\n',Vs2);
Vavgu=aprintf(''2.3f\n',Vavg2);
end
end
subplot(2,1,ll
bar(binl,hl,l,'y');
title('Fig 26. RTD MCA, Normal dist');
grid off
axis([3.9 4.7 0 BOO]);
text(3.95,450,['Vavgs',Vavgr]);
text (3.95,300, ['Vs=',Vsr]);
'
subplot(2,1,2)
bar(bin2,h2,l,'y ' );
title('Fig 27. Uniform dist');
xlabel ( •Volts de • l
axis([3.9 4.7 0 BOO]);
text(3.95,450, ['Vavg=',Vavgu]);
text(3.95,300, [ 'Vs=' ,Vsu] l;
Monte Carlo Analysis 77

function y = G2(R1,R2,R3,R4,RS,R6,R7,R8,R9,RT,E1,Ao)
% mea for rtd function
A=[1 / R1+1 / R4+1 / RT -1 / RT - 1 / R4 0 0 0 -1 / R1; .. .
-1 / RT l / R5+1 / R6+1 / RT 0 -1 / RS 0 0 0; .. .
-1 / R4 0 1 / R2+1 / R3+1 / R4 0 -1 / R3 0 0; . . .
0 -1 / RS 0 1 / R5+1 / R7 0 0 0; ...
0 0 Ao - Ao 1 0 0; ...
0 0 0 0 0 1 / R8+1 / R9 -1 / R9; .. .
0 0 0 0 0 Ao 1);
B=[O;El / R6;E1 / R2;0;0;E1 / R8;0);
C=A \ B;y=C(S);

The MCA numbers for Figure 26 (normal dist) are Vavg1 - Vs1 =
4.343-0.189 = 4.154V and Vavg1 + Vs1 = 4.532V. These numbers
are within 0.36% and 0.11% of the RSS numbers calculated in Part
I (4.139V and 4.527V). Hence the Vrss method of de RSS analysis
in Part I has been verified empirically if not rigorously.

4.8

FIGURE 26 RTD MCA, normal dist


78 Tolerance Analysis of Electronic Circuits

FIGURE 27 RTD MCA, uniform dist

MCA OF BANDPASS FILTER (BPF) CIRCUIT


Before proceeding with a MCA on the multiple feedback BPF, an
explanation of how the MCA output is presented is given. Displaying
N = 10000 BPF frequency responses on one graph would result in
an unreadable smear. Instead, only the highest and lowest output at
each frequency is displayed.
The plot in Figure 28 shows the only the extrema of the 10
samples in Figure 29. One can imagine what Figure 29 would look
like with 10000 samples. Hence all the ac MCA plots to follow will
use this method as it gives a much cleaner picture of how the circuit
is reacting to the random inputs. Note that the minimums in Figure 28
are merely the upper and lower skirts of the highest and lowest center
frequency curves of Figure 29.
The multiple feedback BPF circuit will be first analyzed with
Gaussian inputs. This will show that the for some ac circuits with
Gaussian inputs the outputs can be very non-Gaussian and hence the
3a numbers are no longer significant.
Monte Carlo Analysis 79

This example will use the same asymmetric tolerances as in the


BPF circuit on page 29, and hence we can compare the MCA analysis
of Figures 8 and 9. TheM-file bpfmca.m is used to generate the plots
in Figures 30 and 31.
% MCA of Bandpass Filter
% File: mcabpf. m
% Transfer function method;
% uses function B2.m
clear;clc;
R1=6340;R2=80.6;R3=127000;Cl=O.l*le-6;C2=Cl;
BF=400;LF=600;DF=2;
Trl=0.02;Tcl=O.l5;Tr2=0.01;Tc2=0.1;
T=[-Trl -Trl -Trl -Tel -Tcl;Tr2 Tr2 Tr2 Tc2 Tc2];
N=lO;M=S;Lit=(LF-BF)/DF+l;
randn('state',sum(lOO*clock));
NNl=zeros(N,l);DDl=zeros(N,l);DDO=zeros(N,l);
Vo=zeros(Lit,l);
vm=zeros(N,Lit);Tn=zeros(N,M);
F=linspace(BF,LF,Lit);
% mc=l normal dist; mc=2 uniform dist
for mc=1:2
for k=l:N
for w=l:M
if mc==l
Tn(k,w)=((T(2,w)-T(l,wl)/6)* ...
(randn+3)+T(l,w)+l;
else
Tn(k,wl=(T(2,w) -T(l,w)) * ...
rand+T(l,wl+l;
end
end
end
for i=l:Lit
s=2*pi*F(i)*j;
Vo(i)=B2(Rl,R2,R3,Cl,C2,s);
for k=l:N
Vm(k,i)=B2(Rl*Tn(k,l),R2*Tn(k,2), ...
R3*Tn(k,3),Cl*Tn(k,4), ...
C2*Tn(k,5),s);
end
end
80 Tolerance Analysis of Electronic Circuits

'II get statistics


if mc==l
Vmaxl=max(vm);vminl=min(vm);
else
Vmax2=max(vm);vmin2=minlvml;
end
end
'II
subplot(2,1,1)
h=plot(F,Vmax1,'k',F,vminl,'k',F,Vo,'k');
set(h,'LineWidth',l);grid on
axis ([BF LF 0 15));
ylabel ( 'Volts' )
title('Fig 30. BPF MCA,normal dist')
text(420,12, ['N = •,num2str(N)));
'II
subplot(2,1,2)
h=plot(F,Vmax2,'k',F,vmin2,'k',F,Vo,'k');
set(h, 'LineWidth',l);grid on
axis ([BF LF 0 15]);
xlabel('Freq(Hz) ');ylabel('Volts')
title('Fig 31. BPF MCA, uniform dist')
text(420,12,['N = •,num2str(N)]);

function y = B2(Rl,R2,R3,Cl,C2,s)
'II function for MFBPF
Nl=l/(Rl*Cl);Dl=(l/Cl+l/C2)/R3;
D0=(1/Rl+l/R2)/(R3*Cl*C2);
y=abs(Nl*a/(sA2+Dl*s+D0));

Several interesting facts can be obtained from Figures 30 and 31.


First, note that the max value plot in the first graph is almost ftat.
This confirms our suspicion about the EVA plots in Figures S and
9; i.e., the plots only give extreme center frequency information, and
no conclusions can be made concerning maximum amplitudes at
intermediate frequencies.
From Figure 9, the maximum EVA center frequency was about
600 Hz. Figure 30 shows the highest MCA frequency to be consid-
erably less than this at about 570 Hz. If the number of samples N
were to be increased, the high MCA frequency would move farther
Monte Carlo Analysis 81

FIGURE 28 BPF MCA, min/max only.

FIGURE 29 BPF MCA, entire curves.


82 Tolerance Analysis of Electronic Circuits

FIGURE 30 BPF MCA, normal dist

15r---~--.----,------~~--,---,----.---.---,

•1000

~ ---
FIGURE 31
~
Freq(Hz)
~ ~

BPF MCA, uniform dist


~ ~ ~
Monte Carlo Analysis 83

FIGURE 32 BPF MCA, normal dist

to the right. If N was increased further, the high center frequency


would creep farther out. A diminishing returns case is seen here as
N gets larger. The max center frequency would approach but never
get beyond 600 Hz, and would equal 600 Hz when N is infinite.
The second plot, in Figure 31, shows the affect of using uniform
instead of normal distribution. Both the left and right center frequen-
cies have increased considerably from that in Figure 30. The asym-
metric distribution for the frequencies greater than 500 Hz is due to
the asymmetric tolerances.
The plot in Figure 32 shows an MCA for symmetric tolerances
and is used as a reference for Figure 33.
In Figure 33 the lowest trace at 500 H.z is the average value
(Vavg) of the output. The highest trace at 500 Hz is the average value
plus 3 standard deviations (Vavg + 3cr) at each frequency. From
Figure 32, we know that with 1000 samples the maximum voltage is
about II V. How can it be that Vavg + 30', at the extreme edge of the
Gaussian curve, is about 13.5V? This is much larger than the 11 V
obtained with I 000 MCA samples. This suggests that the distribution
of outputs is non-Gaussian.
84 Tolerance Analysis of Electronic Circuits

FIGURE33 BPF MCA, vavg + 3s.

To show that this is indeed the case, a frequency distribution


matrix is shown below with N = 900 samples. The lst column of
this matrix shows the 10 voltage bins from 1V to 1OV at 400 Hz,
the 2nd column at 420 Hz, 3rd at 440 Hz, and so forth, on up to the
last column 600 Hz.
By examining the numbers in the matrix, it can be readily seen
that the distributions are without a doubt non-Gaussian, at some
frequencies extremely so. Again, 3cr RSS numbers are meaningless
for non-Gaussian distributions.

900 830 287 11 0 0 0 2 92 515 854


0 70 569 400 28 1 20 234 657 375 46
0 0 41 345 154 9 103 387 130 9 0
0 0 3 94 210 40 158 171 18 1 0
0 0 0 28 168 67 175 60 1 0 0
0 0 0 12 118 98 127 24 1 0 0
0 0 0 2 79 117 104 10 1 0 0
0 0 0 6 44 143 81 6 0 0 0
0 0 0 2 66 210 74 5 0 0 0
0 0 0 0 33 215 58 1 0 0 0
Monte Carlo Analysis 85

In summary, Gaussian inputs do not provide the expected informa-


tion with some ac circuits. Hence the effort computing ac RSS and
EVA may not be productive. For most de circuits there are generally
no surprises with RSSIEVA analyses. For de and ac circuits, calcu-
lating the sensitivities can be technically and economically informative.

FAST MONTE CARLO ANALYSIS (FMCA)


In an attempt to provide more insight into this problem, a method
of tolerance analysis called Fast Monte Carlo Analysis (fMCA) is
given below.

If a dime, a nickel, and a penny are tossed up in the air, what


are all the possible combinations of heads and tails? TIT, TI'H,
THH, HHH, ..., etc.

Answer: 2H where N = 3.

1ben, if a circuit has three components, there are eight possible


combinations of the min and max tolerances.
FMCA is analyzing a circuit so that all possible 2H component
tolerance combinations are used. A general procedure to show the
2H combinations is to first create a N-bit binary counter. Then use
the min tolerance if the bit = 0, and the max tolerance if the bit =
1. An example to clarify this is shown below. The example circuit
is a simple voltage divider with two 2% resistors and a I OV, 5% input.

Yo= Ein ·R2


Rl+R2

With El = lOY, Rl = IOK, R2 = 30K, Yo= 7.5V. The tolerance


array Tis

-Tr -Tr -Te]


T= [
Tr Tr Te
86 Tolerance Analysis of Electronic Circuits

Three-bit binary counter:

1010101]
0110011
0 0 0 1 1 1 1

Then it is a simple programming task to place the tolerance multi-


pliers in the same order in the Tn array:

0.98 1.02 0.98 1.02 0.98 1.02 0.98


Tn = 0.98 0.98 1.02 1.02 0.98 0.98 1.02 1.02]
1.02
[
0.95 0.95 0.95 0.95 1.05 1.05 1.05 1.05

Note that rows are in RI, R2, Ein order.


Using a counter k = 1...8, the Tn array is inserted in the circuit
equation as follows:

Vm(k)= Ein ·Tn(3,k}·R2·Tn(2,k)


R1· Tn(1,k}+ R2· Tn(2,k)

which gives:

Vm=[7.053 7.196 7.125 7.875 7.795 7.953 7.875 7.125]

=
Now pick out the min and max values: min(Vm) 7.053, max(Vm)
= 7.953.
Using this scheme, the following MATLAB file fmcadiff.m performs
the FMCA on our ubiquitous de diff amp.
Monte Carlo Analysis 87

% FMCA of de diff amp


% File: fmcadiff.m
% no functions used
clear;clc;
Rl=lO;R2=100;R3=10;R4=100;El=l;E2=-1;
Vo=El*(l+R2/Rl)/(l+R3/R4)-E2*R2/Rl;
Tr=O.Ol;Te=O . OS;
T=[-Tr -Tr -Tr -Tr -Te -Te;Tr Tr Tr Tr TeTe];
% create 6-bit binary counter
M=6;N=2AM;
for k=l : N
for w=l:M
Re(w,k)=k;
end
end
for k=l:N
for w=l : M
Re(w+l,kl=floor(Re(w,k)/2};
Dr(w,k)=Re(w,k)-2*Re(w+l,k);
% create Tn array based on binary array Dr
i f Dr(w,kl==O
Tn(w,k)=l+T(l,w);
else
Tn(w,k)=l+T(2,w);
end
end
end
% insert Tn into output equation
for k=l:N
Vm(k}=El*Tn(5,k}*(l+R2*Tn(2,k)/(Rl*Tn(l,k)})/ ...
(l+R3*Tn(3,k)/(R4*Tn(4,k)))-E2*Tn(6,k)* ...
R2*Tn(2,k)/(Rl*Tn(l,k));
end
VL=min(Vm)
VH=max(Vm)
Running this file gives VL = 18.624 and VH = 21.424. These are of
course, the same answers given in the RSSIEVA analysis. One can
now see that the name "Fast Monte Carlo Analysis" might be appro-
priate. The method ignores intermediate tolerances and finds only
max and min tolerances.
88 Tolerance Analysis of Electronic Circuits

The next step is to perform a FMCA on the BPF circuit. The


M-file fmcabpfl provides the output in Figure 34.

\ FMCA of Bandpass Filter


\ File: fmcabpfl.m
\ functions not used
clc;clear;
Rl=6340;R2=80.6;R3=127000;Cl=O . l*le-6;C2=Cl;
Nl=l/(Rl*Cl);Dl=(l/Cl+l/C2)/R3;
00=(1/Rl+l/R2)/(R3*Cl*C2);
BF=400;LF=600;0F=l;Lit=(LF-BP)/OP+l;
F=linapace(BF,LF,Lit);
Trl=0.02;TclsO.l;Tr2=0.02;Tc2=0.1;
T=(-Trl -Trl -Trl -Tel -Tcl;Tr2 Tr2 Tr2 Tc2 Tc2];
M=5;Lit=(LP-BF)/OF+l;N=2AM;
\ generate 2AM FMCA
\ extreme tolerance combinations
Tn=zeros(M,N);Dr=zeros(M,Nl;
for k=l:N;for w=l:M;Re(w,kl=k;end;end
for k=l:N
for w=l:M
Re(w+l,kl=floor(Re(w,k)/2);
Dr(w,kl=Re(w,k)-2*Re(w+l,k);
if Dr(w,kl==O
Tn(w,k)al+T(l,w);
else
Tn(w,kl=l+T(2,w);
end
end
end
for i=l:Lit
s=2*pi*P(i)*j;
Vo(i)=abs(Nl*s/(sA2+Dl*s+D0)) ;
for k=l :N
Nl2(k)=l/(Rl*Tn(l,k)*Cl*Tn(4,k));
Dl2(k)=(l/(Cl*Tn(4,k))+l/ .••
(C2*Tn(5, k)) I I (R3*Tn(3, k));
002(k)=(l/(Rl*Tn(l,k))+l/ .• .
(R2*Tn(2 , kl l) I (R3*Tn(3, kl * •••
Cl*Tn(4,k)*C2*Tn(S,k));
Monte Carlo Analysis 89

Vm(k,i)=abs(N12(k)*s / . ..
(s A2+D12(k)*s+D02(k)));
end
end
Vmax=max (Vm) ;
subp1ot(1,1,1)
h=p1ot(F,Vmax, 'k',F,Vo, 'k');
set(h, 'LineWidth',2);grid on
axis ([BF LF 0 15])
xlabel('Freq(Hz) ');ylabel('Volts')
title('Fig 34. BPF FMCA')
s1='N = ';s2= ' Vpk = ';
text (410, 11, [s1,num2str (N)], 'FontSize', 8);
Vpk=max (Vmax) ;
text(410, 13, [s2,num2str(Vpk)], 'FontSize', 8);

FIGURE 34 BPF FMCA.


90 Tolerance Analysis of Electronic Circuits

The most glaring change in Figure 34 from the EVA plot in Figure 5
is the maximums in the vicinity offo =500Hz. Hence the EVA plot
did indeed omit much crucial tolerance analysis information. Note
however, that the extreme center frequencies show up to be consistent
with the EVA plot, i.e., 447Hz and 568 Hz. This is not a general
rule and an exception to this will be shown. Once again, it appears
that RSSIEVA analysis for ac circuits in general is not worthwhile.
There are exceptions to this as we have seen with the Butterworth
LPF.
Thus a conservative tolerance analysis method for ac circuits is
to do a FMCA and a uniform distribution MCA with N at least 1000,
preferably more. The advantage of this recommended approach is
shown in the following analysis of the BPF.
Figures 35 and 36 show all the required tolerance analysis infor-
mation in one plolln Figure 35, there are only N = 100 samples for
MCA., while in Figure 36 the difference with N = 5000 is obvious.
The dotted traces in both plots show the FMCA, or the maximum
envelope of the circuit response. Note the difference between the
MCA peak (Vpk) in both cases, and that the FMCA peak (Vfpk) is
the same.
('The M-file fmcabpf3.m used to create Figures 35 and 36, is
given in the Appendix.)
Note the two interior valleys of the FMCA analysis (dotted
traces) at 475Hz and 530Hz. These points represent 2 combinations
of the 25 = 32 extreme tolerance combinations. The MCA plot is
well above these valleys with some random combination of toler-
ances less than the extreme tolerances. Hence, output magnitudes
can be greater at smaller tolerances. This is a subtle characteristic
of some so-called "extreme value" analyses.
The reader can now understand that a true EVA, for this circuit
at least, can only be obtained via MCA using an infinite number of
samples. As in most statistical analyses, an EVA can only be esti-
mated, the accuracy of which improves as N is increased.
Monte Carlo Analysis 91

F1GURE 35 BPF FMCNMCA.

Vl*· ~ 1.2715
V\* ~ 11.4531
N•~
10 ............ .:

6 --

600

F1GURE 36 BPF FMCNMCA.


92 Tolerance Analysis of Electronic Circuits

SALLEN AND KEY BPF

E1

The final ac circuit analyzed contains several surprises and is given


for that reason. The Sallen and Key bandpass filter is well known
and described extensively in active filter literature. The design param-
= =
eters are a moderate Q of l 0 and gain 10 at fo 500 Hz. As in
the multiple feedback BPF, the RSS output should be ignored But
in this analysis, the EVA output should be ignored as well, as all the
information it contains is erroneous. See Figures 37 through 40.

Note: The M-file sakrssrtf.m used to create Figures 37 through


40 is given in the Appendix.

Note the difference in the sensitivity curves with that of the


multiple feedback BPF in Figure 2. In Figure 37 and 38, only the
curves for Rl, Cl, and C2 pass through zero near the resonant
=
frequency fo 500 Hz. The nearest 1% resistor values were chosen
from the design values. It can be seen that the peak nominal at fo in
Figure 39 (middle curve) is far from desired JOY. This is due to the
=
magnitude of the sensitivities at fo 500Hz, as seen in Figures 37
and 38. In the multiple feedback case, the sensitivities were close to
zero at fo = 500Hz.
Monte Carlo Analysis 93

FIGURE 37 Sensitivities: Rl , R2, R3, R4.

FIGURE 38 Sensitivities: RS, Cl , C2.


94 Tolerance Analysis of Electronic Circuits

-1oL-------~-------L------~------_J
400 450 500 550 600
fj"r.q (HZ)

FlGURE 39 RSS.

-10L_______J ________L______~--------
400 450 500 550 600
Freq (Hz.)

FlGURE 40 EVA.
Monte Carlo Analysis 95

FIGURE 41 EVA and FMCA.

According to the EVA plot, the extreme center frequencies are


454 Hz and 557 Hz. Recall that this was reliable information in the
case of the multiple feedback BPF.
The FMCA curve for this same circuit is shown in Figure 41
together with the EVA high plot from Figure 40. Note the large
disparity between FMCA and the so-called "Extreme Value" EVA
plots. The EVA curve does not show the maximum and minimum
center frequencies, not to mention the large amplitude differences
across the frequency band. Hence for this circuit, not only is the RSS
output erroneous, the EVA plot is also of no value and a waste of
computing time. When the circuit Q is increased from the design
value of 10, these RSSIEVA anamolies are aggravated.
We then look to MCA to provide a reliable estimate of this
circuit's performance over time. Unfortunately, another surprise is
in store for us.
96 Tolerance Analysis of Electronic Circuits

/ !

""" \
6.5
I
5
. ............. ...........

/'
\
5.

5 .. ........... I ; . .. ....... - -
5 ................ ........... i/ \.
r. . ................... / '\. ..
/ :
4 ..

3.5

v / T -t·- .
'~ ........

5V;. . .
.......
3
~
;.............. ..
i
2.

2
i i
400 420 440 460 460 500 520 540 560 560 600

FIGURE 42 Sallen and Key BPF nominal output.

The Sallen and Key MCA plot is shown in Figure 42 and 43 .


(TheM-file, mcasallen.m, for Figure 42 and 43 is given in the Appen-
dix.) One glance at Figure 43 and the reader will probably agree that
this belongs in the category of "Ripley's Believe It or Not." As to
why all this is happening, the EVAJFMCA extreme center frequency
disparity will be examined first.
The answer lies in the sensitivities. In Figure 37 at 600Hz, the
trace identifiers from top to bottom are R3, Rl , R4, and R2. In
Figure 38 they are from top to bottom R5, Cl, and C2, again at
600Hz. Note that above fo =500Hz, the sensitivity signs are Rl (-),
R2(-), R3(+), Cl(-), C2(-). The center frequency fo is given by:

fo=

Since R3 is +, we must multiply it by 1.02 (2% tolerance). For Rl


and R2 the multiplier is 0.98, and Cl and C2 it is 0.9 (-10%). When
Monte Carlo Analysis 97

FIGURE 43 Sallen and Key BPF MCA.

this is done, the center frequency using the above formula is fob =
557 Hz, precisely the answer the EVA gives us for the high center
frequency.
In FMCA, all possible combinations of tolerances are tried, so
we recalculate using all low tolerances. The only change here is the
sign of R3. The new center frequency calculates to fah = 568 Hz,
which is what the high-center frequency is in Figure 41. Thus the
difference.
Why didn ' t this happen with the multiple feedback BPF? The
center frequency expression for this filter is the same; the difference
is in the sensitivities. For the multiple feedback BPF at greater than
fo = 500 Hz, the signs for all five components are minu~ . Hence we
get 568Hz again.
The next question concerns the MCA plot. In a functioning
circuit, how could those peaks be greater than 350 volts? (Making
several runs of the file, peaks as high as lOOOV were obtained.)
Using matrix analysis, it would be very difficult to discover the
reason for these peaks. The answer lies in the transfer function. With
u = 1 + R5/R4 subsituted, Nl, Dl, and DO are as shown below:
98 Tolerance Analysis of Electronic Circuits

The magnitude of the transfer function in terms of w is as


follows:

where

l+R5
Nl=~
Rl·Cl

= =
First note that at the center frequency DO mo, Yo Nl/01. We
next create three tolerance multipliers for resistors R2, R4, and R5,
at or within their ±2% range:
Let a= 0.982 be a multiplier for R2; b = 1.02 for R5, and c =
0.9816 for R4. The following MATI...AB routine spike.m calculates
the gain with these multipliers:

% Sallen and Key MCA spike


% File: spike.m
clear;clc;
Rl=l5800;R2=5110;R3=2610;R4:3320;R5=13300;
Cl=le-7;C2=Cl;
% tolerance multipliers
a=0.982;b=l.02:c=0.9816;
Nl=(l+R5/R4)/(Rl*Cl);Dl=(l/Rl-R5/(R2*R4)+2/R3)/Cl;
DO=(l/Rl+l/R2)/(R3*Cl*C2);
% center frequency is
diary ( •OUtput. txt • l
fo•sqrt(D0)/(2*pi)
Monte Carlo Analysis

% with the multipliers


DOa=(l/Rl+l/(R2*a))/(R3*Cl*C2);
foa=sqrt(D0a)/(2*pi)
% then Gain = Nl/01 at frequency foa is
Nla=(l+(RS*b)/(R4*c))/(Rl*Cl)
Dla=(l/Rl-(RS*b)/(R2*a*R4*c)+2/R3)/C1
Gain=Nla/Dla
dBGain=20*loglO(Gain)
diary off

The output of this file is:

fo = 5.0135e+002 foa = 5.04Ble+002


Nla = 3.2676e+003 Dla = 1.6596e-001
Gain = 1.96BBe+004 fo = 5.0135e+002
foa = 5.04Ble+002 Nla = 3.2676e+003
Dla = 1.6596e-001 Gain = 1.968Be+004
dBGain = B.SBB4e+001

Frequency foa = 504.8 Hz is the shifted center frequency due to the


mulipliers. Hence the spike will occur at this frequency. When the
numbers are calculated, the spike at foa is 19,688 Volts, almost 86
dBV· The minus sign in 01 is the reason for this. One can set 01
= 0 by choosing values of R5/(R2·R4) to equal 1/Rl + 2/R3. The
moral of the story is beware of circuits that have minus signs in the
coefficient terms.

MORE MCA/FMCA EXAMPLES


More examples of MCAIFMCA analysis are shown below. For the
sake of brevity, only the circuit schematic, component values, trans-
fer function coefficients or matrices, and plots are given. The M-files
for this and following circuits are given in the Appendix. Uniform
distribution is used for random inputs. In all cases, resistor tolerances
= =
are Tr 0.02. and capacitor tolerances are Tc 0.1. For MCA, N =
1000 samples minimum. The dashed line in the plots represents the
nominal circuit output, the dotted line is the FMCA output, while
the heavy solid line is the MCA output.
100 Tolerance Analysis of Electronic Circuits

OELYIANNIS BPF*

E1 "' ..'
~1----0.--1
V1
V4

fo =500Hz; Q = 20; Rl = 4.93K; R2 = 205K; Ra = lOK; Rb =


252K; Cl = O.OluF; C2 = O.OluF
Transfer function:

Nl Ra+Rb Dt-~f...!...~L Ra DO ._ __.:._ _


Rl·C2·Rb' il\Ct C2}Rl·C2·Rb' Rl·R2·Cl·C2

A nominal Vo, MCA and FMCA plot is shown in Figures 44 and


45. Note the affect of the minus sign in D1 on the FMCA plot.

• From Reference 2.
Monte Carlo Analysis 101

1400
1200 ............ .................

1000

800
•11

800

c-·····
v \
)~ ~
200
- .::.::.··..... .........
·· ····--

..--::: ·::;/
-----
__-:..-::: f------~- - - .........
'-:'
~-----
..:.;.
;-----+-----

F1GURE 44 Delyiannis BPF.

1400r---.---.----.---,---.----.---.----.---,---.

F1GURE 45 Delyiannis BPF.


102 Tolerance Analysis of Electronic Circuits

TWIN·T PASSIVE NOTCH fiLTER

C4 C6

R5r1
111 113
E1 V3
C2
IV2 .l~ R7

= = =
Rl 267K; R3 267K; R5 133K; R7 1M; C2 = =0.02uF; C4 =
O.OluF; C6 = O.OluF; Tr = 0.02; Tc = 0.1

Transfer function (R7= -):

N2 =_1(_!_+_1)
C2 Rl R3
Nl=-~-[-1 (-1 +-1)]
Rl·R3 C2 C4 C6

NO=DO=---------
Rl·R3·R5·C2·C4·C6
Monte Carlo Analysis 103

-10

~ j .•.• ---·· ·.::::;:

t"------
-1
5 ------ :
~ l--::::::: ~
-20
--,,_ ~--~ ~--·

~/---
~--..•.----- ~ -?
i
-25
',,, v ,

/
-30
\, !-'

r---
N-100
I\. /
\j
50 55 eo 70 75 eo
FIGURE 46 Twin-T FMCA/MCA.

-1 0

-1
~ I
------~-:~
-- =
5
, ~ ~ -- -- ---

1~
___

"' /----
-2 ~ l-~::::· - -

~-.- ·:/ ~
0 '',,,

-25

i ',\ """ ,//


-30
\ v
N•2000
i\ /
\j
50 ss eo es 70 75 80
Freq(Hz)

FIGURE 47 Twin-T FMCA/MCA.

LTC 1562 BPF


fo = 10KHz; Q = 20; H = 10; R1 = 10K (Internal); C1 = 159.15pF
(Internal); C2 = C1; R2 = 1M; Rq =2M; Rin = 200K; Tr = 0.01;
Tc = 0.1 (Contact vendor for R1 and C1 tolerances).
104 Tolerance Analysis of Electronic Circuits

R2

Transfer function :

Nl=~ D1 l DO=-----
Rin ·C2 ' = Rq ·C2' Rl ·R2 ·Cl ·C2

FIGURE 48 LTC 1562 BPF.


Monte Carlo Analysis 105

FIGURE 49 LTC 1562 BPF.

MFB ALL-PASS FILTER

C2

All-pass phase angle designed for 'Tt/2 or 90% at 500 Hz; constant
gain= 0.9 VN. Rl = 619, R2 = 22.6K, R3 = 24.9K, R4 = 226K,
Cl = O.luF, C2 = O.luF.
106 Tolerance Analysis of Electronic Circuits

' i l
90 ········--····~·-·--·--···-····~--------·-··--!- ..··-----~----· ...... ········+-··-······..-·
... ___ '

7~50 -460 470 -460 490 500 510 520 530 540 550

FIGURE SO MFB all-pass.

A matrix and B column vector:

I EI
-+s(CI+C2} -s·CI 0 -s ·C2
RI RI
I
-s ·CI -+s ·CI 0 0
A= R2 R2 B=
0 0
I
-+-
I
0 -EI
R3 R4 R3
0 -Ao Ao 0

NS MF1 0 SWITCHED CAPACITOR FILTER*


See manufacturer's data sheet for correct resistor connection pins.
(No external capacitors.)

* Mode 3 (Also LTC1060).


Monte Carlo Analysis 107

k-·
190
f

;,

' r':·r··--
170

;::-- t·--.
I··

1'-,:~· r·- ·.j


-,, ___
~

t--- ~ t··.....t- .
:------
- - - r------
0

~
~
-
~---,r"
N ~1000
90

f.. -
7~ 470 480 490 500 510 520 530 540 550
Fr.q(Hz)

FIGURE 51 MFB all-pass.

Transfer function : fc = switching frequency (51 kHz in


MATLAB example.)

2
we= 27tfc Nl= wc ·R2 Dl= wc ·R2 DO (wc) ·R2
50 ' Rl ' R3 ' R4

fo =640 Hz, Q = 100, H = 1 (gain) in MATLAB example.


Design equations, given Q, we, and H:

Set Rl to some value. Then:

2
R 2 = HRlwo , R4 =R"rwc] , R3 wcQR2
Qwc 1wo wo

Example: Rl = 1.585M, R2 = lOK, R3 = 1.593M, R4 =25.4K.


108 Tolerance Analysis of Electronic Circuits

1 . 2r---~----~----r---~-----.----r----.-----.----,----,

FIGURE 52 MF 10 SCF BPF.

1 . 2.--,----,-----,~-,-----.--,---,----,----.----,

' t : rt '
! .•·'· ------.•n.·.--;,
··· ··· ··--- -~----------1'~-- · .... + .. +.
~~ ~\ --------:~,·\•. ·-···----..• ~-
i! . L---U
. !i
1\ . ~ /11
...,!.... i,· . ..
~-- .---ini. ~~ ..........L.i\.
. .. ... ·;i..... ~.· ·--'.,'.
~ j]\ ; !\ ' ;

· ·\ft·t !
\ i j 1 · ·-·r tt
f \ f. .,-~il. \,~·.il· · · ·~~\.•, ,. . .,. . . .+ ..............+ ........... ....~
....l.. !_;_J·. .

' J .\LI \l .(_i 1.


!
.................t;"'··)<__
~ ·.,',;: ,.,./ '--~t-·················+····
i '
_... ~ . . . 1 ; . . . . . __

620 640 660


Freq(Hz)

FIGURE 53 MF 10 SCF BPF.


Monte Carlo Analysis 109

BUFFERED 60-HZ NOTCH FILTER•

RJ

El

Rl = 19K, R2 = 57.6K, R3 = 464K, R4 = 200, R5 = 4.8K,


Cl = 47nF, C2 = Cl, C3 = Cl

• Electronic Design, IFI>I520, 2/19/96.


110 Tolerance Analysis of Electronic Circuits

~~ +s(C1+C2} -sC2 0 0
Rl
0
1 1
-sC2 R2 +s(C2+C3} -sC3 0 0
R2

A
0 -sC3 ~3tsC3 0 0 0

0 0 0 -1 0

0 0 0 0 -~-~_I
R4 R5 R4
0 0 -1 0 0

aC1

0
1
R3
B
0

0
Monte Carlo Analysis 111

10,-----.-----.-----.-----.-----.-----.-----.-----.

·20 .
..,&;
-30 .

~~o----~4~5----~~~--~5~5----~----~5~5----~7~0-----7~5~--~~-

FIGURE 54 Buffered notch.

10r-----.-----.-----.-----,-----,-----,-----.-----.

FIGURE 55 Buffered notch.


Appendix

DERIVATION OF THE RSS EQUATION:


Using an example function Vo = f(Rl,R2,R3), the RSS definition is:

This definition is derived from the total differential in calculus, which


for the example function is:

iJVo iJVo iJVo


dVo = -·dRl+-·dR2+-·dR3
iJRl iJR2 iJR3

The dR's are differentials and thus are infinitesimally small and
approach zero. When the dR's are set to the component tolerances,
this is stretching the definition somewhat. Thus with large component
tolerances and sensitivities, RSS becomes a poor estimator and
should not be used.
The RSS method is also defined as the variance of a (linear or
non-linear) function in Reference 7.

where Cov~.X,J is the covariance of -"t and ~ If the random


variables -"t are statistically independent, i.e., uncorrelated, then the
variance becomes:

113
114 Tolerance Analysis of Electronic Circuits

For the derivation given in Reference 8, let U be some function of


the three measured quantities X, Y, and Z, that is U = f(X,Y.z>.
If each independent variable is allowed to change by a small
amount dX, dY, dZ, then the quantity U will change by an amount
dU given by the total differential

au au
dU=- ·dX+- ·dY+- ·dZ
au
ax av az
=
Applying this to a set of measurements, let Ax dX, /iy = dY, and
&I. =
dZ, be a set of residuals of the measured quantities. Then letting
/iu = dU

Squaring both sides and adding gives:


Appendix 115

au.= (au)
2 2 .,(au)(au)A. (au)z z
ax Ax.+"\.ax ayr•tJ.y.+ ... + az tJ.z.

If the measured quantities are uncorrelated the cross products are


zero. Dropping these cross products and dividing both sides by n -
1 gives:

~=(au)
2
~+(au)
2
n-1 ax n-1 ay
~+(au)z
n-1 az
~
n-1

or

( )z ( )z (au )z
2 au au 2 2 2
a. = ax a.+ ay a,+ az a. Q.E.D.

BPF SENSITIVITY EXPRESSIONS


The following is a complete description in equation form of the MFB
BPF sensitivities analyzed in Figure 2. They were derived by taking
symbolic derivatives of the BPF transfer function F(s) with respect
to the components, and multiplying by the correct normalizing factors.
The sensitivity equation for Rl is omitted, since it is almost a
constant. Defying convention and using m for the radian frequency
=
variable ro. and letting wo 27tfo, and G = design gain, the equations
are:
116 Tolerance Analysis of Electronic Circuits

Note that gain G is involved in S12 only. Also note the only difference
between Sc1 and S0 is the sign of the wol term in the numerator.

VALUES AT M =WO
Su(wo) =0 Slll(wo) =+1 Sc1(wo) =+lf.z Scz(wo) =~
Compare these numbers with the zoomed plot of the sensitivities
shown in Figure 7.

ZERO CROSSING fREQUENCIES

wo fi _ fo ·Q _
fio = 2x • r3 - ~Qz -1 • .c1 -
& f~-1 &c __ fo ·Q:/2
2 • ,, 2 ~2Qz -1
AppendiX 117

With fo = 500.6 Hz and Q = 20, fr3 = 501.23, fcl = 500.29, fc2 =


500.91

EXTREME fREQUENCIES (PEAKS AND VALLEYS)

For Rl:

fr2v=fo~l+ ~· fr2p•fo~l- ~ fr2v=512.96Hz, fr2p=487.92Hz

For R3:

fr3v=fo~ Q-1
Q , fr3p=fo~ Q
Q+l
fr3v=513.6Hz. fr3p=488.54Hz

For Cl:

fclv=fo
2Ql+~
~ fclp=fo
2Q2 ~
-~
2Q -1 ' 2Q2 -l

From which flcv = 513.28 Hz, and fclp = 488.23 Hz.

Plus and minus peak amplitudes:

Vr2a 2Q2 -G Vr2b- G-2Q2 Vr3a=(Q+lt Vr3b=-(Q- 1t


2(2Q-1}' 2(2Q+l) 2Q+l 2Q-l

With G = 10, and Q = 20, Vr2a = +10.13, Vr2b = -9.63; Vr3a =


+10.76, Vr3b = -9.26. (Volts)
118 Tolerance Analysis of Electronic Circuits

_1-4Q 2 +2Q 2 ~ 1-4Q 2 -2Q 2 ~


Vela- Vc1b = (
2(4Q 2 -1 }
}
2 4Q 2 -1

Vela= +9.5, Vclb = -10.5.

Note the strong dependence of these expression on Q. It can be


shown that the peak amplitudes are approximately Q/2.
To confirm that the sensitivities given for the BPF are consistent,
the equations for R2, R3, Cl, and C2 sensitivities are plotted in
Figures 56 and 57 using theM-file senseqns.m. Compare these plots
with those in Figures 2 and 6. The reader should also compare these
accurate sensitivities with the sensitivities calculated by a Spice-
derived analysis package.

FIGURE 56 Sensitivities of R2, R3, Cl, C2 MFB BPF.


Appendix 119

" 1 ·~ 500.1 500.2 500.3 500.4 500.5 500.6 500.7 500.8 500.9 501
Freq(Hz)

FIGURE 57 Near fo =500.6 Hz.


CONFIDENCE INTERVALS
In Monte Carlo Analysis (MCA), statistical confidence intervals for
the mean and 3cr numbers can be calculated. The confidence level
chosen is usually 95%. The procedure is best illustrated by an example:

Let the number of samples N = 5000 and the nominal output


voltage be Vo = 20V and the 3cr value be calculated as Vo + 3cr =
20.756V.

From the table below, we choose the two numbers in the 5000
column A =0.9808 and B = 1.0200. Then with 95% confidence the
true Vo + 3cr value is between Vo + Vs·A and Vo + Vs·B, or 20 +
0.756(0.9808) = 20.741V and 20 + 0.756(1.0200) = 20.771V, and
similarly for Vo - 3cr.
For 95% confidence level for the mean Vavg = 19.999V we
choose the number C in the 5000 column. Then the 95% confidence
level the true mean is between Vavg- Vs·C and Vavg + Vs·C or
120 Tolerance Analysis of Electronic Circuits

19.999 - 0.756(0.0277) = 19.978V 19.999 + 0.756(0.0277) =


20.020V.

N 100 500 1000 2000 3000 4000

A 0.8785 0.9417 0.9580 0.9700 0.9153 0.9786


B 1.1607 1.0661 1.0458 1.0320 1.0260 1.0224
c 0.1984 0.0879 0.0621 0.0439 0.0358 0.0310
N 5000 6000 7000 8000 9000 1000

A 0.9808 0.9824 0.9837 0.9847 0.9856 0.9863


B 1.0200 1.0182 1.0168 1.0157 1.0148 1.0141
c o.02n 0.0253 0.0234 0.0219 0.0207 0.0196
Reference 7, p.81.

PERCENT YIELD
It is a relatively simple matter to place fail counters in any of the
MCA M-files. Then percent yield can be calculated as lOO*number
failed/number of samples. An outer loop of component tolerances
can be constructed to give percent yield at each tolerance. The
following M-file pcyield.m shows a simple example.

\ Percent yield of diff amp


\ File: pcyield.m
\uses MATLAB function DA2.m
clear;clc;
Rl=l0;R2=100;R3=10;R4=100;Bl=-l;B2=l;Ao=le6;
Vo=DA2(Rl,R2,R3,R4,El,E2,Ao);
N=5000;M=6;
randn('state',sum(lOO*clock));
Tn=zeros (N, M) ;
\ set test limits at
\ UL = Vo+Js; LL = Vo-Js
UL=20.7;LL=20-0.7;LM=(LL UL);
Appendix 121

for r=l:3
% clear fail counters
flo=O;fhi=O;
Tr=r/100;Te=0.05;
Trm(r)=Tr;Tem(r)=Te;
T:[ -Tr -Tr -Tr -Tr -Te-Te; .. .
Tr Tr Tr Tr TeTe];
for k=l:N
for w=l:M
Tn(k,w)=((T(2,w)-T(l,w))/6)* .••
(randn+3)+T(l,w)+1;
end
Vm(k)=DA2(Rl*Tn(k,1),R2*Tn(k,2), .•.
R3*Tn(k,4),R4*Tn(k,4), ...
El*Tn(k,5),E2*Tn(k,6),Ao);
% catch high failures
if Vm(k)>UL;fhi=fhi+l;end
% catch low failures
if Vmlkl<LL;flo=f1o+l;end
end
NFH(r)=fhi ; NFL(r)=flo;
pcy(r)=100*(1-(fhi+flo)/N);
Vs=3*std(Vm);Vavg=mean(Vm);
Vhi(r)=Vavg+Vs;Vlo(r)=Vavg-Vs;
end
diary( 'OUtput. txt')
LM
MV= [Trm; Tem;Vlo;Vhi;NFH;NFL;pcy]
diary off

The output of this file is:


LM = 19.3000 20.7000 Spec limits

0.0100 0.0200 0.0300 Tr


0.0500 0.0500 0.0500 Te
19.2341 19.1144 18.9007 Vo - Vs
20.7647 20.8780 21.0736 Vo + Vs
20.0000 42.0000 139.0000 Failed high
10.0000 47 . 0000 145.0000 Failed low
99.4000 98.2200 94.3200 Percent Yield
122 Tolerance Analysis of Electronic Circuits

This shows that as the resistor tolerance Tr increases from 1% to


3%, the percent yield decreases from 99.4% to 94.32% out of N =
5000 samples.

MATHEMATICAL CURIOS
AN "AccuRAn:" CANCER TEn-
Assume a test for cancer is advertised as 98% acccurate: Ta 0.98 =
Further assume that out of N people tested, 0.5% have cancer:

N = 10000; Cr = 0.005

There are therefore Tp = N·Cr = 50 people with cancer in the


Nsamples.
There are also Tn = N·( 1 - Cr) = 9950 people who do not have
cancer.
= =
Then Tip Ta·Tp 49 of the people with cancer will be diagnosed
conectly or true positive.
However, of Tn people without cancer, TFp = (1 - Ta)·Tn = 199
will be false positive or incorrectly diagnosed.

Hence the true accuracy R of the cancer test is:

R= lOO·Tfp =19.76%
Tfp+TFp

• From J.A. Paulos,IMWMracy, Vintage Books, 1990. Dr. Paulos also relates
a story about a television weatherman who made the rather surprising state-
ment: "We have a SO... chance of rain on Saturday and SO... chance of rain
on Sunday. That means there is a 1~ chance of rain this weekend."
Appendix 123

EASTER DATES

The following M-file calculates the dates of Easter up to the year


2020. The dates for years higher than 2020 can be obtained by
changing the variable LY in the M-file.

'i Easter dates


'i File: Easter.m
clear;clc
BY=1995;LY=2020;a=LY-BY;
for i=1:a
Y=BY+i;C=floor(Y/100);
N=Y-19*floor(Y/19);K=f1oor((C-17)/25);
I=C-floor(C/4)-floor((C-K)/3)+19*N+15;
I=I-30*floor(I/30);
I=I-floor(I/28)*(1-floor(I/28)) ...
*floor(29/(I+l))*floor((21-N)/111;
J=Y+floor(Y/4)+I+2~C+floor(C/4);
J=J-7*floor(J/7);
L=I-J;M=3+floor((L+40)/44);
D=L+28-31*floor(M/4);
year(i)=Y;mon(ii=M;day(i)=D;
end
Z=[year; mon; day];
EM=sprintf('%4.0f %2.0f %2.0f\r',Z)
% output to text file
fid=fopen('Output.txt•, •w•);
fprintf(fid, ''i4.0f 'i2.0f 'i2.0f\r\n',Z);
status=fclose(fid);

The file 'Output.txt' is

1996 4 7 1997 3 30 1998 4 12 1999 4 4


2000 4 23 2001 4 15 2002 3 31 2003 4 20
2004 4 11 2005 3 27 2006 4 16 2007 4 8
2008 3 23 2009 4 12 2010 4 4 2011 4 24
2012 4 8 2013 3 31 2014 4 20 2015 4 5
2016 3 27 2017 4 16 2018 4 1 2019 4 21
2020 4 12
124 Tolerance Analysis of Electronic Circuits

For example, the date of Easter in the year 2016 is March 27. Hence,
Easter can be classified as a "moveable feast."*

NuMBER OF WEEKDAYS BETWEEN Two DATES

Programs that calculate the number of days between dates are com-
mon. However, programs that calculates the number weekdays
between two dates are not well known. The following M-file will
calculate the number of weekdays between to dates in
MM.DDYYYY format. Example: Mar 25, 1998 becomes 3.251998.
The following function is required:

function c = frac(x)
c = x-floor (X) ;

% Number of weekdays between dates


% File: wkdays.m
clear;clc
% What are the number of weekdays
% between Feb 17, 1989 and Mar 25, 1990?
' d1 = 2.171989; d2 = 3.251990;
% Answer is WD = 286
d1•input('First date in MM.DDYYYY form? ');
d2=input( 'Second date in MM.DDYYYY form? ');
date= [d1 d2);
for k=1:2
if date(k)<•3
date(k)=date(k)+11.999999;
end
date(k)=1+date(k);
D(k)=round(100*frac(date(k)));
M(k)=round(date(k));
Y(k)=round(1e4*frac(100*frac(date(k))));
b(k)=floor(Y(k)*365.25);
a(k)=floor(0.75*(floor(Y(k)/100)-7));

• From Explanolory Supplement to the Astronomical Almanac, USNO, Uni-


vmity Science Books, 1992.
Appendix 125

d(k)=floor(M(k)*30.6);
C(k)=floor(O(k)+Y(k)/le4-a(k)+b(k));
W(k)=(d(k)+C(k))/7;F(k)=floor(W(k));
G(k)=floor(l2.6l*frac(W(k)))/10;
H(k)=S*(F(k)+G(k));
end
WD=round(abs(H(l)-H(2)))

M-FILE LISTINGS
For Figures 35 and 36:

% FMCA and MCA of BPF; two values of Nm


% File: fmcabpf2.m
clc;clear
R1=6340;R2=80.6;R3=127000;Cl=O.l*le-6;C2=Cl;
BF=400;LF=600;DF=2;Lit=(LF-BF)/OF+l;
F=linspace(BF, LF, Lit);
Trl=0.02;Tcl=O.l;Tr2=0.02;Tc2=0.1;
T=[-Trl -Trl -Trl -Tel -Tel; ...
Tr2 Tr2 Tr2 Tc2 Tc2];
M=5;Nf=2"M;
% generator 2"M extreme
% tolerance combinations
Tf=zeros (M,Nf);
for k=l:Nf;for w=l:M;Re(w,k)=k;end;end
for k=l:Nf
for w=l:M
Re(w+l,k)=floor(Re(w,k)/2);
Dr(w,k)=Re(w,k)-2*Re(w+l,k);
if Dr(w,k)==O
Tf(w,k)=l+T(l,w);
else
Tf(w,k)=l+T(2,w);
end
end
end
% generate N uniform random
% numbers for M components
rand('state•,sum(lOO*clock));
126 Tolerance Analysis of Electronic Circuits

for nc=1:2
if nc==l
Nm=lOO;
else
Nm=SOOO;
end
for p=l:Nm
for w=l :M
Tn(w,p)=(T(2,w)-T(l,w))*rand+T(l,w)+l;
end
end
for i=l:Lit
s=2*pi*F(i)*j;
if nc==l
Vo(i)=B2(Rl,R2,R3,Cl,C2,s);
for k=l:Nf
Vf(k,i)=B2(Rl*Tf(l,k),R2*Tf(2,k), ...
R3*Tf(3,k),Cl*Tf(4,k),C2*Tf(5,k),s);
end
end
for p=l:Nm
vm(p, i)=B2(Rl*Tn(l,p),R2*Tn(2,p), ...
R3*Tn(3,p),Cl*Tn(4,p),C2*Tn(5,p),s);
end
end
if nc==l
VmaXl=max(vml ;VmaX3=max(Vfl;
Nl=Nm;clear vm;
else
VmaX2=max(vm);N2=Nm;
end
end
subplot(2,1,1)
h=plot(F,VmaX3 , 'k.:',F,Vo, 'k--',F,VmaXl, 'k');
set(h,'LineWidth',2);grid on
axis ([BF LF 0 15])
ylabel ('Volts')
title('Fig 35. BPF FMCA/MCA')
text(410,ll,['N == ',num2str(Nl)),'FontSize',8);
~kl=max(VmaXl);~k3=max(VmaX3);
text(410,13,{'~k = •,num2str(~kl)],'FontSize',8);
text(410,12, ['Vfpk = ',num2str(~k3)],'FontSize',8);

'
Appendix 127

subplot(2,1,2)
h=plot(F,Vmax3,'k.:',F,Vo,'k--',F,Vmax2,'k');
set(h, 'LineWidth',2);grid on
axis ([BF LF 0 15])
xlabel( 'Freq(Hz) ') ;ylabel( 'Volts')
title('Fig 36. BPF FMCA/MCA')
text(410,11, ['N = •,num2str(N2)], ' FontSize',8);
VPk2=max (Vmax2) ;
text(410,13,['Vpk = ',num2str(Vpk2)], 'FontSize',8);
sl= 'Vfpk = •:
text(410,12,[sl,num2str(VPk3)],'FontSize',8);

function y = B2(Rl,R2,R3,Cl,C2,s)
% function for MFBPF
N1=1/(Rl*Cl);Dl=(l/Cl+l/C2)/R3;
D0=(1/Rl+l/R2)/(R3*Cl*C2);
y=abs(Nl*s/(s~2+Dl*s+DO));

For Figures 37 through 40:

% Sallen & Key BPF RSS & WCA


%Pile: sakrsstf.m
clear;clc
R1=15800;R2=5110;R3=2610;R4=3320;R5=13300;
Ao=le6;Cl=le-7;C2=C1;
BF=400;LF=600;DF=l;
Nc=7;dpf=0.0001;Q=dpf*eye(Nc)+1;
% Form tolerance array T
Tr=0.02;Tc=0.1;
T=[-Tr -Tr -Tr -Tr -Tr -Tc -Tc; ...
Tr Tr Tr Tr Tr Tc Tc];
% Start ac analysis
Lit=(LF-BF)/DF+l;A=zeros(4);
F=linspace(BF,LF,Lit);
for i=l:Lit
s=0+2*pi*F(i)*j;
Vo(i)=G3(Rl,R2,R3,R4,R5,Cl,C2,s);
for p=l:Nc
Vr(i,p)=G3(Rl*Q(p,l),R2*Q(p,2), ...
R3*Q(p,3) I • • •
R4*Q(p,4),R5*Q(p,5),Cl*Q(p,6), ...
C2*Q(p,7),s);
128 Tolerance Analysis of Electronic Circuits

Sen(ilp)=((Vr(ilp)/Vo(i))-1)/dpf;
i f Sen(i 1p)>0
L(i 1p)•1+T(l 1p);H(i 1p)=l+T(2 1p);
else
L(i 1p)•l+T(2 1p);H(i 1p)=l+T(1,p);
end
end
' get RSS
suml(i)•O;sum2(i)=O;
for p•l:Ne
suml(i)=suml(i)+(Sen(ilp)*(L(ilp)-1))~2;
sum2(i)=sum2(i)+(Sen(i~p)*(H(ilp)-1))~2;
end
Vrssl(i)=Vo(i)*(l-sqrt(suml(i)));
Vrss2(i)=Vo(i)*(l+sqrt(sum2(i)));
' get EVL &: EVH
VL(i)=G3(Rl*L(ill)IR2*L(i 12) 1R3*L(i 13), ••.
R4*L(i~4l~RS*L(i,S),Cl*L(ii6)1C2*L(i 1 7) 1 s);
VH(i)=G3(Rl*H(i 1l)IR2*H(i 12) 1R3*H(i 13) 1 ..•
R4*H(ii4)1RS*H(ii5)1Cl*H{ii6)1C2*H{il7) 1 s);
end
'
subplot(2,211)
h=plot ( F 1 Sen ( : 1 1) 1 ' k' 1 F 1 Sen ( : 1 2) 1 ' r ' , .•.
F 1 Sen ( : 1 3) 1 ' g' ) ;
hold on
g=plot(FISen(:l4)1 'b');
set(h~'LineWidth'll);set(gi'LineWidth' 1 l)
grid on
axis([BF LF -20 20))
ylabel(''''','FontSize',B)
s1•'Fig 37. Sensitivities; R1,R2 1R3,R4';
title(sll 'FontSize',B)
hold off
'
subplot(2,212)
h=plot ( F 1 Sen ( : 1 5) 1 ' k' 1 F, Sen ( : 1 6) I ' r ' I • • •
F 1 sen< : 1 7 l 1 • g • l ;
set(h, 'LineWidth',l);
grid on
axis([BF LP -20 20))
ylabel('''''l 'FontSize·~Bl
s2='Fig 38. Sensitivities; RSIC1 1C2';
Appendix 129

title(s2, 'FontSize',8)
'
subplot(2,2,3)
m=plot(F,Vrssl, 'k',F,Vrss2, 'k',F,Vo,'r');
set(m,'LineWidth',l)
grid on
axis([BF LF -10 20])
xlabel('Freq (Hz)','FontSize',8);
ylabel('Volts','FontSize',8)
title('Fig 39. RSS','PontSize',8)
'
subplot(2,2,4)
m=plot(P,VL, 'k' ,P,VH, 'k' ,F,Vo, 'r');
set(m,'LineWidth ' ,l)
grid on
axis([BF LP -10 20])
xlabel('Freq (Hz)','FontSize',8);
ylabel('Volts','PontSize',8)
title('Fig 40. EVA','PontSize',8)

function y = G3(Rl,R2,R3,R4,R5,Cl,C2,s)
\ fen for sallen & key transfer function
Nl=(l+RS/R4)/{Rl*Cl);
Dl={l/Rl-RS/{R2*R4)+2/R3)/Cl;
D0=(1/Rl+l/R2)/(R3*Cl*C2);
y=abs(Nl*s/(s~2+Dl*s+D0));

For Figure 41:

\ Sallen & Key BPF RSS & WCA


\File: skevafmcatf.m
\ combined FMCA & EVA for S&K BPF
\uses MATLAB function G3.m
clear;clc
Rl=15800;R2=5110;R3=2610;R4=3320;R5=13300;
Cl=le-7;C2=Cl;
BF=400;LF=600;0F=l;
Nc=7;dpf=O.OOOl;Q=dpf*eye(Nc)+l;
\ Form tolerance array T
Tr=0.02;Tc=O.l;
T=[-Tr -Tr -Tr -Tr -Tr -Tc -Tc; •..
Tr Tr Tr Tr Tr Tc Tc];
130 Tolerance Analysis of Electronic Circuits

\ Start ac analysis
Lit=(LP-BF)/DF+l;
F=linspace(BF,LF,Lit);
for i=l:Lit
S20+2*pi*F(i)*j;
Vo(i)=G3(Rl,R2,R3,R4,R5,Cl,C2,s);
for p=l:Nc
Vr(i,p)=G3(Rl*Q(p,l),R2*Q(p,2), .••
R3*Q{p,3),R4*Q(p,4),R5*Q{p,5), •••
Cl*Q(p,6),C2*Q(p,7),s);
Sen(i,p)=((Vr(i,p)/Vo(i))-1)/dpf;
if Sen(i,p)>O
L(i,p)=l+T(l,p);H(i,p)=l+T(2,p);
else
L(i,p)•l+T(2,p);H(i,p)=l+T(l,p);
end
end
\ get EVH
VH(i)=G3(Rl*H(i,l),R2*H(i,2), •.•
R3*H{i,3),R4*H(i,4),RS*H(i,5), ..•
Cl*H(i,6),C2*H(i,7),s);
end
\ start FMCA
M=7;N=2~M;Tn=zeros(M,N);Dr=zeros(M,N);
for k=l:N;for w=l:M;Re(w,k)=k;end;end
for k=l:N
for w=l:M
Re(w+l,k)=floor(Re(w,k)/2);
Dr(w,k)=Re(w,k)-2*Re(w+l,k);
if Dr(w,k)2•0
Tn(w,k)=l+T(l,w);
else
Tn(w,k)=l+T(2,w);
end
end
end
for i=l:Lit
s=2*pi*F(i)*j;
for k=l:N
vm(k,i)=G3(Rl*Tn(l,k),R2*Tn(2,k), ••.
R3*Tn(3,k),R4*Tn(4,k),RS*Tn(5,k), ...
Cl*Tn(6,k),C2*Tn(7,k),s);
end
AppendiX 131

end
Vmax=max(vml ;Vpk=max(Vmax);
%
subplot(l,l,ll
m=plot(F,VH, 'k' ,F,Vo, 'r' ,F,Vmax, 'g');
set(m,'LineWidth',2)
grid on
axis([BF LF 0 30))
xlabel('Freq (Hz) ','PontSize',8);
ylabel('Volts','FontSize',8)
title('Fig 41. EVA & FMCA','FontSize',8)

function y = G3(Rl,R2,R3,R4,R5,Cl,C2,s)
% fen for sallen & key transfer function
Nl=(l+R5/R4)/(Rl*Cl);
Dl=(l/Rl-R5/(R2*R4)+2/R3)/Cl;
D0= (1/Rl+l/R2)/(R3*Cl*C2);
y=abs(Nl*s/(sA2+Dl*s+D0));

For Figures 42 and 43:


% MCA of Sallen & Key BPF
% File: mcasallen.m
% uses matrix analysis and function B6.m
clear;clc;
Rl=l5800;R2=5110;R3=2610;R4=3320;
R5=13300;Cl=le-7;C2=Cl;
BP=400;LF=600;DF=2;
% Tolerance array
Tr=0.02;Tc=O.l;
T=[-Tr -Tr -Tr -Tr -Tr -Tc -Tc; . • .
Tr Tr Tr Tr Tr Tc Tc);
% generate N random normal
% numbers for Nc COmPOnents
N=lOO;Nc=7;
randn('state',sum(lOO*clock));
rand(•state',sum(lOO*clock));
Tn=zeros(N,Nc);
% normal dist me 1
% uniform dis me 2
for mc=l:2
for k=l:N
132 Tolerance Analysis of Electronic Circuits

for W=l:Nc
if mc:==l
Tn(k,w) = ( (T(2,w) -T(l,wl l /6) * ...
(randn+3l+T(l,w)+l;
else
Tn(k,w)=(T(2,w)-T(l,w) )* •••
rand+T(l,wl +1;
end
end
end
Lit=(LF-BF)/DF+l;
F•linspace(BF,LF,Lit);
for ial:Lit
s=2*pi*F(i)•j;
Vo(i)=B6(Rl,R2,R3,R4,R5,Cl,C2,s);
for k=l:N
D=B6(Rl*Tn(k,l),R2*Tn(k,2), . .•
R3*Tn(k,3) ,R4*Tn(k,4) I •••

R5*Tn(k,5),Cl*Tn(k,6), •••
C2*Tn(k,7),s);
if mc•=l
Vln(k,il=D;
else
Vn(k,i)=D;
end
end
end
end
Vlnaxl=max(VIn) ;Vlnax2-max(Vnl;
'
subplot(2,l,ll
H•plot(P,Vo, 'k');
sl='Fig 42. Sallen & Key';
s2•'BPF Nominal Output';
s3=strcat(sl,s2);
title(s3)
grid on
ylabel ( 'Volts ' l
'
subplot(2,1,2);
h=plot(P,Vlnaxl,'k',F,Vmax2, 'b');
xlabel('Freq(Hz) ');
Appendix 133

ylabel ('Volts •)
title('Fig 43. Sallen & Key BPF MCA')
text(420,120,('N = •,num2str(N)]);

function y = B6(Rl,R2,R3,R4,RS,Cl,C2,s)
\ matrix fen for Sallen & Key BPF
Ao=le6;
A=zeros(4);
A=(l/Rl+l/R2+s*(Cl+C2) -s*C2 0 -l/R2; ••.
-s*C2 1/R3+s*C2 0 0; .. .
0 0 l/R4+l/RS -1/RS; .. .
0 -Ao Ao l];
B={l/Rl;O;O;O];
C=A\B;y=abs(C(4));

For Figures 44 and 45:

\ FMCA and MCA of Delyiannis BPF


\ File: fmcadely.m
clc;clear
R1=4930;R2=205000;Ra=10000;Rb=252000;
Cl=le-8;C2=Cl;
BF=400;LF=600;DF=2;Lit=(LF-BF)/DF+l;
F=linspace(BF, LF, Lit);
Tr=0.02;Tc=O.l;
T=(-Tr -Tr -Tr -Tr -Tc -Tc; ..•
Tr Tr Tr Tr Tc Tc];
M=6;Nf=2"M;
for k=l:Nf;for w=l:M;Re(w,k)=k;end;end
for k=l:Nf
for w=l:M
Re(w+l,k)=floor(Re(w,k)/2);
Dr(w,k)=Re(w,k)-2*Re(w+l,k);
if Dr(w,kl==O
Tf(w,k)=l+T(l,w);
else
Tf(w,k)=l+T(2,w);
end
end
end
rand('state•,sum(lOO*clock));
for nc=1:2
134 Tolerance Analysis of Electronic Circuits

if nc==l;Nm=lOO;else;Nm=lOOO;end
for p=l:Nm
for w=l:M
Tn(w,p)=(T(2,w)-T(l,w))*rand+T(l,w)+l;
end
end
for i=l : Lit
s=2*pi*F(i)*j;
if nc=sl
Vo(i)=B3(Rl,R2,Ra,Rb,Cl,C2,s);
for k=l:Nf
Vf(k,i)=BJ(Rl*Tf(l,k),R2*Tf(2,k), • . .
Ra*Tf(J,k),Rb*Tf(4,k), ..•
Cl*Tf(S,k),C2*Tf(6,k),s);
end
end
for p=l:Nm
Vm(p,i)=BJ(Rl*Tn(l,p),R2*Tn(2,p), ..•
Ra*Tn(J,p) ,Rb*Tn(4,p), ••.
Cl*Tn(S,p),C2*Tn(6,p),s);
end
end
if nc=:l
Vmaxl=max(Ym);Vmax3=max(Vf);
Na=Nm;clear vm;
else
Vmax2=max(vm);Nb=Nm;
end
end
'
subplot(2,1,1)
h=plot(F,VmaxJ, 'k.:',F,Vo, ' k--',F,Vmaxl, 'k');
set(h, 'LineWidth',2);grid on
axis ([BF LF 0 1400])
ylabel ('Volts' I
title('Fig 44. Delyiannis BPF')
text(410,700, ['N = ',num2str(Na)],'FontSize',8);
vpkl=max(Vmaxl);vpkJ=max(Ymax3);

'
subplot(2,1,2l
h=plot(F,Vmax3, 'k.:',F,Vo, 'k--',F,Vmax2, 'k');
set(h, 'LineWidth',2);grid on
Appendix 135

axis ([BF LF 0 1400])


xlabel('Freq(Hz) ');ylabel('Volts')
title('Fig 45. Delyiannis BPF')
text(410,700,['N = ',num2str(Nb)], 'FontSize',8);
vpk2=max(Vmax2);

function y = B3(Rl,R2,Ra,Rb,Cl,C2,s)
% fen for Delyiannis BPF
Nl=(Ra+Rb)/(Rl*C2*Rb);
Dl=(l/Cl+l/C2)/R2-Ra/{Rl*C2*Rb);
DO=l/{Rl*R2*Cl*C2);
y=abs(Nl*s/(sA2+Dl*s+D0));

For Figures 46 and 47:

% FMCA and MCA of Twin-T Notch Filter


% File: fmcatwint.m
clc;clear
Rl=297000;R3=267000;R5=133000;
C2=2e-8;C4=1e-8;C6=1e-8;
BP=40;LF=80;DF=O.S;Lit=(LF-BF)/DF+l;
F=linspace(BF, LF, Lit);
Tr=0.02;Tc=O.l;
T=[-Tr -Tc -Tr -Tc -Tr -Tc; ...
Tr Tc Tr Tc Tr Tc];
M=6;Nf=2AM;
Tf=zeros(M,Nf);
for k=l:Nf;for w=l:M;Re(w,k)=k;end;end
for k=l:Nf
for w=l:M
Re(w+l,k)=floor(Re(w,k)/2);
Dr(w,k)=Re(w,k)-2*Re(w+l,k);
if Dr(w,k>==O
Tf(w,k)=l+T(l,w);
else
Tf(w,k)=l+T(2,wl;
end
end
end
rand('state•,sum(lOO*clock));
for nc=1:2
if nc==l;Nm=lOO;else;Nm=lOOO;end
136 Tolerance Analysis of Electronic Circuits

for p=1:Nm
for w=1:M
Tn(w,p)=(T(2,w)-T(1,w))*rand+T(1,w)+1;
end
end
for i=l:Lit
s=2*pi*F(i)*j;
if nc=:or:1
Vo(i)=T2(R1,R3,R5,C2,C4,C6,s);
for k=1:Nf
Vf(k,i)=T2(R1*Tf(1,k),R3*Tf(3,k), ••.
R5*Tf(5,k),C2*Tf(2,k),C4*Tf(4,k), •..
C6*Tf(6,k),s);
end
end
for p=1:Nm
Vm(p,i)=T2(Rl*Tn(1,p),R3*Tn(3,p), ••.
R5*Tn(5,p),C2*Tn(2,p),C4*Tn(4,p), .••
C6*Tn{6,p), s);
end
end
if nc:o=1
Vmaxl=max(Vm) ;Vmax3=max(Vf);
N1=Nm; clear Vm;
else
Vmax2=max!Vm);N2=Nm;
end
end
t
subplot(2,1,1)
b:or:plot(P,Vmax3,'k.:',F,Vo,'k--',F,Vmaxl,'k');
set(b,'LineWidth',2);grid on
taxis ([BF LF 0 15])
ylabel ( 'dBV')
title('Fig 46. Twin-T FMCA/MCA')
text(45,-35,('N = •,num2str(N1)],'FontSize',8);
t
subplot(2,1,2)
b=plot(F,Vmax3,'k.:',F,Vo,'k--',F,Vmax2,'k');
set(h,'LineWidth',2);grid on
taxis ((BF LF 0 15])
xlabel ( 'Preq(Hz) •) ;ylabel ( 'dBV')
Appendix 137

title('Fig 47. Twin-T FMCA/MCA')


text(45,-35,['N = ',num2str(N2)],'FontSize',8);

function y = T2(Rl,R3,R5,C2,C4,C6,s)
% fen for twin-T passive notch filter
A=zeros(3);
A(l,l)=l/RS+s*(C4+C6);A(l,3)=-s•C6;
A(2,2)=1/Rl+l/R3+s*C2;A(2,3)=-1/R3;
A(3,l)=A(1,3);A(3,2)=A(2,3);
A(3,3)=1/R3+s*C6;
B=[s*C4;1/R1;0];
C=A\B;y=20*log10(abs(C(3)));

For Figures 48 and 49:

% FMCA and MCA of LTC1562 BPF


% File: ltc1562.m
% uses fen BS.m
clc;clear
Rl=lOOOO;R2=le6;Rqr-2e6;Rin=200e3;
C1=159.15e-12;C2=Cl;
BF=8000;LF=12000;DF=40;
Litz(LF-BF)/DF+l;
F=linspace(BF, LF, Lit);
TrzO.Ol;Tc=O.l;
T=[-Tr -Tr -Tr -Tr -Tc -Tc; ...
Tr Tr Tr Tr Tc Tel;
M=6;Nf=2"M;
Tf=zeros (M,Nf);
for k=l:Nf;for w=l:M;Re(w,k)=k;end;end
for k=l:Nf
for w=l:M
Re(w+l,k)=floor(Re(w,k)/2);
Dr(w,k)=Re(w,k)-2*Re(w+l,k);
if Dr(w,k)==O
Tf(w,k)=l+T(l,w);
else
Tf(w,k)=l+T(2,w);
end
end
end
rand('state',sum(lOO*clock));
138 Tolerance Analysis of Electronic Circuits

for nc=l:2
if nc=•l;Nm=lOO;else;Nm=lOOO;end
for p=l:Nm
for w=l:M
Tn(w,p)=(T(2,w)-T(l,w))•rand+T(l,w)+l;
end
end
for i•l:Lit
8"'2•pi*F(i)•j;
if nc==l
Vo(i)=B5(Rl,R2,Rin,Rq,Cl,C2,s);
for lt=l:Nf
Vf(lt,i)=B5(Rl*Tf(l,lt),R2*Tf(2,lt), • • •
Rin*Tf(3,lt),Rq*Tf(4,lt), •••
Cl*Tf(5,1t),C2*Tf(6,lt),s);
end
end
for p=l:Nm
Vm(p,i)=B5(Rl*Tn(l,p),R2*Tn(2,p), •••
Rin*Tn(3,p),Rq*Tn(4,p), •••
Cl*Tn(5,p),C2*Tn(6,p),s);
end
end
if nc==l
Vlllaxl=max(Vm) ,vmax3=max(Vf);
Na=Nm;clear Vm;
else
Vlllax2=max(Vm) ;Nb=Nm;
end
end

'
aubplot(2,1,1)
b=plot(P,VIIIax3, 'k.:',F,Vo,'k--',P,VIIIaxl,'lt');
set(h,'LineWidth',2);grid on
axis ([BF LF 0 15])
ylabel ('Volts')
title('Pig 48. LTC1562 BPF')
text(8200,12,['N = ',num2str(Na)],'FontSize',8);
vPitl=max(VIIIaxl);vPit3=max(VIIIax3);
'
subplot(2,1,2)
h=plot(P,VIIIax3, 'k.:',F,Vo, 'k--',F,Vmax2,'k');
Appendix 139

set(h, 'LineWidth',2);grid on
axis ((BF LF 0 15])
xlabel('Freq(Hz) ');ylabel('Volts')
title('Fig 49. LTC1562 BPF')
text(8200,12,('N = ',num2str(Nb)],'FontSize',8);
Vpk2=max (Vmax2) ;

function y = B5(Rl,R2,Rin,Rq,Cl,C2,s)
\ fen for LTC1562 BPF
Nl=-l/(Rin*C2);Dl=l/(Rq*C2);
DO=l/(Rl*R2*Cl*C2);
y=abs(Nl*s/(sA2+Dl*s+D0));

For Figures 50 and 51 :

\ FMCA and MCA of all-pass filter


\ File: allpass2.m
clc;clear
Rl=619;R2=22600;R3=24900;R4=226e3;
Cl=le-7;C2=Cl;Ao=le6;E1=1;
BF=450;LF=550;DF=2;Lit=(LF-BF)/DF+l;
F=linapace(BF, LF, Lit);
Tr=O.Ol;Tc=O.l;
T=(-Tr -Tr -Tr -Tr -Tc -Tc; ..•
Tr Tr Tr Tr Tc Tc];
M=6;Nf=2AM;
Tf=zeros(M,Nfl;A=zeros(4);
for k=l:Nf;for w=l:M;Re(w,k)=k;end;end
for k=l:Nf
for w=l:M
Re(w+l,k)=floor(Re(w,k)/2);
Dr(w,k)=Re(w,k)-2*Re(w+l,k);
if Dr(w,kl==O
Tf(w,k)=l+T(l,w);
else
Tf(w,k)=l+T(2,w);
end
end
end
rand('state',sum(lOO*clock));
for nc=1:2
if nc==l
140 Tolerance Analysis of Electronic Circuits

Nm=lOO;
else
Nm=lOOO;
end
for p=l:Nm
for w=l:M
Tn(w,p)=(T(2,w)-T(l,w))*rand+T(l,wl+l;
end
end
for i=l:Lit
s=2*pi*F(i)*j;
if nc==l
D=G4(Rl,R2,R3,R4,Cl,C2,Ao,s);
Vo(i)=D;
end
for k=l:Nf
D=G4(Rl*Tf(l,k),R2*Tf(2,k), ..•
R3*Tf(3,k),R4*Tf(4,k),Cl*Tf(S,k), ...
C2*Tf(6,k),Ao,s);
Vf(k,i)=D;
end
for p=l:Nm
D=G4(Rl*Tn(l,p),R2*Tn(2,p), • • •
R3*Tn(3,p),R4*Tn(4,p),Cl*Tn(S,p), .•.
C2*Tn(6,p),Ao,s);
Vln(p,i)=D;
end
end
if nc==l
Vmaxl=max(Vln) ;Vmax3=max(Vf);
Nl=Nm;clear VIII;
else
Vmax2=max(Vln);N2=Nm;
end
end
'
subplot(2,1,1)
h=plot(F,Vmax3, 'k.:',F,Vo, 'k--',F,Vmaxl, 'k');
set(h,'LineWidth',2);grid on
axis ((BF LF 70 190])
ylabel('Phase Angle (deg)')
title("Fig SO. MFB All-pass')
Appendix 141

YT=linspace(70,190,7);
set (gca, 'ytick', YT);
text(460,100,['N = •,num2str(Nl)],'FontSize',8);
vpkl=max(vm&xl);vpk3=max(vm&x3);
'
subplot(2,1,2)
h=plot(F,Vmax3,'k.:',F,Vo,'k--',F,Vmax2,'k');
set(h, 'LineWidth',2);grid on
axis ([BF LF 70 190])
xlabel('Freq(Hz) ');
ylabel('Phase Angle (deg)')
title('Fig 51. MFB All-pass')
YTzlinspace(70,190,7);
set (gca, •ytick', YTJ;
text(460,100,['N = •,num2str(N2)],'Fontsize',8);
VPk2=max (vm&x2 J ;

function y = G4(Rl,R2,R3,R4,Cl,C2,Ao,s)
tall-pass circuit function
A=zeros(4);
A(l,l)=l/Rl+s*Cl+s*C2;
A(l,2)=-s*Cl;A(l,4)=-s*C2;
A(2,1)=A(1,2);A(2,2)=1/R2+s*Cl;
A(2,4)=-l/R2;
A(3,3)=1/R3+1/R4;A(4,2)=-Ao;
A(4,3)=Ao;A(4,4)=1;
B=[l/Rl;O;l/R3;0];
C=A\B;y=(l80/pi)*angle(C(4));

For Figures 52 and 53:


' FMCA and MCA of SCF BPF
\File: scfbpf.m
clc;clear
\ fc = 51kHz switching frequency
fc=5le3;wc=(2*pi*fc)/50;
Rl=l.585e6;R2=10e3;R3=1.593e6;R4=25.4e3;
\Nl=wc*R2/Rl;Dl=wc*R2/R3;00=wcA2*R2/R4;
BF=540;LF=740;DF=l;Lit=(LF-BF)/DF+l;
F=linspace(BF, LF, Lit);
\ Tf = fsw tolerance
Tr=0.02;Tf=0.05;
142 Tolerance Analysis of Electronic Circuits

T=[-Tr -Tr -Tr -Tr -Tf; .•.


Tr Tr Tr Tr Tf);
M=S;Nf=2"M;
Tf=zeros (M,Nf);
for k=l:Nf;for w=l:M;Re(w,k)=k;end;end
for k=l:Nf
for w=l:M
Re(w+l,k)•floor(Re(w,kl/2);
Or(w,k)=Re(w,kl-2*Re(w+l,k);
if Or(w,k)•=O
Tf(w,kl=l+T(l,w);
else
Tf(w,k)zl+T(2,w);
end
end
end
rand('state•,sum(lOO*clock));
for nc=1:2
if nc•=l;Nm=lOO;else;Nm=lOOO;end
for p=l:Nm
for wal:M
Tn(w,p)=(T(2,w)-T(l,w))*rand+T(l,w)+l;
end
end
for i=l:Lit
s=2*pi*P(i)*j;
if nc==l
Vo(i)zSCP(Rl,R2,RJ,R4,wc,s);
for k=l:Nf
Vf(k,i)=SCP(Rl*Tf(l,k),R2*Tf(2,k), .•.
RJ*Tf(3,k),R4*Tf(4,k), ..•
wc*Tf(S,k),s);
end
end
for p=l:Nm
vm(p,i)=SCP(Rl*Tn(l,p),R2*Tn(2,p), •••
R3*Tn(3,p),R4*Tn(4,p), •••
wc*Tn(S,p), s);
end
end
if nc==l
V'maxl=max(vml ;V'maxJ=max(Vf);
Appendix 143

Nl=Nm;clear Vm;
else
Vmax2=max(Vm);N2=Nm;
end
end

'
subplot(2,1,1)
h=plot(F,Vmax3, 'k.:',F,Vo,'k--',F,Vmaxl, 'k');
set(h,'LineWidth',2);grid on
axis ( [BF LF 0 1.2))
ylabel ('Volts')
title('Pig 52. MFlO SCF BPF')
YT=linspace(O,l.2,7);
set (gca, •ytick', YT);
text(560,0.5, ['N = ',num2str(Nl)),'FontSize',8);
VPkl=max(Vmaxl);VPk3=max(Vmax3);

'
subplot(2,1,2)
h=plot(F,Vmax3,'k.:',F,Vo, 'k--',F,Vmax2, 'k');
set(h, 'LineWidth',2);grid on
axis ([BF LF 0 1.2))
xlabel ( 'Freq(Hz) ') ;ylabel ('Volts')
title('Fig 53. MFlO SCF BPF')
YT=linspace(0,1.2,7);
set (gca, •ytick', YT);
text(560,0.5,['N = •,num2str(Nl)), 'FontSize',8);
VPk2=max (vmax2) ;

function y = SCF(Rl,R2,R3,R4,wc,s)
'i function for SCF
Nl=wc*R2/Rl;Dl=wc*R2/R3;DO=wcA2*R2/R4;
y=abs(Nl*s/(sA2+Dl*s+D0));

For Figures 54 and 55:

Iii FMCA and MCA of buffered


\ 60Hz notch filter
\ File: buff60.m
clc;clear
Rl=l9e3;R2=57.6e3;R3=464e3;R4=200;
144 Tolerance Analysis of Electronic Circuits

R5=4.8e3;C1=47e-9;C2=Cl;C3=Cl;
BF=40;LF=80;DF=O.S;Lit=(LF-BF)/DF+l;
F=linspace(BF, LF, Lit);
Tr=O.Ol;Tc=O.l;
T=[-Tr -Tr -Tr -Tr -Tr -Tc -Tc -Tc; .••
Tr Tr Tr Tr Tr Tc Tc Tel;
M=8;Nf=2"M;
Tf=zeros(M,Nf);A=zeros(6);
for k=l:Nf;for w=l:M;Re(w,kl~k;end;end
for k=l:Nf
for w=l:M
Re(w+l,k)~floor(Re(w,k)/2);
Dr(w,k)=Re(w,k)-2*Re(w+l,k);
if or(w,k)~ao
Tf(w,kl=l+T(l,w);
else
Tf(w,k)=l+T(2,w);
end
end
end
rand('state',sum(lOO*clock));
for nc=1:2
if nc==l;Nm=lOO;else;Nm=lOOO;end
for p•l:Nm
for w=l:M
Tn(w,p) = ( (T(2,w) -T(l,w)) /6) * •.•
((3*(2*rand-1))+3)+T(l,w)+l;
end
end
for io:l:Lit
s•2*pi*F(i)*j;
if nc=•l
Vo(i)=G5(Rl,R2,R3,R4,RS,Cl,C2,C3,s);
end
for k=l:Nf
Vf(k,i)=GS(Rl*Tf(l,k),R2*Tf(2,k), . • •
R3*Tf(3,k),R4*Tf(4,k),R5*Tf(S,k), ••.
Cl*Tf(6,k),C2*Tf(7,k),C3*Tf(8,k),s);
end
for p=l:Nm
vm(p,i)=GS(Rl*Tn(l,p),R2*Tn(2,p), .•.
R3*Tn(3,p),R4*Tn(4,p),RS*Tn(S,p), .• •
Appendix 145

Cl*Tn(6,p),C2*Tn(7,p),C3*Tn(8,p),s);
end
end
if nc==l
Vmaxl=max(Vm) ;V!nax3=max(Vfl;
Nl=Nm; clear Vlll;
else
Vmax2=max(Vlli);N2=Nm;
end
end
'
subplot(2,1,1)
h=plot(F,Vmax3, 'k.: ',F,Vo, 'k--',F,Vmaxl, 'k');
set(h, 'LineWidth',2);grid on
axis ([BF LF -60 20])
ylabel ( •dBV. )
title('Fig 54. Buffered Notch')
text(46,-30,['N = •,num2str(Nl)],'FontSize',8l;
vpkl=max(Vlllaxll;VPk3=max(Vlllax3);
'
subplot(2,1,2l
h=plot(F,Vmax3, 'k.:',F,Vo, 'k--',F,Vmax2, 'k');
set(h,'LineWidth ' ,2);grid on
axis ([BF LF - 60 20])
xlabel ( 'Preq(Hz) •) ;ylabel ( 'dBV')
title('Pig 55 . Buffered Notch')
text(46,-30,['N = •,num2str(N2)],'FontSize',8);
VPk2 =max (Vlllax2 l ;

function y = G5(Rl,R2,R3,R4,R5,Cl,C2,C3,s)
% buffered 60Hz notch filter
A=zeros(6);
A(l,l)=l/Rl+s*(Cl+C2);
A(l,2)=-s*C2;A(l,5)=-l/Rl;
A(2,l)=A(l,2)IA(2,2)=1/R2+s*(C2+C3);
A(2,3)=-s*C3;A(2,5)=-1/R2;
A(3,2)=A(2,3);A(3,3):1/R3+s*C3;
A(4,4)=1;A(4,5)=-l;
A(5,5)=1/R4+1/R5;A(5,6)=-l/R4;
A(6,3)=-l;A(6,6)=1;
B=[s*Cl;O;l/R3;0;0;0];C=A\B;
yz20*log10(abs(C(6)));
146 Tolerance Analysis of Electronic Circuits

For Figures 56 and 57:


% Sensitivity equations
% for R21 RJ1 C11 C2
% File: senseqns.m
clear;clc
BF=400;LF=600;DF=l;Lit=(LP-BP)/DP+1;
P=linspace(40016001Litl;
Rl=6340;R2=80.6;R3=127e3;C1=1e-7;C2=C1;
% calculate fo
D0=(1/R1+1/R2)/(R3*Cl*C2);
fo=sqrt(D0)/(2*pi);
wo=2*pi*fo;Q=20;G=l0;
for i=1:Lit
m=2*pi*P(i);
d1(i)z2*(QA2*(woA2-mA2)A2+(m*wo)A2);
SR2(i)=(woA2*(2*QA2-G)*(woA2-mA2))/dl(i);
d2(i)=dl(i)/2;
SR3(i)=woA2*(QA2*(woA2-mA2)+mA2)/d2(i);
SCl(i)•mA2*(2*QA2*(woA2-mA2)+woA2)/dl(i);
SC2(i)=mA2*(2*QA2*(woA2-mA2)-woA2)/dl(il;
end

'
subplot(21111l
h=plot(PISR21'k'IPISR31 'r'IFISCll'g' 1FISC2 1 'b');
set(h 1 'LineWidth' 11);grid on;
axis([BF LF -15 15))
ylabel('%/%');
title('Fig 56. Sensitivities of R21R31C11C2 MFB BPF')
'
subplot(21112l
b=plot(FISR21 'k'1F1SRJ1 'r'1F1SC11 'g' 1F 1SC2 1 'b');
set(bl 'LineWidth'~l);grid on;
axis([500 501 -1.5 1.5))
xlabel('Freq(Hz) ');ylabel('%/%');
title('Fig 57. Near fo = 500.6 Hz')
s1='At fo=500.6 1 high to ';
s2='low order is:';
s3=strcat(sl~s2);
text(500.1~-0.5~s3~'PontSize'~8l
text (500 .11 -0.81 'R31CliR21C2 • 'Fontsize • 8)
I I
References
1. Introduction to Random Signal Analysis and Kalman Filter-
ing, R.G. Brown, Wiley, 1983, p.44.
2. Principles ofActive Network Synthesis and Design, G. Dary-
anani, Wiley, 1976.
3. Tolerance Design of Electronic Cin:uits, R. Spence and R.S.
Soin, Addison-Wesley, 1988. (Emphasis on theoretical
aspects of MCA and circuit design to meet specifications
with maximum manufacturing yield. Tenninology: EVA=
"Vertex Analysis;" RSS = "Method of Moments.")
4. Tolerance Design, C.M. Creveling, Addison-Wesley, 1997.
(Mechanical and economic aspects of tolerance analysis.)
S. New Tolerance Analysis Methods, R. Boyd, RF Design '97
Conference and Expo, Conference Papers, 1997, p.75 and
p.307. (Seminal paper.)
6. Will Your Design Keep on Working? D. Divekar and R. Apte,
Test & Measurement World, 3/89, p.81. (Excellent treatment
of sensitivity.)
7. Spectral Analysis and its Applications, G.M. Jenkins and
D.G. Watts, Holden-Day, 1968, p.76. (Definition of variance
of a non-linear function; confidence intervals.)
8. Surveying, F.H. Moffitt and H. Bouchard, 6th edition, Harper
& Row,1975, pp 166-168. (Derivation ofRSS formula from
total differential.)
9. An Introduction to Error Analysis, 2nd edition, J.R. Taylor,
University Science Books, 1997. (Subtitle: The Study of
Uncertainties in Physical Measurements.)
10. MIL-SID-785B, Task 206, Electronic Parts/Circuits Toler-
ance Analysis.
II. A Handbook ofActive Filters, D.E. Johnson, et al, Prentice-
Hall, 1980.
12. Statistical Tolerancing, D.D. Brady and DJ. Odorizzi, Elec-
tronic Design. 411n8, p.l34.

147

You might also like