Keithley2400_IV Sweep_VIA RS232 - 我想增加":FETCh"的大小?



我是Kwon,一名工科学生。我目前正在生产IV扫描从基斯利2400产品和Python通过rs232。在看手册的时候,我试图弥补各种错误,却陷入了死胡同。我将使用matplotlib绘制一个图,但是x值和y值的数量不正确。经过几次尝试,我发现"y值"被固定为5的大小。(当每个尺寸调整为5时,图表显示得很好。)手册内容如下:

"You can specify from one to all five elements."

请帮我增加':FETCh?,这样我就可以画一个图,把我输入的步骤联系起来。谢谢你看这么长的问题。

import sys
startv = sys.argv[1]
stopv = sys.argv[2]
stepv = sys.argv[3]
filename = sys.argv[4]
startvprime = float(startv)
stopvprime = float(stopv)
stepvprime = float(stepv)
steps = (stopvprime - startvprime) / stepvprime + 1
# Import PyVisa and choose RS-232 as Drain-Source
import pyvisa, time
import serial
rm = pyvisa.ResourceManager()
rm.list_resources()
with rm. open_resource('COM3') as Keithley:
Keithley.port = 'COM3'
Keithley.baudrate = 9600
Keithley.timeout = 25000

Keithley.open()
Keithley.read_termination = 'r'
Keithley.write_termination = 'r'
Keithley.write("*RST")
Keithley.write("*IDN?")

Keithley.write(":SENS:FUNC:CONC OFF")                  
Keithley.write(":SOUR:FUNC VOLT")                      
Keithley.write(":SENS:FUNC 'CURR:DC' ")                 

Keithley.write(":SOUR:VOLT:START ", startv)
Keithley.write(":SOUR:VOLT:STOP ", stopv)               
Keithley.write(":SOUR:VOLT:STEP ", stepv)              
Keithley.write(":SOUR:SWE:RANG AUTO")                   

Keithley.write(":SENS:CURR:PROT 0.1")                     
Keithley.write(":SOUR:SWE:SPAC LIN")                    
Keithley.write(":SOUR:SWE:POIN", str(int(steps)))      
Keithley.write(":SOUR:SWE:DIR UP")
Keithley.write(":TRIG:COUN", str(int(steps)))
Keithley.write(":FORM:ELEM CURR")

Keithley.write(":SOUR:VOLT:MODE SWE")                   
Keithley.write(":OUTP ON")                             

import numpy as np
result = Keithley.query(":READ?")                       
yvalues = Keithley.query_ascii_values(":FETCh?")
Keithley.write(":OUTP OFF")
Keithley.write(":SOUR:VOLT 0")

import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from scipy import stats
xvalues = np.arange(startvprime, stopvprime+1, stepvprime)  
plt.plot(xvalues, yvalues)
plt.xlabel(' Drain-Source Voltage (V)')
plt.ylabel(' Drain-Source Current (mA)')
plt.title('IV Curve')
plt.show()
np.savetxt(filename, (xvalues,yvalues))

error ex) python name.py -10 10 1 savename .py=比;ValueError: x和y必须具有相同的第一个维度,但具有形状(21,)和(5,)

你的代码中的值是什么?我认为yvalues的类型是字符串,因为pyvisa的query_ascii_values。

yvalues = [float(i) for i in Keithley.query_ascii_values(":FETCh?")]

同时,检查'steps'的值。

最新更新