Controlling the Keithley 4200A-SCS Parameter Analyzer Using the External Control Interface (KXCI) and Python 3
APPLICATION NOTE
Introduction
The Keithley External Control Interface (KXCI) enables remote control of instrument modules within the Keithley 4200A-SCS Parameter Analyzer by sending commands from a PC. KXCI commands are specific to different instruments and include sets for SMUs, CVUs, PMUs/PGUs, and user libraries. These commands are sent to the KXCI User Interface on the 4200A-SCS for graphing results, logging commands, and displaying error messages.
A controlling PC can connect to the 4200A-SCS via GPIB or Ethernet to send KXCI commands using a coding environment. Visual Studio Code, combined with Python 3 and NI-VISA, offers a user-friendly environment for reading, writing, and querying KXCI commands for tests.
This application note guides users through setting up a PC and the 4200A-SCS for remote control using Visual Studio Code and Python, providing examples of Python scripts utilizing KXCI commands for test execution.
How to Set Up a PC to Send Remote Commands Using Python
For detailed instructions on setting up Python and Visual Studio Code for instrument control, refer to the guide "Getting Started with Instrument Control Using Python 3 – VS Code Revision," available in the Keithley GitHub folder. This guide covers the installation of Python, Visual Studio Code, and NI-VISA tools. It also provides a link to a Keithley file with wrapper functions for the PyVISA library, used to automate commands via the "instrcomms.py" library.
Follow the installation and setup instructions for these tools. This application note will then demonstrate how to write streamlined program examples for the 4200A-SCS.
How to Set Up the 4200A-SCS for Remote KXCI Commands Using Python on Ethernet
Figure 1 illustrates the back panel of the 4200A-SCS, with the Ethernet connection ports highlighted.
To begin, connect an Ethernet cable from the PC to the 4200A-SCS. On the 4200A-SCS, open the Keithley Configuration Utility (KCon) application to configure the communication type. Access the KXCI Settings in the upper right, as indicated in Figure 2.
Within the settings screen, select 'Ethernet' under the Communications section. Note the port number, as it will be used in the Python script for communication. Select 'String Terminator' as the Reading Delimiter and click 'OK'. Save and exit KCon. Ethernet commands require a NULL terminator, also known as the string terminator. Figure 3 displays the KXCI settings screen configured for an Ethernet connection.
Next, search for 'NI MAX' in the PC search bar. NI MAX, installed from the "Getting Started with Instrument Control Using Python 3 – VS Code Revision" document, is used for instrument control. Expand 'My System', then 'Devices and Interfaces', right-click on 'Network Devices', and select 'Create New VISA TCP/IP Resource...' as shown in Figure 4.
In the submenu, select 'Manual Entry of Raw Socket'. Enter the IP address of the 4200A-SCS and the Ethernet port number obtained from KCon's KXCI settings.
To find the 4200A-SCS IP address, open the Command Prompt (search for "cmd"), type ipconfig /all
, and press Enter. The 'IPv4 Address' is the relevant information, as shown in Figure 5.
After entering the IP address and port, click 'Validate'. Once communication is established, the 4200A-SCS VISA Resource Name will appear under 'Network Devices' in NI MAX, typically in the format "TCPIP0::XXX.XXX.XX.XXX::1225::SOCKET". Record this resource name for use in Python scripts.
Open the KXCI Interface application on the 4200A-SCS. As shown in Figure 6, the KXCI console will indicate that Ethernet communications have started.
The 4200A-SCS is now ready for communication via KXCI over Ethernet.
How to Set Up the 4200A-SCS for Remote KXCI Commands Using Python on GPIB
Figure 7 shows the back panel of the 4200A-SCS, highlighting the GPIB connection port.
To connect a PC to the 4200A-SCS using a GPIB cable, a GPIB to USB adapter is required if the PC lacks a GPIB port. The Keithley KUSB-488B adapter can be used for this purpose (Figure 8).
Drivers for the KUSB-488B must be installed. These drivers are available on the Tektronix website. Download the file, extract it, and run "KI-488.exe" as an administrator, following the on-screen instructions. This application note uses an NI Command Compatible driver version. Note that installing this driver might conflict with existing USB to GPIB converters, potentially requiring uninstallation of other drivers.
Connect the PC to the 4200A-SCS using the KUSB-488B adapter. Open the KCon application and navigate to the KXCI settings (refer to Figure 2). Select 'GPIB' under Communications. Note the GPIB address for communication with the 4200A-SCS. Set the reading; 'Comma' and enable 'EOI on'. Unlike Ethernet commands, GPIB commands do not require a NULL termina; r. Click 'OK', then save and exit KCon. The settings will resemble those in Figure 9.
After installing drivers and connecting the KUSB-488B, verify the connection using the KI-488 Diagnostic Tool, found by searching in the PC's search bar. Ensure the 'Instrument Address' in the tool matches the address set in KCon. Click 'Initialize KI GPIB' in the 'Communications Functions' section, as shown in Figure 10.
Within the KI-488 Diagnostic Tool, verify the 4200A-SCS connection via GPIB. To test the status, enter *IDN?
into the 'GPIB Command String;
Send or Transmit' box and click 'Send'. The response will appear in the 'GPIB Received Message' box, as illustrated in Figure 11. Once connected successfully, the KI-488 Diagnostic Tool can be closed.
Next, verify the 4200A-SCS in NI-VISA. Search for 'NI-VISA Interactive Control' and open it. Under 'Devices', locate 'GPIB Instrument Resources'. This section lists GPIB resources with strings like GPIB0::XX::INSTR
, where XX is the address set in KCon, as shown in Figure 12.
Note the resource string for Python script communication. NI-VISA Interactive Control can now be closed. The 4200A-SCS is ready for KXCI communication via GPIB.
Example 1: MOSFET Drain Family of Curves Using Ethernet
This example generates MOSFET drain family of curves on the 4200A-SCS KXCI interface, displaying ID-VD curves. The setup uses three Source Measure Units (SMUs): SMU1 connected to the Source, SMU2 to the Drain, and SMU3 to the Gate, as depicted in Figure 13.
Ensure KXCI Ethernet connections are configured in KCon as previously described. Before scripting, confirm a device is connected to the test fixture. Open Visual Studio Code, right-click in the Explorer pane, select 'New File', and name it, for example, family_of_curves_ethernet.py
. Ensure the instrcomms.py
file is in the project folder for proper import. SMU settings may need adjustment based on the specific MOSFET.
The Python script for this example is provided below:
import time
from instrcomms import Communications
term = '\0' # terminating character for ethernet commands
INST_RESOURCE_STR = "TCPIP0::169.254.88.169::1225::SOCKET" # instrument resource string, obtained from NI MAX
my4200 = Communications(INST_RESOURCE_STR) # opens the resource manager in PyVISA with the corresponding instrument resource string
my4200.connect() # opens connections to the 4200A-SCS
my4200.write("DE"+term)
my4200.write("CH1, 'VS', 'IS', 1, 3"+term)
my4200.write("CH2, 'VD', 'ID', 1, 1"+term)
my4200.write("CH3, 'VG', 'IG', 1, 2"+term)
my4200.write("SS"+term)
my4200.write("VR1, 0, 5, 0.1, 100e-3"+term)
my4200.write("VP2, 1, 4, 100e-3"+term)
my4200.write("VC1, 0, 100e-3"+term)
my4200.write("HT 0"+term)
my4200.write("DT 0.001"+term)
my4200.write("IT2"+term)
my4200.write("RS 5"+term)
my4200.write("RG 1, 100e-9"+term)
my4200.write("RG 2, 100e-9"+term)
my4200.write("RG 3, 100e-9"+term)
my4200.write("SM"+term)
my4200.write("DM1"+term)
my4200.write("XN 'VD', 1, 0, 5"+term)
my4200.write("YA 'ID', 1, 0, 0.04"+term)
my4200.write("MD"+term)
my4200.write("ME1"+term)
# wait for measurement to complete
status = my4200.query("SP"+term)
while int(status) != 1:
status = my4200.query("SP"+term)
time.sleep(1)
my4200.disconnect() # close communications with the 4200A-SCS
Table 1 lists the KXCI commands used, with descriptions. Non-KXCI commands in the script are commented for clarity. Each command includes the NULL termination character.
KXCI Command | Description |
---|---|
DE | Selects the channel definition page |
CH1, 'VS', 'IS', 1, 3 | Sets up SMU1 (CH1) to V source, constant function |
CH2, 'VD', 'ID', 1, 1 | Sets up SMU2 (CH2) to V source, sweep function |
CH3, 'VG', 'IG', 1, 2 | Sets up SMU3 (CH3) to V source, step function |
SS | Selects the source setup page |
VR1, 0, 5, 0.1, 100e-3 | Configures SMU1 to start sweep at 0V, stop at 5V, and step 0.1V with a compliance of 100mA |
VP2, 1, 4, 100e-3 | Configures SMU2 to step from 1V to 4V with a compliance of 100mA |
VC1, 0, 100e-3 | Configures SMU1 to output constant voltage of 0V with compliance of 100mA |
HT 0 | Sets a hold time of 0s |
DT 0.001 | Sets the time to wait between when the output voltage is set and when measurement is made in the sweep to 1ms |
IT2 | Sets the integration time to 1.0 PLC |
RS 5 | Sets the measurement resolution for all channels to 5 digits |
RG 1, 100e-9 | Sets lowest range of SMU1 to 100nA |
RG 2, 100e-9 | Sets lowest range of SMU2 to 100nA |
RG 3, 100e-9 | Sets lowest range of SMU3 to 100nA |
SM | Selects the measurement setup page |
DM1 | Prepares 4200A-SCS to receive graphics commands |
XN 'VD', 1, 0, 5 | Configures X-axis of graph to plot VD |
YA 'ID', 1, 0, 0.04 | Configures Y-axis of graph to plot ID |
MD | Selects the measurement control page |
ME1 | Runs a single trigger test and stores readings in cleared buffer 1 |
SP | Acquires the GPIB serial poll byte when ethernet communications are enabled. This returns 0 when the measurement is complete |
To execute the code, select 'Run Python File' in Visual Studio Code. Figure 14 shows the results on the KXCI interface, displaying the executed code on the left and the drain family of curves plotted on the right.
Example 2: MOSFET Drain Family of Curves Using GPIB
This example also generates MOSFET drain family of curves using the KXCI interface with the same circuit setup as Example 1 (Figure 13), but via a GPIB connection. Ensure KXCI GPIB connections are configured in KCon as previously described. In Visual Studio Code, create a new file (e.g., family_of_curves_gpib.py
). For GPIB commands, the terminating character is not required. The Python code can be copied and pasted, ensuring instrcomms.py
is in the project folder.
from instrcomms import Communications
INST_RESOURCE_STR = "GPIB0::17::INSTR" # instrument resource string, obtained from NI-VISA Interactive
my4200 = Communications(INST_RESOURCE_STR) # opens the resource manager in PyVISA with the corresponding instrument resource string
my4200.connect() # opens connections to the 4200A-SCS
my4200.write("DE")
my4200.write("CH1, 'VS', 'IS', 1, 3")
my4200.write("CH2, 'VD', 'ID', 1, 1")
my4200.write("CH3, 'VG', 'IG', 1, 2")
my4200.write("SS")
my4200.write("VR1, 0, 5, 0.1, 100e-3")
my4200.write("VP2, 1, 4, 100e-3")
my4200.write("VC1, 0, 100e-3")
my4200.write("HT 0")
my4200.write("DT 0.001")
my4200.write("IT2")
my4200.write("RS 5")
my4200.write("RG 1, 100e-9")
my4200.write("RG 2, 100e-9")
my4200.write("RG 3, 100e-9")
my4200.write("SM")
my4200.write("DM1")
my4200.write("XN 'VD', 1, 0, 5")
my4200.write("YA 'ID', 1, 0, 0.04")
my4200.write("MD")
my4200.write("ME1")
my4200.disconnect() # close communications with the 4200A-SCS
Table 1 lists the commands used. Unlike the Ethernet example, the SP command is not needed to wait for measurement completion. The results are visible on the KXCI interface upon execution, as shown in Figure 15.
Example 3: CVU GPIB Example
This example performs a capacitance-voltage (C-V) sweep on a MOSFET, outputting data to a CSV file. It uses a GPIB connection to send KXCI commands. Ensure KCon is configured for GPIB KXCI connections as described earlier.
The circuit diagram for this test is shown in Figure 16. The MOSFET's Gate terminal connects; HCUR/HPOT, while the Drain, Source, and Bulk terminals connect; LCUR/LPOT.
In Visual Studio Code's Explorer pane, create a new file, e.g., C_V_sweep_gpib.py
. Unlike previous examples using SMU commands, CVU commands do not directly output graphs to the KXCI interface. This example uses Microsoft Excel to plot data from an output CSV file. The Python code is provided below, and the instrcomms.py
file must be in the project folder.
import time
from instrcomms import Communications
import csv
INST_RESOURCE_STR = "GPIB0::17::INSTR" # instrument resource string, obtained from NI-VISA Interactive
my4200 = Communications(INST_RESOURCE_STR) # opens the resource manager in PyVISA with the corresponding instrument resource string
my4200.connect() # opens connections to the 4200A-SCS
my4200.write("DR1")
my4200.write(":CVU:RESET")
my4200.write(":CVU:MODE 1")
my4200.write(":CVU:MODEL 2")
my4200.write(":CVU:SPEED 2")
my4200.write(":CVU:ACZ:RANGE 0")
my4200.write(":CVU:FREQ 1E6")
my4200.write(":CVU:SWEEP:DCV 5, -5, -0.2")
my4200.write(":CVU:DELAY:SWEEP 0.1")
my4200.write(":CVU:TEST:RUN")
time.sleep(20) # time needed for test to finish
CpGp = my4200.query(":CVU:DATA:Z?") # queries readings of Cp-Gp
Volt = my4200.query(":CVU:DATA:VOLT?") # queries readings of Voltage
sep = ';' # separator between Cp-Gp
VoltList = Volt.split(',') # splits voltage list at commas
CpGpList = CpGp.split(',') # splits Cp-Gp list at commas
CapList = [] # list only for capacitance values
for z in CpGpList: # separates the Cp-Gp list into only the Cp values, by removing the value after the semi-colon
CapList.append(z.split(sep, 1)[0])
zipped_list = zip(VoltList, CapList) # creates iterable zipped list
columns = ['Voltage (V)', 'Capacitance (F)'] # column headers
with open('output.csv', 'w', newline='', encoding='utf-8') as f: # opens and writes csv file
writer = csv.writer(f)
writer.writerow(columns)
writer.writerows(zipped_list)
f.close() # close stream
my4200.disconnect() # close communications with the 4200A-SCS
The code retrieves test data, stores it in a Python list, and writes it to a CSV file using the csv
library. Table 2 details the KXCI commands used in this example.
KXCI Command | Description |
---|---|
DR1 | Enables service request for data ready |
:CVU:RESET | Resets CVU to default settings |
:CVU:MODE 1 | Sets CVU to system mode |
:CVU:MODEL 2 | Sets CVU to Cp-Gp model |
:CVU:SPEED 2 | Sets CVU to quiet speed mode |
:CVU:ACZ:RANGE 0 | Sets AC measurement range to auto |
:CVU:FREQ: 1E6 | Sets AC frequency to 1MHz |
:CVU:SWEEP:DCV 5, -5, -0.2 | Configures DC voltage sweep from 5V to -5V, with -0.2V steps |
:CVU:DELAY:SWEEP 0.1 | Sets sweep delay to 0.1s |
:CVU:TEST:RUN | Starts the CVU test |
:CVU:DATA:Z? | Queries the Z measurement, being Cp-Gp with this CVU model |
:CVU:DATA:VOLT? | Queries the voltage measurement on the CVU |
The command :CVU:DATA:Z?
queries the Z measurement. For model 2, this returns Cp-Gp measurements. The data format is Cp1;Gp1,Cp2;Gp2,...
. The Gp measurement is excluded, and only Cp values are retained. After executing the Python script, a CSV file is created containing data points for a capacitance and voltage plot. Figure 17 shows an example graph; it must be created manually in applications like Microsoft Excel.
A successful run displays measured values on the KXCI interface, aiding in test configuration verification, as shown in Figure 18.
Conclusion
The Keithley 4200A-SCS Parameter Analyzer is a powerful tool for automated testing. By using Python with Visual Studio Code and the KXCI interface, users can control instrument modules within the 4200A-SCS. For a comprehensive list of KXCI commands and their descriptions, refer to the document "Model 4200A-SCS KXCI Remote Control Programming."