# Xtralien Scientific Python: Current-Voltage Sweeps With The X100

A current-voltage (IV) sweep is a common measurement used to characterise semiconductor devices, such as photovoltaics (PVs) or light emitting diodes (LEDs). This tutorial will show you how to perform an IV sweep measurement using Xtralien Scientific Python and an Xtralien X100 Source Measure Unit (SMU).

An IV sweep is a series of measurements from one voltage to another, with several steps in between. The voltage choice will depend on the materials used and the device type that is being tested. For instance, a perovskite solar cell typically requires an IV sweep from 0 V to 1 V.

The full code is shown below. Download the IV Sweep Python Script here.

### 1.Sweep Settings ###
vstart = 0  #Starting Voltage (V)
vend = 1    #End Voltage (V)
vstep = 0.1 #Step Size (V)
smu = 'SMU1'

### 2.Create Variables ###
vnum = ((vend-vstart)/vstep) + 1 #Calculate number of steps in sweep
volts = linspace(vstart,vend,vnum) #Create voltage list
### 3. Perform Sweep ###
with X100.USB('COM1') as Dev1: #Connect to the Device via USB
results = vstack([Dev1[smu].oneshot(v) for v in volts]) #Create array of oneshots
print(results) # Print results

We will now break down the code and discuss what is happening in more detail.

### 1. Sweep Settings

Here we choose the settings of our sweep. This program only requires four choices to be made: starting voltage (vstart), end voltage (vend), voltage step size (vstep) and smu choice (smu).

The smu is either 'SMU1' or 'SMU2', depending on which source the device is connected to. The SMUs are labelled in the diagram below.

### 2. Create Variables

#### Calculate Measurement Number

The number of measurements (vnum) we take depends on the settings given in section 1. This can be determined by dividing the voltage range (vend - vstart) by (vstep).

In this example, the calculation would give (1 - 0) / (0.1) = 10.

A list of 10 values between 0 and 10 would give:

[ 0.00, 0.111, 0.222, 0.333, 0.444, 0.556, 0.667, 0.778, 0.889, 1.00 ]

Notice that the step size is 0.111 instead of the 0.1 that we wanted. This is because the vnum calculation gives a value of 10, even though we really need 11 steps between 0 and 10. To solve this problem, we use vnum+1 instead. This gives us the list we wanted:

[ 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]

#### Creating A Voltage List Using Linspace

The numpy linspace function creates a linear list of numbers. The arguments are (start number, end number, total numbers). For instance, linspace(0,50,6) would create this list:

[0, 10, 20, 30, 40 ,50]

We use this to create a list of voltages that we would like to apply during our sweep.

In this example, volts = linspace(vstart,vend,vnum) would create the list:

[ 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]

### 3. Perform Sweep

#### Connecting To The X100

This section is where the commands are sent to the X100 and data is received. First we must establish a connection with the board using with and the USB method. These are discussed in a previous tutorial.

#### Taking Measurements

The measurement commands for the X100 are explained in our Taking Measurements Tutorial.

The oneshot function sets a voltage of v and measures the voltage and current through the device. We use this and our list of voltages to perform the sweep.

Dev1[smu].oneshot(v) tells Dev1 to perform a single oneshot measurement on the chosen smu using voltage v.

A oneshot command returns data in the format [[voltage,current]].

The vstack command combines a series of arrays into a single, vertically stacked array. We can use this and a for loop to create an array of our measurements.

Combining these concepts, we create the line:

results = vstack([Dev1[smu].oneshot(v) for v in volts])

#### Printing The Array

Now that we have stored our sweep data in an array, we can simple use the print command to display the results.