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

2024-10-03 21:32:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将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.

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


Tags: rmsourcereaddatacurrentlistwrite电流
1条回答
网友
1楼 · 发布于 2024-10-03 21:32:50

我试图查找错误,并且能够在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?')

因为这可能会读得稍微快一点

相关问题 更多 >