完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我曾经使用签证和binblockread从pna 5247A用matlab获取数据。
但是,我们现在没有PC环境,只能使用苹果笔记本电脑,我们只能在操作系统中使用tcpip和fread。 代码如下:VNA = tcpip(''*。*。*。*',5025); set(VNA,'InputBufferSize',30000); set(VNA,'timeout',150); fopen(VNA)fprintf(VNA,'CALC:PAR:SEL“CH1_S11_1”'); fprintf(VNA,'FORM:BORD SWAP'); %将数据类型设置为实数32位二进制块fprintf(VNA,'FORM REAL,32'); fprintf(VNA,'CALC:DATA:S2P 2'); %data1 = scanstr(VNA); %fwrite(VNA,'OUTPDATA'); %从binblock读出#A temp = fread(VNA,2,'char')%读出块大小temp = fread(VNA,1,'uint16')%读出跟踪数据data1 = fread(VNA,temp / 4) ,'float32'); 'fread'可以读回#A和blocak的大小,有时虽然需要很长时间。 但是,它无法读回跟踪数据。 我应该用哪个命令快速恢复数据。编辑:lzuxz于2013年2月7日上午7:41 以上来自于谷歌翻译 以下为原文 I used to get data with matlab from pna 5247A by using visa and binblockread. However, we now have no pc environment, and only a apple laptop could be used,we could only use the tcpip and fread in OS. The code is following: VNA=tcpip(''*.*.*.*',5025); set(VNA, 'InputBufferSize', 30000); set(VNA, 'Timeout', 150); fopen(VNA) fprintf(VNA, 'CALC:PAR:SEL "CH1_S11_1"'); fprintf(VNA, 'FORM:BORD SWAP'); % Set data type to real 32 bit binary block fprintf(VNA, 'FORM REAL,32'); fprintf(VNA, 'CALC:DATA:S2P 2'); % data1=scanstr(VNA); % fwrite(VNA, 'OUTPDATA'); %Read out #A from binblock temp=fread(VNA, 2, 'char') %Read out block size temp=fread(VNA, 1, 'uint16') %Read out trace data data1=fread(VNA, temp/4, 'float32'); 'fread' could read back the #A and the blocak size, sometimes, although it need a very long time. However,It could not read back the trace data. Which command should I use to get the data back quickly. Edited by: lzuxz on Feb 7, 2013 7:41 AM |
|
相关推荐
4个回答
|
|
我从你注释掉的“OUTPDATA”fwrite中看到,你可能正在尝试利用为8510或87xx分析器编写的一些代码,或者可能是与PNA的'cXL'代码转换器功能一起使用的代码,它可以兼容
通过物理GPIB执行8510或87xx命令,在通过LAN套接字发送命令时不适用。 8510和87xx分析仪是在IEEE 488.2和SCPI标准形成之前引入的,因此它们的二进制块格式与今天仪器的标准方式略有不同。 以下是在线PNAHelp主题的链接,该主题描述了二进制数据块格式化的标准方式:[http://na.tm.agilent.com/pna/help/latest/Programming/Learning_about_GPIB/Getting_Data_from_the_Analyzer.htm#block]。 最好的祝福, 以上来自于谷歌翻译 以下为原文 I see from your commented-out 'OUTPDATA' fwrite that you were perhaps trying to leverage some code that had been written for an 8510 or 87xx analyzer, or perhaps was code that was used with PNA's 'cXL' code translator feature that enables compatibility with 8510 or 87xx commands via physical GPIB, which does not apply when sending commands via LAN socket. The 8510 and 87xx analyzers were introduced prior to the formation of the standards of IEEE 488.2 and SCPI, so they format their binary blocks a little differently than the standard way today's instruments do. Here's a link to the online PNAHelp topic that describes the standard way the binary data blocks are formatted: [http://na.tm.agilent.com/pna/help/latest/Programming/Learning_about_GPIB/Getting_Data_from_the_Analyzer.htm#block]. Best regards, |
|
|
|
uwyywefwd 发表于 2019-4-17 20:29 感谢您的回复,有些命令来自旧项目8720 ananlyzer与物理GPIB。 当它用于新的分析器时,这些是注释,我已经阅读了数据块格式的文档。 #17ABC + XYZ其中:# - 始终在确定块数据之前发送1 - 指定字节数是一位数(7)7 - 指定将遵循的数据字节数,不计算ABC + XYZ - 数据 - 始终在 块数据的结尾+ temp = fread(VNA,2,'char'); +用于读回块的前2个字符。 + temp = fread(VNA,1,'uint16'); +用于获取数据块的大小。 + data1 = fread(VNA,temp / 4,'float32'); +用于读回所有跟踪数据。 我不知道它为什么这么慢,总是给出一个时间错误。 我怎么能改进这个代码,或者这些命令有什么错误。 以上来自于谷歌翻译 以下为原文 Thanks for your kind reply, Some command was taken from old project for 8720 ananlyzer with a physical GPIB. These was comment when it is used for the new analyzer, and I have read the document for the data block format. #17ABC+XYZ Where: # - always sent before definite block data 1 - specifies that the byte count is one digit (7) 7 - specifies the number of data bytes that will follow, not counting ABC+XYZ - Data - always sent at the end of block data +temp=fread(VNA, 2, 'char') ;+ was used to read back the first 2 character of the block. +temp=fread(VNA, 1, 'uint16') ;+ was used to get the size of the data block. +data1=fread(VNA, temp/4, 'float32');+ was used to read back all the trace data. I do not know why it is so slow, and always give a time out error. How could I improve this code, or is there any mistake in these command. |
|
|
|
LingMao 发表于 2019-4-17 20:39 它是你的代码的最后三行仍然对应于8720格式二进制数据块的方式。 如果我提供另一个示例,除了PNAHelp主题中显示的示例之外,可能会有所帮助。 如果我能熟练掌握Matlab,那么我可能会有信心为你编写和发布一些替代的Matlab代码,但我不是。 或者也许正在读这个程序Matlab的其他人可能会插入。但这里是第二个数据块示例:#210ABCDE + WXYZ这个例子驱动了一个事实,你必须始终通过检查'#后面的单个字符的值开始 ”。 在这种情况下,'2'告诉你紧随其后将有*两个字符*两个字节*,即“10”。 “10”告诉你THAT之后的数据块中的字节数是10(“ABCDE + WXYZ”),然后是换行符(即)和握手(这是切换的 使用GPIB时GPIB总线上的EOI线路,因此仅适用于GPIB或VXI-11.2)。 所以你看,这与PNAHelp中的例子有什么不同,就是在PNAHelp示例中,'1'告诉你'7'只是一个字符(字节),当你解释7,它告诉你有7个 随后的总字节数。 因此,您的代码必须始终解释“#”之后的第一个字符,以便能够考虑该numberOfDataBytes字段的不同宽度。 编辑:bhokkan于2013年2月6日上午8:41编辑:bhokkan于2013年2月6日上午8:44 以上来自于谷歌翻译 以下为原文 It it those last three lines of your code which still corresponded to the way the 8720 formatted binary data blocks. What might help is if I give another example in addition to the one shown in that PNAHelp topic. If I were fluent in Matlab then I might be confident in writing-and-posting some alternative lines of Matlab code for you, but I am not. Or perhaps someone else reading this who programs Matlab might chime in. But here is a second data block example: #210ABCDE+WXYZ This example drives home the fact that you must always start by examining the value of the single character that follows the '#'. In this case, the '2' tells you that there will be *two characters which is two bytes* immediately following that, which are the "10". The "10" tells you that the number of bytes in the data block following THAT is ten (the "ABCDE+WXYZ"), and that is followed by a linefeed character (which is the ) and the handshake (which is the toggling of the EOI line on the GPIB bus when using GPIB and so only occurs for GPIB or VXI-11.2). So you see, how this differs from the example in PNAHelp, is that in the PNAHelp example the '1' tells you that the '7' is just one character (byte), and when you interpret the 7 that tells you there are 7 total bytes that follow. So your code has to always interpret that first character after the '#', to be able to account for the varying width of that numberOfDataBytes field. Edited by: bhokkan on Feb 6, 2013 8:41 AM Edited by: bhokkan on Feb 6, 2013 8:44 AM |
|
|
|
uwyywefwd 发表于 2019-4-17 20:58 非常感谢你的回复和提及。 我读的文件比较旧,或者我已经阅读了8720的文件。应该正确读取字节数,然后我们就可以得到数据了。 谢谢! 以上来自于谷歌翻译 以下为原文 Thank you very much for your kind reply and mentioned. The document I read was an older one, or I have read the document for our 8720. The number of bytes should be read properly, then we could get the data back. Thank you! |
|
|
|
只有小组成员才能发言,加入小组>>
1294 浏览 0 评论
2377 浏览 1 评论
2199 浏览 1 评论
2068 浏览 5 评论
2955 浏览 3 评论
1127浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
758浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
936浏览 0评论
1294浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 16:14 , Processed in 1.689762 second(s), Total 83, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号