0

我正在尝试使用 Python 和 SCPI 命令设置和测量 Keysight N6701A 电源的输出电压。在控制台中,我可以看到命令发送成功,但它也告诉我电压仍然为 0。

编码:

import pyvisa
import visa
import time

rm = visa.ResourceManager()
print(rm.list_resources())
my_instrument = rm.open_resource('USB0::0x0957::0x0C07::MY54005240::INSTR')
#input()
print(my_instrument.query('*IDN?'))
time.sleep(1)
print(my_instrument.write("VOLT:LEV 4, (@1)"))
time.sleep(1)
print(my_instrument.write("VOLT:LEV 4, (@2)"))
time.sleep(1)
for i in range (0, 5):
    print("Channel 1: " + str(my_instrument.query_ascii_values("MEAS:VOLT? (@1)")))
    print("Channel 2: " + str(my_instrument.query_ascii_values("MEAS:VOLT? (@2)")))

控制台日志:

PS C:\Users\pfra\Desktop\01_Dev\Keysight_UI_Python> & python c:/Users/pfra/Desktop/01_Dev/Keysight_UI_Python/CalibrationScript.py
('USB0::0x0957::0x0C07::MY54005240::INSTR', 'TCPIP0::A-N6950A-00114.local::inst0::INSTR', 'TCPIP0::A-N6950A-00115.local::inst0::INSTR', 'TCPIP0::A-N6950A-00116.local::inst0::INSTR', 'TCPIP0::A-N6950A-00117.local::inst0::INSTR', 'TCPIP0::smbv100a257607::hislip0::INSTR', 'TCPIP0::smbv100a257607::inst0::INSTR', 'TCPIP0::smbv100a260402::hislip0::INSTR', 'TCPIP0::smbv100a260402::inst0::INSTR', 'ASRL1::INSTR', 'ASRL3::INSTR')
Agilent Technologies,N6701A,MY54005240,D.04.08

(18, <StatusCode.success: 0>)
(18, <StatusCode.success: 0>)
Channel 1: [-0.001918833]
Channel 2: [-0.0004460463]
Channel 1: [-0.001917686]
Channel 2: [-0.000448439]
Channel 1: [-0.001880813]
Channel 2: [-0.0004386235]
Channel 1: [-0.001835363]
Channel 2: [-0.0004804141]
Channel 1: [-0.001857561]
Channel 2: [-0.0004568406]

我查看了论坛并查阅了程序员参考指南,但我认为它应该按照我尝试的方式工作。有人知道可能出了什么问题吗?非常感谢和亲切的问候!

4

1 回答 1

0

我想通了...我没有打开输出-.-

命令应该是这样的:

print(my_instrument.write("OUTPut ON, (@1);VOLT:LEV 4,(@1)"))
于 2020-04-20T12:48:19.617 回答