Skip to main content

Python interface for Keithley 4200A-SCS Semiconductor Characterization System through KXCI

Project description

Py4200A

[!NOTE] This project is not complete yet, work in progress.
Currently supported features : SMU usage, PMU/RPMs usage, result fetching

py4200A is a python library that provides support for controlling the Keithley Instrument 4200A SCS.
The library is object oriented, to make it easy to use. It translates settings to instructions for KXCI.
Made in collaboration with the USAL (University of SALamanca) in Salamanca, Spain.

Install

The py4200A library is available on PyPi, the main pip package repository. This way, you an simply install it in your python virtual env using :

pip install py4200A

If you have NI-VISA (or another vendor VISA library) already installed on your system, this is all you need.

If you are on Linux or don't have a vendor VISA (e.g. using linux-gpib), add the optionnal Python VISA backend:

pip install py4200A[visa-py]

[!IMPORTANT] Linux users
You will need a GPIB backend if you want to use GPIB. I would recommend doing a proper linux-gpib installation beforehand. Make sure your installation of 'linux-gpib' works before opening an issue. You can use the ibtest tool installed with 'linux-gpib' to test GPIB connection (run as sudo)

If you run on Linux, only the root user (and through the sudo command) will be able to access your GPIB ports.
Run the AddUserPermissions.sh script to create (and join) a group that has permission to use the GPIB devices without using sudo. This will allow you to run your scripts and also the ibtest tool without sudo.

How to use

KI 4200A Configuration

KXCI takes full controll of the intrument. This means it cannot run alongside other programs like Clarius on the Keithley.

  1. Power on the Keithley 4200A SCS;
  2. Close Clarius, or any other software that is open;
  3. Open KCon -> KXCI Config;
  4. Choose your string delimiter, connection mode (GPIB or TCPIP), GPIB port, etc.
  5. Make sure the channel numbers are in order and not duplicate;
  6. Close KCon;
  7. Start KXCI.

Wiring

GPIB

Using a GPIB to USB National Instrument cable (worth 1.5k€), you can just connect your computer to the Keithley. Your computer will make a new virtual GPIB interface you can use.

TCPIP

The Keithley documentation specifies that the TCPIP communcation for the 4200A cannot work by just wiring you PC's eth to the Keithley's. It is said that both devices have to be on the same network, equipped with a router of some kind.
I have yet to confirm if the real requirement would just be to have a DHCP server on the PC, or maybe set a static IP. But I'm pretty sure this is not a real limitation.

[!WARNING] In the Keithley's network settings, make sure that the connected network is in "Private" mode and not "Public" mode. In public mode, the Keithley will not accept incoming packets nor pings. You will need admin access though.

Code

In Python, import the lib to use it. You can choose to either manually control the device in real time, or pre-programm it to run with settings.
Using pre-programmed (normal) mode, performance is way better than realtime manual control. The below examples are doing the exact same gate test on a MOSFET type component :

  • Component : HEF4007UBP
  • Ground : pin 7 (Vss)
  • Gate : pin 6 (G)
  • Source : pin 8 (D)

Results :

  • Normal mode : 101.2s
  • Realtime mode : 408.9s

Normal mode is ~4 times faster for this test.

[!WARNING] This script must be run with root privilege to be able to access the GPIB0 interface

Normal (pre-programmed)

import py4200A
from py4200A import KI4200A
import time

#> Connecting to the Keithley
# INST_RESOURCE_STR = "TCPIP0::192.0.2.0::1225::SOCKET"
INST_RESOURCE_STR = "GPIB0::17::INSTR"

ki4200: KI4200A = KI4200A(INST_RESOURCE_STR)
ki4200.reset()

#> Getting the SMUs
source = ki4200.getSMU(3)
gate = ki4200.getSMU(2)
unused = ki4200.getSMU(1)
unused.deactivate()

#> Configure the SMUs
gate.setupSMU("VGT", "IGT", py4200A.consts.SourceType.VOLT, py4200A.consts.SourceFunction.STEP)
gate.setStepFunction(start=0, stop=5, step=1, compliance=0.1)

source.setupSMU("VSRC", "ISRC", py4200A.consts.SourceType.VOLT, py4200A.consts.SourceFunction.SWEEP)
source.setSweepFunction(py4200A.consts.SweepType.LINEAR, start=0, stop=15, step=0.1, compliance=0.05)

#> Configure the display
ki4200.display.displayGraph(x=source.voltage_measurement, y1=source.current_measurement) # x= time, y1 = gateV, y2 = srcV

#> Run and wait for test
print("Starting test.")
t_start = time.time()
ki4200.runSmuTest()
ki4200.waitForDataReady()

#> Collect results as a BlobDependent
result: py4200A.results.BlobDependent = ki4200.makeDependentFrom(
    data=source.current_measurement,
    params=[source.voltage_measurement, gate.voltage_measurement],
)

print(f"Done. ({time.time() - t_start:.1f}s)")

ki4200.disconnect()

You can display (plot) the graph on your computer by adding these few lines :

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt

#> Plot ISRC vs VSRC, one curve per VGT value
colors: list[str] = ["red", "green", "blue", "magenta", "yellow", "cyan"]
vgt_values = result.parameters["VGT"]
vsrc_values = result.parameters["VSRC"]

fig, ax = plt.subplots()
for i, vgt in enumerate(vgt_values):
    ax.plot(vsrc_values, result.value[i, :], color=colors[i % len(colors)], label=f"Gate = {vgt:.2f} V")

ax.set_xlabel("Vsource (V)")
ax.set_ylabel("Isource (A)")
ax.legend()
plt.tight_layout()
plt.show()

Realtime

from py4200A import realtime
import numpy as np
import time

#> Connecting to the Keithley
# INST_RESOURCE_STR = "TCPIP0::192.0.2.0::1225::SOCKET"
INST_RESOURCE_STR = "GPIB0::17::INSTR"

rt: realtime.RT_KI4200A = realtime.RT_KI4200A(INST_RESOURCE_STR)

#> Getting the SMUs
source = rt.getSMU(3)
gate   = rt.getSMU(2)
unused = rt.getSMU(1)
unused.deactivate()
rt.userMode()

#> Define sweep ranges
vgt_values  = np.linspace(0, 5,  6)    # 0, 1, 2, 3, 4, 5 V
vsrc_values = np.linspace(0, 15, 151)  # 0 to 15 V, step 0.1 V
results     = np.zeros((len(vgt_values), len(vsrc_values)))

#> Run the sweep
print("Starting test.")
t_start = time.time()
for i, vgt in enumerate(vgt_values):
    gate.setVoltageOutput(float(vgt), compliance=0.1)
    for j, vsrc in enumerate(vsrc_values):
        source.setVoltageOutput(float(vsrc), compliance=0.05)
        results[i, j] = source.measure_current()
print(f"Done. ({time.time() - t_start:.1f}s)")

rt.disconnect()

You can display (plot) the graph on your computer by adding these few lines :

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt

#> Plot ISRC vs VSRC, one curve per VGT value
colors: list[str] = ["red", "green", "blue", "magenta", "yellow", "cyan"]

fig, ax = plt.subplots()
for i, vgt in enumerate(vgt_values):
    ax.plot(vsrc_values, results[i, :], color=colors[i % len(colors)], label=f"Gate = {vgt:.2f} V")

ax.set_xlabel("Vsource (V)")
ax.set_ylabel("Isource (A)")
ax.legend()
plt.tight_layout()
plt.show()

Roadmap

  • Connection to KI4200A-SCS through PCIB or TCPIP
  • Perform basic instruction to get Model and SN from KXCI
  • Listing of all the boards available
  • Correctly type the boards
  • Send basic setting instructions to SMUs
  • Allow test execution
  • Basic result retrieval
  • Analysis and plotting
  • Publish on PyPi
  • PMU RMP commands
  • Matlab wrapper
  • Full instruction dictionnary capabilities

Contribute

If you are not a developer, or do not wish to publish code, feel free to open an issue. I will review and get to work on it as soon as possible. Please understand that it may take some time though, as I am currently the only maintainer and have other things to do in life.
Feel free to open pull request. I will review each one, making sure it is properly documented, properly commented, and really brings something to the table. Check existing file for documentation example. Typing and using PyLint in "strict" mode will also be required
Garbage AI-generated spaghetti code (also know as "vibe coding") will be rejected. I have nothing against good and proper usage of AI tools though. Simply keep your code relevant and readable.

See also

MATLAB wrapper - A Matlab project to wrap this library and use it "natively".
instrcom.py - Sample file from Tektronix under a very permissive license.
linux-gpib - GPIB driver I'm using on my Linux (Ubuntu) laptop.
PyVISA - Python library to communicate with a device via most interfaces through VISA.
PyVISA-py - Replaces proprietary VISA libraries with a python implementation.
USAL - The university that works on this project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py4200a-0.2.5.tar.gz (33.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py4200a-0.2.5-py3-none-any.whl (42.6 kB view details)

Uploaded Python 3

File details

Details for the file py4200a-0.2.5.tar.gz.

File metadata

  • Download URL: py4200a-0.2.5.tar.gz
  • Upload date:
  • Size: 33.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for py4200a-0.2.5.tar.gz
Algorithm Hash digest
SHA256 caa07094098ee9e39e4a03b239927ce4f671dfd3f64adb544075d4a5dceaa8a4
MD5 427541a2b421680140b0e9ef7f1affb1
BLAKE2b-256 76208d6f77e1a969bf9827d47dc7b7dc57c8d2b2f32d085056f024c3a534980d

See more details on using hashes here.

File details

Details for the file py4200a-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: py4200a-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 42.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for py4200a-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3e936c4293777fbdd6519f412913129f16343290c8a5e68dd719058ca710635c
MD5 a1f8a68226e4862129acd251a818e7cf
BLAKE2b-256 b2a701c8cfc877200dd86d0d31567a1983b66d037b93d7dad9ee060215ee5abf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page