1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我这里有一个E3646A电源,我想用RS-232接口编程。
到目前为止,在不同的仪器上,我一直在使用* OPC? 命令等待当前命令成功执行。 代码基本上可以归结为类似的东西(在Python中):*版本1:* s = serial.Serial('/ dev / ttyUSB0',stopbits = 2)s.write('VOLT 2 n')s。 write('* OPC? n')result = s.readline()但是,当我这样做时,仪器不返回任何数据(readline最终超时),当发送下一个命令时,仪器将报告错误 :-410,“Query INTERRUPTED”当我更改代码以包含命令之间的中断时,它确实有效,例如:* Version 2:* s.write('VOLT 2 n')sleep(0.2)s.write( * OPC? n')result = s.readline()但是,我不太喜欢这个解决方案,因为插入睡眠语句往往很脆弱,而且我已经发现某些命令需要更长的睡眠时间以便 * OPC? 被电源认可。 我还发现将命令连接到一行确实有效:*版本3:* s.write('VOLT 2; * OPC? n')result = s.readline()这对我来说有点奇怪 。 为什么我可以将命令链接在一条线上但不能直接相互发送。 所以我的问题是:1)这台仪器是否需要两个RS-232命令之间的时间延迟以及所需的值有多大,以便所有命令都能正常工作? 我发现文档中没有指定任何内容,除了它们似乎使用500毫秒的示例。 2)链接* OPC? 与本仪器一起使用同步RS-232时,与请求在同一行上的命令是首选方式。 遗憾的是,使用GPIB而不是RS-232不是我的选择。 以上来自于谷歌翻译 以下为原文 I have a E3646A power supply here that I want to program using the RS-232 interface. So far, on different instruments, I've been using the *OPC? command to wait until the current command has executed successfully. The code would basically boil down to something like this (in Python): *Version 1:* s = serial.Serial('/dev/ttyUSB0', stopbits=2) s.write('VOLT 2n') s.write('*OPC?n') result = s.readline() However, when I do this, the instrument does not return any data (readline eventually times out) and when the next command is sent the instrument will report an error: -410,"Query INTERRUPTED" It does work when I change the code to contain a break between the commands, e.g.: *Version 2:* s.write('VOLT 2n') sleep(0.2) s.write(*OPC?n') result = s.readline() However, I don't like this solution particularly much since inserting sleep statements tends to be brittle and I've already found that some commands require longer sleep periods in order for the *OPC? to be recognized by the Power Supply. I've also found that the concatenating the commands to one line does work: *Version 3:* s.write('VOLT 2;*OPC?n') result = s.readline() This seems a bit odd to me. Why can I chain the commands together on one line but not send them directly after one another. So my questions would be: 1) Does this instrument require a time delay between two RS-232 commands and how big is the value required so that all commands will definitely work? I've found nothing specified in the documentation except the examples where they seem to use 500ms. 2) Is chaining an *OPC? command on the same line as the request the preferred way when using synchronized RS-232 with this instrument. Using GPIB instead of RS-232 is not an option for me unfortunately. |
|
相关推荐
1个回答
|
|
好吧,我想我找到了解决方案。
使用DTR / DSR同步允许等到仪器准备再次接受数据的那一刻。 代码看起来像这样:s = serial.Serial('/ dev / tty.u***serial-A702XGUI',baudrate = 9600,stopbits = serial.STOPBITS_TWO,dsrdtr = True)s.write('VOLT 2 n')sleep (0.1)而不是s.getDSR():sleep(0.01)s.write('* OPC? n')result = s.readline()延迟是必需的,因为仪器没有立即拉低DSR线 ,这需要几毫秒。 然后,等到DSR再次变高,再次让我不再有中断查询或类似的错误。 我真的很想在手册中阅读类似的东西。 感谢python-ivi的作者,他的出色工作使我在这个问题上走上正轨。 以上来自于谷歌翻译 以下为原文 Alright, I think I found a solution. Using DTR/DSR synchronization allows to wait until the moment the instrument is ready to accept data again. The code looks somewhat like this: s = serial.Serial('/dev/tty.u***serial-A702XGUI', baudrate=9600, stopbits=serial.STOPBITS_TWO, dsrdtr=True) s.write('VOLT 2n') sleep(0.1) while not s.getDSR(): sleep(0.01) s.write('*OPC?n') result = s.readline() The delay is required because the DSR line is not immediately pulled low by the instrument, this requires a couple of ms. Afterwards, waiting until DSR goes high again yielded me no more errors with interrupted queries or similar. I'd really like to read things like that in a manual. Thanks to the author of python-ivi for his awesome work that got me on the right track for this problem. |
|
|
|
只有小组成员才能发言,加入小组>>
1283 浏览 0 评论
2371 浏览 1 评论
2189 浏览 1 评论
2062 浏览 5 评论
2946 浏览 3 评论
1104浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
751浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
922浏览 0评论
1284浏览 0评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 20:48 , Processed in 1.303872 second(s), Total 75, Slave 59 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号