Keysight PNA Series COM/DCOM Programming Examples


For those just starting out in COM, make sure you read the "Getting started with VB and COM/DCOM" document. It contains critical information on setting up your PC to communicate with the PNA. There is also a very short program that will verify the proper setup. This document is in .rtf format which can be opened by Word, WordPad, TextPad and many other applications.

COM / DCOM Programming Examples

Note: The first couple of months of Windows 7 production units units did not have the mschrt20.ocx file properly registered. This is needed for some of the below program examples. To fix this, open a command prompt as administrator, navigate to C:\Windows\SysWOW64 and execute this command: regsvr32 mschrt20.ocx

  • Basic Instrument Control   This example shows basic instrument control and is great for those just starting out with PNA control. Windows and traces are controlled, the PNA stimulus settings are changed and all four S paramenters are measured. The user can enter desired marker frequencies which will then be used to read out the current marker amplitude values. With a one line change (documented in the code) this program can be changed from using 2 traces in one window to one trace in two windows. When run, try entering different frequencies into the marker entry area, the click on the Update button. Both forward and reverse measurements can be made. The program assumes the use of a 177MHz bandpass filter.

  • Reading and Charting Trace Data   This example demonstrates one method of reading trace data from the PNA. The data read can be from any of the 4 S-parameters. In addition, it also shows how to display the resulting trace data in a chart using the MS Chart Control. The data type measured can be log, phase, raw, memory, or sdata (real & imag.) If sdata or raw is chosen, the program displays two charts with the upper chart being the real data.

  • Saving and Recalling Cal Sets   This example shows how to properly save and recall cal sets. Improper programming of this can easily result in overwriting an existing cal, which results in invalid measurements. Also shows how to programatically do a full 2-port cal as well as a response cal. User is instructed to make 3 cals, presumably using different external conditions (e.g. use different attenuators.) User can then recall these cals in any order.

  • Determining End of Averaging   This very simple example shows how to detect the end of averaging.

  • Simulated Cal using ICalData and Simulated Cal using ICalData2   These examples show how to upload, download, and apply error terms to a measurement. This is done for a full 2-port calibration, so all 12 error terms are handled. A full 2-port Cal is performed, then error terms are read from the PNA, and a dummy cal is uploaded to the PNA. The error terms are also graphed so that the results can be seen. Both the older ICalData and the newer ICalData2 methods are provided. The ICalData2 method also involves the manipulation of the Cal Set structure and requires firmware revision 2.0 or above. A ReadMe.txt file is included with more information. Operation on revisions less than Rev 2.62 is unknown.

  • Using Events with PNA   This zipped file contains two programs that can be used to test the ability of a PC to use events on the PNA. The examples verify the ability to detect the end-of sweep event. This includes a tutorial on using events which can be frustrating if you don't understand the complexities of DCOM permissions. This 6-page tutorial covers mostly VB6 but also discusses .Net and C# usage.

  • Controlling GPIB Instruments over COM   This example shows one method for remotely (from a PC) controlling instruments that are connected to the PNA's GPIB port. This program is designed only for use on a PC since that is the whole point of this program. A ReadMe file with more instructions is included.

  • Reading Real32 Complex Data over COM   This example shows how to read Real32 Complex data. This is the fastest way to obtain complete trace data. It also shows how to store this data to a file in binary format. This produces the smallest file size. Each data point (Real & Imag) takes up only 8 bytes; so a 201 point trace will result in a file of just 1608 bytes plus a fixed 4 bytes of overhead.

Last Updated: Mar 5, 2014