我想通过RS232toUSB将Keithley 6485皮安表连接到我的Linux PC(CentOS 6.9)上,并用pyvisa用python编写代码(2.7.13版):
#! /usr/local/bin/python2.7
import sys
import visa
from visa import constants
rm = visa.ResourceManager('/usr/local/vxipnp/linux/lib64/libvisa.so')
#open serial connection and set baud to 9600, 8 data bits, CR termination, one stop bit, none parity, no flow control
amm = rm.open_resource('ASRL2::INSTR', baud_rate = 9600, data_bits = 8, write_termination= '\r', read_termination = '\r')
constants.VI_ASRL_STOP_ONE
constants.VI_ASRL_PAR_NONE
constants.VI_ASRL_FLOW_NONE
amm.write("*RST") # Return 6485 to RST default
amm.write("SYS:ERR:ALL?") # Return error message
amm.write("TRIG:DEL 0") # Set trigger delay to zero seconds
amm.write("TRIG:COUNT 2500") # Set trigger count to 2500
amm.write("SENS:CURR:RANG:AUTO OFF") # Turn auto range off
amm.write("SENS:CURR:NPLC .01") # Set integration rate to NPLC 0.01
amm.write("SENS:CURR:RANG 2e-7") # Use 200 nA range
amm.write("SYST:ZCH OFF") # Turn zero check off
amm.write("SYST:AZER:STAT OFF") # Turn auto zero off
amm.write("DISP:ENAB OFF") # Turn Display off
amm.write("*CLS") # Clear status model
amm.write("TRAC:POIN 2500") # Set buffer size to 2500
amm.write("TRAC:CLE") # Clear buffer
amm.write("TRAC:FEED:CONT NEXT") # Set storage control to start on next reading
amm.write("STAT:MEAS:ENAB 512") # Enable buffer full measurement event
amm.write("*SRE 1") # Enable SRQ on buffer full measurement event
amm.write("*OPC?") # operation complete query (synchronize completion of commands)
amm.write("INIT") # start taking and storing readings wait for GPIB SRQ line to go true
amm.write("DISP:ENAB ON") # Turn display on
print(amm.query_ascii_values("TRAC:DATA?")) # Request data from buffer
当我运行这个脚本时,我只得到“1”作为打印输出,尽管它应该以ASCII格式返回:Reading、Timestamp、Status和之后的错误消息amm.写入(“*RST”):-113未定义的标头。所以我认为这些信息没有正确传递。在
我知道在RS-232接口上,只允许使用ASCII格式。但是当我按照pyvisa instruction中的例子写ascii_值(文本,值)并给它分配一个列表时,我只从device-100命令错误中得到一条错误消息。在
有人能告诉我如何正确设置write_ascii_值中的变量,或者我做错了什么?我的串行设备设置错误吗?有时,当我执行2次时,我也会收到错误“VI\u error_ASRL_FRAMING(-1073807253):传输过程中发生了帧错误。”。我只是不知道该怎么办。在
谢谢你!在
谨致问候, 罗兰
SCPI有几个协议规则。希望我能引导你通过“查询”规则。在
如果向仪器询问查询,则必须读取缓冲区中的结果:
一旦你发送了“系统:错误:全部?”仪器希望你能读出结果。将其从write命令转换为查询,否则以下命令将出错并无法按预期执行:
^{pr2}$操作完成命令也是如此:
*OPC?将在上一个命令完成后返回“1”。在
相关问题 更多 >
编程相关推荐