6705-003REVA这sp202een是什么芯片功能的芯片,有哪位大神有没有数据手册?

通过PC控制矢网去做测量和数据采集有SCPI和DCOM两种方式,最常用的是SCPI命令的方式。基于SCPI命令的方式,物理连接可以是GPIB电缆、USB-GPIB转接线(Agilent 82357)、USB电缆或网线,或者还可以直接把程序运行在矢网上面。基于DCOM的控制方式,物理连接只能是网线,或者把程序运行在矢网上。例如PNA Macro里面的Adaptor Characterization宏程序,就是运行在PNA上的一个基于DCOM控制的程序。下面我们探讨最常用的SCPI控制方式。第一步需要建立PC和仪器的物理连接,以及编程用的逻辑连接(从而获得仪器的逻辑地址,VISA Address)。PC上需要安装Keysight的免费程序IO Libraries Suite(IO 程序库套件),通过它可以建立程序和仪器的逻辑连接,并且它包含了程序需要引用的VISA COM组件。安装成功后,在PC桌面右下角的小三角图标展开后会看到一个IO图标。如果是用GPIB电缆、USB-GPIB转接线或USB电缆直接连接PC和矢网,仪器能够自动被搜索到,则不需要手动在IO Libraries里建立矢网的逻辑连接。这时双击PC桌面右下角包含的IO图标,打开Connection Expert程序,会看到已经建立好的仪器连接。如果是通过局域网或网线建立物理连接,仪器无法自动找到,则需要手动创建仪器的逻辑连接。先把PC和矢网连到同一局域网下或用网线直连设置近似的IP,保证可以从PC ping通矢网。然后双击PC上桌面右下角的IO图标打开Connection Expert程序,选择Add LAN Instrument,输入仪器的IP地址或机器名,测试连接,然后点OK。通过以上方式自动或手动创建了仪器的逻辑连接后,在Connection Expert程序里点击创建好的连接,就能看到该仪器获得的一个逻辑地址-VISA Address。我们在程序中需要通过这个地址和矢网通信。如果是GPIB线的连接,这个地址可能是这样:GPIB0:16:INSTR 如果是基于网线的连接,地址可能是这样:TCPIP0::a-n5242a-22276::inst0::INSTR下面直接上干货。注意以下都采用了二进制的读数据方法而不是ASCII码的读数方式,速度会更快。但是需要对二进制数据进行解析。Matlab中有直接的函数做解析,但是在其它程序语言里则需要自己去解析了。PNA帮助文档里有详细的二进制数据的格式说明,大家可以参考我下面的C#实例:1. 通过Matlab程序读取矢网上的s2p数据:%Set VISA Address String for InstrumentvisaString = 'GPIB1::16::0::INSTR';% Create a VISA-GPIB object.vi = instrfind('Type', 'visa-gpib', 'RsrcName', visaString, 'Tag', '');% Create the VISA-GPIB object if it does not exist% otherwise use the object that was found.if isempty(vi)vi = visa('AGILENT', visaString);elsefclose(vi);vi = vi(1);end% Configure instrument object, vi.set(vi, 'InputBufferSize', 20000);set(vi, 'Timeout', 30);% Connect to instrument object, vi.fopen(vi);% Communicating with instrument object, vi.opc_comp = query(vi, 'SYST:PRES; *OPC?', '%s\n' ,'%s');fprintf(vi, 'CALC:PAR:SEL "CH1_S11_1"');% Query selected measurement namemeas = query(vi, 'CALC:PAR:SEL?', '%s\n' ,'%s');% Set byte order to swapped (little-endian) format fprintf(vi, 'FORM:BORD SWAP');% Set data type to real 64 bit binary blockfprintf(vi, 'FORM REAL,64');% Read S2P data back from PNA. A S2P file will return number of points * 9% data points back.fprintf(vi, 'CALC:DATA:SNP? 2');[data, count, msg] = binblockread(vi, 'double');% Flush the bufferclrdevice(vi);% Disconnect gpib object.fclose(vi);% Reshape data so it is split into columnsdata_r=reshape(data, [(length(data)/9),9]);data_r=data_r';% Read frequency data back from returned datafreqs=data_r(1,:);% This assumes that the return format is in log mag, angle pairs in the S2P% fileS11mag=data_r(2,:);plot(freqs,S11mag);title('S11 mag');xlabel('Frequency');ylabel('dB');% Clean up all objects.delete(vi);2. 在C# Console Application中读取单条曲线数据(创建好工程后需要添加Visa Com Type library的引用):using System;using System.Collections.Generic;using System.Linq;using System.Text;using Ivi.Visa.Interop;namespace ReadTraceData{
class Program
{
static void Main(string[] args)
{
const int MAXPOINTS = 32001;
//read S21 data from PNA
FormattedIO488 ioDmm = new FormattedIO488Class();
ResourceManager grm = new ResourceManager();
string visaAddress = "TCPIP0::a-n5242a-22276::5025::SOCKET";
http://ioDmm.IO = (IMessage)grm.Open(visaAddress, AccessMode.NO_LOCK, 0, "");
ioDmm.WriteString("*idn?");
string result = ioDmm.ReadString();
ioDmm.WriteString("CALC:PAR:EXT 'CH1_S21_1', 'S21'");
ioDmm.WriteString("CALC:PAR:SEL 'CH1_S21_1'");
ioDmm.WriteString("CALC:PAR:SEL?");
result = ioDmm.ReadString();
ioDmm.WriteString("CALC:FORM MLOGarithmic");
//set transfer mode to binary
ioDmm.WriteString("FORMAT:DATA REAL,32", true);
ioDmm.WriteString("FORMAT:BORDER SWAPPED", true);
//set timeout to 10 seconds
ioDmm.IO.Timeout = 10000;
//=== Read the trace data into the buffer.
ioDmm.WriteString("CALC1:DATA? FDATA", true);
byte[] pound = ioDmm.IO.Read(1);
byte[] count = ioDmm.IO.Read(1);
int numToRead = int.Parse(((char)count[0]).ToString());
byte[] rawcount = ioDmm.IO.Read(numToRead);
List<char> al = new List<char>(rawcount.Length);
foreach (byte b in rawcount)
al.Add((char)b);
char[] chByteCount = (char[])al.ToArray();
int numBytes = int.Parse(new string(chByteCount));
byte[] rawTraceData = ioDmm.IO.Read(numBytes);
byte[] trailingNL = ioDmm.IO.Read(1);
int numPoints = numBytes / 4;
float[] tracedata = new float[numPoints];
int indx = 0;
int x = 0;
for (int i = 0; i < numPoints; ++i)
{
tracedata[i] = BitConverter.ToSingle(rawTraceData, indx);
if (i > MAXPOINTS)
x = i;
indx += 4;
}
ioDmm.IO.Close();
}
}}3. 在C# Console Application中读取s2p数据(创建好工程后需要添加Visa Com Type library的引用):using System;using System.Collections.Generic;using System.Linq;using System.Text;using Ivi.Visa.Interop;using System.Diagnostics;namespace ReadSnp{
public class FmtIoBinaryReader
{
//
// Read binary format data from IO.
// PNA return a binary stream in order: [#][byte count of count][count][data...data...data...][end]
//
protected FormattedIO488 _ioDmm;
protected ulong _lenOfDataInByte;
protected ulong _currentPos;
public ulong LenOfDataInByte
{
get { return _lenOfDataInByte; }
protected set { _lenOfDataInByte = value; }
}
public FmtIoBinaryReader(FormattedIO488 io)
{
_ioDmm = io;
_currentPos = 0;
}
public ulong BeginRead()
{
byte[] pound = _ioDmm.IO.Read(1);
byte[] count = _ioDmm.IO.Read(1);
int numToRead = int.Parse(((char)count[0]).ToString());
byte[] rawcount = _ioDmm.IO.Read(numToRead);
List<char> al = new List<char>(rawcount.Length);
foreach (byte b in rawcount)
al.Add((char)b);
char[] chByteCount = al.ToArray();
LenOfDataInByte = ulong.Parse(new string(chByteCount));
return LenOfDataInByte;
}
public bool Read(ulong len, out byte[] buff)
{
if (_currentPos == _lenOfDataInByte)
{
buff = null;
return false;
}
else if (_currentPos + len > _lenOfDataInByte)
len = _lenOfDataInByte - _currentPos;
buff = _ioDmm.IO.Read(Convert.ToInt32(len));
_currentPos += len;
return true;
}
public void EndRead()
{
if (_currentPos >= _lenOfDataInByte)
_ioDmm.IO.Read(1);
}
}
class Program
{
static void Main(string[] args)
{
//从PNA上读取snp文件的数据。如对一个2端口测试来说,一次性读回频率、S11、S21、S12和S22的数据。
//需要注意的是,如果当前测试没有经过校准,需要把所有的测试参数都显示在PNA上,读回的数据才有值;但是如果当前测试时校准后的,即使屏幕上只显示S11曲线,通过calculate:data:snp:ports?命令也能正确读回所有S参数的数据
FormattedIO488 ioDmm = new FormattedIO488Class();
ResourceManager grm = new ResourceManager();
string visaAddress = "GPIB0::16::INSTR";
http://ioDmm.IO = (IMessage)grm.Open(visaAddress, AccessMode.NO_LOCK, 0, "");
//将超时的时间设为20秒
ioDmm.IO.Timeout = 20000;
ioDmm.WriteString("trigger:sequence:source immediate");
//设置为单次扫描,然后进入Hold状态
ioDmm.WriteString("sense:sweep:mode single");
ioDmm.WriteString("*OPC", true);
//读扫描点数
ioDmm.WriteString("sense:sweep:points?");
string s = ioDmm.ReadString().TrimEnd('\n').Trim('\"');
int sweepPoints = Convert.ToInt32(s);
//设置二进制读取方式
ioDmm.WriteString("format:data real,64");
ioDmm.WriteString("format:border swapped");
//将读回的snp数据格式设为LogMag和Phase
ioDmm.WriteString("mmemory:store:trace:format:snp DB");
//获取当前测量
ioDmm.WriteString("calculate:parameter:catalog?");
s = ioDmm.ReadString().TrimEnd('\n').Trim('\"');
string[] meas = s.Split(',');
string command = string.Format("calculate:parameter:select '{0}'", meas[0]);
ioDmm.WriteString(command);
//开始读取snp数据,"1,2"参数表示读取s2p数据
ioDmm.WriteString("calculate:data:snp:ports? \"1,2\"");
FmtIoBinaryReader reader = new FmtIoBinaryReader(ioDmm);
ulong numBytes = reader.BeginRead();
int sizeOfDouble = sizeof(double);
Debug.Assert(numBytes == Convert.ToUInt64((1 + 2 * 2 * 2) * sweepPoints * sizeOfDouble));
// 读取频率数据
{
ulong len = Convert.ToUInt64(sweepPoints * sizeOfDouble);
byte[] byteFreq = null;
reader.Read(len, out byteFreq);
double[] freq = new double[sweepPoints];
int startIndex = 0;
for (int i = 0; i < sweepPoints; ++i)
{
freq[i] = BitConverter.ToDouble(byteFreq, startIndex);
startIndex += sizeOfDouble;
}
//此处保存频率数据
//.....
}
// 读取S参数数据,对2端口数据而言,参数顺序为S11, S21, S12, S22
for (int i = 0; i < 2 * 2; ++i)
{
ulong len = Convert.ToUInt64(sweepPoints * sizeOfDouble * 2);
byte[] byteSparameter = null;
reader.Read(len, out byteSparameter);
int points = sweepPoints * 2;
double[] sparam = new double[points];
int startIndex = 0;
for (int j = 0; j < points; ++j)
{
sparam[j] = BitConverter.ToDouble(byteSparameter, startIndex);
startIndex += sizeOfDouble;
}
//此处保存读到的S参数数据。注意对每个S参数数组来说,前半部分是LogMag数据,后半部分是相位的数据
//...
}
reader.EndRead();
ioDmm.IO.Close();
}
}}

我要回帖

更多关于 sp202een是什么芯片 的文章

 

随机推荐