a low-cost 100 mhz vector network analyzer with …n5eg/index_files/final_qex_mcdermott.pdf · this...

12
Jul/Aug 2004 3 265 Daniel Dr Plano, TX 75094 [email protected] A Low-Cost 100 MHz Vector Network Analyzer with USB Interface By Tom McDermott, N5EG, and Karl Ireland This article describes a low-cost vector network analyzer that operates from 200 kHz to 100 MHz, and connects to a personal computer using a USB 1.1 interface. 1 Introduction One of the more useful pieces of test equipment for designers and experi- menters is the vector network analyzer (VNA). The VNA allows mea- suring the forward and reverse gain and phase response of a circuit, as well as the input and output reflection properties (complex impedance). Traditionally, the VNA has used s-parameters to describe the four prop- erties of a two-port circuit being mea- sured. The VNA is used to measure and adjust filters, coaxial cables, am- plifiers, antenna input impedance vs. frequency, and so forth. A full VNA consists of two measurement sections: one in the forward direction that mea- sures s 21 (forward gain and phase) and s 11 (input reflection magnitude and phase), and a duplicate circuit in the reverse direction that measures s 22 (output reflection magnitude and phase) and s 12 (reverse gain and phase, usually called reverse isolation). To save cost, many instruments only pro- vide enough hardware to measure in one direction. Then, the device under test is physically reversed and the measurements rerun. Most properly, this simplified piece of equipment is called a transmission-reflection test set; but most of the time, it is still re- ferred to as a VNA, the same as its big brother. One significant difference between the two instruments is that a true VNA can be more accurately calibrated through true two-port techniques, whereas the transmission-reflec- tion test set relies on precision stan- dards (open, short, 50 Ω) to calibrate the reflection measurement. A two- port calibration based on the TRL (Through-Reflect-Line) technique can theoretically dispense with the need for precision load standards. Another related piece of equipment is the scalar network analyzer. The dif- ference between the scalar analyzer and the VNA is that the scalar ana- lyzer does not include the additional circuitry to measure the phase com- ponent of the transmission and reflec- 1 Notes appear on page 14. 2517 Lawndale Plano, TX 75023

Upload: dothu

Post on 19-Sep-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A Low-Cost 100 MHz Vector Network Analyzer with …n5eg/index_files/final_QEX_mcdermott.pdf · This article describes a low-cost vector network analyzer that operates from 200 kHz

Jul/Aug 2004 3

265 Daniel DrPlano, TX [email protected]

A Low-Cost 100 MHzVector Network Analyzer

with USB Interface

By Tom McDermott, N5EG, and Karl Ireland

This article describes a low-cost vector network analyzer thatoperates from 200 kHz to 100 MHz, and connects to

a personal computer using a USB 1.1 interface.1

IntroductionOne of the more useful pieces of test

equipment for designers and experi-menters is the vector networkanalyzer (VNA). The VNA allows mea-suring the forward and reverse gainand phase response of a circuit, as wellas the input and output reflectionproperties (complex impedance).Traditionally, the VNA has useds-parameters to describe the four prop-erties of a two-port circuit being mea-sured. The VNA is used to measureand adjust filters, coaxial cables, am-plifiers, antenna input impedance vs.frequency, and so forth. A full VNA

consists of two measurement sections:one in the forward direction that mea-sures s21 (forward gain and phase) ands11 (input reflection magnitude andphase), and a duplicate circuit in thereverse direction that measures s22(output reflection magnitude andphase) and s12 (reverse gain and phase,usually called reverse isolation). Tosave cost, many instruments only pro-vide enough hardware to measure inone direction. Then, the device undertest is physically reversed and themeasurements rerun. Most properly,this simplified piece of equipment iscalled a transmission-reflection test

set; but most of the time, it is still re-ferred to as a VNA, the same as itsbig brother.

One significant difference betweenthe two instruments is that a true VNAcan be more accurately calibratedthrough true two-port techniques,whereas the transmission-reflec-tion test set relies on precision stan-dards (open, short, 50 Ω) to calibratethe reflection measurement. A two-port calibration based on the TRL(Through-Reflect-Line) techniquecan theoretically dispense with theneed for precision load standards.

Another related piece of equipmentis the scalar network analyzer. The dif-ference between the scalar analyzerand the VNA is that the scalar ana-lyzer does not include the additionalcircuitry to measure the phase com-ponent of the transmission and reflec-

1Notes appear on page 14.

2517 LawndalePlano, TX 75023

Page 2: A Low-Cost 100 MHz Vector Network Analyzer with …n5eg/index_files/final_QEX_mcdermott.pdf · This article describes a low-cost vector network analyzer that operates from 200 kHz

4 Jul/Aug 2004

tion parameters of the circuit undertest, while the vector analyzer mea-sures both the magnitude and phasecomponents. Thus the VNA is quite abit more complicated. The vector prop-erties are often of great interest, suchas when measuring the input imped-ance of an antenna, or the group delayof a filter, and thus the vector analyzeris a more useful instrument for manytypes of measurements.

This article will describe a vectortransmission-reflection type of instru-ment; but we’ll borrow the more gran-diose title VNA, since most people aremore familiar with that terminology.Fig 1 is a picture of the first prototypeboard—before the debug/fixes! The TXand RX BNC connectors are on the leftand the Universal Serial Bus (USB)and DC power connectors are on theright. The directional coupler (metalcase) is next to the TX connector. Fig-ures 2 and 3 respectively show frontand rear views of the completed unit.

Overview of the InstrumentCommercially available VNAs are

very expensive pieces of precision equip-ment, costing tens of thousands ofdollars. These instruments provide tre-mendous dynamic range (approaching90 to 100 dB), a high degree of accu-racy, and many software options formanipulating and displaying data. It’spossible to sacrifice some of the dynamicrange and precision to save a lot on thecost and complexity of the measure-ment hardware. Today’s personalcomputers, however, provide extensiveability to manipulate and display datafor virtually no additional cost—just thetime and effort of creating the software.So the instrument itself is kept assimple as possible by offloading muchof the work to the host computer.

Fig 4 is a block diagram of the low-cost VNA measurement device. Theequipment consists of a quadraturefrequency synthesizer, a reflectionmeasurement circuit, a transmissionmeasurement circuit, a pair of phase/magnitude RF detectors (one for trans-mission and one for reflection), amulti-channel analog-to-digital con-verter (ADC), and a specialized USB-aware microprocessor.2 Additionally, a+3.3 V regulator and a +5 to –5 V in-verter provide the digital and analogsupply voltages for the board.

The need for a quadrature synthe-sizer takes a little explanation. Therecently released Analog DevicesAD83023 device measures the magni-tude ratio and relative phase differ-ence between two RF signals (up to2.7 GHz). The phase response is am-biguous, however. It is symmetrical

Figure 1—Photograph of the assembled prototype board. The 4-layer board isapproximately 4×6 inches.

Figure 2—Photograph of the front panel of the assembled unit.

Figure 3— Photograph of the rear panel of the assembled unit.

Page 3: A Low-Cost 100 MHz Vector Network Analyzer with …n5eg/index_files/final_QEX_mcdermott.pdf · This article describes a low-cost vector network analyzer that operates from 200 kHz

Jul/Aug 2004 5

about 0°, at which point the phase ac-curacy is significantly degraded. Thiscan be seen from Fig 5, a plot of thephase and amplitude detector outputresponses of the device vs the inputphase difference, from the AD8302data sheet. To resolve the phase sign,the VNA instrument switches the ref-erence input to the detector betweenan in-phase (I) and quadrature-phase(Q) reference signal and measures thedetector output for both conditions.Software on the host computer thenresolves the correct phase quadrantbetween the two RF detector inputs.The low-pass filters are used to recon-struct the DDS output from the digi-tal stair-step waveform produced. TheAnalog Devices AD98544 DDS isclocked by a 24 MHz sine wave; it theninternally multiplies it up to 288 MHzwith an on-chip PLL. This 288 MHzinternal signal clocks the DDS fre-quency-generation circuits and thedigital-to-analog (DAC) circuits on thechip. Significant aliasing of the out-put signal is observed on an oscillo-scope even at an output frequency ofless than 100 MHz. The two low-passfilters, one on I and one on Q, removemost of these aliasing and stair-step-ping artifacts and produce clean sinewaves in phase quadrature.

The RF detectors are broadbandand have a total dynamic range of al-most 60 dB, but with the restrictionthat the range is ±30 dB between thereference signal and the unknownsignal. The performance of these de-tectors sets the dynamic range of theinstrument. To achieve greater dy-namic range, a much more expensivetuned-receiver configuration would berequired. For a reflection measure-ment, the practical measurement limitis about 30 dB of return loss.

Two selectors are implemented witha pair of dual-input Maxim 200-MHzvideo amplifiers that are programmableby the target processor. One allows se-lection of whether the I or Q DDS ref-erence signal is applied to both of theRF detectors. The other selects the re-flected signal or a monitor signal (usedonly for debugging) to be measured bythe reflection RF detector.

The transmission measurementprocess is very simple. A BNC connec-tor (labeled RX) and terminated in50 ohms is connected to one of the RFdetectors. This measures the ampli-tude and phase of the signal receivedon the RX connector against the in-ternal reference signals I and Q. Thereflection circuit uses a Mini-Circuits20-dB directional coupler5 to derivethe signal reflected by the load fromthe other BNC connector (labeled TX).

Figure 5—Analog Devices AD8302 phase output response. The response is symmetricabout 0°, and thus a quadrature technique is needed to resolve the sign of the phaseangle. The accuracy is poor near 0° and 180° due to detector output saturation,necessitating compensation.

Figure 4—Block diagram of the Vector Network Analyzer.

The reflected signal produced by thedirectional coupler is the complex re-flection coefficient gamma, Γ. Themagnitude and phase of this reflectionsignal are derived by measurementsagainst the internal I and Q referencesignals.

In operation, the host processor (the

PC) sends a command to the VNA overthe USB port, triggering a measure-ment. In the command, the host sendsa single frequency word as a 64-bitinteger to the target. The target pro-cessor (the microprocessor on theVNA) then programs the quadraturedirect digital synthesizer (DDS) to

Page 4: A Low-Cost 100 MHz Vector Network Analyzer with …n5eg/index_files/final_QEX_mcdermott.pdf · This article describes a low-cost vector network analyzer that operates from 200 kHz

6 Jul/Aug 2004

that frequency. Once the frequency isprogrammed, the target processormakes a series of analog measure-ments. These measurements are madeby using the input multiplexer of amulti-channel ADC chip to sequen-tially select and digitize the variousRF detector analog output voltages.Additionally, the target processorswitches between the I-reference sig-nal and the Q-reference signal to theRF detectors and remeasures thedetector’s analog outputs. The targetthen repeats these two sets of mea-surements in the reflected direction.The RF detector’s output a referencedc voltage, and the target processormeasures these as well. In total, morethan a dozen analog voltages are digi-tized and returned by the target pro-cessor. All of these measurements areassembled into a single 64-byte USBresponse packet.

Next, the host processor polls thetarget to see if it has the measurementready. When it is ready, the targetsends a response data packet back tothe host containing the set of datasamples that it has measured. Thetarget is then ready to accept a newmeasurement request.

The host computer processes themeasurement data set at each fre-quency and organizes the informationinto a useful display. A Windows ap-plication controls the USB device andprovides a GUI interface that lookslike a traditional VNA, displaying s-parameters in rectangular or polar(Smith chart) format, providing forcalibration and error correction of themeasurements, selection of the fre-quency sweep range, printing of thecharts, and so on. The host applicationwas written in Microsoft Visual C++.NET version 2003.

The USB port is capable of supply-ing 100 to 500 mA (at the option ofthe host) to the target device. The VNAdraws about 1 A, so it is powered froma +5 V dc wall-cube supply. On theVNA board, a Maxim inverter pro-duces –5 V dc for the video selectors; aMaxim linear regulator produces +3.3V dc for the digital parts. The voltageinverter needed to be decoupled withL-C filters to lower the noise level onthe analog lines. Additionally, thevideo amplifiers required 10-ohm re-sistors and decoupling capacitors inthe +5 and -5 volt lines to produce goodlow-level signal measurements of thereturn-loss signals. Power decouplingof the digital parts required just by-pass capacitors. The DDS chip and the+3.3 V regulator are each heat sinkedto the circuit board itself. A metalizedpad on the top layer of the board is

connected to the ground plane througha large number of vias. The soldermask is then opened on the top layerdirectly underneath each part, permit-ting each to be soldered directly to thecircuit board itself. Without this heatsink, these two parts would overheat.

Overview of USBMany newer computers do not in-

clude an EIA-232 serial interface.Many laptops now have only a USBinterface for connection of the com-puter to outside devices. The USB in-terface supports a large variety of de-vice types. It automatically identifiestarget devices, and then loads the ap-propriate Windows device driver. Thedriver is loaded when the USB targetis plugged in, and unloaded when thetarget device is disconnected. USB canprovide a minimum of 100 mA of sup-ply current to the target device. Insome cases it can supply more, up to500 mA, but only 100 mA is guaran-teed. This voltage is nominally +5 V,but resistive losses in the USBcable can drop it down to +4.4 V in theworst case.

When a USB device is first con-nected to a host and powered up, thehost senses the additional connectionvia a 1.5 kohm resistor that the tar-get asserts onto one USB data line.This process is called enumeration.Through a sequence of packets, thehost learns the identity of the devicetype that connected, its configuredcapabilities, and which Windows de-vice driver needs to be used to com-municate with the USB target.

The target in the VNA is repro-grammable; it does not contain anynon-volatile memory, just RAM. Thisallows the VNA target code to bechanged quite painlessly. The VNAhost application program downloadsthe executable code to the target eachtime it is connected and powered up—an extremely flexible arrangement. Itpermits different application loads tobe sent to the VNA target. A minordrawback, however, is that the targetthen has to go through a somewhatmore complex enumeration process.

The Cypress EZUSB microproces-sor supports a minimum level of func-tionality in the processor at power-upwhen no code has yet been loaded toit—namely the ability to identify itself,to accept a download file, and to restartitself. After initially enumerating thetarget, the VNA host application soft-ware downloads the desired target codeand then restarts the target. Then thenewly downloaded code on the targettakes control away from the Cypress-supplied default values and it re-

enumerates itself by disconnectingthen reconnecting the 1.5-k ohm resis-tor, this time with different capabili-ties identified. The new capabilities arespecified by the newly downloaded andrunning target application. Cypresssupplies a Windows device driver withtheir free development kit that is usedby the VNA host application. Addition-ally, Cypress supplies a free C-lan-guage code framework for the targetEZUSB processor that is USB 1.1, Sec-tion 9 compliant (named after the USBspecification chapter). While there is abit of a learning curve associated withit all, once understood, the frameworkmakes developing a C-language appli-cation very easy—just the relevantUSB endpoint handlers have to becoded. Everything else is done. Theentire target application was devel-oped in the evenings of about twoweeks without requiring any debugger.Note that Windows 95 does not sup-port USB. (Win95 OSR2.1 theoreticallysupports it, but what I’ve read claimsthat it is too buggy to use). Win 98 Gold(original edition) supports USB 1.0,and Win 98 SE (Second Edition) sup-ports USB 1.1. All versions of Windowslater than Win98 also support USB 1.1.WinXP also supports USB 2.0. The 1.1version of USB adds an interruptpacket type that is not used in this VNAtarget application.

The USB host sends packets to thetarget device and receives packetsfrom the target device. The format ofthese packets is under software con-trol. The USB interface is synchronouswith exactly 1 ms time slots. Duringeach slot, the host can send one con-trol packet, one data packet, and oneisochronous packet (useful for audio,for example). The target can returnone data packet and one isochronouspacket during the next slot. All USBtarget devices are polled. To retrievea data packet, the host sends a con-trol packet to the host requesting aresponse. The target then returns adata packet. Data packets can be upto 64 bytes in length, while isochro-nous packets can be 1023 bytes inlength (1024 bytes in USB 2.0). A goodtext on USB is available.6

SoftwareThe software consists of two inde-

pendently compiled and linked soft-ware executables: the host software,and the target software. The host com-puter is a PC with an Intel IA32 pro-cessor (Pentium) running Windows.The target is a Cypress EZUSB pro-cessor (derived from the 8051) runningjust the target code image—no oper-ating system or scheduler. Each

Page 5: A Low-Cost 100 MHz Vector Network Analyzer with …n5eg/index_files/final_QEX_mcdermott.pdf · This article describes a low-cost vector network analyzer that operates from 200 kHz

Jul/Aug 2004 7

Figure 6—Host software source tree.

requires a different software develop-ment system.

Run-Time SoftwareThe description of the tools below

is of interest if you want the compileor change the software, which mostpeople will not want to do. To just runthe VNA software, the following bina-ries are needed:• VNA host executable file,• Microsoft .NET 1.1 Common Lan-

guage Runtime (CLR) package,• Host-compiled help file,• VNA target (EZUSB processor) ex-

ecutable file,• USB device driver file—supplied by

Cypress: EZUSB.SYS,• USB .inf file (driver information file)

also supplied by Cypress.EZUSBW2K.INF.

Target SoftwareThe target software was developed

in C using the AnchorChips USB frame-work. This is available on the CypressWeb site for free in the EZUSB devel-opment download package. Literally,the framework is a couple of C moduleskeletons. You just need to fill in thevarious USB endpoint handlers andstrip out anything you don’t need, whichisn’t much. Getting this up and runningon the target was really fast. After find-ing a hardware bug (two missing pull-up resistors), the framework came rightup and ran. From that point it was amatter of adding functionality to thetarget through about four prototypebuilds. Each prototype added featuresover the previous build as we noted anyerrors in execution. These were usuallyquickly tracked down to the last addedchanges. Two tricky parts: The DDSchip comes out of reset at a slightlyhigher reset voltage than does theEZUSB processor, so some delay cycleswere added to the USB code before ittried to initialize the DDS. The paral-lel interface was used on the DDS, sincethe chosen EZUSB device (AN2135) hasan 8-bit parallel interface. Two I/O lineson the EZUSB are used for RD and WRlines to the DDS chip. Some have re-ported difficulty using the serial inter-face on the Analog Devices DDS chip,but the parallel interface was problemfree. Secondly, the USB device is hap-pier with exactly 64-byte bulk packets,so they are always sent this size. Inter-estingly, only one bulk-type packet issent per frame, so sending 1-byte or 64does not change the effective rate ofpackets per second because the framerate does not change with packet size.Thus, for maximum throughput, 64 bytebuffers should be used.

Host SoftwareThe host software was written in

Microsoft C++ .NET 2003. This is themost current version of the MicrosoftC++ compiler. The standard edition isavailable at a reasonable price.Microsoft used the name .NET (dotNET) to reference a lot of different prod-ucts and services, which has confusedpeople as to what it really is. The C++.NET product contains a run-time li-brary and a compiler/debugger. Thecommon-language run-time library(CLR) provides a language-independentenvironment to execute the MicrosoftIntermediate Language (IL), which isjust in time compiled. It handlesmemory management and garbage col-lection (freeing up unused memory).This is pretty traditional for Basic, butnovel for C and C++, which previouslyrequired the software developer to ex-plicitly control the lifetime of objectsand variables in memory. According tosome, memory leaks and lifetime man-agement constitute the largest categoryof programming errors in C and C++,and .NET is supposed to help minimizethese types of errors. The same CLRsupports Basic, C# (C-sharp) and C++,so mixing languages is possible. The2003 edition of .NET supports a GUIdesigner for C++. After manually con-structing several windows and dialogboxes in the 2002 edition, it’s a relief tohave that task partially automated.Programming in .NET is a lot different

than standard C++. Reading the step-by-step tutorial book and going throughthe exercises is a must unless you arealready familiar with .NET. Fortu-nately, the book and standard-editioncompiler can be purchased together asa set at about the same price as justthe compiler itself—if you do some shop-ping. The GUI designer has its ownunusual way of constructing code. Wechose to rewrite the initial host softwareprototype into a style better alignedwith how that designer works. Thismade subsequent changes and espe-cially additions a lot faster.

The VNA application consists of anumber of software modules:• The main program VNAR2, which

holds the primary program controland display window

• Several dialog-box modules (calibra-tion, numeric entry, etc.).

• Several utility modules that providesome general computations withcomplex numbers, and translatevalues into screen coordinates

• A wrapper module to encapsulate theinterface to the USB device driver

• Several resource files (RESX) thathold the resources for the display-able windowsThe source tree for the host program

is shown in Fig 6. Microsoft .NET C++has an unusual approach to its file-naming convention: For the designer-generated code, the .h file holds mostof the executable code, while the .cppfile contains a few headers. Form1 isthe main program, holding the top-level display and control window(Form1.h), and is also the entry pointto the .NET program (Form1.cpp). Fornon-designer generated code, we choseto adopt the opposite convention bydeclaring class, module, and subrou-tine interfaces in .h files, putting theclass methods and subroutines in the.cpp files. Old habits die hard.

Calibration contains the interface tothe test-fixture calibration routines andthe computations for deriving a virtuals-parameter error matrix equivalent tothe fixture’s influence on the measure-ment. DisplayRoutines contains code toderive screen coordinates for the displaywindow given rectangular or polar dis-play coordinates. In addition, it containsFrequencyGrid, CalibrationDatSet, andDetector class definitions and methods.The frequency grid allows decouplingthe number of data points measured bythe VNA in a single sweep from the dis-play resolution of the screen display it-self. InstrumentCal contains the menuinterface and methods needed to per-form the calibration of the individualAD8302 detectors.

Page 6: A Low-Cost 100 MHz Vector Network Analyzer with …n5eg/index_files/final_QEX_mcdermott.pdf · This article describes a low-cost vector network analyzer that operates from 200 kHz

8 Jul/Aug 2004

The NumEntBox routine containsmethods to allow direct entry of thestart and stop frequencies or levelswhen a large numeric indicator isdouble-clicked. The EZ_USB_interfacecontains a wrapper for interfacing tothe Cypress EZUSB.SYS low-leveldevice driver.

In addition, several support datafiles are needed:• The binary executable code for the

target, which the host applicationreads and downloads to the targetthrough the USB interface

• A calibration data set file. The appli-cation writes this file with calibra-tion parameters after a calibrationis performed. It can also be read bythe application to retrieve previouslysaved calibration parameters. Thedata in the file is stored in binaryformat.

• Export files. The host software hasan option to generate measured s11and s21 values in a tabular formatas a text output file. There are sev-eral standard file-header and polar/rectangular formats, which supportseveral popular simulation andCAD packages. This allows mea-sured device parameters to be di-rectly imported to those CAD pro-grams as an s-parameter model.

• A compiled help file was generatedto provide help for the VNA; it’scompatible with the MicrosoftHTML help engine (which requiresIE4.0 or later).The interface to the USB driver

was—and is—pretty tricky. We’re notaltogether satisfied with the result. Thedriver was written pre-.NET and it can-not be invoked directly by a .NET pro-gram. Microsoft provides a P/Invokecommand that marshals data into a for-mat compatible with direct API calls toWindows. The calls have to be proto-typed so the compiler knows how to callthem; hence, each one was done byhand. (There are about 10 calls in thedriver.) The variables passed to thedriver are somewhat complex, and theyhave to be described to the compiler aswell. To describe these variables, sev-eral header files from the WindowsDevice Driver DDK need to be included.Microsoft distributed the DDK betaversion free of charge, but now chargesfor the completed version. Worse yet,#including the header files breaks al-most all .NET code.

The strategy was to build a .CPPand an .H file for the wrapper. The .Hfile describes the interface to the wrap-per to the compiler and other .NETmodules. The .CPP file includes theactual code, as well as the #includefiles. Then that .CPP file is compiled

without the run-time library, and that.CPP file is not exposed to other .NETfiles, only the linker sees it; however,other modules know how to call thewrapper because of the .H descriptionswhich they #include. This worked inthe 2002 edition, but broke in the 2003edition. The 2003 edition requires thatall class methods and class variables,whether public or private, be declaredin the CPP file and be identical tothose exposed in the .H file. The #in-cludes needed to do this immediatelyto break the compilation of all theother .NET modules. A temporarysolution was to bury the variable defi-nitions inside the methods of thewrapper class as automatic variables.This way they are never exposed asan interface or class variable of thewrapper itself. Unfortunately, thismakes the saving of driver state in aprivate-class variable difficult, sinceuseful variables cannot be declared.

We ended up throwing away muchof the wrapper code that made a cleanwrapping of the driver, and ended upjust re-acquiring driver data inside ev-ery method every time it is called.There are probably several betterways to solve this significant problem.The byproduct of our approach is thatyou need to have several of the headerfiles from the DDK to compile the ap-plication, since we cannot distributethem. It is probably possible to writethe driver wrapper as a .DLL in anolder version of C++ and avoid manyof these issues.

USB Device Driver and InitializationUSB is a plug-and-play interface in

Windows. To associate a device driverto a device, Windows needs to know theID of the USB device that is installedand which device driver to connect toit. When the VNA is plugged into acomputer for the first time, the new-hardware-detected wizard is called byWindows. It causes the VNA to enumer-ate without any code loaded into it. TheCypress EZUSB will answer this enu-meration request with the VID (VendorID) and PID (Product ID) code of theEZUSB processor. Then Windows willpop up a dialog box and ask the user tochoose between supplying a disk file orletting Windows search for the file. Inthe VNA package, an .inf file (driver in-formation file) supplied by Cypress tellswindows to use the EZUSB.DRV driverfile when the VID_PID device is con-nected. The wizard makes an entry inthe registry associating the VID_PIDwith the device driver so that the wiz-ard and user dialog box don’t have tobe displayed again. One needs to copythe EZUSB driver into the driver di-

rectory in Windows, which is differentfor different versions of Windows, touse it. (In WinXP, it’s \Windows\System32\Drivers.) Having done thatthe first time, Windows can find andload the driver anytime one plugs inthat USB device.

The USB interface to Windows isfairly complex, and writing devicedrivers is not a trivial task. So thedriver supplied by Cypress is used forthe VNA. It’s a very low-level driver,but we’ve had good results with it sofar. It does have a few bugs. Those thatare known have been avoided in thewrapper module code.

Other than the wrapper problem,very few issues were encountered inconstructing and debugging the NETcode. The 2003 version of the C++.NET debugger is a lot more stablethan the 2002 version.

HTML HelpA help package was generated for

the VNA using the Microsoft HTMLHelp Compiler 1.4, available for freefrom the Microsoft Web site. There’salso a good tutorial available on theWeb7 about how to use this tool tobuild help and context-sensitive help.Each help topic is actually an HTMLpage; the compiler links all the pagesinto a single compressed binary fileusing the .chm suffix along with thetable of contents, index, and searchtags. The tags can point within the fileor across the Internet, but we decidedto leave all of them within the com-piled file so that an Internet connec-tion is unneeded to use the help file— or the VNA! The computer does re-quire IE 4.0 or later to view the helptopics since they are HTML. This typeof help interface should look familiarto most Windows users.

Available source code can be foundat www.arrl.org/qexfiles.Calibration and Error Correction

All s-parameter measurementsmade by the VNA need to be calibrated.The actual measurement occurs on theprinted circuit board itself, which isremoved from the device under test(DUT). The connecting leads and com-ponents on the circuit board, connec-tors, interconnecting cables to the DUTand measurement imperfections of thecomponents transform the measure-ment values. Additionally, the VNAdoes not have an absolute amplitudeor phase reference, but only a relativereference. In practice, error correctionand calibration are combined into asingle compensation to the measure-ment. Different cable lengths may beneeded for different measurements

Page 7: A Low-Cost 100 MHz Vector Network Analyzer with …n5eg/index_files/final_QEX_mcdermott.pdf · This article describes a low-cost vector network analyzer that operates from 200 kHz

Jul/Aug 2004 9

and the cable length significantlyaffects the measurement. Thus, cali-bration is usually required for each dif-ferent test-fixture setup. The host pro-gram has a mode to take a calibrationset and store it with a descriptive filename to be recalled as needed.

Calibration involves compensatingthe phase delay of the instrument andthe interconnecting cables. It also com-pensates for amplitude variation withfrequency. Because the VNA is reallyonly half a network analyzer (forwarddirection only), the TRL technique can-not be used. The TRL technique canavoid the need for precision standards.Instead, calibrations for s21 and s11are derived independently using ac-curate RF loads—well, we hope they’reaccurate.

Transmission Calibration (s21)The transmission calibration (s21) is

easier to understand. There are two in-terconnecting cables—one from the TXconnector to the DUT, and anotherfrom the DUT to the RX connector. Inthe through-calibration mode, thesetwo cables are disconnected from theDUT, and directly connected togetherwith a very short connector called a“bullet.” The software makes the as-sumption that the bullet has no lengthand is a perfect impedance match. Thatwould be a poor assumption at micro-wave frequencies, but at 120 MHz, it’snot too bad. The transmit signal is thenswept across the frequency range of theinstrument and the received magni-tude and phase recorded for 1024 dif-ferent discrete frequencies. The phasedelay and amplitude received are com-puted and stored in a table by fre-quency. Obviously, longer cables wouldhave greater phase delay and perhapsmore attenuation at higher frequen-cies. The RX port is terminated on thecircuit board with a fairly accurate50-ohm resistive load. Similarly, the TXport is sourced from a fairly accurate50-ohm resistive pad at the output ofthe TX buffer amplifier, resulting in agood source match. To apply the trans-mission calibration against the mea-sured DUT data, the measurement ofs21 of the DUT is divided by the re-corded calibration value at the samefrequency. Since both these data arecomplex numbers, this involves usingcomplex division.

21

measured21actual

21 Cals

s = (Eq 1)

If the measured value of s21 wereexactly the same as the stored calibra-tion constant, then s21

actual would be1.0+j0, signifying that the DUT had no Figure 7—Fixture Calibration Menu.

Table 1Reflection coefficient for terminated, shorted, and open loads in polar andrectangular coordinates.

Γ Polar Coordinates Rectangular CoordinatesLoad Magnitude Phase Real ImaginaryShort 1 ±180° –1 050 Ω 0 arbitrary 0 0Open 1 0° +1 0

gain, loss, or phase shift. Since the DUTdoes have s21 imperfections, Eq 1 justderives the difference between the DUTmeasurement and the calibration mea-surement, thus removing most instru-ment and interconnection cable errors.

Reflection Calibration (s11)The reflection calibration (s11) is a

bit more complex. Three calibrationruns are made using different loadsattached to the end of the TX cablethat has been removed from the DUT:1) with a 50-ohm load, 2) with ashorted load, and 3) with an open load.The accuracy of these calibration loadsdirectly affects the correction accuracyof subsequent measurements. Table 1shows the value of the reflection coef-ficient Γ for each load type directly atthe load itself, assuming that they areperfect loads, which they are not. TheVNA instrument measures a value forΓ that is rotated in phase and attenu-ated in magnitude by the interconnect-ing cables, PC-board traces, andcomponents in the cable and instru-ment itself. The calibration computa-tion involves de-rotating the measured

value by the calibration phase delay,and adjusting the measured magni-tude by subtracting the reflection cali-bration amplitude component. Thiscalibration computation must be doneat each frequency.

The three load components lie alongthe center horizontal straight line ona Smith chart, a short being at the left,50-ohm in the center, and an open onthe right. See Fig 8. The calibrationmeasurement will indicate insteadthree points on a line that is rotatedfrom the horizontal position by theamount of phase delay in the trans-mission cable plus the delay internalto the instrument itself. The amountof rotation is frequency-dependent.

After de-rotation to the horizontalposition, the three measurements willnot lie exactly on the ideal positionson the Smith chart listed in the table,but will be offset by the remainingmeasurement errors. Before the de-ro-tation, the amplitude measurement ofthe DUT is scaled differently on theleft and righthand side of center (lowand high resistive components, respec-tively) using the short and open cali-

Page 8: A Low-Cost 100 MHz Vector Network Analyzer with …n5eg/index_files/final_QEX_mcdermott.pdf · This article describes a low-cost vector network analyzer that operates from 200 kHz

10 Jul/Aug 2004

bration values as full-scale (left and right, respectively),and the 50-ohm value as a zero scale constant. This is be-cause some measurement errors are dependent on theimpedance seen by the directional coupler itself. After thisadjustment, the value is de-rotated by the calibration re-flection phase delay value, which results in the final valuefor Γ. Fig 7 shows the fixture calibration menu, with theshort calibration completed.

We can place reflection measurement errors into threetypes:• Ed Directivity error—this error is caused by leakage in

the directional coupler and impedance mismatches be-tween the VNA and the DUT reflecting additional en-ergy.

• Es Source mismatch error—this error is caused by im-pedance mismatch between the signal source and thedirectional coupler. In the VNA, an attenuator pad isused between the buffer and the directional coupler toprovide a reasonably good match, but it’s not perfect.

• Et Tracking errors—these are errors in the measuringcircuits that provide the magnitude and phase valuesand include test-cable artifacts.In his book on microwaves, Pozar describes how to ana-

lyze and derive these reflection measurement error termsfor the one-port calibration.8 The technique models thethree errors as a virtual s-parameter error matrix insertedbetween the VNA and the DUT.

Refer to Fig 9 for s-parameter definitions. In an s-parameter matrix, the forward input voltage, a1, reverseinput voltage, a2, forward output voltage, b2, and reverseoutput voltage, b1 are related by the s-parameters:

2222112

1221111

sasabsasab

+=+=

(Eq 2)

Thus the voltage emerging from the network lefthandside, b1 is the sum of the input reflection property of thenetwork times the input voltage a1, plus the reverse isola-tion of the network times the voltage supplied into thenetwork from the right-hand side, a2. We substitute theerror terms into the s-parameters of the virtual error ma-trix:

s11 is the source directivity error, Ed.The product s21s12 is the reflection tracking error, Et,

which we can allocate between the two terms as we like—in this case, setting s21 to unity, and s12 to Et (see Fig 10).

s22 is the source matching error, Es.

If we place the DUT that has an actual reflection s11actual

(Γ actual) on the output of this virtual S-parameter errornetwork, then from the input of this error network wemeasure s11

measured (Γ measured). It can be shown that theactual measured value of the DUT looking through theerror matrix is:

tdm11s

dm11a

11E)E(sE

Ess

+−

−= (Eq 3)

The derivation requires a bit of algebra and Pozar cov-ers this in his book. We have three unknown terms andthree measurements, so it is possible to solve for the threeerror terms. The solution to the first term is:

mload11,d sE = (Eq 4)

This is because the reflection from a perfectly termi-nated load is zero. Thus a2 of the virtual error matrix iszero, and the Es and Et terms fall out of the bt voltage term(reflected signal). Similarly:

Figure 8—Smith Chart plot of ideal calibration load points aftercomputationally removing the test cable transmission line length.

Figure 9—S-parameterdefinition.

Figure 10—S-parametererror matrix.

( )m

open11,m

short11,

mopen11,

mshort11,

mload11,

sss

ss2sE

+−= (Eq 5)

and

( )( )m

open11,m

short11,

mload11,

mshort11,

mload11,

mopen11,

tss

ssss2E

++= (Eq 6)

Et includes the phase delay and attenuation of theinterconnecting cable between the VNA and the deviceunder test. Thus, different calibration files need to be col-lected for different cabling setups, since Et will be differ-ent in each case.

D. Pozar’s book on microwave engineering covers the

Page 9: A Low-Cost 100 MHz Vector Network Analyzer with …n5eg/index_files/final_QEX_mcdermott.pdf · This article describes a low-cost vector network analyzer that operates from 200 kHz

Jul/Aug 2004 11

topic of VNA calibration and compen-sation. In the host program, the cali-bration routine guides the userthrough four test setups, and makesfour measurements—short, open,load, and through. All are swept overthe complete frequency range of theanalyzer. It then derives the values ofEd, Es, and Et over frequency, and alsoderives the transmission calibrationterm discussed previously. The threereflection error terms, as well as theraw reflection calibration data, can beplotted on the polar chart to give anidea of what they look like. The cali-bration routine stores a table of thethree derived error terms, along withthe s21 transmission calibration value,each at 1024 frequencies, in a file ondisk. The name of the file can be se-lected at the time the calibration fileis saved.

The calibration function also allowsloading a named calibration file insteadof having to repeat a previous calibra-tion run, which saves a lot of time. Thismakes it easier to have different cali-bration files for each test setup. The rawdata is also saved to the file allowingrerunning the calibration and chang-ing only one measurement type (for ex-ample “through”), and then saving thecal data set. The raw data will be over-written by any new measurementswhile preserving raw data not re-col-lected. Then the cal file can be savedagain. This updates the cal data setwith only the new data type. This saveda lot of time during the debug cycle.

Fig 11 shows the measurement ofa shorted cable without fixture cali-bration applied. Without calibration,the short describes a circle near theedge of the polar chart, illustratingthat the connecting cable between theshort and the VNA rotates the phaseangle of the short. After the fixturecalibration is applied (Fig 12), thecable phase rotation has been removedand the short shows up as point onthe left side of the polar chart, withall frequencies being measured fall-ing on the same point (0 ohms).

Phase Measurements &Detector Calibration

At first, a simple technique wasused to translate the phase detectoranalog measurements measured bythe AD8302 from voltage to phase, indegrees, with respect to the referencesignal. The arctangent of the I-mea-surement divided by the Q-measure-ment, with appropriate correction forthe measurement quadrant, was uti-lized. Unfortunately, this simple tech-nique suffers from a significant errorbecause of phase-detector saturation

Figure 11—Shorted cable without fixture calibration.

Figure 12—Shorted cable with fixture calibration applied.

Figure 13—Error of phase reading over360°caused by detector saturation nearzero and +2.0 V.

in the AD8302. Particularly near 0 Voutput, the phase-detection gain dropsnon-linearly. The range near positiveoutput (+1.8 V) is less saturated, butthe actual positive voltage peak valuevaried a lot from device to device. Inone case, it significantly exceeded thevalue of Vref from the specific devicebeing measured.

The nature of the error causes asomewhat sinusoidal error in thephase reading— the phase varies bothabove and below the actual value. Thiserror was particularly significant ingroup-delay measurements, since thegroup-delay routine differentiates thephase slope at adjacent frequencysample points. Fig 11 shows the

Page 10: A Low-Cost 100 MHz Vector Network Analyzer with …n5eg/index_files/final_QEX_mcdermott.pdf · This article describes a low-cost vector network analyzer that operates from 200 kHz

12 Jul/Aug 2004

slightly oblong shape of the phase re-sponse caused by detector saturation.

A new phase calibration routinewas devised that uses a length of co-axial cable as a reference element.This calibration result is used to com-pensate the converted phase values.A fixed length of cable has a constanttime delay, and thus has a linear phasechange with frequency. The detectorcalibration routine measures a smallfixed length of cable and compares itwith the actual phase-detector mea-surement. The software then stores atable containing the difference, in de-grees, between the measured phaseand the phase calculated by linearlyinterpolating the cable phase. That is,it finds two points in frequency thatdiffer in phase by 360º because of thecalibration cable, then derives thephase at any frequency in betweenusing a linear fit to the two endpoints.This phase difference is stored in atable with one-degree resolution.

A separate table is generated forthe transmit and receive AD8302phase detectors. This same calibrationroutine also finds the midpoint of eachphase detector’s output range by find-ing the detected output voltage— ap-proximately +0.9 V, but slightly differ-ent from device to device—wherein thereference cable produces 0º, 180º and360º phase differences at the sameoutput voltage. The process convergesin about three iterations. The algo-rithm thus fully characterizes eachAD8302 by its individual performance.

This phase calibration process isdone separately for the TX and RXphase detectors, since they are differ-ent physical devices and have differ-ent errors. The detector constants andcorrection tables are stored in a smalldetector calibration file in the programstartup directory—the directorywhere the VNA program starts execu-tion. The detector calibration does notchange with the test setup; thus it onlyneeds to be measured once, then thevalues are relatively permanent. Thesoftware automatically looks for andloads this detector calibration file onstartup and provides a warning mes-sage to run the one-time detector cali-bration routine if the file cannot befound. A menu option to run the de-tector calibration allows the initialgeneration and storage of the con-stants in this file using a couple ofshort test cables. Running the detec-tor calibration routine overwrites anyexisting detector cal file.

A small residual error remains af-ter this improved calibration tech-nique, which can be seen most easilywhen measuring group delay. Fig 14

Figure 14—Phase response before and after detector calibration.

Figure 15—Transmission Magnitude, Phase and Group Delay of a 3 m test cable.

Figure 16—Return loss of KT34XA antenna through 300 feet of hardline. Vertical scale is5 dB/div.

shows the phase response of an ap-proximately 3 m long cable with andwithout this error correction.

Fig 15 shows the transmission

amplitude response, phase andgroup delay of a 3 m long cable.The group delay scale is 10 ns perdivision, thus this test cable has

Page 11: A Low-Cost 100 MHz Vector Network Analyzer with …n5eg/index_files/final_QEX_mcdermott.pdf · This article describes a low-cost vector network analyzer that operates from 200 kHz

Jul/Aug 2004 13

about 14 ns of delay. A perfect resultwould be a straight horizontal line forgroup delay. This measurement wasmade by differentiating the phase ateach incremental frequency sample,thus it produces the noisiest measure-ment. When the delay differentiationis spread across several samples(called the frequency aperture of thegroup-delay measurement), the errorsare significantly filtered. The resultshown in the figure we consider to bequite good. Seven different detector-calibration algorithms were tried toget to this point. The drop in delayabove 100 MHz is caused by reference-signal degradation, in turn caused bythe DDS’s reconstruction low-pass fil-ter cutoff limitation described earlier.

Software Source CodeVNA source files for both the tar-

get processor and the host processorhave been made available in openformat on the Web for amateur andnon-commercial use. It’s hoped thatreaders will add useful and interest-ing functionality to the VNA and makeany changes similarly available foramateur and non-commercial use.

Software Tool SourcesThe development software can be

purchased inexpensively. The target iswritten in C and 8051 assembly.Cypress provides a limited-capabilityfree copy of the Keil compiler in its de-velopment package. Another compilerpackage, Reads-51, which is free fornon-commercial use can be down-loaded from the Web,9 but the targetsoftware has not been ported to thatpackage yet. The host software is writ-ten in C++. The Microsoft compiler canbe purchased as part of the MicrosoftC++ .NET 2003 Step-by-Step DeluxeLearning Edition, which contains boththe excellent Step-by-Step book andthe C++ standard-edition compiler,bundled together.10 The set can befound at local bookstores, or at a dis-count from several Web-based book-stores. We found it commercially avail-able on the Web for less than $80. TheHTML Help compiler v1.4 is free fromthe Microsoft Web site, and a good tu-torial is available by Char James-Tanny, as was mentioned earlier. Theinstaller was generated using the Jor-dan Russell INNO installer program,which is free for any use (commercialor not) and is very simple to use.11

ApplicationsThere are a large number of appli-

cations for a VNA. We’ll examine acouple of them here.

Figure 17—Return loss of Fig 16 from 13.5 MHz to 14.5 MHz. 26 dB return loss (best caseat 13.94 MHz) is an SWR of 1.105 (at the ham-shack end of the feed line).Vertical scale is5 dB/div.

Figure 18—Return loss of Fig 17 with fixture calibration applied (the fixture is theinstrument itself and one m of cable). Note the best-case return loss is now 28 dB at afrequency of 13.96 MHz (an SWR of 1.083). Vertical scale is 5 dB/div.

Antenna Return Loss (SWR)One of the most common measure-

ments made is the standing wave ra-tio of an antenna. A low SWR meansthat the antenna input impedance isclose to that of the measuring refer-ence impedance. Return loss is thecommon term for an equivalent mea-surement, that being the ratio of thereflected voltage to the incident volt-age, usually expressed in dB. To con-vert from return loss to SWR, thefollowing formulas are used (S = SWR,ρ= reflection coefficient, RL = returnloss in dB):

ρ1ρ1

S−+

= (Eq 8)

So, for example, a return loss of20 dB is a reflection coefficient of 0.1,and an SWR of 1.22. A return loss of10 dB is a reflection coefficient of0.316, and an SWR of 1.92.

The following measurements showthe magnitude of the return loss ver-sus frequency for a KT34XA antennaat the end of 300 feet of hard-linecable. The resonance points are clearlyvisible. The phase part of the imped-ance is that at the ham-shack end ofthe cable, not at the antenna. Fig 16shows the return loss at 5 dB/div ofthe antenna swept from 1 MHz to50 MHz. The 20-m, 15-m and 10-m

⎟⎠⎞

⎜⎝⎛−

= 20RL

10ρ(Eq 7)

Page 12: A Low-Cost 100 MHz Vector Network Analyzer with …n5eg/index_files/final_QEX_mcdermott.pdf · This article describes a low-cost vector network analyzer that operates from 200 kHz

14 Jul/Aug 2004

Figure 19—Return loss of Fig 18 on a polar scale.

Figure 20—Return loss of Fig 19 with calibration applied. Note the significant amount ofphase rotation that is removed with instrument calibration and just 1 meter of cablecorrection.

band resonances are easily seen. Fig17 shows a closeup of the return lossfrom 13.5 to 14.5 MHz; Fig 18 showsthe same reading after the instrumenthas been calibrated with a 1-m lengthof cable. This short cable is used to con-nect to the analyzer to the hard-linecable and thus represents the loadthat would be seen by a transmitterconnected to the cable. Note that theapparent return loss is improved atsome frequencies because imperfec-tions in the instrument and direc-tional coupler have been subtractedout of the measurement. Fig 19 showsthis same closeup on a polar plot. Fig20 is the same polar plot but with fix-ture calibration enabled. Note the ro-tation of the polar plot.

The instrument limitation for re-turn loss measurements is about30 dB, and this degrades by a few dBat frequencies above about 50 MHz.The apparent return loss of the an-tenna looks better than it really is athigher frequencies because of the in-creasing loss of the 300 feet of hardline with frequency.

Notes1Universal Serial Bus Specification, Revi-

sion 1.1, Compaq, Intel, Microsoft, NEC,September 23, 1998, available at www.usb.org/developers/docs/.

2AN2135 Microprocessor Data sheet andCypress EZUSB Development kit areavailable from Cypress Semiconductor,Inc., www.cypress.com, look under USBFull-Speed Peripherals.

3Analog Devices, Inc, AD8302 data sheet,Rev A., www.analog.com.

4Analog Devices, Inc., AD9854 DDS datasheet, Rev B, www.analog.com

5Minicircuits Inc., directional coupler PDC-20-3, datasheet available at www.minicircuits.com/dg03-192.pdf.

6 J. Axelson, USB Complete, 2nd edition,Lakeview Research, ISBN 096508195-8,www.lvr.com.

7C. James-Tanny, Creating HTML Help withMicrosoft’s HHW, 2003, JTF Associates,Inc,www.mvps.org/htmlhelpcenter/htmlhelp/hhtutorials.html.

8D. Pozar, Microwave Engineering, AddisonWesley, 1998, ISBN 0-471-17096-8.

9Rigel Corporation Inc, Reads-51 package,PO Box 90040, Gainesville, FL 32607,www.rigelcorp.com.

10J. Templeman, A. Olsen, Microsoft VisualC++ .NET Step by Step, Version 2003,Microsoft Press, ISBN 0-7356-1907-7 isjust the book; ISBN 0-7356-1908-5 is theDeluxe Learning Edition that includes theC++ standard edition compiler package.

11Jordan Russell’s software, INNO installerprogram, www.jrsoftware.org/isinfo.php.