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.
Basic SMU controlling is already supported, but no pulse mode available (PMU/RPM not existing yet)

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)

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
  • Util to export results to CSV, txt, BLOB
  • Util to save/export and load/import settings profiles
  • Export to XLSX
  • 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

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.1.1.tar.gz (27.7 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.1.1-py3-none-any.whl (36.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for py4200a-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b7243770f0a79137cdca0ac14c29029387cb2a53ebeb8ca5a5baa2002faf68f4
MD5 ee92dbab390e8189e4102cf0377b012e
BLAKE2b-256 5cac33ba3dd5d0b239435ecdbc37201e6d6c325f025f04bb36387d21df9e74e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py4200a-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 36.1 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c87c836689c3cd59499ea402a16ede784097ff56ea79a0dc0b3150e8c68895b9
MD5 115e0e4b7a47f1e29a348d566c8e1bb3
BLAKE2b-256 c9dd6453afecb87701842f98a19183c4f83d43d4bba122ccdade40e044799d48

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