Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

Problem in using python to communicate with 2651a

Model 2651A
Post Reply
Kuser2651a
Posts: 3
Joined: October 8th, 2012, 1:35 pm
Country: United States

Problem in using python to communicate with 2651a

Post by Kuser2651a » October 8th, 2012, 1:45 pm

I'm trying to query the 2651a through python / GPIB but am not successful.

I can, for example, set the voltage of the sourcemeter without problem. This works:
instrument.write("smua.source.levelv = 1")

However, when I try to query the voltage level with this line of code:
reading = instrument.ask("smua.measure.v()")

I get error code -420, Query UNTERMINATED

Is "smua.measure.v()" the right command to issue?

Dale C
Keithley Applications
Keithley Applications
Posts: 2845
Joined: June 10th, 2010, 6:22 am
Country: United States
Contact:

Re: Problem in using python to communicate with 2651a

Post by Dale C » October 9th, 2012, 6:04 am

Try the following commands...
smua.source.levelv=1
smua.source.output-smua.OUTPUT_ON
reading=smua.measure.v()
print("Voltage reading="..reading)

Kuser2651a
Posts: 3
Joined: October 8th, 2012, 1:35 pm
Country: United States

Re: Problem in using python to communicate with 2651a

Post by Kuser2651a » October 9th, 2012, 12:42 pm

I've tried the following:

instrument.write("smua.source.levelv = 1")
instrument.write("smua.source.output-smua.OUTPUT_ON")
reading = instrument.ask("reading=smua.measure.v()")

The first two commands work but not the last one. I still get error code -420, query UNTERMINATED.

Kenneth P
Keithley Applications
Keithley Applications
Posts: 212
Joined: October 25th, 2010, 1:31 pm
Country: United States
Contact:

Re: Problem in using python to communicate with 2651a

Post by Kenneth P » October 9th, 2012, 6:57 pm

You might want to try assigning the measurement string to a variable if your GPIB function call will allow and send as parameter:

WrtString='reading=smua.measure.v()'

prtStr = 'print(reading)'

gpib.send(instrAddr,WrtString)
gpib.send(instrAddr,prtStr)
ReadString = gpib.enter(instrAddr,256)

The GPIB .send and .enter functions are from a Keithley Python Library. In this case, the reading is assigned to a variable in the 2600A and then printed directly.

Kuser2651a
Posts: 3
Joined: October 8th, 2012, 1:35 pm
Country: United States

Re: Problem in using python to communicate with 2651a

Post by Kuser2651a » October 10th, 2012, 8:28 am

Thanks. Where can I download the Keithley python module? And are there any example python scripts showing how to use it?

Kenneth P
Keithley Applications
Keithley Applications
Posts: 212
Joined: October 25th, 2010, 1:31 pm
Country: United States
Contact:

Re: Problem in using python to communicate with 2651a

Post by Kenneth P » October 12th, 2012, 6:58 am

If I am not mistaken, your function call:
instrument.ask() is a GPIB query. You used with a source measurement function call. The reason why your syntax does not work is because the 2600A does not issue data on the GPIB in this fashion. Dale and I have noted in our examples that you must use the print() function call to return any information onto the GPIB.
You must first assign the measurement to a local variable within the 2600A and then use the print() fucntion to return the reading to the controller.

instrument.write("smua.source.levelv = 1")
instrument.write("smua.source.output-smua.OUTPUT_ON")
instrument.write("reading=smua.measure.v()")
reading = instrument.ask("print(reading)")

Again, I caution you in using ( and ) within a function. I don't know whether your library will handle this properly. I believe it will but if not, assign the strings with ( and ) to a local variable and using the variable as a parameter in your function calls. I.E.

PrtStr = "reading=smua.measure.v()"
instrument.write(PrtStr)

Post Reply

Return to “2651A High Current SourceMeter”

Who is online

Users browsing this forum: No registered users and 3 guests