Specifications
For i = 0 To num_points - 1
Sheet1.Cells(3 + i, 1) = result(i)
Next
Set chan = Nothing
app.Quit
End Sub
5.1.4.3 Application Output
The figure below shows the displayed results when the
application is executed.
5.1.5 Microsoft Visual C++ Example
5.1.5.1 Application Configuration
Microsoft Visual C++ version 6 was used for this exam-
ple. In order to perform this example, create a new proj-
ect in Microsoft Visual C++. Add a C++ file to the
project and paste the following code into the file. The
path for the type library in the code below should be
changed to reference its location on the development
PC.
5.1.5.2 Application Code
The application can be run on a PC or on the PNA.
#include "stdafx.h"
// import the Tsunami type library
//------------------------------------------------------------------------
#import "C:\Program Files\Agilent\Network Analyzer\835x.tlb"
no_namespace, named_guids
int main(int argc, char* argv[])
{
// interface pointers to retrieve COM interfaces
IUnknown* pUnk = 0;
IApplication* pNA = 0;
IChannel* pChan = 0;
IMeasurement* pMeas = 0;
IArrayTransfer* pTrans = 0;
int i, num_points = 0;
float* pScalarData;
HRESULT hr;
// Initialize the COM subsystem
CoInitialize(NULL);
// Create an instance of the network analyzer
// Request the NA's IUnknown interface
hr = CoCreateInstance(CLSID_Application,0,
CLSCTX_ALL,IID_IUnknown, (void**) &pUnk);
if (!FAILED(hr)) {
// QueryInterface for the INetworkAnalyzer interface
of the NetworkAnalyzer object
hr = pUnk->QueryInterface(IID_IApplication,
(void**)&pNA);
if (!FAILED(hr)) {
// Reset the analyzer to instrument preset
pNA->Reset();
// Create S11 measurement
pNA->CreateSParameter(1,1,1,1);
// Set pChan variable to point to the active
channel
pNA->get_ActiveChannel(&pChan);
if (pChan) {
// Set pMeas variable to point to the active
measurement
pNA->get_ActiveMeasurement(&pMeas);
if(pMeas) {
// Setup the channel for a single trigger
pChan->Hold(true);
pNA->TriggerSignal = naTriggerManual;
pChan->TriggerMode =
naTriggerModeMeasurement;
// Make the PNA application visible
pNA->put_Visible(true);
// Set channel parameters
pChan->NumberOfPoints = 11;
pChan->StartFrequency = 1e9;
pChan->StopFrequency = 2e9;
15