当前位置: 华文问答 > 科学

安捷伦34970A数据采集器 如何程序控制?

2014-06-24科学

我们将用实例演示如何在C#环境中利用visa32.cs进行仪器控制及自动测试。希望对您的测试有帮助。

描述

  1. IO Libraries Suite下载和安装: https://www. keysight.com/us/en/lib/ software-detail/computer-software/io-libraries-suite-downloads-2175637.html

2. 在IOconnect expert中添加仪器,可以用仪器的网络IP地址,也可以用HOSTID:

3. 创建一个C#的窗体程序,并在project中添加visa32.cs,作为和仪器建立通信及控制的动态链接库:

添加的visa.cs可以是以下地址中的任何一个:

C:\Program Files (x86)\IVI Foundation\VISA\WinNT\ktvisa\include\KtVisa32.cs

C:\Program Files (x86)\IVI Foundation\VISA\WinNT\ktvisa\include\visa32.cs

C:\Program Files (x86)\IVI Foundation\VISA\WinNT\agvisa\include\agvisa32.cs

4. 编写代码,可以参照IO Libraries Suite中的文件VISA Help文档,了解VISA中的各种方法和接口。

5. 以下是一个带通滤波器的设置及测试代码,使用的仪器是Keysight VNA E5080B:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Threading; namespace Csharp_program_with_VISA { class Program { // Simple example using KtVisa32.dll through KtVisa32.cs or visa32.cs or agvisa32.cs //C:\Program Files (x86)\IVI Foundation\VISA\WinNT\ktvisa\include\KtVisa32.cs //C:\Program Files (x86)\IVI Foundation\VISA\WinNT\ktvisa\include\visa32.cs //C:\Program Files (x86)\IVI Foundation\VISA\WinNT\agvisa\include\agvisa32.cs static void Main(string[] args) {

Console.WriteLine("Start Program with VISA method Demo:\n");

string VNA_VISA_Adress = "TCPIP0::k-e5080b-00951::hislip0::INSTR";

//Filter test demo-connection

int rM = 0;

int vI = 0;

int stringSize = 100;

string idnString = "", filter_data = "", opc = "";

int len = 0;

double BW, Center, Q, Loss;

KtVisa32.viOpenDefaultRM(out rM);

KtVisa32.viOpen(rM, VNA_VISA_Adress, KtVisa32.VI_NO_LOCK, KtVisa32.VI_TMO_IMMEDIATE, out vI);//默认accessMode和timeout参数:KtVisa32.VI_NULL ,KtVisa32.VI_NULL

KtVisa32.viPrintf(vI, "*RST\n");

KtVisa32.viPrintf(vI, "*OPC?\n");

KtVisa32.viRead(vI, out opc, stringSize);

KtVisa32.viPrintf(vI, "*IDN?\n");

KtVisa32.viRead(vI, out idnString, stringSize);

KtVisa32.viPrintf(vI, "*OPC?\n");

KtVisa32.viRead(vI, out opc, stringSize);

if (opc == "+1\n")

{

Console.WriteLine("Instrument Informtion: " + idnString + "\n");

}

else

{

Console.WriteLine("\n Instrument connect failed" + "Please check the instrument address and hardware connection!");

return;

}

//Filter test demo- setup and measure

KtVisa32.viPrintf(vI, "*RST\n");

KtVisa32.viPrintf(vI, "*OPC?\n");

KtVisa32.viRead(vI, out opc, stringSize);

KtVisa32.viPrintf(vI, "*WAI\n");

KtVisa32.viPrintf(vI, ":CALCulate1:MEASure1:PARameter \"S21\"\n");

KtVisa32.viPrintf(vI, ":SENSe1:BANDwidth:RESolution 10000\n");

KtVisa32.viPrintf(vI, ":SENSe1:FREQuency:CENTer 3780000000\n");

KtVisa32.viPrintf(vI, ":SENSe1:FREQuency:SPAN 6000000000\n");

KtVisa32.viPrintf(vI, ":SENSe1:SWEep:POINts 201\n");

KtVisa32.viPrintf(vI, ":SOURce1:POWer1:COUPle 1\n");

KtVisa32.viPrintf(vI, ":SOURce1:POWer4:LEVel:IMMediate:AMPLitude -10\n");

KtVisa32.viPrintf(vI, ":INITiate1:CONTinuous 1\n");

Thread.Sleep(1000);

KtVisa32.viPrintf(vI, ":FORMat:DATA REAL,32\n");

KtVisa32.viPrintf(vI, "*OPC?\n");

KtVisa32.viRead(vI, out opc, stringSize);

KtVisa32.viPrintf(vI, ":INITiate1:CONTinuous 0\n");

KtVisa32.viPrintf(vI, ":ABORt\n");

KtVisa32.viPrintf(vI, ":INITiate1:IMMediate\n");

KtVisa32.viPrintf(vI, "*OPC?\n");

KtVisa32.viRead(vI, out opc, stringSize);

KtVisa32.viPrintf(vI, ":DISPlay:WINDow1:Y:AUTO\n");

KtVisa32.viPrintf(vI, "*OPC?\n");

KtVisa32.viRead(vI, out opc, stringSize);

KtVisa32.viPrintf(vI, ":INITiate1:CONTinuous 0\n");

KtVisa32.viPrintf(vI, ":ABORt\n");

KtVisa32.viPrintf(vI, ":INITiate1:IMMediate\n");

KtVisa32.viPrintf(vI, "*OPC?\n");

KtVisa32.viRead(vI, out opc, stringSize);

KtVisa32.viPrintf(vI, ":CALCulate1:MEASure1:MARKer1:BWIDth:STATe 1\n");//测量滤波器参数

KtVisa32.viPrintf(vI, "*OPC?\n");

KtVisa32.viRead(vI, out opc, stringSize);

KtVisa32.viPrintf(vI, ":CALCulate1:MEASure1:MARKer1:BWIDth:DATA?\n");

KtVisa32.viRead(vI, out filter_data, stringSize);

KtVisa32.viPrintf(vI, "*OPC?\n");

KtVisa32.viRead(vI, out opc, stringSize);

char[] delimiterChars = { ',', '\n' };

string[] filter_data_array = filter_data.Split(delimiterChars);

len = filter_data_array.Length;

BW = Convert.ToDouble(filter_data_array[0]) / 1e9;

Center = Convert.ToDouble(filter_data_array[1]) / 1e9;

Q = Convert.ToDouble(filter_data_array[2]) / 1e9;

Loss = Convert.ToDouble(filter_data_array[3]) / 1e9;

Console.WriteLine("Filter parameter test results:\n");

Console.WriteLine("BW= " + BW + " GHz\n");

Console.WriteLine("Center=" + Center + " GHz\n");

Console.WriteLine("Q= " + Q + "\n");

Console.WriteLine("Loss= " + Loss + " dB\n");

Console.WriteLine("Filter parameter test completed!\n");

Console.ReadLine();

//关闭连接

KtVisa32.viClose(vI);

KtVisa32.viClose(rM);

}

}

}

6.测试后窗体输出连接情况及测试结果,主要包括滤波器的带宽(BW),中心频率(Center),品质因子(Q),带内插损(Loss);

需要更多信息,您可访问:

是德科技