Planar R54 Programming Manual page 227

Vector reflectometer; programming com/dcom
Table of Contents

Advertisement

Example 5. Program Written in C++
The following C++ program represents an example of the measurement parameter
setting, as well as acquisition and display of the measurement data array. The program
also shows a method of the sweep triggering and waiting for the sweep completion.
//---------------------------------------------------------------------------
// Simple example of using COM object of PlanarR54x2.exe application.
//
// This example is console application. GUI is not used in this example to
// simplify the program. Error proccessing is very restricted too.
//
#include "stdafx.h"
//---------------------------------------------------------------------------
// Generate description of COM object of PlanarR54x2.exe application.
#import "PlanarR54x2.exe" no_namespace
//---------------------------------------------------------------------------
int _tmain(int argc, _TCHAR* argv[])
{
IR54x2Ptr pNWA;
CComVariant Data;
// Init COM subsystem
HRESULT hr = CoInitialize(NULL);
if(hr != S_OK) return -1;
// Create COM object
hr = pNWA.CreateInstance(__uuidof(R54x2));
if(hr != S_OK) return -1;
// Preset network analyzer
pNWA->SCPI->SYSTem->PRESet();
// Set frequency start to 1 GHz
pNWA->SCPI->SENSe[1]->FREQuency->STARt = 1e9;
// Set frequency stop to 1.2 GHz
pNWA->SCPI->SENSe[1]->FREQuency->STOP = 1.2e9;
// Set number of measurement points to 51
pNWA->SCPI->SENSe[1]->SWEep->POINts = 51;
// Set trigger source to GPIB/LAN bus or COM interface
pNWA->SCPI->TRIGger->SEQuence->SOURce = "BUS";
// Trigger measurement and wait
pNWA->SCPI->TRIGger->SEQuence->SINGle();
// Get measurement data (array of complex numbers)
Data = pNWA->SCPI->CALCulate[1]->SELected->DATA->FDATa;
// Display measurement data.
// Data is array of NOP * 2 (number of measurement points).
// Where n is an integer between 0 and NOP - 1.
// Data(n*2)
// Data(n*2+1) : Secondary value at the n-th measurement point. Always 0
//
CComSafeArray<double> mSafeArray;
if (mSafeArray.Attach(Data.parray) == S_OK)
{
for (unsigned int n = 0; n < mSafeArray.GetCount() / 2; ++n)
{
printf("%+.9E\t%+.9E\n",
mSafeArray.GetAt(n*2),
mSafeArray.GetAt(n*2+1));
}
mSafeArray.Detach();
}
// Pointer to COM object of PlanarR54x2.exe
// Variable for measurement data
: Primary value at the n-th measurement point.
when the data format is not the Smith chart or the polar.
227

Advertisement

Table of Contents
loading

Table of Contents