Transfer function analysis isn't necessarily difficult, but there is a trigonometric booby trap to look out for, and correct for if encountered.
For some very simple circuit, a two-pole RC lowpass filter in this case, we can very easily derive the algebraic transfer function and look at the circuit’s gain and phase properties. An examination is easily made using a SPICE simulation (Figure 1).
Figure 1 This analysis is for a two-pole RC filter.
The denominator of the transfer function has a “real” component, which we call DR, and an ‘imaginary” component, which we call DI, from which gain and phase are calculated. However, it we don’t happen to have a SPICE program at hand and we try to do the algebraic calculations in a few lines of code, we can get into trouble, as shown in Figure 2.
Figure 2 Trying to do algebraic calculations in a few lines of code can get you into trouble.
As we sweep through our frequency range, the DR value in the denominator changes sign from positive to negative and when that happens, the arctangent function creates a step change in the curve of the calculated phase lag.
Figure 3 The arctangent function creates a step change in the curve of the calculated phase lag.
Trigonometric tangents are negative in the second and fourth quadrants of a standard phase diagram. When the DR becomes less than zero, the arctangent function returns not the real phase lag angle of our circuit, but instead returns the principal value angle, which for our purposes can be taken as the angle that is closest to the zero degrees position of the positive side of the real axis. The result is a sudden 180° step in the calculated phase result, which we know full well ain’t gonna happen when we build this thing.
The SPICE program is smart enough to know this and to make an appropriate but invisible-to-us correction. It’s when we are writing our own code that we have to detect and correct for this issue ourselves.
CORRECTION=0:IF ABS(PHASEHOLD-PHASELAG)>90 THEN CORRECTION=180
Figure 4 When writing our own code, we have to detect and correct for this issue ourselves.
This article was originally published on EDN.
John Dunn is an electronics consultant, and a graduate of The Polytechnic Institute of Brooklyn (BSEE) and of New York University (MSEE).