Build an I-V curve tracer with a Keithley 2400 SourceMeter in Python

Build an I-V curve tracer with a Keithley 2400 SourceMeter in Python

View the app user interface

With this Dash DAQ application written in Python, you can create UI components to interface with a Keithley 2400 SourceMeter.  Our app will help you source and measure current and voltage, and design an I-V curve tracer.

We used PySerial and a GPIB-to-USB controller to allow Dash DAQ to interface with the Keithley 2400. But modules like PyVisa work as well, and RS232 interfacing is also possible.

Check out the online demo app, and keep reading to see how we made it!

The Dash DAQ app

Firstly, we’ll import the necessary Plotly and Dash libraries, as well as NumPy and keithley_instruments. This is a Python driver that we coded separately.

Creating the layout

The first thing we need to do is to create an instance of the instrument class:

Note that the if mock argument is set to True, no physical connection to the instrument will be attempted. This allows users to test the app without a live connection to the instrument.

If the instr_port_name argument is provided, the instrument will connect to this port. The design of a distinct driver for the instrument allows for separate testing and better modularity.

Here is what the app looks like:

The app layout contains a graph component from the dash_core_components package to plot the I-V curve. It also contains an invisible Interval component from the same package. For more detailed information about those components, please read the Dash core components webpage.

Directly to the right side of the graph are two Dash DAQ ToggleSwitch controls where the user can choose sourcing (voltage or current), and measurement mode (single measurement or sweep). As you can see in the demo app, the GUI will change in response to these inputs. There is also a dash DAQ StopButton component to clear the data displayed on the graph.

On the top right of the app is the section reserved for the connection to the instrument. The Dash DAQ PowerButton component is used to turn the layout on or off, in which case, most of the components are greyed out and the controls are disabled.

Users can input the port name of the GPIB or COM connection to the instrument. The “Connect” button will be enabled only if the port name is of the format “com[integer]” or “GPIB0::[integer]”. In the app, the name of the instrument will be displayed under the “Connect” button if the connection was successful.

Now let’s present the components below the graph area.

This Dash DAQ Knob component is used to adjust the value of the source, and the Dash DAQ LEDDisplay component below displays its actual value. It will not be set at the instrument before the user presses the “Single Measure” button, described below.

This is the view of the “Single measure mode”:

The “Sweep” mode, shown below, has three Dash DAQ PrecisionInput components which allow the user to define the sweep start, stop and step values. It also has a Dash DAQ NumericInput component to change the Interval time step, which varies the time spent on each step of the sweep. Finally, a Dash DAQ Indicator shows us when the sweep is on or not.

The hidden `Indicator` is useful to know if the “Single measure” button or “Sweep” button has been pressed or not.

Finally, the value which is sourced and the value which is measured are both displayed on the bottom right of the graph thanks to two LED display components.

As many elements have similar callbacks (for example, all the components which need to be greyed out when the power button is switched off), we decided to create a function to implements these callbacks using a for-loop:

One of the important callbacks changes the Interval component between the single measure and the sweep mode:

A measure is triggered when the “Single Measure” button is clicked, and a series of events happen: The source LED display is updated, which triggers the update of the measure LED display, which triggers a measure at the instrument level with the given source value. It then outputs the result and triggers the graph update.

In “sweep” mode, this scheme is repeated as long as the sweep indicator component is on (it is set to off, whenever the sourced value is equal to the stop value provided in the sweep controls described above.

With the power of Dash DAQ, you can reproduce hardware changes and create clean UI components in your lab, all in Python. The full source code for this app and the other example apps comes with the purchase of a Dash DAQ license!