The Keithley 2602B and 2636B source meter is controlled remotely with TSP (Test Script Processor) commands. TestFlow's instrument library holds 69 commands for it, 14 of them queries that read values or state, grouped below by subsystem with their arguments. It is the same library TestFlow's AI agent uses to drive the 2602B on a real bench.
With PyVISA, any VISA backend, and the instrument on USB, LAN or GPIB, this opens a session, identifies the instrument, sends one setting, and reads one value. Every command in it comes from the reference below. For a full walkthrough, see the PyVISA tutorial and the SCPI command cheat sheet.
import pyvisa
rm = pyvisa.ResourceManager()
print(rm.list_resources()) # find the Keithley 2602B's VISA address
# Paste the address of your Keithley 2602B (USB, LAN or GPIB).
inst = rm.open_resource("PASTE_VISA_ADDRESS_HERE")
inst.timeout = 5000 # ms
print(inst.query("*IDN?")) # identify the instrument
inst.write("smua.source.output = smua.OUTPUT_ON") # Turn On CHA
print(inst.query("print(smua.measure.v())")) # Measure Voltage CHA
inst.close()Describe the test in a sentence, for example “turn on cha on the 2602B, then measure voltage cha and log it against a limit”. TestFlow's agent builds the steps from this command library, runs them on your bench through the TestFlow desktop app, and writes the report from the measured values. See AI test automation for lab instruments for how that works and where it stops.
69 commands in 10 groups. A ? marks a query that returns a value. Placeholders in angle brackets take the listed values. The 2602B and 2636B share this command set in TestFlow's library.
| Command | What it does | Arguments |
|---|---|---|
| smua.source.output = smua.OUTPUT_ON | Turn On CHA. Enables the output of SMU channel A (TSP command). | None |
| smua.source.output = smua.OUTPUT_OFF | Turn Off CHA. Disables the output of SMU channel A (TSP command). | None |
| smua.source.func = smua.OUTPUT_DCVOLTS | Set Source Function Voltage CHA. Sets the source function of channel A to DC voltage. | None |
| smua.source.func = smua.OUTPUT_DCAMPS | Set Source Function Current CHA. Sets the source function of channel A to DC current. | None |
| smua.source.levelv = <Voltage> | Set Voltage Source CHA. Sets the output voltage level in volts on channel A. | Number |
| smua.source.leveli = <Amp> | Set Current Source CHA. Sets the output current level in amps on channel A. | Number |
| smua.source.rangev = <Range> | Set Source Voltage Range CHA. Sets the source voltage range in volts on channel A. | Number |
| smua.source.rangei = <Range> | Set Source Current Range CHA. Sets the source current range in amps on channel A. | Number |
| smua.source.autorangev = smua.AUTORANGE_ON | Source Voltage Autorange On CHA. Enables source voltage autorange on channel A. | None |
| smua.source.autorangev = smua.AUTORANGE_OFF | Source Voltage Autorange Off CHA. Disables source voltage autorange on channel A. | None |
| smua.source.limitv = <Voltage> | Set Voltage Compliance CHA. Sets the voltage compliance (limit) in volts on channel A. | Number |
| smua.source.limiti = <Amp> | Set Current Compliance CHA. Sets the current compliance (limit) in amps on channel A. | Number |
| smua.measure.rangev = <Range> | Set Measure Voltage Range CHA. Sets the voltage measurement range in volts on channel A. | Number |
| smua.measure.rangei = <Range> | Set Measure Current Range CHA. Sets the current measurement range in amps on channel A. | Number |
| smua.measure.autorangev = smua.AUTORANGE_ON | Measure Voltage Autorange On CHA. Enables voltage measurement autorange on channel A. | None |
| smua.measure.autorangev = smua.AUTORANGE_OFF | Measure Voltage Autorange Off CHA. Disables voltage measurement autorange on channel A. | None |
| smua.measure.nplc = <Cycles> | Set NPLC CHA. Sets the integration time in power line cycles on channel A. | Number |
| smua.sense = smua.SENSE_REMOTE | Set Four Wire On CHA. Enables 4-wire (remote sense) measurement on channel A. | None |
| smua.sense = smua.SENSE_LOCAL | Set Four Wire Off CHA. Disables 4-wire sense on channel A (uses 2-wire local sense). | None |
| smua.source.offmode = smua.OUTPUT_HIGH_Z | Set Output Off Mode Himp CHA. Sets the output-off state to high impedance on channel A. | None |
| smua.source.offmode = smua.OUTPUT_NORMAL | Set Output Off Mode Normal CHA. Sets the output-off state to normal on channel A. | None |
| smua.source.offmode = smua.OUTPUT_ZERO | Set Output Off Mode Zero CHA. Sets the output-off state to zero on channel A. | None |
| smua.measure.count = <Count> | Set Measure Count CHA. Sets the number of measurements made per trigger on channel A. | Number |
| smua.reset() | Reset Channel CHA. Resets channel A to its default settings. | None |
| Command | What it does | Arguments |
|---|---|---|
| smub.source.output = smub.OUTPUT_ON | Turn On CHB. Enables the output of SMU channel A (TSP command). | None |
| smub.source.output = smub.OUTPUT_OFF | Turn Off CHB. Disables the output of SMU channel A (TSP command). | None |
| smub.source.func = smub.OUTPUT_DCVOLTS | Set Source Function Voltage CHB. Sets the source function of channel A to DC voltage. | None |
| smub.source.func = smub.OUTPUT_DCAMPS | Set Source Function Current CHB. Sets the source function of channel A to DC current. | None |
| smub.source.levelv = <Voltage> | Set Voltage Source CHB. Sets the output voltage level in volts on channel A. | Number |
| smub.source.leveli = <Amp> | Set Current Source CHB. Sets the output current level in amps on channel A. | Number |
| smub.source.rangev = <Range> | Set Source Voltage Range CHB. Sets the source voltage range in volts on channel A. | Number |
| smub.source.rangei = <Range> | Set Source Current Range CHB. Sets the source current range in amps on channel A. | Number |
| smub.source.autorangev = smub.AUTORANGE_ON | Source Voltage Autorange On CHB. Enables source voltage autorange on channel A. | None |
| smub.source.autorangev = smub.AUTORANGE_OFF | Source Voltage Autorange Off CHB. Disables source voltage autorange on channel A. | None |
| smub.source.limitv = <Voltage> | Set Voltage Compliance CHB. Sets the voltage compliance (limit) in volts on channel A. | Number |
| smub.source.limiti = <Amp> | Set Current Compliance CHB. Sets the current compliance (limit) in amps on channel A. | Number |
| smub.measure.rangev = <Range> | Set Measure Voltage Range CHB. Sets the voltage measurement range in volts on channel A. | Number |
| smub.measure.rangei = <Range> | Set Measure Current Range CHB. Sets the current measurement range in amps on channel A. | Number |
| smub.measure.autorangev = smub.AUTORANGE_ON | Measure Voltage Autorange On CHB. Enables voltage measurement autorange on channel A. | None |
| smub.measure.autorangev = smub.AUTORANGE_OFF | Measure Voltage Autorange Off CHB. Disables voltage measurement autorange on channel A. | None |
| smub.measure.nplc = <Cycles> | Set NPLC CHB. Sets the integration time in power line cycles on channel A. | Number |
| smub.sense = smub.SENSE_REMOTE | Set Four Wire On CHB. Enables 4-wire (remote sense) measurement on channel A. | None |
| smub.sense = smub.SENSE_LOCAL | Set Four Wire Off CHB. Disables 4-wire sense on channel A (uses 2-wire local sense). | None |
| smub.source.offmode = smub.OUTPUT_HIGH_Z | Set Output Off Mode Himp CHB. Sets the output-off state to high impedance on channel A. | None |
| smub.source.offmode = smub.OUTPUT_NORMAL | Set Output Off Mode Normal CHB. Sets the output-off state to normal on channel A. | None |
| smub.source.offmode = smub.OUTPUT_ZERO | Set Output Off Mode Zero CHB. Sets the output-off state to zero on channel A. | None |
| smub.measure.count = <Count> | Set Measure Count CHB. Sets the number of measurements made per trigger on channel A. | Number |
| smub.reset() | Reset Channel CHB. Resets channel A to its default settings. | None |
| Command | What it does | Arguments |
|---|---|---|
| print(smua.source.output) | Read Output State CHA. Reads whether SMU channel A output is on or off. | None |
| print(smua.source.compliance) | Read Compliance Tripped CHA. Reads whether channel A is in compliance (limit reached). | None |
| print(smua.measure.v()) | Measure Voltage CHA. Triggers and returns the measured voltage in volts on channel A. | None |
| print(smua.measure.i()) | Measure Current CHA. Triggers and returns the measured current in amps on channel A. | None |
| print(smua.measure.r()) | Measure Resistance CHA. Triggers and returns the measured resistance in ohms on channel A. | None |
| print(smua.measure.p()) | Measure Power CHA. Triggers and returns the measured power in watts on channel A. | None |
| print(smub.source.output) | Read Output State CHB. Reads whether SMU channel A output is on or off. | None |
| print(smub.source.compliance) | Read Compliance Tripped CHB. Reads whether channel A is in compliance (limit reached). | None |
| print(smub.measure.v()) | Measure Voltage CHB. Triggers and returns the measured voltage in volts on channel A. | None |
| print(smub.measure.i()) | Measure Current CHB. Triggers and returns the measured current in amps on channel A. | None |
| print(smub.measure.r()) | Measure Resistance CHB. Triggers and returns the measured resistance in ohms on channel A. | None |
| print(smub.measure.p()) | Measure Power CHB. Triggers and returns the measured power in watts on channel A. | None |
| print(errorqueue.next()) | Read Error. Reads the next message from the error queue. | None |
| print(localnode.description) | Identify. Returns the instrument identification string. | None |
| Command | What it does | Arguments |
|---|---|---|
| beeper.beep(<Duration>, <Frequency>) | Beep. Sounds the beeper for the given duration and frequency. | Number; Number |
| Command | What it does | Arguments |
|---|---|---|
| reset() | Reset. Resets the entire instrument to its default state. | None |
| Command | What it does | Arguments |
|---|---|---|
| status.reset() | Clear Status. Clears all status registers and the error queue. | None |
| Command | What it does | Arguments |
|---|---|---|
| waitcomplete() | Wait To Continue. Waits until all overlapped operations are complete before continuing. | None |
| Command | What it does | Arguments |
|---|---|---|
| <Output Variable>=<Equation> | Math. Variable equals an equation like (${Var_name}= ${Var_name}/2) | Number; Text |
| Command | What it does | Arguments |
|---|---|---|
| wait(<ms>) | Wait. Waits for number of milliseconds | Number |
| Command | What it does | Arguments |
|---|---|---|
| save2var <Variable_name> | Save2Variable. Saves last measurement to a variable | Text |
This reference is generated from TestFlow's instrument library, which is drafted from Keithley's programming documentation for the 2602B and 2636B and checked when the agent runs it. Ranges, timing, and option-dependent commands are defined by Keithley's programming manual: check it before you rely on an edge case. Last updated June 18, 2026.
Yes. The Keithley 2602B is programmed with TSP (Test Script Processor) commands, a Lua-based command set, sent over USB, LAN or GPIB. TestFlow's library holds 69 TSP commands for it. Reading a value uses print(), for example print(smua.measure.v()).
Install PyVISA and a VISA backend, find the instrument's address with ResourceManager().list_resources(), open it, then send commands with write() and read values with query(). The example on this page sends *IDN?, smua.source.output = smua.OUTPUT_ON and print(smua.measure.v()).
print(smua.measure.v()) (measure voltage cha). Triggers and returns the measured voltage in volts on channel A. The full list of queries is in the command reference on this page, grouped by subsystem.
Yes. TestFlow is an AI agent for electronics testing: you describe the test, and it builds the automation from this command library, runs it on the Keithley 2602B through the TestFlow desktop app, and writes the report from the measured results.
Describe the test. TestFlow builds the workflow, runs it on your instruments, and writes the report. See it on a bench like yours.