.~l\\a- fiafi‘ntd an». - 'r .1‘ \\1 N . M. A ...u pip » _ ,, .y g... . , 7r 5 n :21". AS. .LH': '\ ..' can I . F mu; .‘Hv PA" H1“ Iwfla \"5 ~j. ‘ Aka ,.. u. ;..‘.u .w 23-? 3: ...- .4 . .a‘ -I... . fi‘ ..r 3 .K’ M.) ‘hh‘n‘u 5’34 . 1w” »...n n- In 5M: r‘n’rwxaf. Apr, 7,; .‘i «LLHHHUH éw’w .. A£;..:.v.‘ ln-v'l v! “'4 - livn 11p. T‘“‘% if"; .A‘ §n ». ~ ; ,u a“:- n .u, ,u: . n: ” ‘4'.le : .3. 3‘ . .r.‘ . a 1». ' 7:3": at”: b u Jru‘rv. .n‘ 1 ‘ r.“ . .4 37'» '3 a: ‘ ‘1 w 2.. «'2‘! ,. F r ~ , ‘. u‘ ... {HF-31‘s MICHIGAN STATE III I III IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 008918421 This is to certify that the thesis entitled Precision Automated Measurements presented by Robert Jay Randel has been accepted towards fulfillment of the requirements for Master's Electrical degree in Engineering m ‘ // A0 / a flajoru pr essor Date 0C [7/ /77‘) // 0.7 639 MS U is an Affirmative Action/Equal Opportunity Institution ’— LIBRARY “tomcat: State University w v ._ ~ ...l' ‘— PLACE IN RETURN BOX to remove this checkout from your record. T AVOID FINES return on or before date due. 0 I DATE DUE DATE DUE DATE DUE II ___— #fi!— I___________I A VT"? MSU Is An Atflrmdlve ActiorVEqual Opportunity Institution cw . __ -,__,_.. PRECISION AUTOMATED MEASUREMENTS By Robert Jay Randel A THESIS Submitted to Michigan State University in partial fulfillment of the requirements for the degree of MASTER OF SCIENCE Department of Electrical Engineering 1990 ABSTRACT PRECISION AUTOMATED MEASUREMENTS By Robert Jay Randel Due to their IEEE-488 GPIB capabilities, the latest series of Fluke/Philips instruments can be programmed to perform a wide variety of automated measurements. The Test'l‘eam software package supplied by Philips contains drivers which make this programming directly possible from Microsoft QuickBASIC. Techniques and software are developed using these drivers to automate tedious steady-state measurements. The topics covered are bode magnitude and phase plots, locating cutofl' (-3 dB) frequencies, measuring gain- bandwidth-products of op-amps, and finding the second order filter parameters fl, Ho, and Q0. This software is tested on numerous circuits. Copyright by ROBERT JAY RANDEL 1990 ACKNOWLEDGEMENTS My appreciation to Ken Noren for his support and advice. Much thanks to Jim MacKay for his assistance and support. My infinite gratitude to Professors G.M. Wierzba and C.R. MacCluer for their guidance and assistance in completing this document. iv TABLE OF CONTENTS List of Tables , vii List of Figures viii Chapter 1 Introduction to TestTeam Software 1 1. 1 Introduction and Preview of Results, 1 1.2 Choosing a Programming Language, 2 1.3 Hardware Requirements, 3 1.4 Installation and Configuration of TestTeam Software, 4 1.5 Analysis of the Configuration Program, 6 1.6 Programming the Instruments, 7 1.7 Using the TestTeam Drivers, 7 1.8 Summary, 8 Chapter 2 Steady State Analysis of Passive Networks 9 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 Introduction, 9 Creating a Bode Magnitude Plot of a Passive Circuit, 9 Speeding Up Operation of This and Other Routines, 12 Creating a Bode Phase Plot, 14 Defects and Potential Improvements, 18 Implementation of Improvements, 19 2.6.1 Access to Raw Data, 19 2.6.2 Correcting for Input Voltage Errors, 19 2.6.3 Disabling the Counter to Prevent Erroneous Data, 20 2.6.4 Correction of Phase Angle, 20 ' 2.6.5 Finding a -3 dB Point, 21 The Program BODE5C.BAS, 22 Sample Data from BODE5C.BAS, 26 Summary, 28 Chapter 3 Steady State Analysis of Active Networks 29 3.1 Introduction, 29 3.2 Enhancements For the Measurement of Active Circuits, 29 3.2. 1 Addition of a Second Voltmeter, 29 3.2.2 Modification of -3 dB Routine for Active Circuits, 34 3.2.3 Measuring the Gain-Bandwidth-Product of an Op-Amp, 34 3.2.4 Aborting the Program, 37 3.3 The Listing of BODE6C.BAS, 38 3.4 Sample Data From BODE60.BAS, 43 3.5 Testing for Linearity, 44 3.6 Automated Measurement of Filter Parameters, 45 3.6.1 Location of a Second -3 dB Point, 45 3.6.2 Calculation of the Center Frequency of a Second-order Notch Filter, 46 3.6.3 Finding the Parameters of Band-pass Filters, 47 3.7 Accuracy of These Routines, 48 3.8 The Program BODE7C.BAS, 49 3.9 Summary, 56 Chapter 4 Experimental and Theoretical Verification 57 4. 1 Introduction, 57 4.2 A Diflicult Test for BODE7C.BAS, 57 4.3 Measuring the Gain-Bandwidth-Products, 58 4.4 Testing the Filter, 62 4.5 Theoretical Verification of Measured Results, 65 4.6 Summary, 70 Chapter 5 Conclusions and Future Research 71 5.1 Conclusions, 71 5.2 Future Research, 71 List of References 79 Table 1.1 Table 1.2 Table 1.3 Table 2.1 Table 4.1 Table 4.2 Table 4.3 Table 4.4 Table 4.5 Table 4.6 Table 4.7 Table 4.8 LIST OF TABLES Directories of TestTeam Files ........................ 4 Variable Names for Instruments ..................... 7 Summary of Important TestTeam Functions ............ 8 Raw Data For High Pass Filter ..................... 28 Gain-Bandwidth—Products of Measured Op-Amps ........ 61 Gain-Bandwidth-Product vs. Time ................... 62 Component Values for the Tow-Thomas Filter .......... 63 Measured Results of Relocated Tow-Thomas Filter ....... 63 Measured Results of Original Tow-Thomas Filter ........ 65 Measured Output Resistance of Op-Amps .............. 68 Parameter Shifting Predicted by Sspice ............... 69 Predicted Parameters and Errors .................... 69 'vii Figure2.1 Figure2.2 Figure2.3 Figure2.4 Figure2.5 Figure2.6 Figure2.7 Figure3.1 Figure3.2 Figure3.3 Figure3.4 Figure3.5 Figure3.6 Figure3.7 Figure3.8 Figure3.9 Figure 3.10 Figure4.1 Figure4.2 Figure4.3 Figure4.4 Figure5.1 Figure5.2 Figure5.3 LIST OF FIGURES Low-Pass Filter ................................ 11 Bode Magnitude Plot of Low-Pass Filter .............. 12 High-Pass Filter ................................ 17 Bode Magnitude Plot of High Pass Filter ............. 17 Bode Phase Plot of High Pass Filter ................. 18 Bode Magnitude Plot of High Pass Filter ............. 27 Bode Phase Plot of High Pass Filter ................. 27 Thevenin Equivalent of Function Generator ........... 31 Passive Notch Filter ............................. 31 Incorrect Bode Magnitude Plot for Notch Filter ........ 32 Bode Phase Plot for Notch Filter ................... 33 Correct Bode Magnitude Plot for Notch Filter ......... 33 Inverting Amplifier ............................. 35 Controlled Source Model of Inverting Amplifier ........ 35 Non-inverting Amplifier .......................... 35 Bode Magnitude Plot of Non-inverting Amplifier ....... 43 Bode Phase Plot of Non-inverting Amplifier ........... 44 Relocated Tow-Thomas Filter ...................... 59 Original Tow-Thomas Filter ....................... 60 Bode Magnitude Plot of Relocated Tow-Thomas Filter . . . 64 Bode Phase Plot of Relocated Tow Thomas Filter ....... 65 Oscilloscope Output for Positive Pulse ............... 76 Oscilloscope Output for Triangle Wave ............... 77 Oscilloscope Output for Square Wave ................. 78 CHAPTER 1 INTRODUCTION TO TES'ITEAM SOFTWARE 1.1 Introduction and Preview of Results One tedious task a modern electrical engineer faces is the testing of a circuit. Despite advances in computer modelling and simulation, there is no substitute for building a circuit. Often problems are discovered that did not show up in the simulation. Many of the tests that are run on these circuits are very tedious measurements that can take even the most skilled of engineers many hours. Until recently automation of these measurements was not possible. However many newer test instruments now include some kind of computer interface. When properly connected to a computer, the computer can control the test equipment and perform the measurements for the engineer. Of course the computer and the test equipment both need to be programmed. One such set of instruments and software is the newest line of Fluke/Philips instruments and the Philips TestTeam sofiware package. TestTeam can be an extremely powerful tool to aid in the automation of circuit measurements. To unleash this power, however, it is necessary to program the package. The package is composed of a programming environment (called LabWindows) and a complete set of drivers which support many Fluke/Philips instruments. When these drivers are combined with some programming, they allow the experimenter to automate measurements. The 2 documentation that accompanies this package can be described as sparse at best. It consists of descriptions of the drivers and an introduction to LabWindows, but contains no usefirl examples or techniques. The goal of this document is to indicate an approach to the deve10pment of software to automate precision measurements using these drivers. In Chapter 2, sample software is designed for the automated measurements of Bode magnitude and phase plots and cutoff frequencies of passive networks. This sofizware is tested on low and high-pass filters. In Chapter 3, the software is expanded to include active circuits and perform such measurements as gain-bandwidth-products of op-amps and the second order filter parameters f,, Ho, and Q. In Chapter 4, the software is utilized to perform measurements to analyze a high-Q band- pass filter. Complete listings of the developed programs are provided to assist the user in further development. The examples herein will enable a user to fully exploit the powerful device drivers included in TestTeam. 1.2 Choosing a Programming Language The TestTeam drivers and the programming environment are compatible with two programming languages, Microsoft QuickBASIC and Microsoft C. This study will use Microsoft QuickBASIC. Although not a widely used language in the academic community, BASIC is widely used in industry. BASIC achieved great popularity in the late 197 0’8 because it was included in 3 the ROM of virtually every personal computer of that time. These older versions of BASIC are best suited to simple tasks. Critics complained that it is difficult or impossible to write structured, easy-to-follow code since there were no "while-until" or "repeat-until" commands nor were there subroutines with parameters. Also, since it is an interpreted language (as opposed to compiled) it could be too slow for many problems. Microsoft QuickBASIC has obviated all of these objections. It is a free-form language (requiring no line numbers) with a compiler, supporting subroutines and functions similar to Pascal, and has numeric coprocessor support. It would appear to be an ideal choice for a study whose goal is to make TestTeam more accessible to industry users. 1.3 Hardware Requirements The TestTeam software requires an BM PC/XT/AT, IBM PS/2, or compatible computer with one floppy disk drive, one hard disk drive, 640 KB of RAM, and the Philips PM 2201 IEEE-488 GPIB Bus Interface. For graphical output, a graphics card and monitor are also required. This study employed a 6 MHz Zenith 80286-based computer with monochrome CGA and an 80287 coprocessor. 4 1.4 Installation and Configuration of TestTeam Software One should begin by making backup copies of the TestTeam distribution disks. To install TestTeam onto a hard drive, insert the first diskette, make floppy drive A the current drive and type A>setup and press the Enter key. The program now prompts the user to insert all of the TestTeam disks for installation. The directories into which the setup program will place the files are shown in Table 1.1 [1]. Table 1.1 - Directories of TestTeam Files I \LW System files \LW\FONTS Font files required for graphics I. operations I \LW\LIBRARY Library files for linking with standalone programs I \LW\INCLUDE Include files associated with I libraries : \LW\PROGRAMS Source code to sample programs I \LW\INSTR Instrument modules The setup program also performs some necessary changes to the CONFIG.SY S file in the root directory of the hard disk. These include adding the lines FILES=20 and DEVICE=\LW\GP1B.COM. The former allows a 5 maximum of 20 files to be open simultaneously, while the latter allows the system to be aware of the IEEE-488 port. Next one must configure the TestTeam software to the instruments. The instruments used in this study are the Philips PM 3365 Oscilloscope, PM 5183 Programmable Synthesizer/Function Generator, PM 6666 Programmable Timer/Counter, and the Fluke 8840A Digital Multimeter. Before we can connect the instruments to the computer, their IEEE address must be set. This is done by using the front panel keys (PM 5193, PM 3365) or by setting DIP switches (PM 6666, Fluke 8840A). Any address can be chosen as long as there are no conflicts. Using standard IEEE-488 cables, connect each of the four instruments to the computer’s interface. A typical way to do this is to "daisy-chain" the instruments to the computer; this makes the detection of a bad cable easier should that problem arise. Once this is complete turn on the instruments (making sure there are no front panel connections present) and type the following commands at the DOS prompt: c: cd\lw contig/a The last command selects the configuration program, and the la stands for automatic. The automatic configuration seems to work well. It recognizes the instruments attached to the GPIB bus and configure itself accordingly. 6 1.5 Analysis of the Configuration Program One of the files created by the configuration program is called TESTTEAMBAS. A sample listing is shown below: REM File : TESTTEAM.BAS REM Setup file for Philips/Fluke Instrument drivers REM This will assign logical names to the instruments REM and initialize the instruments REM Following include statements can be removed in Interactive window REM SINCLUDE: '\lw\instr\generato.inc' REM SINCLUDE: ’\lw\instr\counter.inc’ REM SINCLUDE: '\lw\instr\multimet.inc' REM SINCLUDE: '\lw\instr\scope.inc’ REM $INCLUDE: '\lw\instr\general.inc’ DEFINT A-Z COMMON SHARED /DMM1/ DMMI AS INTEGER COMMON SHARED /GNR1/ GNRl AS INTEGER COMMON SHARED /OSC1/ OSC1 AS INTEGER COMMON SHARED /CNT1/ CNTI AS INTEGER CALL res.glb CALL reset.config CALL config(DMM1,"8840A,A 706,N DMMl") CALL confithNRl,"PM5193/V2.5,A 707,N GNRl") CALL config(OSC1,"PM3365/V07V04,A 708,N OSC1") CALL config(CNT1,"PM6666/22,A 710,N CNTl") CALL allinittDEFAULT.SET) IF glb.stat > 1 THEN PRINT "Error: ",glb.str :REM Print global error string call res.glb :REM Reset global error status ELSE IF glb.stat - 1 THEN PRINT "Warning: ",glb.str :REM.Print global warning string call res.glb :REM Reset global error status END IF END IF This file serves as the basis for all applications developed. Its purpose is to initialize the GPIB bus and the instruments so they will be ready for the commands. 7 1.6 Programming the Instruments Within the QuickBASIC environment, the instruments are given integer variable names consistent with their function. For example the 8840A is given the variable name dmml % (which stands for Digital Multi-Meter). Ifmore than one of a given type of instrument is connected, the last digit will increase, e.g. dmm2%. A summary of these variable names is given in Table 1.2. Table 1.2 - Variable Names for Instruments s...1.v.....1. Name I Digital Multimeter dmm1% Function Generator gnr1% Timer/Counter cnt1% Oscilloscope osc1% I 1.7 Using the TestTeam Drivers The real power of the TestTeam package lies in its driver functions. These drivers, when properly utilized, can be used to configure the instruments, perform measurements, and display graphs. The QuickBASIC syntax for these functions is CALL function.name (...) where the ellipses stand for whatever parameters are required for the function. A summary of these functions is provided in Table 1.3. [2] Table 1.3 - Summary of Important TestTeam Functions .amplitude Sets output amplitude of function generator . set.function Sets function of instrument (e.g. VOLTS—DC or ‘ VOLTS-AC for multimeter) I set.speed Sets speed of instrument (note that speed is . inversely proportional to significant figures) set.coupling Allows AC or DC coupling to be selected . set.sensitivity Sets sensitivity of counter 1 measure Triggers instrument and performs measurement grfreset Clears the graphics display setxdatatype Sets data type for x-axis (integer, real, etc.) setydatatype Sets data type for y-axis grfcuerd Creates x-y plot grflreset I Resets graphics library iolocal I Returns instrument to local control setaxname Labels x or y axis 1.8 Summary In this chapter the goals of the document have been outlined. An introduction to using TestTeam software was given, and Microsoft QuickBASIC was chosen as the programming language to use. Finally the TestTeam software was installed, preparing us for what lies ahead. CHAPTER 2 STEADY STATE ANALYSIS OF PASSIVE NETWORKS 2.1 Introduction In this chapter routines are designed to employ TestTeam for steady state passive circuit analysis. In particular these routines automate common tedious measurements such as Bode magnitude and phase plots, and to automatically locate a -3 dB point. 2.2 Creating a Bode Magnitude Plot of a Passive Circuit To use TestTeam to perform a measurement, one starts by envisioning how to perform that measurement manually, and then translate those steps into a program. To make a bode magnitude plot by hand, one would: Connect the circuit to the function generator and multimeter. Set the function generator to the beginning frequency. Set the output of the function generator to 1 V rms. Set the multimeter to read rms ac voltage. Wait at least 5 t for the circuit to settle. Measure the output on the voltmeter. Convert the output to dB. Increase the frequency. Ifnot done, go to 5. PPSP’P‘PS‘F’!‘ 10 It would also be wise to choose the frequencies logarithmically if we intend to make a semilog plot. Translating these steps into QuickBASIC: CALL set.amplitude (GNR1%, VRMS%, 1.0) ’set generator to 1V RMS CALL set.function (DMM1%, VOLT.AC%) 'set DMM to read.RMs AC v pdeS ’points per decade strt !-1 .5 ' log of starting frequency stpl-4 . 0 ' log of stopping frequency for il-strt! to stp! step l/ppd p-(il-strt!)*ppd 'offset in array xttp)-10“i! ’actual frequency CALL set.frequency (GNR1%, x#(p)) ’set freq of generator CALL measure (DMM1%, y#(p)) 'take voltage measurement y#(p)-20*log(y#(p))/log(10) 'convert to dB print x#(p),y#(p) 'print frequency and d3 x#(p)-i! 'store log of frequency next i! CALL GrfReset (4) 'set up graphics screen np-(stpt-strt!)*ppd 'number of points read CALL GrfCuerD (x#(). y#()' np) 'do x-y'plot/wait for key CALL GrfLReset (0, 0, 1, 2) 'return to text mode This program may be run directly from the LabWindows environment, provided it is added to the configuration program, TESTTEAMBAS. To enter- the LabWindows program, type the following commands at the DOS prompt: cd\ 1w 1w This program is relatively straightforward in its operation. The first two lines set the function generator to 1 V rms and the multimeter to AC voltage, respectively. The next three set the number of points to take per decade and the starting and stopping frequencies. After this comes the loop which takes the frequencies. Since the FOR-NEXT loop chooses points linearly, if we take . the antilog of each point, we will have the actual frequency. This is done in the line x# (p) =1 0 " i . Next the frequency of the function generator is set and the measurement is taken. Note that the internal settling time of the 11 multimeter (551 ms in VAC mode) [3] is sufiicient for many circuits to settle, thus no delay is included. Then the measurement is converted to dB (log in QuickBASIC is to the base e, thus we must divide by log( 10) to convert to base . 10) and the result is displayed. The log of the fi'equency is stored so we can plot dB vs. log(frequency). Finally the data is plotted using the graphics library drivers. A test run of this program was done using the first-order Butterworth low-pass filter shown in Figure 2.1. The actual values of the components (as measured by the HP 4284A Precision LCR Meter) are R = 1.0169 k!) for the resistor, and R3 = 7.6 Q and C8 = 100.11 nF (measured at 4 kHz) for the capacitor. The generated plot appears in Figure 2.2. This plot appears to be what would be expected from such a circuit. R 0——_W\r O + + VIN ;:C VOUT C ‘ C Figure 2.1 - Low-Pass Filter 12 .. r. 2!!! 2&1 Elsi '51-] an ill 21!) Figure 2.2 - Bode Magnitude Plot of Low-Pass Filter 2.3 Speeding Up Operation of This and Other Routines The LabWindows interactive environment, an interpreted subset of QuickBASIC, is too slow by modern standards. Each measurement and calculation takes several seconds. For professional lab measurements, one must employ the full Microsoft QuickBASIC 4.5 compiler. An additional driver package is then required: the PM2233 Instrument Drivers. This package allows the interface of compiled QuickBASIC with the necessary drivers to control the instruments. The installation of these drivers is identical to the installation of the TestTeam software. It will place its files in the directory \DRIVERS. The only necessary changes to the program are in the INCLUDE statements at the beginning of the program. These changes can be seen in the 13 listing of the program BODE3C.BAS in the next section. It is possible to program directly in the QuickBASIC environment using these libraries, however it is limited to small programs. Thus the QuickBASIC editor was used to type the programs, and then they were compiled and linked from DOS. To automate this procedure, the batch file DOIT.BAT was created. Its listing is shown below. bc/o %1; \qb45\link %1,,@linkme.lnk The command bc invokes the QuickBASIC compiler, and the / o parameter tells it to compile stand-alone, i.e. without a run-time module. The % 1 represents the parameter passed to the batch file. Finally the @linkmelnk for the linker tells it to get its input fi'om the file linkmelnk. The contents of this file are shown below. NUL.MAP/NOE/NOD/SEGMENTS:IOOO/STACK:10000, \LW\LIBRARY\formatio+ \LW\LIBRARY\graphics+ \LW\LIBRARY\gpib qn+\LW\LIBRARY\1wqb1+\qb45\bcom45+ \LW\LIBRARY\ttdrqub+\DRIVERS\drivers+\LW\LIBRARY\lwqbZ: The first line tells the linker not to create a cross-reference file and to set aside 10 KB for the stack. The other lines tell the linker where to find the necessary libraries. For example, to compile and link the program BODE3C.BAS, type at the DOS prompt: ’ . doit b04034: and press ENTER. Afier the process is complete, to run the program simply type bodeac and press ENTER. 14 2.4 Creating a Bode Phase Plot A method of measuring phase angle is via an oscilloscope by finding a common point on the two waveforms and measuring the time delay between them. The ratio of this time delay to the period of the waveform is then proportional to the phase angle. Symbolically this is ALL. T 360° The problem is obtaining an accurate measure of AT. Fortunately there is a simple solution. The PM6666 counter has a measurement mode called "TIME A-B". This mode gives the time delay between a positive slope on channel A and a positive slope on channel B [4]. Since the frequency (and thus the period), is known, the calculation of phase follows. The only other consideration is the coupling of the counter. For low frequencies, below about 500 Hz., the counter should be on DC coupling to avoid errors. Above 500 Hz. the counter should be set for AC coupling. The QuickBASIC implementation of this is shown below. REM File : BODE3C.BAS REM SINCLUDE: '\lw\instr\generato.inc' REM SINCLUDE: '\lw\instr\counter.inc' REM SINCLUDE: '\lw\instr\multimet.inc' REM $INCLUDE: '\1w\instr\scope.inc' REM SINCLUDE: '\lw\instr\general.inc' REM SINCLUDE: '\lw\include\phildecl.inc' REM SINCLUDE: '\lw\inc1ude\graphics.inc’ DEFINT A-Z COMMON SHARED ldmml/ dmml AS INTEGER COMMON SHARED Ignrl/ gnrl as INTEGER COMMON SHARED /osc1/ oscl AS.INTEGER l5 COMMON SHARED /cntl/ cntl AS INTEGER CLEAR ’ ' 2048 DIM SHARED x#(100), y#(100): ph#(100) CALL getmemIZOOOO) overlay.memory.size& - 98304 memory.size& - SETMEM(640000) memory.size& - SETMEM(-overlay.memory.size&) CLS CALL res.glb CALL reset.config PRINT "Initializing Multimeter..." CALL config(dmm1, "8840A,A 706,N DMMl") PRINT "Initializing Function Generator..." CALL config(gnr1, "PM5193/V2.$,A 707,N GNRl") PRINT "Initializing Oscilloscope..." CALL config(oscl, ”PM3365/V07V04,A 708,N OSC1") PRINT "Initializing Counter..." CALL config(cnt1, “PM6666/22,A 710,N CNTI”) PRINT "Setting up defaults...” CALL allinit(DEFAULT.SET) 'or ACTUAL.SET to leave unchanged IF Glb.Stat > 1 THEN PRINT "Error: ", Glb.Str: REM Print global error string CALL res.glb: REM Reset global error status ELSE IF Glb.Stat - 1 THEN PRINT "Warning: ", Glb.Str: REM Print global warning string CALL res.glb: REM Reset global error status END IF END IF PRINT StartOfProg: CALL set.amplitude(gnrl%, VRMSt, 1!) CALL set.function(dmm1%, VOLT.AC%) CALL set.speed(dmm1, low) CALL set.function(cntl%, TIMEINTERVAL.A.B) CALL set.coupling(cntl%, chall%, dc%) CALL set.sensitivity(cnt1%, cha%, .02) CALL set.sensitivity(cnt1%, chb%, .02) INPUT "Enter starting frequency ->", strt! INPUT "Enter ending frequency ->', stp! INPUT "Enter number of points per decade ->", ppd PRINT PRINT "Frequency dB Angle" PRINT strt! - LOG(strt!) / LOG(10) stp! - LOG(stp!) / LOG(10) FOR i! - strt! TO stp! STEP 1 / ppd p - (i! - strt!) * ppd X#(p) - 10 “ 1! CALL set.frequency(gnr1%, x#(p)) CALL measure(dmm1%, yi(p)) 16 IF x#(p) > 500 THEN 'set AC coupling above 500 82 CALL set.coupling(cnt1%, chall%, ac%) ELSE CALL set.coup1ing(cntl%, chall%, dc%) END IF CALL measure(cnt1%, diff!) ph#(p) - -di£f# * x#(p) * 360* IE ph#(p) < -180 THEN ph#(p) - ph#(p) + 360! END IF y#(p) - 20 * LOG(y#(p)) / LOG(10) 'convert to dB LOCATE CSRLIN - 1 PRINT USING "##.###“““ +###.### +###.###"; x#(p); y#(p); Ph*(P) x#(p) - i! NEXT i! CALL GrfReset(4) np - (stp! - strt!) * ppd 'number of points CALL SetXDataType(4) CALL SetYDataType(4) CALL GrfCurv2D(x#(), y#(). np) ’x-y plot of dB vs. log(f) CALL GrfReset(4) 'clear the graphics display CALL GrfCuerD(x#()p ph#(), np) 'x-y plot of phase vs.log(f). CALL GrfLReset(0, 0, 1, 2) ’return to text mode CLS PRINT "Again (y/n)?"; a$ - INPUT$(1) PRINT : PRINT IF UCASE$(a$) - "Y" THEN GOTO StartOfProg REM Now return to local control CALL ioloca1(dmm1%) CALL ioloca1(osc1%) CALL iolocal(cnt1%) CALL ioloca1(gnr1%) END REM $DYNAMIC SUB ReportError END SUB The output of this program for a the high-pass R—C circuit in Figure 2.3 is shown in Figures 2.4 and 2.5. The values of the components used were Cs = 105.48 nF, R5 = 11.9 9 (measured at 400 Hz), and R = 4.028 kn. The frequency range was from 20 Hz to 50 kHz, taking 9 points per decade. 17 7:0 O o + + VIN R VOUT O 0 Figure 2.3 - High-Pass Filter l’s.’ E a “Iii 111 m E] w ill an ill all Figure 2.4 - Bode Magnitude Plot of High Pass Filter 18 EE‘LEEE E“ Figure 2.5 - Bode Phase Plot of High Pass Filter 2.5 Defects and Potential Improvements The program BODE3C.BAS discussed above suffers from several defects. When measuring a low-pass filter, as the output voltage falls below a certain level, the counter can no longer lock onto the signal and erroneous data is taken. Also no access is given to the raw data in case an error is suspected. In addition the counter may occasionally give a time delay that is ofi‘ by a period or two, e.g. yielding a phase angle of -362° as opposed to the correct value of -2°. Still another problem is that the output of the function generator may not be exactly 1 V RMS. It would also be useful to label the axes of the graph. Another desirable feature would be to implement a routine that would locate a -3 dB point. 19 2.6 Implementation of Improvements 2.6.1 Access to Raw Data Providing the user with access to the raw data accumulated would be a convenient feature. This way the user could verify the data by hand if an error is suspected, or even use this data in another program. It would be best to supply all the calculated quantities as well as the measured values. The values to be stored in the file are: frequency, dB, phase, measured voltage, and measured time delay. 2.6.2 Correcting for Input Voltage Errors When the PM5193 Function Generator is set for 1 V RMS output, the open-circuit output is not exactly 1 V RMS. This effect does depend upon frequency somewhat, although if we were to assume a constant error over a range of fiequencies (which may or may not be accurate depending upon the range), we could divide all our voltage measurements by a correlation to approximate the actual transfer function. The optimum solution, of course, would be to use a second voltmeter, then the transfer fimction would simply be output divided by input. The former shall be implemented for the time being, assuming that access to a second voltmeter is not possible. The 20 implementation of the second voltmeter is addressed in Section 3.2. 1. 2.6.3 Disabling the Counter to Prevent Erroneous Data When the output voltage falls below 10 mV RMS, the counter becomes unable to lock onto the signal even when it is set for maximum sensitivity. To solve this problem there are several options: (1) discard phase measurements when the output falls below the 10 mV threshold (although some value must be assigned to the array), or (2) we could stop taking phase measurements below the threshold. The latter shall be implemented. 2.6.4 Correction of Phase Angle Occasionally the counter gives a time delay that is off by a period or two. This would result in a phase angle of say -722° or -362° instead of -2° (it always appears to be off in the negative direction). The simplest method to correct this is to add 360° to the phase angle as long as it is less that -180°. Translated to QuickBASIC: while phttp) < —180 ph#(P) - phttp) + 360! wend 21 2.6.5 Finding a -3 dB Point Finding a -3 dB point is a common required measurement. It may represent the bandwidth or a cutofi‘ frequency of a circuit. By hand it is a tedious procedure, which makes it a particularly desirable feature to implement by machine. The method chosen here is the linear interpolation method. This method assumes a Bode plot has already been performed and that the data from this plot is stored in an array. The steps followed are detailed below. 1. Find two points whose magnitudes are "close" to- ‘12/2 ~ 0.70711. If there are none, inform the user to re-run the bode plot to include such points. 2. Use the linear interpolation formula (from basic calculus) flx +Ax)~flx) +f’(x)Ax where fix), flx+Ax), f(x), and x are known and Ax is the only unknown. (f(x+Ax) = ‘12/2 and f(x) can be approximated by using the two points found in step 1). That is, if the two known frequencies are f1 and f2, and the two magnitudes are t1 and t2, respectively, then ‘2 Itl f2 ‘f 1 and the target frequency is f’(x)- [3:2 f’(x) +f" 3. Set the target frequency to the value found in step 2. Read the output voltage from the voltmeter. If the voltage does not equal 0.70711 V (the 8840A displays 5 decimal points) then use one of 22 the original points and point found in step 2 and return to step 2. Translating steps 2 and 3 into QuickBASIC: DO slope! - (t2! - t1!) / (f2! - f1!) f0? - (0.70711 - t1?) / slope? + £1! CALL set.£requency(gnr1%, f0#) CALL measure (dmm1%, t0#) IE (f2? - £0!) < (f0# - f1?) THEN f1¥ - f0¥ tlt - t0# ELSE f2# - f0# t2# - t0# END IF LOOP UNTIL t0# - 0.70711 In practice this routine seems to require an average of 6 or 7 tries before it finds the cutofi' frequency. Also we will want to include this value in the raw data file. 2.7 The Program BODE5C.BAS A listing of the finished code with the modifications discussed in Sections 2.5 - 2.6 and some miscellaneous cosmetic changes is shown below: REM File : BODE5C.BAS REM- SINCLUDE: ’\lw\instr\generato.inc’ REM SINCLUDE: '\lw\instr\counter.inc' REM $INCLUDE: '\lw\instr\multimet.inc' REM SINCLUDE: '\lw\instr\scope.inc’ REM SINCLUDE: '\1w\instr\genera1,inc’ REM SINCLUDE: '\lw\include\phildec1.inc’ REM SINCLUDE: '\1w\include\graphics.inc’ DEFINT A-Z COMMON SHARED ldmml/ dmml AS INTEGER COMMON SHARED lgnrl/ gnrl AS INTEGER COMMON SHARED /osc1/ oscl AS INTEGER COMMON SHARED /cnt1/ cntl AS INTEGER 23 CLEAR , , 2048 DIN SHARED X#(500)I Y‘(500)I Ph#(500) CALL getmethOOOO) overlay.memory.size& - 98304 memory.size& - SETMEM(640000) memory.size& - SETMEM(-over1ay.memory.sizeE) CLS CALL res.glb CALL reset.config PRINT "Initializing Multimeter..." CALL configtdmml, "8840A,A 706,N DMMl”) PRINT "Initializing.Function Generator...” CALL configtgnrl, "PM5193/V2.5,A 707,N GNRl") PRINT "Initializing Oscilloscope..." CALL config(oscl, "PM3365/V07V04,A 708,N OSC1”) PRINT "Initializing Counter..." CALL config(cnt1, "PM6666/22,A 710,N CNTl") PRINT "Setting up defaults..." CALL allinit(DEFAULT.SET) 'or ACTUAL.SET to leave unchanged IF Glb.$tat > 1 THEN PRINT "Error: ”, Glb.$tr: REM Print global error string CALL res.glb: REM Reset global error status ELSE IF Glb.$tat - 1 THEN PRINT "Warning: ", Glb.$tr: REM Print global warning string CALL res.glb: REM Reset global error status END IF END IF PRINT StartOfProg: OPEN "rawdata." FOR OUTPUT AS #1 'save data in file CALL set.amp1itude(gnr1%, VRMS%, 1!) CALL set.function(dmml%, VOLT.AC%) CALL set.speed(dmm1, low) CALL set.function(cnt1%, TIMEINTERVAL.A.B) CALL set.coup1ing(cnt1%, chall%, dc%) CALL set.sensitivity(cnt1%, cha%, .02) CALL set.sensitivity(cnt1%, chb%, .02) INPUT "Enter starting frequency ->", strt! INPUT ”Enter ending frequency ->", stp! INPUT ”Enter number of points per decade ->", ppd INPUT ”Enter actual RMS output of function generator ->”, ff? IF ff! - 0 THEN ff? - 1 'assume 1 if they hit return PRINT PRINT "Frequency dB Angle" PRINT strt! - LOG(strt!) / LOG(lO) stp! - LOG(stp!) / LOG(lO) np - (stp! - strt!) * ppd 'number of magnitude points nph - np 'number of phase points FOR 1! - strt! TO stp! STEP 1 / ppd 24 p - (i! - strt!) * ppd x#(p) - 10 “ i! CALL set.frequency(gnr1%, xttp)) CALL measure(dmm1%, dvmt) dvmi - dvmi / ff# IF dvmt > .01 AND nph - np THEN ’take phase reading only if voltage 'is greater than 10 mv RMS IF xttp) > 500 THEN CALL set.coup1ing(cnt1%, chall%, ac%) ELSE CALL set.coup1ing(cntl%, chall%, dc%) END IF CALL measure(cntl%, difft) phitp) - -diff# * x#(p) * 360i WHILE ph#(p) < -180 phttp) - ph#(p) + 360! WEND ELSE IF nph - np THEN nph - p END IF y#(p) - 20 * LOG(dvmt) / LOG(lO) ’convert to dB LOCATE CSRLIN - 1 PRINT USING "##.###“‘““ +###.### +###.###": xttp); yttp); ph#(p) PRINT #1, USING "#§.§t#“‘“ +§##.### ‘+###.##i -+###.#t# ##.####“‘“‘": x#(p): yitp): phttp): dvmt; diff! x#(p) - i! NEXT i! PRINT 'Now look for -3 dB point targeti - .70711# / ff# 1 - 1 WHILE ABS(EXP(LOG(10) * y#(i) / 20) - target#) / target¥ > .1 AND 1 < np i - i + 1 WEND IF i - np THEN PRINT ”Couldn't find -3 dB frequency... run again with different points" PRINT #1, "" PRINT #1, ”Couldn’t find -3 dB frequency... run again with different points" ELSE flt - 10 ‘ x#(i - 1) 'starting frequencies f2! - 10 ‘ x#(i) t1! - 10 ‘ (y#(i - 1) / 20) 'starting target values t2# - 10 “ (ytti) / 20) DO slope} - (t2# - t1!) / (f2! - fl!) f0! - (target! - t1!) / slope! + £1! , PRINT USING ”Locating -3 dB frequency: #####.##": f0! LOCATE CSRLIN - 1 'now find to CALL set.frequency(gnr1%, f0!) 25 CALL measuretdmml%, t0!) IF (f2# - f0#) < (f0! - flt) THEN f1! - f0# t1} - t0# ELSE f2! - f0# t2! - t0! END IF LOOP UNTIL t0# - target? PRINT USING "The cutoff frequency is ##i##.## Hz.": f0! PRINT #1, "" PRINT #1, USING "The cutoff frequency is #####.## 32.”; f0! END IF WHILE INKEY$ - ”"z WEND CLOSE #1 'output raw data file CALL GrfResett4) CALL SetAxGridVist-l, 1) 'enable grid lines for both axes CALL SetAxAutot-l, 21) 'auto-scale both axes every time CALL SetXDataTYPe(4) CALL SetYDataTYP6(4) CALL SetAxNametO, ”log(f)") 'set name of x-axis CALL SetAxName(1, ”dB') 'set name of y-axis CALL GrfCurv2D(x#(), y#(), np) 'x-y plot of dB vs. log(f) CALL GrfReset(4) 'clear the graphics display CALL SetAxName(1, "Phase Angle”) 'set name of y-axis CALL GrfCurv2D(x#(), phtt), nph) 'x-y plot of phase vs. log(f) CALL GrfLReset(0, 0, 1, 2) 'return to text mode CLS PRINT "Again (y/n)?": as - INPUTS (1) CLS IF UCASE$(a$) - "Y" THEN GOTO StartOfProg REM Now return to local control CALL iolocal(dmm1%) CALL iolocaltosc1%) CALL iolocaltcnt1%) CALL iolocaltgnr1%) END REM $DYNAMIC SUB ReportError END SUB 26 2.8 Sample Data from BODE5C.BAS The program was run for the high pass circuit shown in Figure 2.3. The resulting Bode plots are shown in Figures 2.6 - 2.7, and the raw data is shown in Table 2.1. The actual values of the components are R = 3.801 kn, R8 = 12.120, and Cs = 105.31 nF (measured at 400 Hz.). The data was collected using 10 points per decade over a frequency range of 20 Hz to 50 kHz. The cutoff frequency was found to be 416.59 Hz by the program. Note that this is not the same as the theoretical cutofl‘ frequency (396.34 Hz) but rather is the frequency at which the voltmeter read 0.70711. The error is due to the presence of R8 of the capacitor and the output impedance of the function generator. Correction of these errors is dealt with in the next chapter. can. CID-“3:9 OVI’!‘ 27 9:; D; C: I 31h] 1!! an ill 1!.) Lil! Ell ill SI!) . 09 Figure 2.6 - Bode Magnitude Plot of High Pass Filter EEEE EE & ill '5!!! 2m 1% ill 21!] 211 an 09 Figure 2.7 - Bode Phase Plot of High Pass Filter 28 Table 2.1 - Raw Data For High Pass Filter 2.000D+01 -26.225 +82.968 +0.049 3.8477D-02 2.518D+01 -24.164 +83.496 +0.062 3.0505D-02 3.1?0D+01 -22.159 +82.968 +0.0?8 2.4277D-02 3.991D+01 -20.16? +82.852 +0.098 1.9292D-02 S.024D+01 -18.18? +81.544 +0.123 1.5397D-02 6.325D+01 -16.225 +80.142 +0.154 1.2292D-02 ?.962D+01 -14.288 +78.08? +0.193 9.8352D-03 1.002D+02 -12.386 +75.480 +0.240 7.8846D-03 1.262D+02 -10.S43 +72.680 +0.29? 6.3246D-03 1.589D+02 -8.??S +68.233 +0.364 5.1016D-03 2.000D+02 -?.120 +63.631 +0.441 4.1162D-03 2.518D+02 -5.613 +58.315 +0.524 3.3283D-03 3.1?0D+02 -4.294 +52.302 +0.610 2.6965D-03 3.991D+02 -3.191 +45.??9 +0.693 2.18730-03 5.024D+02 -2.315 +38.062 +0.?66 1.?801D-03 6.325D+02 -1.653 +32.418 +0.82? 1.4388D-03 7.962D+02 -1.1?4 +26.988 +0.8?4 1.1618D-03 1.002D+03 -0.842 +22.121 +0.908 9.3633D-04 1.262D+03 -0.616 +18.199 +0.932 7.5239D-04 1.589D+03 -0.465 +14.543 +0.948 6.0404D-04 2.000D+03 -0.366 +11.691 +0.959 4.8376D-04 2.518D+03 -0.299 +9.530 +0.966 3.86650-04 3.170D+03 -0.255 +7.596 +0.9?1 3.08820-04 3.99ID+03 -0.224 +6.383 +0.9?S 2.4615D-04 5.024D+03 -0.203 +5.30? +0.97? 1.96120-04 6.325D+03 -0.189 +4.190 +0.979 1.5627D-04 7.962D+03 -0.177 +3.380 +0.980 1.2442D-04 1.002D+04 -0.168 +2.?31 +0.981 9.900?D-05 1.262D+04 -0.159 +2.1?3 '+0.982 ?.8?6?D-05 1.589D+04 -0.150 +1.?01 +0.983 6.2649D-05 2.000D+04 -0.140 +1.282 +0.984 4.9822D-OS 2.518D+04 -0.138 +0.954 +0.984 3.9611D-05 3.1?0D+04 -0.14? +0.?95 +0.983 3.1478D-05 3.991D+04 -0.154 +0.?31 +0.982 2.5009D-05 The cutoff frequency is 416.59 Hz. 2.9 Summary In this chapter TestTeam was utilized to analyze passive networks. Routines for creating Bode magnitude and phase plots were developed, and an algorithm for locating a -3 dB point was presented. These programs were tested as they were developed and sample data was provided. CHAPTER 3 STEADY STATE ANALYSIS OF ACTIVE NETWORKS 3.1 Introduction In the previous chapter we developed techniques to analyze passive networks. Now techniques are developed to measure active circuits. The topics covered include gain-bandwidth-products of op-amps and the second order filter parameters ft, Ho, and Q0. 3.2 Enhancements for the Measurement of Active Circuits 3.2.1 Addition of a Second Voltmeter There are many circuits to which the 50!) output impedance of the PM 5193 function generator is significant. That is, for the one-port network shown in Figure 3.1, V5' is significantly less than Vs. Until now, we have been assuming that Vs a V8, which can result in significant errors. Consider the passive notch filter shown in Figure 3.2 with component values R=116.9 0, C3 = 206.2 nF, Rec = 0.87 9, L3 = 907.34 uH, Ra = 12.45 9 (measured at 10 kHz). The output of the program as it is now is shown in Figures 3.3 - 3.4. The data was collected using 80 points per decade over a frequency range of 1 kHz to '29 30 100 kHz. The magnitude plot, however, is incorrect. At the center (notch) frequency, the input impedance of this circuit is R+R3L+Rsc = 130.22 Q. Thus assuming the 50 52 output impedance of the fimction generator is purely resistive, Vg= 13022 (1 V)=0.723 V 130.22+5o which is already nearly 3 dB down. The best solution to this problem is to add a second voltmeter to measure Vs’. As stated earlier, as long as the IEEE address is different, there will be no conflict on the bus. Afier re-running the configuration program, a new TESTTEAMBAS file is generated. REM File : TESTTEAM.BAS REM Setup file for Philips/Fluke Instrument drivers REM This will assign logical names to the instruments REM and initialize the instruments REM Following include statements can be removed in Interactive window REM SINCLUDE: '\lw\instr\generato.inc’ REM SINCLUDE: '\lw\instr\counter.inc' REM SINCLUDE: '\lw\instr\multimet.inc' REM $INCLUDE: '\1w\instr\scope.inc' REM $INCLUDE: '\lw\instr\general.inc’ DEFINT A-Z COMMON SHARED /DMM1/ DMMl AS INTEGER COMMON SHARED /DMM2/ DMMZ AS INTEGER COMMON SHARED /GNR1/ GNRl AS INTEGER COMMON SHARED /OSC1/ OSC1 AS INTEGER COMMON SHARED /CNT1/ CNTl AS INTEGER CALL res.glb CALL reset.config CALL config(DMM1,"8840A,A ?05,N DMMl”) CALL config(DMM2,"884OA,A 706,N DMMZ") CALL confithNRl,"PM5193/V2.5,A 707,N GNRl") CALL config(OSC1,"PM3365/V07V04,A 708,N OSC1") CALL configtCNTl,"PM6666/22,A 710,N CNTl") CALL allinit(DEFAULT.SET) IF glb.stat > 1 THEN PRINT "Error: ",glb.str :REM Print global error string call res.glb . :REM Reset global error status 31 ELSE IF glb.stat - 1 THEN PRINT "Warning: ",glb.str :REM Print global warning string call res.glb :REM Reset global error status END IF END IF There are only three difi‘erent lines in this code. First is the declaration of the new variable ('11ng . TestTeam recognizes the two meters as dmml and dmmz . Then in the two CALL config lines the proper IEEE address is assigned to each meter (address 5 is assigned to the new meter). These three changes may be made directly to the BODE5C.BAS program. +, 1-Port 3 VS Network Figure 3.1 - Thevenin Equivalent of Function Generator R O——’VVV O + + L V I N VOUT _ C _ o ’f‘ 0 Figure 3.2 - Passive Notch Filter 32 The only necessary changes to the code to utilize the two meters are to take the ratio of the two measurements instead of taking only one measurement. The correct magnitude plot for the notch filter is shown in Figure 3.5. Another advantage of using a second voltmeter is increased bandwidth. The upper frequency limit for the 8840A is 100 kHz. When using a second meter though, if its measurements roll ofi' at the same rate as the first meter, their ratio will still be correct. For the set of instruments used, an efi‘ective increase in bandwidth to 400 kHz within 1% (0.1 dB) was observed. 5:: ah!!!” mmmlm&)mm ll-l mm 09 Figure 3.3 - Incorrect Bode Magnitude Plot for Notch Filter 33 [L O—Iflap temps-01: 1% S!!! mmmlm&)mm an 113 all , 09 Figure 3.4 - Bode Phase Plot for Notch Filter EEEEEEBEEE 3% ill I!!! mmlzrg)mm II! was 09 Figure 3.5 - Correct Bode Magnitude Plot for Notch Filter 34 3.2.2 Modification of .3 dB Routine for Active Circuits In previous sections we have found the -3 dB point with respect to 1 V. For many circuits this may not be true. Let us examine a one-pole active low- pass filter. In this case we will measure the DC gain of the circuit, then find the -3 dB point with respect to it. Of course this will not work for high-pass or band-pass filters since their DC gain will be small. A solution to this problem is presented in section 3.6.3. 3.2.3 Measuring the Gain-Bandwidth-Product of an Op-Amp Measuring the gain-bandwidth—product of an op-amp is another common required measurement. However certain circuit configurations make the measurement easier than others. Consider the inverting amplifier in Figure 3.6. By inserting a controlled source model of the op-amp (Figure 3.7) it can be shown that V _ _ Ii!2 1 TI: TI: _1_R,+R,' . (3.1) A4,. R1 1+ 35 R2 V10-—W\r— } ——-OV2 Figure 3.6 - Inverting Amplifier V10—MN— 5I| 0 V2 Figure 3.7 - Controlled Source Model of Inverting Amplifier ""1. V e IN —0 —~w—~ R2 R, l Figure 3.8 - Non-inverting Amplifier 36 Likewise for the non-inverting amplifier (Figure 3.8) it can be shown that V: R2+R1 1 V, R, 1 R,+R,' (3.2) 1+... A4... 31 Note that both of these configurations (and indeed all one op-amp circuits [5]) have a transfer function of the form 1 -K F(s) __ 1 1+ 1 ' (3.3) Ade For low to mid frequencies, the open-loop difi'erential mode gain A,“ is not constant, rather it acts as a one-pole transfer function. A one-pole model for Ad... is given by Adm- A°‘°°. (3.4) 8+0)o The frequency (on is the frequency at which the gain is down by 3 dB. From the Fairchild data sheet for the 741 op-amp, A0 is 200,000 and f, is 5 Hz. The product Aof0 is the gain-bandwidth-product. For frequencies much greater than 1;, Ah can be approximated as A°‘°°. (3.5) 8 Ad,"- Inserting this expression into Equation 3.3 yields 37 F(s)-K 1 . 1+ 8 .1; A000 B and making the substitution 3 = jm gives (3.6) pom-K 1 , 1&2. (3.7) where " 1 (3.8) Note that if K = 1/B, then the product K-fe = GBP. The non-inverting amplifier has this property; the inverting amplifier does not. Thus to find the gain-bandwidth-product of an opoamp, configure it as a non-inverting amplifier. Then use BODE6C.BAS to find the -3 dB frequency of the circuit. The product of the DC gain and the cutofi' frequency is then the gain-bandwidth-product. This is true as long as the one-pole approximation of Adm holds. Thus K must be chosen large enough that the second pole of Adm does not efi'ect the results. 3.2.4 Aborting the Program At certain times it may be desirable to abort operation of the program. Perhaps the circuit is not responding as expected, the wrong number of points 38 per decade was selected, or a different sweep is desired. It would be convenient to simply press the ESCape key to stop operation of the program. This feature will also be implemented below. 3.3 The Listing of BODE6C.BAS A listing of the program as it stands now is shown below. REM File : BODE6C.BAS REM Support for second voltmeter added REM and support for active circuits REM Following include statements can be removed in Interactive window' REM $INCLUDE: '\lw\instr\generato.inc’ REM $INCLUDE: '\lw\instr\counter.inc' REM $INCLUDE: '\lw\instr\multimet.inc' REM $INCLUDE: '\lw\instr\scope.inc' REM $INCLUDE: ’\lw\instr\general.inc’ REM $INCLUDE: '\1w\include\phildecl.inc' REM $INCLUDE: '\lw\include\graphics.inc' DEFINT A-Z COMMON SHARED ldmmll dmml AS INTEGER COMMON SHARED /dmm2/ dmm2 AS INTEGER COMMON SHARED /gnr1/ gnrl As INTEGER COMMON SHARED loscll oscl AS INTEGER COMMON SHARED /Cnt1/ Cntl AS INTEGER CLEAR , , 2048 DIM SHARED x#(500), y#(500). PhttSOO) CALL getmem(20000) overlay.memery.size& - 98304 memory.size& - SETMEM(640000) memory.size& - SETMEM(-overlay.memory.size&) CLS CALL res.glb CALL reset.config PRINT "Initializing Multimeters..." CALL config(dmml, ”8840A,A ?05,N DMMl“) CALL config(dmm2, "8840A,A 706,N DMMZ") PRINT "Initializing Function Generator..." CALL config(gnrl, ”PMSl93/V2.5,A ?0?,N GNRl") PRINT "Initializing Oscilloscope..." CALL config(oscl, "PM3365/V0?V04,A 708,N OSC1") PRINT "Initializing Counterr..” 39 CALL config(cntl, "PM6666/22,A ?10,N CNTl") PRINT "Setting up defaults..." CALL a11init(DEFAULT.SET) ’or ACTUAL.SET to leave unchanged IF Glb.$tat > 1 THEN PRINT "Error: ”, Glb.$tr: REM Print global error string CALL res.glb: REM Reset global error status ELSE IF Glb.$tat - 1 THEN PRINT "warning: ", Glb.$tr: REM Print global warning string CALL res.glb: REM Reset global error status END IF END IF PRINT StartOfProg: OPEN "rawdata." FOR OUTPUT AS #1 'save data in file CALL set.function(dmm1%, volt.ac%) CALL set.function(dmm2%, volt.ac%) CALL set.speed(dmml, low) CALL set.speed(dmm2, low) CALL set.function(cnt1%, TIMEINTERVAL.A.B) CALL set.coupling(cnt1%, chall%, dc%) CALL set.sensitivity(cnt1%, cha%, .02) CALL set.sensitivity(cnt1%, chb%, .02) INPUT "Enter starting frequency ->", strt! INPUT ”Enter ending frequency ->", stp! INPUT "Enter number of points per decade ->", ppd INPUT "Enter desired RMS function generator voltage (default 1 V) ->", gnv! IF gnv! - 0 THEN gnv! - 1 CALL set.offset(gnr1, 0%) CALL set.amplitude(gnr1, vrms, gnv!) PRINT PRINT "Frequency dB Angle" PRINT strt! - LOG(strt!) / LOG(10) stp! - LOG(stp!) / LOG(10) np - (stp! - strt!) * ppd 'number Of magnitude points nph - np 'number Of phase points FOR i! - strt! TO stp! STEP 1 / ppd p - (i! - strt!) * ppd x#(p) - 10 ‘ i! IF INKEY$ - CHR$(27) THEN PRINT PRINT ”Run aborted..." PRINT PRINT #1, "” PRINT #1, "Run aborted..." CLOSE GOTO Again END IF 40 CALL set.frequency(gnr1%, x#(p)) CALL measure(dmm1%, dvmli) CALL measure(dmm2%, dvm2i) dvm! - ABStdva! / dvmli) 'input 'output 'find transfer fn output/input IF dvm2# > 0 AND nph - np THEN output 'take phase reading only if 'is greater than 10 my RMS IF x#(p) > 500 THEN CALL set.coupling(cnt1%, Chall%, ac%) ELSE CALL set.coup1ing(cnt1%, Chall%, dc%) END IF CALL measure(cntl%, diff!) ph#(p) - -diff# * x#(p) * 360* WHILE ph#(p) < -180 ph#(p) - phttp) + 360* WEND ELSE IF nph - np THEN nph - p END IF y#(p) - 20 * LOG(dvmi) / LOG(lO) 'convert to dB LOCATE CSRLIN - 1 +##§.### +§§#.#§#”; x§(p): PRINT USING "##.##§““ ph#(p) PRINT #1, USING ”##.###““““ +###.i## +t##.### ##.##i#““‘": x#(p): yttp): ph#(p): dvmi: difft x#(p) - i! NEXT i! Yttp): +###.### PRINT 'Now CALL CALL CALL CALL CALL CALL hdci CALL CALL CALL CALL find DC gain 'turn Off AC voltage from gen 'turn on DC volts from gen set.amp1itude(gnr1, vrms, 0) set.offset(gnr1, gnv!) set.function(dmm1, volt.dc) set.function(dmm2, volt.dc) measure(dmm1, dvml!) measure(dmm2, dvm2t) - dvm2§ / dvmli 'DC gain (NOT dB) 'return DMM to its original ’state set.offset(gnr1, Oi) set.function(dmm1, volt.ac) set.function(dmm2, volt.ac) set.amplitude(gnr1, vrms, gnv!) PRINT PRINT #1, PRINT USING "DC Gain - i#§.###"; hdci: IF hdc’ <> 0 THEN PRINT USING ' - ##.##i dB": 20 * LOG(ABS(hdc§)) / LOG(IO) PRINT #1, USING ”DC Gain - ###.###": hdci: IF hdci <> 0 THEN PRINT #1, USING " - ##.### dB": 20 * LOG(ABS(hdc#)) / LOG(lO) 41 'Now look for -3 dB point from.left side PRINT PRINT #1, ”" target# - hdc? / SQR(2#) IF target! < .001 THEN PRINT "DC Gain is too low - Cannot sweep for -3 dB point from left" PRINT #1, "DC Gain is too low - Cannot sweep for -3 dB point from left" GOTO graphit END IF i - 1 WHILE ABStEXP(LOG(10#) * ytti) / 20%) - targett) / target! > .1# AND i < np i - i + 1 WEND IF 1 - np THEN PRINT "Couldn't find -3 dB frequency... run again with different points" PRINT #1, "" PRINT #1, "Couldn't find -3 dB frequency... run again with different points" ELSE flt - 10 “ x#(i - 1) 'starting frequencies f2! - 10 “ x#(i) t1! - 10 ‘ (y#(i - 1) / 20) 'starting target values t2? - 10 “ (y#(i) / 20) DO slope# - (t2t - t1!) / (f2! - f1!) f0! - (target# - t1!) / slope! + f1# PRINT USING "Locating -3 dB frequency: #####.##”; f0# LOCATE CSRLIN - 1 IF INKEYS - CHR$(27) THEN . PRINT "Location of -3 dB frequency aborted... . " PRINT #1, "” PRINT #1, "Location of -3 dB frequency aborted..." GOTO graphit END IF 'now find to CALL set.frequency(gnr1%, f0!) CALL measure(dmm1, dvmlt) CALL measure(dmm2, dvm2#) t0! - dvm2§ / dvml! IF (f2! - £0!) < (f0# - f1!) THEN fli - f0! t1? - t0! ELSE f2! - f0! t2! - t0# END IF hgs - 100000! * t0! / hdci LOOP UNTIL hg& - 70711 PRINT USING ”The cutoff frequency is #####.#t Hz.'; f0! PRINT USING "GBP - ##§!#####.## Hz"; f0! * hdct PRINT #1, USING "The cutoff frequency is #####.## Hz.'; f0# PRINT #1, USING "GBP - ###}#####.## Hz"; f0! * hdct 42 PRINT #1, "Actual cutoff ratio - ": t0# / hdc# END IF graphit: CLOSE #1 'output raw data file CALL set.amp1itude(gnr1, vrms, 0) 'turn off AC voltage from gen 'to facilitate changing components PRINT PRINT "Press any key to see graphs..."; WHILE INKEYS ' "": WEND CALL GrfReset(4) CALL SetAxGridVis(-1, 1) axes 'enable grid lines for both CALL time CALL CALL CALL CALL SetAxAutO(’1, 21) SetXDataType(4) SetYDataType(4) SetAxName(0, "log(f)") SetAxName (1, "dB") 'auto-scale both axes every 'set name of x-axis 'set name Of y-axis CALL GrfCurv2D(x#(), y#(). np) ’x-y plot of dB vs. log(f) CALL GrfReset(4) ‘ 'clear the graphics display CALL SetAxName(1, "Phase Angle”) 'set name of y-axis CALL GrfCurv2D(x#()p ph#(), nph) 'x-y plot of phase vs. log(f) CALL GrfLReset(0, 0, 1, 2) ’return to text mode CLS Again: PRINT "Again (y/n)?"; a$ - INPUT$(1) CLS IF UCASE$(a$) REM CALL 'CALL CALL CALL CALL END Now return to local control ioloca1(dmml%) iolocal(dmm2%) iolocal(osc1%) ioloca1(cnt1%) iolocal(gnr1%) REM SDYNAMIC SUB ReportError END SUB - "Y" THEN GOTO StartOfProg 43 3.4 Sample Data from BODE6C.BAS As stated earlier, one useful application of this program is to measure the Gain-Bandwidth-Product of an op-amp. A non-inverting amplifier (Figure 3.8) is configured using an LM741 op-amp with R1 = 1 k!) and R2 = 47 k9 (nominal values). The resulting Bode plots are shown in Figures 3.9 - 3.10. Unfortunately, the bandwidth of the meters is only 400 kHz, since by examining the phase plot there appears to be a second pole around 4 MHz. The DC gain was found to be 48.01, with a GBP of 828.3 kHz. The Fairchild data sheet for the 7 41 lists a GBP 'of 1 MHz, however this characteristic varies widely from sample to sample. Thus the results are considered acceptable. I h '5!!! ll] m 31-1619 ii! an: all m 09 Figure 3.9 - Bode Magnitude Plot of Non-inverting Amplifier til 31 P h a!!!) S e :19 (t 0 gm] 1 e “E! as as '5!!! fling!!! 1&1 a!!! 2!] m 09 Figure 3.10 - Bode Phase Plot of Non-inverting Amplifier 3.5 Testing for Linearity The measurements we have been taking are only valid when performed on linear systems. If a circuit is not behaving linearly, the measurements may be worthless. One possibility is that an op-amp in a circuit has saturated. A method of checking for linearity is to reduce the input by some ratio (perhaps 50%) and check that the output is also reduced by the same ratio. If not, a warning to the user is displayed. The QuickBASIC code to add to the program to do this is given below. CALL set.amplitude(gnr1, vrms, gnv! / 2!) CALL measure(dmml, dvmlfl CALL measure(dmm2, dvm2#) IF Assmvair / dvmli - dvmi 7 2+) / (dvmt / 2:) > .01 THEN 45 PRINT USING "Warning - Linearity Check Failed at f - ##.####"“"": pr) LOCATE CSRLIN - 1 PRINT #1, USING "Warning - Linearity Check Failed at f - #§,*§##eecc"; pr) END IF CALL set.amplitude(gnr1, vrms, gnv!) It may also be desirable to do this only once every five or ten points, since it slows down the program considerably. Due to the delays imposed by this routine, it is not included in any other listings. 3.6 Automated Measurement of Filter Parameters Another tedious measurement that would be useful to implement is the measurement of the second order filter parameters f,, Ho, and Q0. Finding Q0 of a high-Q filter by hand is particularly dificult. When properly programmed, however, it becomes as simple as the touch of a button. 3.6.1 Location of a Second -3 dB point If the program BODEGCBAS was run on a notch filter, it would locate the -3 dB fiequency to the left of the notch. This is because we begin our sweep from the left. If we were to sweep for a second -3 dB point from the right, we would be able to calculate the bandwidth of this filter. One question that rises immediately is what to find this second -3 dB point with respect to: 46 the DC value or the highest fi'equency point taken. There are some notch filters that do not return to the DC gain to the right of the notch. We will assume that all notch filters swept by this program do return to the DC gain. To ensure compatibility of this program with other filters, we will allow the user to look for 0, 1, or 2 cutofi‘ frequencies. 3.6.2 Calculation of the Center Frequency of a Second-order Notch Filter If the notch filter is a second-order filter, then the center frequency can be calculated by the formula fcgfi (3.9) where f, and f, are the two cutofi‘ fi'equencies, and the Q of the filter can be found by f ,=._¢_. (3.10) Q f2 ‘f1 Calculating f; is certainly faster than searching for the center of the notch, and is sufficiently accurate for many applications. In the next section we will develop a technique for locating the peak of a band-pass filter; if desired that routine could be altered to locate the center of the notch. 47 3.6.3 Finding the Parameters of Band-pass Filters Locating the cutofi' frequencies of a band-pass filter is much more difiicult than it was for the notch filter. The hardest part is finding the center fi-equency. Unlike the notch filter, where we could use the DC gain as the reference for the -3 dB frequencies, there is no reference to begin with. Thus the only way to find the cutoff frequencies is to first find the peak of the filter. An algorithm to find the peak is detailed below. Sweep the bode plot as before. Find the maximum value in the array y#. This will be the starting point. Call this point Q. 3. Set the variable Alogf = 0.1. This will be the logarithmic window in which we will look. 4. Measure the voltage at the two endpoints of the window, P!" f13=100°l fM 5. If the voltage at either f1 or f2 is larger than at f0, then set f, to the frequency at which the voltage is highest, and go to step 4. 6. Otherwise divide Alogf by 2. 7. If Alogf > 0.00001 (or some acceptable tolerance), go to step 4. Otherwise, f, = fo is the center frequency. Once we have found )2. we can find H(, by measuring the output voltage at that frequency, and we can find the cutoff frequencies relative to H0 in the same manner as we have done all along. The formula given for Q0 in Equation 3.10 is still valid, and now we have all the filter parameters. Note that once these modifications are made to the program, it can be used to locate the cutoff frequency of a high-pass filter by sweeping the bode plot to the highest 48 allowable frequency (400 kHz for the set of instruments used), then finding one cutofi' frequency with respect to the peak output. 3.7 Accuracy of These Routines The accuracy of these routines are limited mainly by the accuracy of the instruments used. For a Fluke 8840A DMM calibrated within one year in True RMS AC volts mode, the worst case accuracy (fi'om 50 - 100 kHz) is given by the manual to be :(0.5% + 400 counts). In the 2 V range (full scale reading 1.99999 V), if the voltmeter reads 1 V, this says that the actual voltage lies in the range 0.991 S V 5 1.009. So the worst possible readings of a transfer function of 1 when using the ratio of two meters are flame 0.991 and L991=oaaa 1.009 Based upon the agreement of theoretical and experimental data presented in chapter 4, however, it appears that these numbers may be quite pessimistic. The program does appear to be quite consistent in its results, within one count 49 at the fourth significant figure. Henceforth all measured values are reported to four significant figures. 3.8 The Program BODE7C.BAS A Hating of the program BODE7C is given below. The program will be tested in the next chapter. REM File : BODE7C.BAS REM Added ability to search for two -3 dB points REM and calculate Ho, 00 for band-pass & notch filters REM Following include statements can be removed in Interactive window REM $INCLUDE: '\lw\instr\generato.inc' REM . $INCLUDE: '\lw\instr\counter.inc’ REM $INCLUDE: '\1w\instr\multimet.inc' REM $INCLUDE: ’\lw\instr\scope.inc' REM $INCLUDE: '\lw\instr\genera1.inc' REM $INCLUDE: '\lw\include\phildecl.inc' REM $INCLUDE: '\lw\include\graphics.inc' DEFINT A-Z COMMON SHARED /dmml/ dmml AS INTEGER COMMON SHARED /dmm2/ dmmZ AS INTEGER COMMON SHARED /gnr1/ gnrl AS INTEGER COMMON SHARED /Oscl/ oscl AS INTEGER COMMON SHARED Icntll cntl AS INTEGER CLEAR , , 2048 DIM SHARED x#(500), y#(500), Ph#(500) CALL getmem(20000) overlay.memery.size& - 98304 memery.size& - SETMEM(640000) memory.size& - SETMEM(-overlay.memery.sizes) CLS CALL res.glb CALL reset.config PRINT "Initializing Multimeters..." CALL config(dmml, “8840A,A ?05,N DMMl") CALL config(dmm2, "8840A,A 706,N DMMZ") PRINT "Initializing Function Generator..." CALL config(gnrl, "PM5193/V2.5,A ?0?,N GNRl") 50 PRINT "Initializing Oscilloscope..." CALL config(oscl, "PM3365/V0?V04,A 708,N OSC1") PRINT "Initializing Counter..." ' CALL config(cntl, "PM6666/22,A ?10,N CNTl") PRINT "Setting up defaults..." CALL a11init(DEFAULT.SET) 'or ACTUAL.SET to leave unchanged IF Glb.$tat > 1 THEN PRINT "Error: ”, Glb.$tr: REM Print global error string CALL res.glb: REM Reset global error status ELSE IF Glb.$tat - 1 THEN PRINT "Warning: ", Glb.$tr: REM Print global warning string CALL res.glb: REM Reset global error status END IF END IF PRINT StartOfProg: OPEN "rawdata." FOR OUTPUT AS #1 'save data in file CALL set.function(dmm1%, volt.ac%) CALL set.function(dmm2%, volt.ac%) CALL set.speed(dmm1, low) CALL set.speed(dmm2, low) CALL set.function(cnt1%, TIMEINTERVAL.A.B) CALL set.coupling(cnt1%, chall%, dc%) CALL set.sensitivity(cnt1%, cha%, .02) CALL set.sensitivity(cnt1%, chb%, .02) INPUT "Enter starting frequency ->", strt! INPUT "Enter ending frequency ->", stp! INPUT "Enter number of points per decade ->", ppd INPUT "Enter desired RMS function generator voltage (default 1 V) IF gnv! - 0 THEN gnv! - 1 CALL set.offset(gnr1, 0%) CALL set.amplitude(gnrl, vrms, gnv!) PRINT PRINT "Frequency dB Angle" PRINT strt! - LOG(strt!) / LOG(lO). stp! - LOG(stp!) / LOG(lO) np - (stp! - strt!) * ppd 'number of magnitude points nph - np 'number of phase points ' FOR i! - strt! TO stp! STEP 1 / ppd p ' (i! - strt!) * ppd x#(p) - 10 “ i! IF INKEY$ - CHR$(27) THEN PRINT PRINT "Run aborted..." PRINT PRINT #1, "" PRINT #1, "Run aborted...“ 51 CLOSE GOTO Again END IF CALL set.frequency(gnr1%, x#(p)) CALL measure(dmml%, dvml#) 'input CALL measure(dmm2%, dvm2#) 'output dvm# - ABS(dvm2# / dvm1#) 'find transfer fn output/input IF dva# > 0 AND nph - np THEN 'take phase reading only if output 'is greater than 10 mV RMS IF x#(p) > 500 THEN CALL seg,coupling(cnt1%, chall%, ac%) ELSE CALL set.coupling(cnt1%, cha11%, dc%) END IF CALL measure(cnt1%, diff#) ph#(p) - -diff# * x#(p) * 360# WHILE ph#(p) < -180 ph#(p) - ph#(p) + 360# WEND ELSE IF nph - np THEN nph - p END IF y#(p) - 20 * LOG(dvm#) / LOG(lO) ’convert to dB LOCATE CSRLIN - l PRINT USING "##.###“‘“ +###.### +###.###”; x#(p); y#(p); ph‘lI (p) PRINT #1, USING "##.###““ +###.### +###.### . +###.### ##.####““‘"; x#(p): y#(p); ph#(p); dvm#; diff# x#(p) - i! NEXT i! PRINT ’Now find out what to do with this data DO INPUT "Find (P)eak or (D)C gain? ", g5 95 - UCASE$(g$) LOOP UNTIL 95 3 ”P" OR g5 - "D" DO INPUT "Search for how many -3 dB frequencies (0,1,2) ? ", cf LOOP UNTIL Cf - 0 OR of - 1 OR cf - 2 IF g$ - "D” THEN GOTO dcgain 'Find peak value of the points we took first k - 1 'pointer to maximum value FOR i - 2 TO np - 1 IF y#(i) > y#(k) THEN k - i 'reset pointer if we found a new max. NEXT i IF k - np - 1 THEN 'if rightmost point is max, use it as h0 h0# - 10# ‘ (y#(k) / 20#) GOTO sweepleft END IF 52 PRINT deltalogf# - .1 f0# - x#(k) ’log of freq. of peak magnitude t0! - y#(k) ’dB of peak magnitude WHILE deltalogf! > .00001 PRINT USING "Locating center frequency: ######.##"; 10! “ f0! LOCATE CSRLIN - 1 CALL set.frequency(gnr1, 10% “ (f0# - deltalogf#)) CALL measure(dmm1%, dvmlt) 'input CALL measure(dmm2%, dvm2#) ’output tlt - 20# * LOG(dvat / dvmlt) / LOG(lOt) ’gain at lower freq. CALL set.frequency(gnr1, 10% ‘ (f0# + deltalogf#)) CALL measure(dmm1%, dvmlt) 'input CALL measure(dmm2%, dvm2#) ’output t2# - 20% * LOG(dvm2# / dvmlt) / LOG(10#) 'gain at upper freq. IF t1§ < t0? AND t2? < t0? THEN deltalogft - deltalogft / 2i ELSE IF t1# > t0# THEN t0! - t1} f0! - f0# - deltalogft 'set new freq. lower END IF IF t2# > t0! THEN t0# - t2# f0! - £0} + deltalogf! 'set new freq. higher END IF END IF WEND h0i - 10* ‘ (t0# / 20*) ’convert back from dB fcnf - 10* “ f0§ PRINT USING "fc - ######.### Hz. ”; fcni PRINT USING "HO - ##.*§§§§"; h0# PRINT #1, USING "fc - ##§#i§.### 32."; fen? PRINT #1, USING "HO - ##.#i#§§"; h0§ GOTO sweepleft 'Now find DC gain dcgain: CALL set.amp1itude(gnr1, vrms, 0) 'turn off AC voltage from gen CALL set.offset(gnr1, gnv!) ’turn on DC volts from gen CALL set.function(dmm1, volt.dc) CALL set.function(dmm2, volt.dc) CALL measure(dmml, dvmli) CALL measure(dmm2, dvm2#) h0# - dvm2# / dvmlt ’DC gain (NOT dB) CALL set.offset(gnr1, 0!) ’return DMM to its original CALL set.function(dmm1, volt.ac) 'state CALL set.function(dmm2, volt.ac) 53 CALL set.amplitude(gnr1, vrms, gnv!) PRINT PRINT #1, "" PRINT USING "DC Gain - ##§.#####"; h0#: IF hat <> 0 THEN PRINT USING " - ##.### dB"; 20 * LOG(ABS(h0#)) / LOG(lO) PRINT #1, USING "DC Gain - ###.#####"; hat; IF hat <> 0 THEN PRINT #1, USING " - ##.### dB"; 20 * LOG(ABS(h0#)) / LOG(lO) 'Now look for -3 dB point from left side sweepleft: IF cf - 0 THEN GOTO graphit PRINT PRINT *1, "" target! - h0# / SQR(2#) IF target¥ < .001 THEN PRINT "DC Gain is too low - Cannot sweep for -3 dB point from left" PRINT #1, "DC Gain is too low - Cannot sweep for -3 dB point from left” f0! - 0 GOTO sweepright END IF i - 1 WHILE ABS(EXP(LOG(10#) * y#(i) / 20%) - target!) / target! > .2# AND 1 < np i - i + 1 WEND IF i - np THEN PRINT "Couldn't find left -3 dB frequency... run again with different points" PRINT #1, "” PRINT #1, "Couldn’t find left -3 dB frequency... run again with different points” ELSE flt - 10 ‘ x#(i - 1) 'starting frequencies f2! - 10 ‘ x#(i) t1! - 10 “ (y#(i - 1) / 20) 'starting target values t2! - 10 “ (y#(i) / 20) DO slope! - (t2# - t1!) / (f2! - f1!) f0! - (target# - t1?) / slope§ + £1} PRINT USING "Locating left -3 dB frequency: #####.##"; f0! LOCATE CSRLIN - 1 IF INKEYS - CHR$(27) THEN PRINT ”Location of left -3 dB frequency aborted... PRINT #1, "” PRINT #1, "Location of left -3 dB frequency aborted...” f0! - 0 GOTO sweepright END IF 54 'now find to CALL set.frequency(gnr1%, f0#) CALL measure(dmml, dvm1#) CALL measure(dmm2, dvm2#) t0# - dvm2# / dvm1# IF (f2# - f0#) < (f0# - f1#) THEN f1# - f0# t1# - t0# ELSE f2# - f0# t2# - t0# END IF hg& - 100000# * t0# / h0# LOOP UNTIL hg& - 70711 fcl# - f0# ’left cutoff frequency PRINT USING "The left cutoff frequency is #####.## Hz.'; f0# PRINT #1, USING "The left cutoff frequency is #####.## Hz.': f0# IF Cf - 1 THEN PRINT USING "GBP - #########.## Hz": f0# * h0# PRINT #1, USING "GBP - #########.## Hz"; f0# * h0# GOTO graphit END IF END IF sweepright: 'Now look for -3 dB point from right side PRINT PRINT #1, "" IF target# < .001 THEN PRINT "Rightmost Gain is too low - Cannot sweep for -3 dB point from right" PRINT #1, "Rightmost Gain is too low - Cannot sweep for -3 dB point from right" GOTO graphit END IF 1 - np - 1 YHILE ABS(EXP(LOG(10#) * y#(i) / 20#) - target#) / target# > .2# AND > 0 i - i - 1 WEND IF 1 - 0 THEN PRINT "Couldn’t find right -3 dB frequency... run again with different points" PRINT #1, ”" PRINT #1, "Couldn’t find right -3 dB frequency... run again with different points" ELSE f1# - 10 “ x#(i - 1) 'starting frequencies f2# - 10 “ x#(i) t1# - 10 ‘ (y#(i - 1) / 20) 'starting target values t2# - 10 “ (y#(i) / 20) DO slope# - (t2# - t1#) / (f2# - f1!) f0# - (target# - t1#) / slope# + f1# PRINT USING "Locating right -3 dB frequency: #####.##"; f0# 55 LOCATE CSRLIN - 1 IF INKEY$ " CHR$ (27) THEN PRINT "Location of right -3 dB frequency aborted... PRINT #1, PRINT #1, ' GOTO graphit END IF ’now find to CALL set.frequency(gnr1%, CALL measure(dmml, dvm1#) CALL measure(dmm2, dvm2#) t0# - dvm2# / dvm1# IF (f2# - f0#) < (f0# - f1#) f1# - f0# t1# - t0# ELSE f2# - f0# t2# - t0# END IF hg& - 100000# * t0# / h0# f0#) LOOP UNTIL hg& - 70711 fc PRINT PRINT IF 93 r#‘- f0# PRINT PRINT - fc PRINT PRINT (fcr# - END USING "fc - #####.## l#) *1, an #1, USING fc1#) ”fc = #####.## IF graphit: CLOS CALL set.amplitude(gnr1, vrms, E #1 0) PRINT PRINT "Press any key to see graphs... WHILE INKEY$ - "": CALL CALL axes CALL time CALL CALL CALL CALL CALL CALL WEND GrfReset(4) SetAxGridVis(-1, 1) SetAxAuto(-1, 21) SetXDataType(4) SetYDataType(4) SetAxName(0, "log(f)") SetAxName (1, "dB") GrfCurv2D(x#(), y#(), np) GrfReset(4) Oo - ###.####”: "Location of right -3 dB frequency aborted...” THEN 'right cutoff frequency USING "The right cutoff frequency is #####.## Hz.": #1, USING "The right cutoff frequency is #####.## Hz."; f0# - "D” THEN fcn# - SQR(fc1# * fcr#) f0# fcn#; fcn# / (fcr# do = ###.####"; fcn#: fcn# / 'output raw data file ’turn off AC voltage from gen 'to facilitate changing 'components 'enable grid lines for both 'auto-scale both axes every 'set name of x-axis 'set name of y-axis 'x-y plot of dB vs. log(f) 'clear the graphics display 56 CALL SetAxName(1, "Phase Angle") 'set name of y-axis CALL GrfCurv2D(x#(), ph#(), nph) 'x-y plot of phase vs. log(f) CALL GrfLReset(0, 0, 1, 2) 'return to text mode CLS Again: PRINT ”Again (y/n)?"; as - INPUT$(1) CLS IF UCASE$(a$) - "Y" THEN GOTO StartOfProg REM Now return to local control CALL iolocal(dmml%) CALL iolocal(dmm2%) CALL iolocal(osc1%) CALL iolocal 11) THEN PRINT : PRINT "BASIC error"; ERR; "in line": ERL ELSE ReportError END IF RESUME NEXT 'END Drivers.Report.Error Application: ' USER APPLICATION STARTS HERE 73 DIM SHARED ca%(512), cb%(512), ma#(512), mb#(512), reg.settings#(89), t#(512) CALL getmem(20000) overlay.memory.size& - 98304 memory.size& - SETMEM(640000) memory.size& - SETMEM(-over1ay.memory.size&) CLS PRINT StartOfProg: PRINT "Into my routine...” CALL Set.Frequency(GNRl, 1000#) CALL Set.Amplitude(GNR1, PP, 8!) CALL Set.Waveform(GNR1, triangular) PRINT "Calling Auto Set..." CALL Auto.Set(osc1) CALL set.polarity(oscl, chall, positive) PRINT ”Setting DC coupling..." CALL Set.Coupling(oscl, chall, DC) PRINT "Setting channel format..." CALL set.chan.trans.format(oscl, 1, real.data, 512) PRINT ”Setting horizontal mode..." CALL Set.Horizonta1.Mode(oscl, SINGLE.SHOT) PRINT "Measuring scope data...” CALL measure.chan.data(oscl, accu, cha, ca%()) 'measure forces trigger CALL read.chan.data(osc1, accu, chb, cb%()) 'read does not PRINT ”Scaling data..." CALL get.reg.settings(osc1, accu, reg.settings#()) CALL scale.chan.data(osc1, cha, reg.settings#(), ca%(), ma#()) CALL scale.chan.data(osc1, chb, reg.settings#(), cb%(), mb#()) FOR i - 0 TO 512 t#(i) - i NEXT 1 graphit: CALL Set.Amplitude(GNR1, VRMS, 0) 'turn off AC voltage from gen PRINT PRINT "Press any key to see graphs...": WHILE INKEYS ' "": WEND CALL GrfReset(4) CALL SetAxAuto(-1, 21) ’auto scale both axes CALL SetPlotMode(0) 'no wait for keypress CALL SetXDataType(4) CALL SetYDataType(4) 'eight-byte floating point CALL GrfCurv2D(t#(), ma#(),.512) 74 CALL SetPlotMode(2) 'wait for keypress CALL GrfCurv2D(t#(), mb#(), 512) CALL GrfLReset(0, 0, 1, 2) 'return to text mode CLS Again: PRINT "Again (y/n)?"; as - INPUT$(1) CLS IF UCASE$(a$) - "r" THEN GOTO StartOfProg REM Now return to local control CALL Iolocal(DMM1%) CALL Iolocal(DMM2%) CALL Iolocal(osc1%) CALL Iolocal(CNT1%) CALL Iolocal(GNRl%) END REM $DYNAMIC DEFSNG A-Z SUB Drivers.Initialization '******************i************************************i********* '* DRIVERS INITIALIZATION PROCEDURE 't********************t******************************************* ON ERROR GOTO Drivers.Report.Error CLS CALL Reset.Config overlay.memory.size& - 141312 memory.size& - SETMEM(640000) ' Try' to get all memory' now available memory.size& - SETMEM(-overlay.memory.size&) ' Free memory for instrument overlays PRINT "Initializing Multimeters...” CALL Config(DMM1, ”8840A,N DMM1,A 705") CALL Config(DMM2, ”8840A,N DMM2,A 706") PRINT "Initializing Function Generator..." CALL Config(GNRl, "PM5193/V2.5,N GNR1,A 707") PRINT "Initializing Oscilloscope..." CALL Config(oscl, ”PM3365/V07V04,N OSC1,A 708") PRINT "Initializing Counter..." CALL Config(CNT1, "PM6666/22,N CNT1,A 710”) PRINT "Setting up defaults..." CALL Allinit(actual.SET) END SUB 'Drivers.Initialization SUB ReportError f******************ti***************************************t**t** '* DEFAULT ERROR HANDLER I***************************************************************** GPIB.ERR - Err.Num IF (GPIB.ERR <> 0) THEN GPIB.STAT - Err.Stat GPIB.ERR$ - Err.Str$ GPIB.GLBSTAT - Glb.$tat. 75 GPIB.GLBERR$ - Glb.$tr$ PCIB.ERR - IOErr.Num PCIB.ERR$ - IOErr.Str$ status = GPIB.STAT SELECT CASE status CASE 0: PRINT ”IOdrivers error in line”; ERL: PRINT GPIB.ERR$ CASE 1: PRINT ”Warning in line"; ERL: PRINT GPIB.ERR$ CASE 2: PRINT "Error in line"; ERL: PRINT GPIB.ERR$ CASE 3: PRINT "Fatal error in line"; ERL: PRINT GPIB.ERR$: END END SELECT END IF END SUB 'ReportError The output of this program with the same signal fed to both channels is shown in Figures 5.1 - 5.3. It is clear from these plots the ofl'set of the two channels is not the same, nor is it consistent among different waveforms. If the two outputs were correct, one measurement which could be made is the slew rate of an op-amp. The first step is to read the oscilloscope data when the time base of the oscilloscope was set see the slewing. Then two points could then be used to calculate the slope, perhaps at 30% and 80% of the peak voltage values. The sampling rate can be read from the oscilloscope using a driver, and the calculation of the slew rate follows. 76 MW wax—u.” .1 ,1 W W “- fl 9 ll i! “MW '1] W 51511] $151!] 'ililil iIEIEJ Figure 6.1 - Oscilloscope Output for Positive Pulse 77 i H till Sill ills] Figure 5.2 - Oscilloscope Output for Triangle Wave mm W W . 78 Figure 5.3 - Oscilloscope Output for Square Wave LIST OF REFERENCES [1] [2] [3] [4] [5] [6] [7] LIST OF REFERENCES "Getting Started with TestTeam," National Instruments Corporation, 1989. "TestTeam User Manual," National Instruments Corporation, 1988. "8840A Digital Multimeter Instruction Manual," John Fluke Mfg. 00., Everett Washington, 1985. "Programmable Timer/Counter PM 6666 Operator’s Manual," Philips Export B.V., The Netherlands, 1988. G.M. Wierzba, Desigg’ng Electronic Circuits Using Analog ICs, Texas Instruments Inc, Dallas, TX and Prentice-Hall, Englewood Cliffs, NJ, in press. . . G.M. Wierzba and J .A. Svoboda, "An op-amp relocated bandpass filter with zero center frequency sensitivity to gain-bandwidth-product," Invited Paper, Proc. of the 29th Midwest Smposium on Circuits and Systems, Lincoln, NE, pp. 28-32, August, 1986. G.M. Wierzba, V. Joshi, A. Srivastava, and J .A. Svoboda, "Sspice - Symbolic SPICE for Linear Active Circuits," Invited Paper, Proc. of the 32nd Midwest Smmsium on Circuits and Systems, Urbana, IL, pp. 1197-1201, August, 1989. ‘79 NTS RTE UNIV II II II IIIIII II IIIII III IIIIIIIIII IIIIIIIIIIIIIIIII II IIIIII