Create New Cal Kit using SCPI

When creating new cal kits programmatically, the order in which cal kit commands are sent can be important.

For example to create a kit with opens, shorts, loads, and thrus. Be sure to use the following sequence for each newly defined standard.

  1. Programmatically select the standard number

  2. Programmatically select the standard type.  

  3. Program the cal standard's values.

  4. Repeat steps 1, 2, 3 for additional new standards being defined.

See Also

Python Basics

 

import pyvisa as visa

# Change this variable to the address of your instrument
VISA_ADDRESS = 'TCPIP0::localhost::inst0::INSTR'

# Create a connection (session) to the instrument

resourceManager = visa.ResourceManager()
session = resourceManager.open_resource(VISA_ADDRESS)
session.timeout = 25000             # Changed timeout to 25 seconds

# Helper functions

def Get_label():
    label = session.query("SENS:CORR:COLL:CKIT:STAN:LAB?")
    print(label)

def Get_std():
    type = session.query("SENS:CORR:COLL:CKIT:STAN:TYPE?")
    print(type)

def Print_connector():
    name = session.query("SENS:CORR:COLL:CKIT:CONN:SNAME?")
    print(name)

def Verify_std():
    label = session.query("SENS:CORR:COLL:CKIT:STAN:LAB?")
    print(label)

# Select the standard number
# Select the standard type
# Program the cal standard's values
# Repeat above steps for additional new standards being defined

calkitNum = int(session.query("SENS:CORR:CKIT:COUN?")) + 1
session.write(f"SENS:CORR:COLL:CKIT {calkitNum}")

# Name the kit with your name
session.write("SENS:CORR:COLL:CKIT:NAME 'Special 2.4 mm Model 85056'")

# Set up standard #1
print("Defining kit standard 1...")
session.write("SENS:CORR:COLL:CKIT:STAN 1")
session.write("SENS:CORR:COLL:CKIT:STAN:TYPE SHORT")
Get_std()
session.write("SENS:CORR:COLL:CKIT:STAN:CHAR COAX")
session.write("SENS:CORR:COLL:CKIT:STAN:LAB 'My Short'")
Get_label()

# Set up standard #2
print("Defining kit standard 2...")
session.write("SENS:CORR:COLL:CKIT:STAN 2")
session.write("SENS:CORR:COLL:CKIT:STAN:TYPE OPEN")
Get_std()
session.write("SENS:CORR:COLL:CKIT:STAN:CHAR COAX")
session.write("SENS:CORR:COLL:CKIT:STAN:LAB 'My Open'")
Get_label()

# Set up standard #3
print("Defining kit standard 3...")
session.write("SENS:CORR:COLL:CKIT:STAN 3")
session.write("SENS:CORR:COLL:CKIT:STAN:TYPE LOAD")
Get_std()
session.write("SENS:CORR:COLL:CKIT:STAN:CHAR COAX")
session.write("SENS:CORR:COLL:CKIT:STAN:LAB 'My Fixed Load'")
Get_label()

# Set up standard #4
print("Defining kit standard 4...")
session.write("SENS:CORR:COLL:CKIT:STAN 4")
session.write("SENS:CORR:COLL:CKIT:STAN:TYPE THRU")
Get_std()
session.write("SENS:CORR:COLL:CKIT:STAN:CHAR COAX")
session.write("SENS:CORR:COLL:CKIT:STAN:LAB 'My Thru'")
Get_label()

# Set up standard #5
print("Defining kit standard 5...")
session.write("SENS:CORR:COLL:CKIT:STAN 5")
session.write("SENS:CORR:COLL:CKIT:STAN:TYPE SLOAD")
Get_std()
session.write("SENS:CORR:COLL:CKIT:STAN:CHAR COAX")
session.write("SENS:CORR:COLL:CKIT:STAN:LAB 'Sliding Load'")
Get_label()


# Set up standard #6
print("Defining kit standard 6...")
session.write("SENS:CORR:COLL:CKIT:STAN 6")
session.write("SENS:CORR:COLL:CKIT:STAN:TYPE SHORT")
Get_std()
session.write("SENS:CORR:COLL:CKIT:STAN:CHAR COAX")
session.write("SENS:CORR:COLL:CKIT:STAN:LAB 'Short'")
Get_label()

# Set up standard #7
print("Defining kit standard 7...")
session.write("SENS:CORR:COLL:CKIT:STAN 7")
session.write("SENS:CORR:COLL:CKIT:STAN:TYPE SHORT")
Get_std()
session.write("SENS:CORR:COLL:CKIT:STAN:CHAR COAX")
session.write("SENS:CORR:COLL:CKIT:STAN:LAB 'Short'")
Get_label()

# Set up standard #8
print("Defining kit standard 8...")
session.write("SENS:CORR:COLL:CKIT:STAN 8")
session.write("SENS:CORR:COLL:CKIT:STAN:TYPE ARBI")
Get_std()
session.write("SENS:CORR:COLL:CKIT:STAN:CHAR COAX")
session.write("SENS:CORR:COLL:CKIT:STAN:TZR 15")
session.write("SENS:CORR:COLL:CKIT:STAN:TZI -9")
session.write("SENS:CORR:COLL:CKIT:STAN:LAB 'Z Load'")
Get_label()

# Remove old connector names
session.write("SENS:CORR:COLL:CKIT:CONN:DEL")

# Verify no connectors are currently installed'
emptyConn = session.query("SENS:CORR:COLL:CKIT:CONN:CAT?")
print(f"Verify empty list: {emptyConn}")

# Define new connectors

session.write("SENS:CORR:COLL:CKIT:CONN:ADD 'PSC 2.4', 0HZ, 999GHZ, 50.0, MALE, COAX, 0.0")
session.write(
"SENS:CORR:COLL:CKIT:CONN:ADD 'PSC 2.4', 0HZ, 999GHZ, 50.0, FEMALE, COAX, 0.0")

# Verify no connectors are currently installed'
newConn = session.query("SENS:CORR:COLL:CKIT:CONN:CAT?")
print(f"Verify new connectors: {newConn}")

# Set up Standard #1
print("Defining conn std 1...")
session.write("SENS:CORR:COLL:CKIT:STAN 1")
Verify_std()
session.write("SENS:CORR:COLL:CKIT:CONN:SNAM 'PSC 2.4',FEMALE,1")
Print_connector()

# Set up Standard #2
print("Defining conn std 2...")
session.write("SENS:CORR:COLL:CKIT:STAN 2")
Verify_std()
session.write("SENS:CORR:COLL:CKIT:CONN:SNAM 'PSC 2.4',FEMALE,1")
Print_connector()

# Set up Standard #3
print("Defining conn std 3...")
session.write("SENS:CORR:COLL:CKIT:STAN 3")
Verify_std()
session.write("SENS:CORR:COLL:CKIT:CONN:SNAM 'PSC 2.4',FEMALE,1")
Print_connector()

# Set up Standard #4
print("Defining conn std 4...")
session.write("SENS:CORR:COLL:CKIT:STAN 4")
Verify_std()
session.write("SENS:CORR:COLL:CKIT:CONN:SNAM 'PSC 2.4',FEMALE,1")
session.write("SENS:CORR:COLL:CKIT:CONN:SNAM 'PSC 2.4',MALE,2")
Print_connector()

# Set up Standard #5
print("Defining conn std 5...")
session.write("SENS:CORR:COLL:CKIT:STAN 5")
session.write(
"SENS:CORR:COLL:CKIT:STAN:LAB 'Sliding Load'")
Verify_std()
session.write("SENS:CORR:COLL:CKIT:CONN:SNAM 'PSC 2.4',MALE,1")
Print_connector()

# Set up Standard #6
print("Defining conn std 6...")
session.write("SENS:CORR:COLL:CKIT:STAN 6")
Verify_std()
session.write("SENS:CORR:COLL:CKIT:CONN:SNAM 'PSC 2.4',MALE,1")
Print_connector()

# Set up Standard #7
print("Defining conn std 7...")
session.write("SENS:CORR:COLL:CKIT:STAN 7")
Verify_std()
session.write("SENS:CORR:COLL:CKIT:CONN:SNAM 'PSC 2.4',MALE,1")
Print_connector()

# Set up Standard #8
print("Defining conn std 8...")
session.write("SENS:CORR:COLL:CKIT:STAN 8")
Verify_std()
session.write("SENS:CORR:COLL:CKIT:CONN:SNAM 'PSC 2.4',MALE,1")
Print_connector()

print("Class Assignments...")      # Designate the order associated with measuring the standards
# Set Port 1, 1st standard measured to be standard #2
session.write("SENS:CORR:COLL:CKIT:ORD1 2")
# Set Port 1, 2nd standard measured to be standard #1
session.write("SENS:CORR:COLL:CKIT:ORD2 1,6,7")
# Set Port 1, 3rd standard measured to be standard #3 and #5
session.write("SENS:CORR:COLL:CKIT:ORD3 3,5")
# Set Port 1, 4th standard measured to be standard #4
session.write("SENS:CORR:COLL:CKIT:ORD4 4")

# Set Port 2, 1st standard measured to be standard #2
session.write("SENS:CORR:COLL:CKIT:ORD5 2")
# Set Port 2, 2nd standard measured to be standard #1
session.write("SENS:CORR:COLL:CKIT:ORD6 1,6,7")
# Set Port 2, 3rd standard measured to be standard #3 and #6
session.write("SENS:CORR:COLL:CKIT:ORD7 3,5")
# Set Port 2, 4th standard measured to be standard #4
session.write("SENS:CORR:COLL:CKIT:ORD8 4")

# Set Port 1, 1st standard
session.write("SENS:CORR:COLL:CKIT:OLAB1 'MyOpen1'")
# Set Port 1, 2nd standard
session.write("SENS:CORR:COLL:CKIT:OLAB2 'MyShorts1'")
# Set Port 1, 3rd standard
session.write("SENS:CORR:COLL:CKIT:OLAB3 'MyLoads1'")
# Set Port 1, 4th standard measured to be standard #4
session.write("SENS:CORR:COLL:CKIT:OLAB4 'MyThrus1'")

# Set Port 2, 1st standard
session.write("SENS:CORR:COLL:CKIT:OLAB5 'MyOpen2'")
# Set Port 2, 2nd standard
session.write("SENS:CORR:COLL:CKIT:OLAB6 'MyShorts2'")
# Set Port 2, 3rd standard
session.write("SENS:CORR:COLL:CKIT:OLAB7 'MyLoads2'")
# Set Port 2, 4th standard
session.write("SENS:CORR:COLL:CKIT:OLAB8 'MyThrus2'")

print("Done")