Please enable JavaScript to view this site.

 Network Analyzers using RVNA and RNVNA software

Example. Instrument Information String Readout

The following program reads out and displays on the screen the instrument information string – the Name property of the COM object. The string contains the following fields:

<manufacturer>, <model>, <serial number>, <software version>/<hardware version>.

For example:

COPPER MOUNTAIN TECHNOLOGIES, R140, 00000001, 21.4.1/1.1

Dim app As Object

Sub Example1()

Set app = CreateObject("RVNA.Application")

ID = app.Name

MsgBox ("Information string read out: " + ID)

End Sub

 

Example. Checking the Instrument Ready State

Normally, the user control program starts when the Analyzer executable module is running, the instrument booting is completed, and the instrument is ready for use. In some cases, it is recommended to check if the instrument is ready for use. The instrument may be not ready for use if it is not connected to PC via USB cable. Moreover, if the analyzer executable module has not been started in advance, the CreateObject function will automatically start the application and then within about 10 seconds the instrument booting will be in progress. The instrument will not be ready for use until the booting is completed. The Ready property is used to check if the instrument is ready for use.

The following program checks the Ready property right after a COM object has been created. If the RVNA.exe or RNVNA.exe application has been started in advance and the booting is completed, “Analyzer is ready” will be displayed. If the Ready property value is False, 10 second delay is activated for the case the RVNA.exe  RNVNA.exe application has been started by the COM object creation. In 10 seconds the program rechecks the Ready property. If the value is True, “Analyzer is ready” will be displayed, if otherwise, “Analyzer is not ready” will be displayed, what means the instrument is not connected to LAN or it is not connected to PC via USB cable.

Dim app As Object

Sub Example2()

Set app = CreateObject("RVNA.Application")

If app.Ready = False Then

Application.Wait (Now + TimeValue("0:00:10"))

If app.Ready = False Then

MsgBox ("Analyzer is not ready")

Exit Sub

End If

End If

MsgBox ("Analyzer is ready")

End Sub

 

Example. Setting the Measurement Parameters

The following program shows the setting of some measurement parameters. First, the instrument is reset to the factory settings. Then the following parameters are set:

Two channel windows are opened and allocated one above the other.

The number of traces is set to 2 in the first channel window.

For the first channel the stimulus parameters are set as follows: the frequency range from 100 MHz to 1.2 GHz, the number of measurement points 401.

For the second channel the stimulus parameters are set as follows: the frequency range from 800 MHz to 900 MHz, the number of points 51, IF bandwidth 100 Hz, output power low.

In the first channel window SWR format is set for the trace 1, logarithmic magnitude format is set for the trace 2.

In the second channel window: logarithmic magnitude format is set for the single trace. Then the auto scale function is called for this trace.

Dim app As Object

 

Public Sub Example3()

Set app = CreateObject("RVNA.Application")

 

app.SCPI.SYSTem.PRESet

app.SCPI.DISPlay.Split = 2

app.SCPI.Calculate(1).Parameter.Count = 2

app.SCPI.SENSe(1).Frequency.Start = 100000000

app.SCPI.SENSe(1).Frequency.STOP = 1200000000

app.SCPI.SENSe(1).SWEep.Points = 401

app.SCPI.SENSe(2).Frequency.Start = 800000000

app.SCPI.SENSe(2).Frequency.STOP = 900000000

app.SCPI.SENSe(2).SWEep.Points = 51

app.SCPI.SENSe(2).BANDwidth.RESolution = 100

app.SCPI.Source(2).Power.LEVel.STATe = ”LOW”

app.SCPI.Calculate(1).Parameter(1).Select

app.SCPI.Calculate(1).Selected.Format = "SWR"

app.SCPI.Calculate(1).Parameter(2).Select

app.SCPI.Calculate(1).Selected.Format = "MLOG"

app.SCPI.Calculate(2).Parameter(1).Select

app.SCPI.Calculate(2).Selected.Format = "MLOG"

app.SCPI.DISPlay.Window(2).TRACe(1).Y.SCALe.AUTO

 

End Sub

 

Example. Measurement Data Acquisition

The following program shows data array acquisition with further writing into a file. The program also shows the method of a sweep triggering and waiting for the sweep completion.

Three variables F, M, P are declared in the second string of the code. They are used for arrays of frequency values (Hz), magnitude values (dB), and phase values (degree) respectively.

After the instrument has been reset to the factory settings, two operators are used for the sweep triggering and waiting for the sweep completion:

app.SCPI.TRIGger.SEQuence.Source = "BUS"

app.SCPI.TRIGger.SEQuence.Single

The first operator sets the LAN bus command or the COM/DCOM interface command as a trigger source. It aborts the sweep and switches the instrument to waiting for a trigger. The second operator is used for a new sweep triggering and waiting for the sweep completion.


NOTE

Unlike the SCPI.TRIGger.SEQuence.IMMediate and   SCPI.IEEE4882.TRG commands, which are completed immediately after a trigger generation, the SCPI.TRIGger.SEQuence.Single command is not completed until the end of the sweep. Using the SCPI.TRIGger.SEQuence.Single command is the simplest way to set the waiting for the sweep completion.


On completion of the sweep, three arrays are read out: frequency values, magnitude values and phase values. Before the magnitude and phase arrays are read out, the corresponding trace format is set.

The array size of frequency F is equal to the number of measurement points, and the array size of magnitude M and phase P is equal to the double number of measurement points (See Measurement Data Arrays). In rectangular formats (for magnitude and phase) the measurement data are real numbers located in even cells of the array. Odd cells of the array contain 0.

On completion of the program, the frequency, magnitude and phase values for each measurement point are written string by string into the file named TESTFILE.

Dim app As Object

Dim F, M, P

 

Public Sub Example4()

Set app = CreateObject("RVNA.Application")

 

app.SCPI.SYSTem.PRESet

 

app.SCPI.TRIGger.SEQuence.Source = "BUS"

app.SCPI.TRIGger.SEQuence.Single

 

F = app.SCPI.SENSe.Frequency.Data

 

app.SCPI.Calculate.Selected.Format = "MLOG"

M = app.SCPI.Calculate.Selected.Data.FDATa

 

app.SCPI.Calculate.Selected.Format = "PHASe"

P = app.SCPI.Calculate.Selected.Data.FDATa

 

Open "TESTFILE" For Output As #1

 

For i = LBound(F) To UBound(F)

Print #1, F(i), M(i * 2), P(i * 2)

Next i

 

Close #1

End Sub

 

Example. Measurement Data Acquisition

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 RVNA.exe application.

// This example is console application. GUI is not used in this example to

// simplify the program. Error processing is very restricted too.

#include "stdafx.h"

//---------------------------------------------------------------------------

// Generate description of COM object of RVNA.exe application.

#import "RVNA.exe" no_namespace

//---------------------------------------------------------------------------

int _tmain(int argc, _TCHAR* argv[])

{

IRVNAPtr        pNWA;                                // Pointer to COM object of RVNA.exe

CComVariant Data;                                        // Variable for measurement data

// Init COM subsystem

HRESULT hr = CoInitialize(NULL);

if(hr != S_OK) return -1;

// Create COM object

hr = pNWA.CreateInstance(__uuidof(RVNA));

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)         : Primary value at the n-th measurement point.

// Data(n*2+1) : Secondary value at the n-th measurement point. Always 0

// when the data format is not the Smith chart or the polar.

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();

}

printf("Press ENTER to exit.\n");

getc(stdin);

// Release COM object

pNWA.Release();

CoUninitialize();

return 0;

}

 

Rev.:  24.1