# -*- coding: utf-8 -*- """ this is a small demo program to control an HP/Agilent/Keysight E3634A that performs the following: * Identify Instrument * set output voltage and current * enable output * readback current output voltage and current * disable output * read Instrument Errors """ import pyvisa as visa import time rm = visa.ResourceManager() psu=rm.open_resource('USB0::1003::8293::HEWLETT-PACKARD_E3634A_0_1.6-5.0-1.0::0::INSTR') print(psu.query('*IDN?')) psu.write('VOLT 5.0') psu.write('CURR 0.3') psu.write('OUTP ON') time.sleep(3) v_meas=psu.query('MEAS:VOLT?') i_meas=psu.query('MEAS:CURR?') print(f'V={v_meas.strip()} I={i_meas.strip()}') psu.write('OUTP OFF') inst_error='' while inst_error.strip() != '+0,"No error"': inst_error=psu.query('SYST:ERR?') print(inst_error) psu.close() rm.close()