The examples in this section demonstrate the use of the au37xxx CVI driver for controlling the MS464xB. The following few steps are necessary before getting started with programming.
1. Set up communications to the MS464xB using VXI-11 (TCP/IP) by noting the IP Address of the VNA and set up a resource (a connection string).
MS464xB IP Address
2. Launch NI-MAX and create a new resource. The programs will reference this resource rather than a specific address.
Measurement and Automation Explorer (MAX)
3. Select the VISA TCP/IP Resource.
Creating a New Resource Dialog
4. If the controlling PC and the VNA are on the same local sub-network (this is usually true if the first 3 numbers in the IP address are the same – for example, 10.0.1.x in this case), then you can Auto-detect the VNA. Otherwise, you need to manually enter the IP address.
Create New VISA TCP/IP Resource Dialog
5. Select the detected instrument.
Create New VISA TCP/IP Resource Dialog
6. Give the instrument an alias (the VectorStar_Test alias is used in LabWindows/CVI).
Create New VISA TCP/IP Resource Dialog
7. Note that the VISA connection string has been replaced with the VISA alias.
Measurement and Automation Explorer Configuration
8. In LabWindows/CVI, create a new Project from Template.
9. Use the Command-line Application Template.
10. Set up the CVI to load the Anritsu driver automatically every time CVI starts up in: Library | Customize to have CVI load the driver into our user Library every time CVI starts. This is a preferable way to have access to the driver.
Customizing CVI
11. Browse to find the au37xxx.fp file.
Customize Library Menu
12. Add the Function Tree (“.fp”) file.
Selecting File
13. The driver is now in the Libraries folder.
Driver Library
14. Copy the driver DLL to someplace on the on the system path. If the system path is not known or a custom path is not important, copy the file to C:\Windows\System32.
Copying Driver DLL
15. Copy the DLL to C:\Windows\System32. This step is necessary (the LabWindows/CVI documentation explains more about copying the DLL file).
Copying Driver DLL
Example 0 – Opening a Session
This first example opens a communication session to the VNA and then uses two of the driver VIs to get some information about the VNA.
// Include files #include <ansi_c.h> #include "au37xxx.h"
int main (int argc, char *argv[]) { ViSession session; ViStatus status; ViChar d[256]; ViChar d1[256];
The results of running Example 0 are shown below. The au37xxx_revision_query() function returns two strings. The first is the version of the driver and the second is the version of firmware on the VNA.
Example 0
Example 1 – Sending the *IDN? Command and Displaying Results
The previous example used only driver functions to get some information from the VNA. The GPIB command, “*IDN?” returns the Manufacturer, Model #, Serial Number and Firmware Version. This command was used previously in the Anritsu GPIB, USB, VXI-11, and TCP/IP Exerciser. In this example, the “*IDN?” command is directly issued and then the different parts of the response string are parsed.
The output from Example 1 is shown below. The au37xxx_write() function is used to directly send GPIB commands. The VISA function viRead() is then used to read the results.
Example 1
Example 2 – Error Checking
This example shows that if an invalid GPIB string is sent to the VNA then the CHECKERR macro catches the error and displays the error message from the VNA. Here we send two valid strings: “*IDN?” and then “OID”. Note that the third string is not a valid GPIB command and the instrument reports this.
The Service Request Status Register is shown below and is slightly changed from Lightning to the MS464xB VNA. If LANG LIGHT is set, then the Lightning configuration of the Status Register is used. In this example the “LANG NATIVE” command is sent to use the MS464xB status register. The code checks b2 to see if the error queue is not empty.
MS464xB Service Request Status Register
The command error is caught after sending the erroneous “ABC” command and reports the message, “Faulty program mnemonic syntax.”
Example 2
Example 3 – Sending Data to a File with the LIST Command
The Lightning commands “FMT1;LIST” are sent to get the full list of commands supported by the MS464xB. The sting returned is an ASCII arbitrary block and the au37xxx_readAsciiARBBlock() function is used to strip off the arbitrary block header. The results are then sent to a file.
The list of all commands supported by the MS464xB are listed in the commands.txt file.
MS464xB VNA Programming Commands List
Use the Anritsu GPIB, USB, VXI-11 Exerciser to get more help on any command. Help will tell you what type of command (Native, Lightning, HP8510) and provides syntax.
Anritsu GPIB, USB, VXI-11, and TCP/IP Exerciser
Example 4 – Acquiring Trace Data
In this example, the final data from Trace 2, which is set to Log magnitude and Phase data, is acquired programmatically. The data comes out in a one dimensional, interleaved array. The array must be parsed to get the log magnitude and phase data into two separate arrays.
The impedance/reactance data from Trace 1 (Smith chart) is parsed into an ASCII file with a three-column format: Frequency (Hz), Impedance, and Reactance (note that the data is simulated).
Simulated Trace Data
Example 5 is modified to use the built-in Smith chart control. The following program is adapted from the Smith chart Demo in the samples\apps\smithchart directory. The smithchart fp, found in toolslib\toolbox\smith.fp. is used. By default, Trace1 is set to output impedance values. Most Smith chart controls actually take a normalized impedance (normalized to 1), so the impedance/reactance pairs are divided by 50 ohms to get normalized Smith chart data.
The Labwindows/CVI smith.fp is used to plot Smith chart data.
Smith Chart Demo
Example 6 – Output S2P File
This example uses au37xxx_write() calls to accomplish tasks that the driver cannot perform. Specifically, to send Native MS464xB commands along with Lightning commands to output an S2P file from the VNA to the PC.
The resulting S2P file is transferred to the PC as shown below.
Transfer of an S2P file to the PC
Example 7 – Output BMP File
A similar technique can be used to get the bitmap data to a file as in the previous example. The Lightning commands “BMPC;OBMP” are used to output a bitmap file. BMPC selects color on white as the color scheme, making for better printouts. The au37xxx_readAsciiARBBlock() function is used to strip off the arbitrary block header and place the bitmap data into a file (the header corrupts the bitmap file).