Nikita Belooussov
Nikita Belooussov

Reputation: 606

Pyvisa timing out with a Keysight power generator

I am trying to read back the values that the Keysight generator has measured during the sampling period, but I keep getting a time out error:

pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): 
Timeout expired before operation completed.

I am able to read in other data such as the IDN, so I dont think it is an error with the termination signal, I have been using this to get my commands from: http://literature.cdn.keysight.com/litweb/pdf/N6705-90001.pdf The part I was looking at is from page 162 to page 168. Here is my code the first part gets the IDN and reads off the voltage and current fine, it is the part after the measurements comment that seems to be not working. Thank you in advance.

#request info from keysight power generator
print(keysight.query("*IDN?"))
#set voltage, current and turn on otuput
keysight.write("VOLT 10, (@1)")
keysight.write("CURR 1, (@1)")
keysight.write("OUTP ON,(@1)")
#read current volt and curr
print(keysight.query_ascii_values("MEAS:VOLT? (@1)"))
print(keysight.query_ascii_values("MEAS:CURR? (@1)"))
#sets a limit on current and voltage
keysight.write("CURR:LIM .5, (@1)")
keysight.write("VOLT:LIM 30, (@1)")
#measurments
keysight.write("SENS:FUNC:VOLT ON,(@1)")
keysight.write("SENS:SWE:TINT RES1000,(@1)")
keysight.write("SENS:SWE:POIN 500,(@1)")
keysight.write("SENS:SWE:OFFS:POIN 10,(@1)")
keysight.write("INIT:ACQ (@1)")
time.sleep(1)
keysight.write("TRIG:ACQ (@1)")
time.sleep(1)
keysight.write("VOLT 1, (@1)")
time.sleep(1)
keysight.write("VOLT 2, (@1)")
time.sleep(1)
keysight.write("VOLT 3, (@1)")
time.sleep(1)
keysight.write("VOLT 4, (@1)")
time.sleep(1)
keysight.write("VOLT 5, (@1)")
time.sleep(1)
keysight.write("ABOR:ACQ(@1)")
print(keysight.query_ascii_values("FETC:VOLT:MAX?(@1)"))
time.sleep(.5)

Upvotes: 1

Views: 1037

Answers (1)

Nikita Belooussov
Nikita Belooussov

Reputation: 606

Turns out it was spacing problems, here is the code now:

#request info from keysight power generator
print(keysight.query("*IDN?"))
#set voltage, current and turn on otuput
keysight.write("*RST")
keysight.write("VOLT 3, (@1)")
keysight.write("CURR 1, (@1)")
keysight.write("OUTP ON,(@1)")
#read current volt and curr
print(keysight.query_ascii_values("MEAS:VOLT? (@1)"))
print(keysight.query_ascii_values("MEAS:CURR? (@1)"))
#sets a limit on current and voltage
keysight.write("CURR:PROT:STAT .5, (@1)")
keysight.write("VOLT:PROT 30, (@1)")
#measurments
keysight.write("SENS:FUNC:VOLT ON,(@1)")
#keysight.write("SENS:FUNC:CURR ON,(@1)")
keysight.write("SENS:SWE:TINT .001,(@1)")
keysight.write("SENS:SWE:POIN 5000,(@1)")
keysight.write("INIT:ACQ (@1)")
keysight.write("TRIG:ACQ (@1)")
keysight.write("VOLT 1, (@1)")
time.sleep(1.2)
keysight.write("VOLT 2, (@1)")
time.sleep(1)
keysight.write("VOLT 3, (@1)")
time.sleep(1)
keysight.write("VOLT 4, (@1)")
time.sleep(1)
keysight.write("VOLT 5, (@1)")
time.sleep(1)
print "\n\n"
time.sleep(5)
x=keysight.query_ascii_values("FETC:ARR:VOLT? (@1)")
print x

Upvotes: 1

Related Questions