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.

Python 3 Code

Post Reply
Posts: 1
Joined: July 21st, 2021, 10:58 am
Country: Germany

Python 3 Code

Post by ahmadattar32 » July 21st, 2021, 11:33 am

I am using Keithley_2750_DMM to measure the 4 wire resistance with 6 channels ,with 6 sample count

when i am trying to read the values ,but it is showing errors
does anybody wrote code in python to measure the 4 wire resistance
apparently the error comes out when I try to query any value for example print(inst.query(':READ?')

the code i am trying is

import pyvisa

rm = pyvisa.ResourceManager()

inst = rm.open_resource('ASRL1::INSTR')




inst.write(":FUNC "FRES" , (@101:106).;:FRES:RANG:AUTO ON")

inst.write("(@101:106).;:FRES:DIG 7 , (@101:106)")

inst.write(":FRES:OCOM ON , (@101:106)")

inst.write(":FRES:DCIR ON , (@101:106)")

inst.write("ROUT:SCAN (@101:106)")


inst.write("FORM:ELEM READ.;READ?")


thanks in advance

Andrea C
Keithley Applications
Keithley Applications
Posts: 1577
Joined: October 15th, 2010, 10:35 am
Country: United States

Re: Python 3 Code

Post by Andrea C » July 23rd, 2021, 7:41 am

I imagine you are getting syntax errors for a few of the commands (why the period in some of them?).

Also, to start a scan use the ':INIT' command rather than the ':READ?' command.

Try this:

Code: Select all

#define some parameters
dataElements = "TST, READ, CHAN"
number_data_elements_per_chan = len(dataElements)  #timestamp, reading and channel tag
chanList = "(@101:106)"  
number_channels_in_scan = 6
number_of_scans = 6
bufferSize = number_of_scans * number_channels_in_scan
debug = 1

cmd_list = ["*RST",
            "INIT:CONT OFF",
            "TRACE:POINTS " + str(bufferSize),
            "TRACE:FEED SENS",
            "TRACE:FEED:CONT NEXT",
            "FORM:DATA ASCII",
            "FORM:ELEM " + dataElements,
            "TRIG:COUN " + str(number_of_scans),
            "SAMP:COUN " + str(number_channels_in_scan),
            "TRIG:SOUR IMM",
            "ROUT:SCAN:TSO IMM",
            "FUNC 'FRES', " + chanList,
            "FRES:NPLC 1, " + chanList,
            "ROUT:SCAN " + chanList,
            "ROUT:SCAN:LSEL INT",
            "STAT:MEAS:ENAB 512",
            "*SRE 1",

for cmd in cmd_list:

print(my_instr.read())   #read the *OPC? response
print("*OPC received; finished setting up 2700....starting the scan")

#detect the scan is finished
#repeat until the SRQ bit is set
still_running = True
status_byte = 0

while still_running:
    status_byte = int(my_instr.query('*STB?'))
    if debug: print(status_byte)
    if (status_byte and 64) == 64:
         still_running = False
    time.sleep(0.250)  #250msec pause before asking again

print("Scan is done, status byte: " + str(status_byte))        

#read the data to this PC

#how many are in the buffer to send to us?
num_data_pts = my_instr.query(":TRAC:POINTS?")
print("Number of buffer pts: " + str(num_data_pts))  

#ask for all the data
raw_data = my_instr.query("TRAC:DATA?")

#split, parse, etc.
raw_data will be comma delimted string of 
timestamp, reading, chanTag, timestamp, reading, chanTag,... etc.
raw_data_array = raw_data.split(',')

Post Reply

Return to “Series 2700 Multimeter/Data Aquisition/Switch System”

Who is online

Users browsing this forum: No registered users and 4 guests