[如何在测量期间将数据存储在Keithley2400缓冲区中并通过rs232进行检索?

问题描述 投票:0回答:1

我正在尝试将IV测量(源电流,感测电压)存储到Keithley2400缓冲区中,并将测量到的数据(电压和电流)检索到我的python程序变量'data'中。

rm = pyvisa.ResourceManager()
connected_list=rm.list_resources()
print(connected_list) # list[0] is RS-232 reference
Ki2400 = rm.open_resource(connected_list[0])
Ki2400.read_termination = '\r'
Ki2400.timeout=5000
print(Ki2400.query('*IDN?'))

Ki2400.write('*RST')
Ki2400.write(':sens:func:conc off')
Ki2400.write(':sour:func current')
Ki2400.write(":sens:func 'volt:dc'")
Ki2400.write(':SENS:VOLT:NPLC 0.01')
Ki2400.write(':sens:volt:prot 30')
Ki2400.write(':source:current:start 1e-12')
Ki2400.write(':source:current:stop 100e-3')
#Ki2400.write(':source:current:step 4e-4')
Ki2400.write(':source:sweep:points 500')
Ki2400.write(':source:current:mode sweep')
Ki2400.write(':sour:swe:rang auto')
Ki2400.write(':sour:swe:spac log')
Ki2400.write(':trig:coun 500')
Ki2400.write(':sour:del 0.1')
Ki2400.write('output on')
Ki2400.write('read?')
data=Ki2400.read()
Ki2400.write(':outp off')

但是这会产生以下错误:

VisaIOError: VI_ERROR_ASRL_OVERRUN (-1073807252): An overrun error occurred during transfer. A character was not read from the hardware before the next character arrived.

我不确定是否要对缓冲区中的存储进行编码并正确读取。任何帮助将不胜感激

python serial-port instruments visa pyvisa
1个回答
0
投票

我试图查找错误,并且能够在National Instruments' website上找到一些线程,并且看来您的缓冲区可能太小或读取速度不够快。 This thread from GitHub详细介绍了一些您可以用来增加缓冲区大小的方法,因此您需要:

from visa import constants
rm.visalib.set_buffer(Ki2400.session, constants.VI_IO_IN_BUF, 20)
rm.visalib.set_buffer(Ki2400.session, constants.VI_IO_OUT_BUF, 20)

在代码的顶部。或者,也许您可​​以更改

Ki2400.write('read?')
data=Ki2400.read()

进入

data = Ki2400.query('read?')

因为这可能会读得更快。

© www.soinside.com 2019 - 2024. All rights reserved.