完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
亲爱的先生们,拜托,您能帮助我使用SCPI命令从ENA读取S参数吗?
我尝试了很多次,但我没有成功。 我想使用matlab从ENA读取S11参数并将此数据放在工作空间(Matlab)上。 我会感激任何帮助。 以上来自于谷歌翻译 以下为原文 Dear Gentlemen, Please, could you help me to read S parameters from ENA to PC using SCPI commands ? I've tried many times, but I haven't success. I would like read S11 parameter from ENA using a Matlab and put this data on workspace (Matlab). I'll be grateful for any help. |
|
相关推荐
11个回答
|
|
您是否看过这个示例:http://www.mathworks.com/help/instrument/examples/characterizing-a-low-noise-amplifier-by-measuring-its-s-parameters.html该示例已经过测试
PNA,但您应该能够修改它以使用ENA。 请参阅您的SCPI手册,了解仪器的确切命令。 以上来自于谷歌翻译 以下为原文 Have you looked at this example: http://www.mathworks.com/help/instrument/examples/characterizing-a-low-noise-amplifier-by-measuring-its-s-parameters.html The example was tested with a PNA, but you should be able to modify it to work with the ENA. Refere to your SCPI manual for the exact commands for your instrument. |
|
|
|
干得好。
您可能需要使用CALC1:DATA:FDAT? 如果要读取ENA上的格式化数据。 下面是阅读复杂的数据。 %设置仪器的VISA地址字符串visaString ='GPIB0 :: 17 :: INSTR'; %创建VISA-GPIB对象。 vi = instrfind('Type','visa-gpib','RsrcName',visaString,'Tag',''); %如果不存在,则创建VISA-GPIB对象%否则使用找到的对象。 if isempty(vi)vi = visa('AGILENT',visaString); 否则fclose(vi); vi = vi(1); end%配置仪器对象,vi。 set(vi,'InputBufferSize',20000); set(vi,'Timeout',100); %连接仪器对象,vi。 的fopen(VI); fprintf(vi,'CALC1:PAR1:DEF S11'); %将字节顺序设置为交换(little-endian)格式fprintf(vi,'FORM:BORD SWAP'); %将数据类型设置为实际的64位二进制块fprintf(vi,'FORM:DATA REAL'); %从PNA读取S2P数据。 S2P文件将返回点数* 9%数据点。 fprintf(vi,'CALC1:DATA:SDAT?'); [[data,count,msg]] = binblockread(vi,'double'); 同相=数据(1:2:结束); 正交=数据(2:2:结束); IQData =同相+ 1I *正交; %刷新缓冲区clrdevice(vi); %断开gpib对象。 FCLOSE(VI); %清理所有对象。 删除(VI); 以上来自于谷歌翻译 以下为原文 Here you go. You may need to use CALC1:DATA:FDAT? if you want to read formatted data on the ENA. Below is reading complex data. %Set VISA Address String for Instrument visaString = 'GPIB0::17::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); else fclose(vi); vi = vi(1); end % Configure instrument object, vi. set(vi, 'InputBufferSize', 20000); set(vi, 'Timeout', 100); % Connect to instrument object, vi. fopen(vi); fprintf(vi,'CALC1:PAR1:DEF S11'); % Set byte order to swapped (little-endian) format fprintf(vi, 'FORM:BORD SWAP'); % Set data type to real 64 bit binary block fprintf(vi, 'FORM:DATA REAL'); % Read S2P data back from PNA. A S2P file will return number of points * 9 % data points back. fprintf(vi, 'CALC1:DATA:SDAT?'); [[data, count, msg]] = binblockread(vi, 'double'); inphase=data(1:2:end); quadrature=data(2:2:end); IQData=inphase+1i*quadrature; % Flush the buffer clrdevice(vi); % Disconnect gpib object. fclose(vi); % Clean up all objects. delete(vi); |
|
|
|
干得好。
您可能需要使用CALC1:DATA:FDAT? 如果要读取ENA上的格式化数据。 下面是阅读复杂的数据。 %设置仪器的VISA地址字符串visaString ='GPIB0 :: 17 :: INSTR'; %创建VISA-GPIB对象。 vi = instrfind('Type','visa-gpib','RsrcName',visaString,'Tag',''); %如果不存在,则创建VISA-GPIB对象%否则使用找到的对象。 if isempty(vi)vi = visa('AGILENT',visaString); 否则fclose(vi); vi = vi(1); end%配置仪器对象,vi。 set(vi,'InputBufferSize',20000); set(vi,'Timeout',100); %连接仪器对象,vi。 的fopen(VI); fprintf(vi,'CALC1:PAR1:DEF S11'); %将字节顺序设置为交换(little-endian)格式fprintf(vi,'FORM:BORD SWAP'); %将数据类型设置为实际的64位二进制块fprintf(vi,'FORM:DATA REAL'); %从PNA读取S2P数据。 S2P文件将返回点数* 9%数据点。 fprintf(vi,'CALC1:DATA:SDAT?'); [[data,count,msg]] = binblockread(vi,'double'); 同相=数据(1:2:结束); 正交=数据(2:2:结束); IQData =同相+ 1I *正交; %刷新缓冲区clrdevice(vi); %断开gpib对象。 FCLOSE(VI); %清理所有对象。 删除(VI); 以上来自于谷歌翻译 以下为原文 Here you go. You may need to use CALC1:DATA:FDAT? if you want to read formatted data on the ENA. Below is reading complex data. %Set VISA Address String for Instrument visaString = 'GPIB0::17::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); else fclose(vi); vi = vi(1); end % Configure instrument object, vi. set(vi, 'InputBufferSize', 20000); set(vi, 'Timeout', 100); % Connect to instrument object, vi. fopen(vi); fprintf(vi,'CALC1:PAR1:DEF S11'); % Set byte order to swapped (little-endian) format fprintf(vi, 'FORM:BORD SWAP'); % Set data type to real 64 bit binary block fprintf(vi, 'FORM:DATA REAL'); % Read S2P data back from PNA. A S2P file will return number of points * 9 % data points back. fprintf(vi, 'CALC1:DATA:SDAT?'); [[data, count, msg]] = binblockread(vi, 'double'); inphase=data(1:2:end); quadrature=data(2:2:end); IQData=inphase+1i*quadrature; % Flush the buffer clrdevice(vi); % Disconnect gpib object. fclose(vi); % Clean up all objects. delete(vi); |
|
|
|
非常感谢ningchen! 您的帮助对我的硕士学位项目的发展非常重要。 当我完成这项工作后,我将在这里提出一个主题,逐步展示所做的工作。 我也会尝试在Visual C#或C ++中创建一个版本。 谢谢你的支持。 以上来自于谷歌翻译 以下为原文 Thank very much ningchen ! Your help will be very important to development of my masters degree project. When I finish the work, I will put here an topic showing step-by-step what was made. I also will try make a version in Visual C# or C++. Thank you by support. |
|
|
|
对于C#,它有点复杂,因为你必须编写自己的代码来从GPIB总线读取二进制数据。 以下是我之前做过的功能,祝你的硕士学位好运。 public ComplexData [] ReadComplexTraceData(){FormattedIO488 ioDmm = new FormattedIO488Class(); ResourceManager grm = new ResourceManager(); string visaAddress =“GPIB0 :: 16 :: INSTR”; ioDmm.IO =(IMessage)grm.Open(visaAddress,AccessMode.NO_LOCK,0,“”); int oldTimeout = ioDmm.IO.Timeout; //将超时设置为10秒ioDmm.IO.Timeout = 10000; ioDmm.WriteString(“CALC1:PAR1:DEF S11”); //将传输模式设置为二进制ioDmm.WriteString(“FORM:BORD SWAP”); ioDmm.WriteString(“FORM:DATA REAL”); // ===将跟踪数据读入缓冲区。 ioDmm.WriteString( “CALC:DATA:SDAT?”); 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); 列表al = new List(rawcount.Length); foreach(rawcount中的字节b)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 / 16; ComplexData [] tracedata = new ComplexData [[numPoints]]; int indx = 0; for(int i = 0; i {tracedata = new ComplexData(0,0); tracedata .Re = BitConverter.ToDouble(rawTraceData,indx); indx + = 8; tracedata .Im = BitConverter.ToDouble(rawTraceData,indx); indx + = 8;} ioDmm.IO.Timeout = oldTimeout; return tracedata;}编辑:ningchen于2014年7月13日上午7:42 以上来自于谷歌翻译 以下为原文 For C# it is a little more complicated because you have to write your own code to read binary data from the GPIB bus. Below is the function I did before to do this, good luck on your master's degree. public ComplexData[] ReadComplexTraceData() { FormattedIO488 ioDmm = new FormattedIO488Class(); ResourceManager grm = new ResourceManager(); string visaAddress = "GPIB0::16::INSTR"; ioDmm.IO = (IMessage)grm.Open(visaAddress, AccessMode.NO_LOCK, 0, ""); int oldTimeout = ioDmm.IO.Timeout; //set timeout to 10 seconds ioDmm.IO.Timeout = 10000; ioDmm.WriteString("CALC1:PAR1:DEF S11"); //set transfer mode to binary ioDmm.WriteString("FORM:BORD SWAP"); ioDmm.WriteString("FORM:DATA REAL"); //=== Read the trace data into the buffer. ioDmm.WriteString("CALC:DATA:SDAT?"); 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 al = new List(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 / 16; ComplexData[] tracedata = new ComplexData[[numPoints]]; int indx = 0; for (int i = 0; i < numPoints; ++i) { tracedata = new ComplexData(0, 0); tracedata.Re = BitConverter.ToDouble(rawTraceData, indx); indx += 8; tracedata.Im = BitConverter.ToDouble(rawTraceData, indx); indx += 8; } ioDmm.IO.Timeout = oldTimeout; return tracedata; } Edited by: ningchen on Jul 13, 2014 7:42 AM |
|
|
|
平凡的世界12 发表于 2018-12-3 16:51 你好ningchen! 您的matlab代码完美地作为scritp工作,文件类型为m(例如:sparameter.m)。 但是,当我使用此代码创建matlab gui时,该程序无法正常工作且未显示响应。 感谢您的matlab脚本,运行良好。 现在我将尝试在图形界面中解决问题。 这是GUI的测试代码:函数varargout = teste(varargin)%TESTE MATLAB代码,用于teste.fig%TESTE,它本身创建一个新的TESTE或引发现有的%singleton *。 %% H = TESTE返回新TESTE的句柄或现有单例*的句柄。 %% TESTE('CALLBACK',hObject,eventData,handles,...)使用给定的输入参数调用TESTE.M中名为CALLBACK的本地%函数。 %% TESTE('Property','Value',...)创建一个新的TESTE或者提高%现有的单例*。 从左侧开始,在调用teste_OpeningFcn之前,属性值对应用于GUI。 %无法识别的属性名称或无效值使属性应用程序%停止。 所有输入都通过varargin传递给teste_OpeningFcn。 %% *请参阅GUIDE工具菜单上的GUI选项。 选择“GUI只允许一个%实例运行(单例)”。 %%参见:GUIDE,GUIDATA,GUIHANDLES%编辑上述文本以修改响应以帮助测试%上次修改时GUIDE v2.5 14-Jul-2014 12:41:18%开始初始化代码 - 不要编辑gui_Singleton = 1; gui_State =结构( 'gui_Name',mfilename,... 'gui_Singleton',gui_Singleton,... 'gui_OpeningFcn',@teste_OpeningFcn,... 'gui_OutputFcn',@teste_OutputFcn,... 'gui_LayoutFcn',[]。 ..'gui_Callback',[]); 如果是nargin&amp;&amp; ischar(varargin {1})gui_State.gui_Callback = str2func(varargin {1}); 结束如果nargout [varargout {1:nargout}] = gui_mainfcn(gui_State,varargin {:}); else gui_mainfcn(gui_State,varargin {:}); 结束%结束初始化代码 - 不要编辑%---在teste可见之前执行。 function teste_OpeningFcn(hObject,eventdata,handles,varargin)%此函数没有输出参数,请参见OutputFcn。 %hObject手柄推测%EVENTDATA保留 - 在MATLAB%未来版本中定义处理结构与手柄和用户数据(参见GUIDATA)%varargin命令行参数TESTE(见VARARGIN)%选择为泰斯特手柄默认命令行输出 .output = hObject; %Update处理结构guidata(hObject,handles); %UIWAIT使teste等待用户响应(参见UIRESUME)%uiwait(handles.figure1); %---此函数的输出返回到命令行。 function varargout = teste_OutputFcn(hObject,eventdata,handles)%varargout单元格数组,用于返回输出args(参见VARARGOUT); %hObject句柄来保留%eventdata保留 - 在未来版本的MATLAB中定义%处理带句柄和用户数据的结构(参见GUIDATA)%从句柄结构获取默认命令行输出varargout {1} = handles.output; %---在s11中按下按钮执行。 功能s11_Callback(hObject,EVENTDATA,处理)%hObject处理到S11(见GCBO)%EVENTDATA保留 - 在MATLAB%以后的版本中定义的手柄和用户数据(见GUIDATA)*为%设定VISA地址字符串处理结构 仪表* visaString = 'GPIB0 :: 17 :: INSTR'; *。*%创建VISA-GPIB对象* VI = instrfind( '类型', '签证-GPIB', 'RsrcName',visaString, '标签' ,''); * *%创建VISA-GPIB对象(如果不存在)* *%否则使用找到的对象。* * if isempty(vi)* * vi = visa('AGILENT',visaString); * * else * * fclose(vi); * * vi = vi(1); * * end * *%配置仪器对象,vi。* * set(vi,'InputBufferSize',20000); * * set(vi, '超时',100); * *%连接仪器对象,vi。* * fopen(vi); * * fprintf(vi,'CALC1:PAR1:DEF S11'); * *%设置字节顺序交换(小) -endian)format * * fprintf(vi,'FORM:BORD SWAP'); * *%将数据类型设置为真正的64位二进制块* * fprintf(vi,'FORM:DATA REAL'); * *%读取S2P数据 从PNA回来。 一个S2P文件将返回点数* 9 * *%数据点返回。* * fprintf(vi,'CALC1:DATA:SDAT?'); * * [data,count,msg] = binblockread(vi,'double' ); * * inphase = data(1:2:end); * * quadrature = data(2:2:end); * * IQData = inphase + 1i * orthrature; * *%刷新缓冲区* * clrdevice(vi) ; * *%断开gpib对象。* * fclose(vi); * *%清理所有对象。* * delete(vi); *编辑者:Danhen 2014年7月14日上午11:31 以上来自于谷歌翻译 以下为原文 Hello ningchen ! Your matlab code worked prefectly as scritp, a file type m (ex: sparameter.m). However when I created a matlab gui using this code, the program didn't work and didn't show response. Thanks for your matlab script, worked well. Now I will try to solve the problem in the graphical interface. This is code of test of the GUI: function varargout = teste(varargin) % TESTE MATLAB code for teste.fig % TESTE, by itself, creates a new TESTE or raises the existing % singleton*. % % H = TESTE returns the handle to a new TESTE or the handle to % the existing singleton*. % % TESTE('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in TESTE.M with the given input arguments. % % TESTE('Property','Value',...) creates a new TESTE or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before teste_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to teste_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help teste % Last Modified by GUIDE v2.5 14-Jul-2014 12:41:18 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @teste_OpeningFcn, ... 'gui_OutputFcn', @teste_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before teste is made visible. function teste_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to teste (see VARARGIN) % Choose default command line output for teste handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes teste wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = teste_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in s11. function s11_Callback(hObject, eventdata, handles) % hObject handle to s11 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) *%Set VISA Address String for Instrument* *visaString = 'GPIB0::17::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);* *else* *fclose(vi);* *vi = vi(1);* *end* *% Configure instrument object, vi.* *set(vi, 'InputBufferSize', 20000);* *set(vi, 'Timeout', 100);* *% Connect to instrument object, vi.* *fopen(vi);* *fprintf(vi,'CALC1:PAR1:DEF S11');* *% Set byte order to swapped (little-endian) format* *fprintf(vi, 'FORM:BORD SWAP');* *% Set data type to real 64 bit binary block* *fprintf(vi, 'FORM:DATA REAL');* *% Read S2P data back from PNA. A S2P file will return number of points * 9* *% data points back.* *fprintf(vi, 'CALC1:DATA:SDAT?');* *[data, count, msg] = binblockread(vi, 'double');* *inphase=data(1:2:end);* *quadrature=data(2:2:end);* *IQData=inphase+1i*quadrature;* *% Flush the buffer* *clrdevice(vi);* *% Disconnect gpib object.* *fclose(vi);* *% Clean up all objects.* *delete(vi);* Edited by: Danhen 2014 on Jul 14, 2014 11:31 AM |
|
|
|
60user142 发表于 2018-12-3 16:56 将您的电子邮件地址发送给我,我将向您发送一个示例GUI,用于从网络分析仪进行测量并绘制它。 这是一个连续从仪器获取数据并更新图表的示例:http://www.mathworks.com/matlabcentral/fileexchange/25519 以上来自于谷歌翻译 以下为原文 Send me your email address and I will send you an example GUI that makes measurements from a network analyzer and plots it. Here's an example that continuously gets data from an instrument and updates plots: http://www.mathworks.com/matlabcentral/fileexchange/25519 |
|
|
|
fen556 发表于 2018-12-3 17:05 你好vcherian! 我的电子邮件是projectdream07@gmail.com。 感谢您的帮助。编辑:Danhen 2014年7月14日,下午10:53 以上来自于谷歌翻译 以下为原文 Hello vcherian ! My e-mail is projectdream07@gmail.com. Thank you for your help. Edited by: Danhen 2014 on Jul 14, 2014 10:53 PM |
|
|
|
60user142 发表于 2018-12-3 16:56 将您的电子邮件地址发送给我,我可以向您发送一个测量S参数数据并更新数字的GUI示例。 您可能还想参考此示例:http://www.mathworks.com/matlabcentral/fileexchange/25519,它根据测量数据更新GUI。 以上来自于谷歌翻译 以下为原文 Send me your email address and I can send you a GUI example that measures S-parameter data and updates a figure. You might also want to refer to this example: http://www.mathworks.com/matlabcentral/fileexchange/25519 that updates GUI based on measured data. |
|
|
|
60user142 发表于 2018-12-3 16:56 你好Danhen 2014:我不熟悉Matlab GUI代码,所以我看不出代码中的问题。 您需要调试代码以检查错误。 1.您可以在代码的第一行放置断点,然后使用F10进入下一行,然后查看它停在哪一行。 2.问题发生后,Matlab状态窗口上应该会显示一些错误消息。 你看到了吗? 以上来自于谷歌翻译 以下为原文 Hello Danhen 2014: I'm not familliar with the Matlab GUI code, so I couldn't see what is the problem in your code. You need to debug your code to check what is wrong. 1. You can put breakpoint on the first line of your code and use F10 to step into next lines, then see on which line it stops. 2. After the problem occurs, there should be some error message on the Matlab status window. Did you see any? |
|
|
|
平凡的世界12 发表于 2018-12-3 17:44 你好ningchen! 我会这样做,也许我会看到matlab代码中的错误。 我的印象是matlab GUI不能与工作空间通信......它们之间的交互似乎很麻烦。 谢谢 ! 以上来自于谷歌翻译 以下为原文 Hello ningchen ! I will do it, maybe I get to see the error in matlab code. My impression is that matlab GUI not comunicate to workspace... It seems a trouble of interaction between them. Thank you ! |
|
|
|
只有小组成员才能发言,加入小组>>
956 浏览 0 评论
2242 浏览 1 评论
2022 浏览 1 评论
1893 浏览 5 评论
2762 浏览 3 评论
745浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
541浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
633浏览 0评论
2422浏览 0评论
1474浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-9-1 07:42 , Processed in 1.346451 second(s), Total 67, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191