-
RE: arbitrary current pulses using 2450
I have implemented the code below to generate the pulses. However, it is not accurate. I am exploring more accurate methods of generating the current pulses. Is it possible to write the data ( data in the .csv) into the internal memory of 2450 and use the internal timer to generate accurate pulse waveforms?
import pyvisa
import pandas as pd
import time
# Load CSV file
csv_file = 'C:/Users/Dalin EM/.spyder-py3/test1.csv'
df = pd.read_csv(csv_file)
# Extract current values
if 'Current' in df.columns:
currents = df['Current'].tolist() # List of currents in amperes
else:
currents = df.iloc[:, 0].tolist() # Assume single column if no header
# Connect to Keithley 2450
rm = pyvisa.ResourceManager()
resource_name = 'TCPIP0::10.0.0.38::5025::SOCKET'
instrument = rm.open_resource(resource_name)
instrument.timeout = 10000
instrument.read_termination = '\n'
instrument.write_termination = '\n'
try:
# Initialize instrument
instrument.write('*IDN?')
time.sleep(1)
print(f"Instrument ID: {instrument.read()}")
instrument.write(':SYST:CLE')
time.sleep(1)
instrument.write('*RST')
time.sleep(1)
instrument.write(':SOUR:FUNC CURR')
time.sleep(1)
instrument.write(':SOUR:CURR:RANG 0.001') # 1 mA range
time.sleep(1)
instrument.write(':SENS:FUNC "CURR"')
time.sleep(1)
instrument.write(':SOUR:CURR:VLIM 3')
time.sleep(1)
instrument.write(':SENS:CURR:RANG 0.001') # sense current range
time.sleep(1)
instrument.write(':OUTP ON')
time.sleep(1)
print(f"Error state: {instrument.query(':SYST:ERR?')}")
interval = 0.02
start_time = time.time()
for current in currents:
current_time = time.time()
elapsed_since_start = current_time - start_time
target_time = start_time + (interval * currents.index(current))
sleep_time = max(0, target_time - current_time)
if sleep_time > 0:
time.sleep(sleep_time)
print(f"Setting current to {current*1e6:.1f} µA")
instrument.write(f':SOUR:CURR:LEV {current}')
measurement = instrument.query(':READ?')
print(f"Measurement: {measurement}")
# Cleanup
instrument.write(':OUTP OFF')
instrument.write('*RST')
print(f"Final error state: {instrument.query(':SYST:ERR?')}")
except pyvisa.VisaIOError as e:
print("VI_ERROR_IO Details:", e)
except Exception as e:
print("Unexpected Error:", e)
finally:
try:
instrument.write(':OUTP OFF')
instrument.close()
except:
print("Failed to close connection cleanly") -
RE: arbitrary current pulses using 2450
Yeah, the duration is about 2sec to 4 sec. I am planning to use a step size of 50ms or 40 points. I want source current and measure it. Can you please provide pyvisa code or coding manual to accurately use the trigger or timer to program 2450. -
RE: arbitrary current pulses using 2450
Is it possible to load a .csv to 2450 using pyVISA to generate the current pulses? -
RE: arbitrary current pulses using 2450
I’ve attached an image of the simulated current pulses I want to generate using 2450. I'm using PyVISA to configure and automate the testing process. However, I'm currently encountering an issue when trying to set the protection limit.
Specifically, I'm receiving the following error:
Sending: :SENS:VOLT:PROT 5
Error state: -113,"Undefined header;1;2025/04/10 12:31:32.785"Below is the Python code I'm using:
import pyvisa
import timerm = pyvisa.ResourceManager()
resource_name = 'TCPIP0::10.0.0.38::5025::SOCKET'try:
print("Connecting to Keithley 2450...")
instrument = rm.open_resource(resource_name)
instrument.timeout = 10000
instrument.read_termination = '\n'
instrument.write_termination = '\n'print("Sending: *IDN?")
idn = instrument.query('*IDN?')
print(f"Instrument ID: {idn}")
print(f"Error state: {instrument.query(':SYST:ERR?')}")print("Sending: :SYST:CLE")
instrument.write(':SYST:CLE')
time.sleep(0.5)
print(f"Error state: {instrument.query(':SYST:ERR?')}")print("Sending: *RST")
instrument.write('*RST')
time.sleep(2)
print(f"Error state: {instrument.query(':SYST:ERR?')}")print("Sending: :SOUR:FUNC CURR")
instrument.write(':SOUR:FUNC CURR')
time.sleep(0.5)
print(f"Error state: {instrument.query(':SYST:ERR?')}")print("Sending: :SOUR:CURR:RANG 0.001")
instrument.write(':SOUR:CURR:RANG 0.001')
time.sleep(0.5)
print(f"Error state: {instrument.query(':SYST:ERR?')}")
print("Sending: :SOUR:CURR:LEV 0.0002")
instrument.write(':SOUR:CURR:LEV 0.0002')
time.sleep(0.5)
print(f"Error state: {instrument.query(':SYST:ERR?')}")print("Sending: :SENS:VOLT:PROT 5")
instrument.write(':SENS:VOLT:PROT 5')
time.sleep(1)
print(f"Error state: {instrument.query(':SYST:ERR?')}")
print("Sending: :SENS:FUNC VOLT")
instrument.write(':SENS:FUNC "VOLT"')
time.sleep(1)
print(f"Error state: {instrument.query(':SYST:ERR?')}")
print("Sending: :SENS:VOLT:RANG 5")
instrument.write(':SENS:VOLT:RANG 5')
time.sleep(1)
print(f"Error state: {instrument.query(':SYST:ERR?')}")
print("Sending: :OUTP ON")
instrument.write(':OUTP ON')
print("Sending: :Trigger ON")
instrument.write(':READ?')
time.sleep(20)
print("Sending: :OUTP OFF")
instrument.write(':OUTP OFF')
print("Sending: *RST")
instrument.write('*RST')
time.sleep(2)
print(f"Error state: {instrument.query(':SYST:ERR?')}")
except pyvisa.VisaIOError as e:
print("VI_ERROR_IO Details:", e)
except Exception as e:
print("Unexpected Error:", e)
finally:
try:
instrument.close()
except:
passrunfile('C:/Users/Dalin EM/.spyder-py3/test4.py', wdir='C:/Users/Dalin EM/.spyder-py3')
Connecting to Keithley 2450...
Sending: *IDN?
Instrument ID: KEITHLEY INSTRUMENTS,MODEL 2450,04434429,1.6.7c
Error state: 0,"No error;0;0 0"
Sending: :SYST:CLE
Error state: 0,"No error;0;0 0"
Sending: *RST
Error state: 0,"No error;0;0 0"
Sending: :SOUR:FUNC CURR
Error state: 0,"No error;0;0 0"
Sending: :SOUR:CURR:RANG 0.001
Error state: 0,"No error;0;0 0"
Sending: :SOUR:CURR:LEV 0.0002
Error state: 0,"No error;0;0 0"
Sending: :SENS:VOLT:PROT 5
Error state: -113,"Undefined header;1;2025/04/10 12:31:32.785"
Sending: :SENS:FUNC VOLT
Error state: 0,"No error;0;0 0"
Sending: :SENS:VOLT:RANG 5
Error state: 0,"No error;0;0 0"
Sending: :OUTP ON
Sending: :Trigger ON
Sending: :OUTP OFF
Sending: *RST
Error state: 2.189537E+00 -
arbitrary current pulses using 2450
Any idea, How to generate arbitrary current pulses using a 2450 Source Meter? Specifically, is it possible to import waveform shapes from a CSV file using TSP?
Thanks