完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
总之,我可以成功地将命令写入仪器(带有ARB的Agilent E4438C信号发生器),但我无法读回它们。
我正在使用PyVISA并安装了Agilent IO库。 我附上了一个我创建的脚本,用于说明问题以及安捷伦IO监视器的屏幕截图,我将在以下段落中对其进行介绍。 您可以在上面的第9-31行中看到Python正被用于访问仪器。 您还应该能够在第9-19行看到命令“RAD:ARB:STAT ON。 n”(注意新行字符串之前的尾随句点),并返回成功。 我还可以验证是否在仪器上执行了请求的操作。 第20-31行显示了当我尝试回读状态时会发生什么。 写入“RAD:ARB:STAT?。 n”命令,但读取超时,如第29行所示。第1-8行显示使用随Agilent Connection Manager提供的交互式命令实用程序的相同操作序列。 请注意,这些命令在新行字符串之前没有尾随句点,并且写入和读取命令都成功执行,并且read命令返回正确的值“1 n”,表示状态为“on”。似乎 就像PyVISA实现在新行字符串之前添加这个尾随句点一样,这似乎不会影响写入命令,但可能会影响读取命令。 我很感激任何人都可以提供的任何帮助或见解。 IO Monitor.jpg193.0 KB 以上来自于谷歌翻译 以下为原文 In summary, I can write commands successfully to an instrument (the Agilent E4438C signal generator with ARB), but I can’t read them back. I’m using PyVISA and have installed the Agilent IO libraries. I have attached a script I created that illustrates the issue and a screenshot from the Agilent IO Monitor, which I will reference in the following paragraphs. You can see in lines 9-31 above that Python is being used to access the instrument. You should also be able to see in lines 9-19 that the command “RAD:ARB:STAT ON.n” (note the trailing period before the new line string) is written and a success is returned. I can also verify that the requested action is performed on the instrument. Lines 20-31 show what happens when I try to read back the status. The command “RAD:ARB:STAT?.n” is written, but the read times out as indicated in line 29. Lines 1-8 show the same sequence of actions using the interactive command utility provided with the Agilent Connection Manager. Note that these commands do not have the trailing period before the new line string, and both the write and read commands are executed successfully, and the read command returns the proper value “1n” indicating the status as “on.” It seems like the PyVISA implementation adds this trailing period before the new line string, which does not seem to affect write commands but might be affecting read commands. I’d appreciate any help or insight anyone might be able to provide. 附件
|
|
相关推荐
2个回答
|
|
您好***ennett_apl,我看到您正在使用套接字会话。
对于套接字会话,您需要为仪器手柄启用结束指示器。 您还需要将结束指示符分配给十进制10,即“ n”。 套接字会话是一个开放的管道,不提供类似于VXI-11协议的终端指示线。 当它从仪器中看到终止字符“ n”时,您需要告诉VISA会话终止读取。 连接 以上来自于谷歌翻译 以下为原文 Hi ***ennett_apl, I see that you are using a socket session. For socket sessions, you will need to enable the end indicator for your instrument handle. You will also need to assign the end indicator to decimal 10 which is a "n". Socket sessions are an open pipe and do not provide an end indicator line like that of the VXI-11 protocol. You will need to tell the VISA session to terminate reads when it sees the termination character "n" from the instrument. Connectivity |
|
|
|
schumi_LYQ 发表于 2019-5-21 06:37 试试这个 - 适用于MXG,所以应该适用于ESG-C - 简单的IDN IO通信....#------------------------- -------------------------------------------------- --- #File:MXG.py#作者:AMS#Rev:1-00#Date:13-05-06#状态:Beta#注:#代码片段显示IO通信与N5182B信号发生器##历史:# 1-00 12-05-05首次发布#--------------------------------------- ---------------------------------------#---------- -------------------------------------------------- ------------------#初始屏幕信息#--------------------------- -------------------------------------------------- - 打印'----------------------------------------------- - '打印'SIMPLE IO,带N5182B信号发生器'打印'文件:MXG.py'打印'Vers:1-00'打印'日期:13-05-06'打印''打印'1。 使用MXG'print'的简单IO通信------------------------------------------ ------'#------------------------------------------ ------------------------------------#静态参数#---------- -------------------------------------------------- ------------------ #IO参数#根据完整的VISA仪器地址#例如设置VISA地址 如果在GPIB上那么GPIB0 :: 19 :: inst0(或GPIB1 ......等)#addrSRC ='TCPIP0 :: 134.27.147.22 :: inst0'#MXG VISA地址addrSRC ='TCPIP0 :: 134.27.147.22 :: 5025: :SOCKET'TIMO = 5#IO超时5秒termChar =' n'#Terminionion字符#----------------------------- -------------------------------------------------# 加载库#----------------------------------------------- -------------------------------打印''打印'从签证导入中加载库......'从导入时间开始 ,睡觉,时钟打印'加载库....完成 n'#--------------------------------- ---------------------------------------------#Initialize MXG# - -------------------------------------------------- --------------------------- src = instrument(addrSRC)src.timeout = TIMO #set IO timeout src.term_chars = termChar #set termintaion character src.write('* cls')print'MXG IDN return: t t t%s'%(src.ask('* idn?')) 以上来自于谷歌翻译 以下为原文 Try this - works for an MXG, so should work for ESG-C - simple IDN IO comms.... # ------------------------------------------------------------------------------ # File: MXG.py # Author: AMS # Rev: 1-00 # Date: 13-05-06 # Status: Beta # Notes: # Code snippet to show IO commns with N5182B signal generator # # History: # 1-00 12-05-05 Initial release # ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------ # Initial screen info # ------------------------------------------------------------------------------ print '------------------------------------------------' print 'SIMPLE IO WITH N5182B SIGNAL GENERATOR ' print 'File: MXG.py' print 'Vers: 1-00' print 'Date: 13-05-06' print '' print '1. Simple IO comms with MXG' print '------------------------------------------------' # ------------------------------------------------------------------------------ # Static Parameters # ------------------------------------------------------------------------------ # IO Parameters # Set VISA address according to the full VISA instrument address # e.g. if on GPIB then GPIB0::19::inst0 (or GPIB1... etc) #addrSRC='TCPIP0::134.27.147.22::inst0' # MXG VISA address addrSRC='TCPIP0::134.27.147.22::5025::SOCKET' TIMO=5 # IO timeout 5 secs termChar='n' # Termintaion character # ------------------------------------------------------------------------------ # Load libraries # ------------------------------------------------------------------------------ print '' print 'Loading libraries...' from visa import * from time import time, sleep, clock print 'Loading libraries....donen' # ------------------------------------------------------------------------------ # Initialize MXG # ------------------------------------------------------------------------------ src=instrument(addrSRC) src.timeout=TIMO # set IO timeout src.term_chars=termChar # set termintaion character src.write('*cls') print 'MXG IDN return:tt%s' %(src.ask('*idn?')) |
|
|
|
只有小组成员才能发言,加入小组>>
1240 浏览 0 评论
2352 浏览 1 评论
2164 浏览 1 评论
2030 浏览 5 评论
2914 浏览 3 评论
983浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
713浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
813浏览 0评论
1240浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-29 20:06 , Processed in 1.555829 second(s), Total 51, Slave 43 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号