IV_SWEEP
Python Code
import serial
import numpy as np
from flojoy import SerialConnection, flojoy, OrderedPair, Vector
from typing import cast
@flojoy(deps={"pyserial": "3.5"}, inject_connection=True)
def IV_SWEEP(
connection: SerialConnection, default: OrderedPair | Vector
) -> OrderedPair:
"""Take an I-V curve measurement with a Keithley 2400 source meter (send voltages, measure currents).
Inputs
------
default: OrderedPair | Vector
The voltages to send to the Keithley 2400 source meter.
Parameters
----------
connection: Serial
The open connection with the Keithley2400 source meter.
Returns
-------
OrderedPair
"""
# Start serial communication with the instrument
ser = cast(serial.Serial, connection.get_handle())
if ser is None:
raise ValueError("Serial communication is not open")
# Keithley 2400 Configuration
ser.write(b"*RST\n") # reinitialisation of the instrument
ser.write(
b":SOUR:FUNC:MODE VOLT\n"
) # Sourcing tension ser.write(b':SENS:FUNC "CURR"\n') # Measuring current
ser.write(
b":SENS:CURR:PROT 1.05\n"
) # Current protection set at 1.05A (Keithley 2400)
match default:
case OrderedPair():
voltages = default.y
case Vector():
voltages = default.v
currents_neg: list[float] = [] # measured currents
for voltage in voltages:
ser.write(b":SOUR:VOLT %f\n" % voltage) # Source Tension (V)
ser.write(b":OUTP ON\n") # Instrument output open
ser.write(b":INIT\n") # Start measuring
ser.write(b":FETC?\n") # Retrieve the measured values
current_str = ser.readline().decode("ascii").strip() # Save answers in a string
voltage_current_values = current_str.split(",") # Split the string
currents_neg.append(-float(voltage_current_values[1]))
ser.write(b":OUTP OFF\n") # Close output from Instrument
# Close Serial Communication
ser.close()
return OrderedPair(x=voltages, y=np.array(currents_neg))
Videos
Measure voltage from a solar panel using Flojoy
Example
In this example, we demonstrate how to record an I-V curve using Flojoy, a Keithley2400 source meter, and a computer. Fist you need to connect the Keithley2400 sourcemeter to the computer with a serial communication cable. Then, connect your device (Solar cell in this example) to the sourcemeter. After that you can prepare your flojoy app:
The LINSPACE
node defines the voltage range sent to the electronic device. The user defines the voltage range by setting these parameters with Numeric Input:
- LINSPACE START: Define your first Voltage.
- LINSPACE END: Define your last Voltage.
- LINSPACE STEP: Define the number of voltages between the first and the last one.
The KEITHLEY2400
node will communicate with the source meter by serial communication to send voltages and measure currents from the device.
The connection must first be opened using the OPEN_KEITHLEY_24XX
node, which has two communication parameters set by the user after connecting the Keithley2400 to their computer:
- DEVICE: Select the serial device that corresponds to the Keithley2400.
- BAUDRATE: Define the Baud rate of your communication protocol (the default is 9600, the value has to correspond to the Instrument settings).
The LINE
node will display the I-V curve by plotting the currents received from the device as a function of the voltages transmitted to the device.
When the setup is ready, and the parameters above are well defined, the experiment can be started by turning on the source meter and clicking the PLAY button.