Untitled
Anonymous
plain_text
02/25/2026 12:21 AM
1.6 KB
14
Indexable
import csv
import time
from pymeasure.instruments.keithley import Keithley2400
# ---- Connect ----
keithley = Keithley2400(
"USB0::0x05E6::0x2450::04564746::INSTR",
write_termination="\n",
read_termination="\n"
)
# Use rear terminals if that’s how you're wired
keithley.use_front_terminals()
# ---- Configure Source (Voltage) ----
keithley.apply_voltage(voltage_range=2, compliance_current=0.01)
keithley.source_voltage = 1
keithley.enable_source()
# ---- Configure Resistance Measurement ----
keithley.wires = 4 # Use 4-wire if Kelvin leads
keithley.measure_resistance(nplc=1)
# ---- Measurement Loop ----
data = []
print("Starting measurement...")
for i in range(50):
resistance = keithley.resistance
voltage = keithley.source_voltage
timestamp = time.time()
print(f"{i}: V={voltage:.3f} V R={resistance:.6f} Ohm")
data.append([timestamp, voltage, resistance])
# ---- Save to CSV ----
with open("resistance_data.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["Timestamp", "Voltage (V)", "Resistance (Ohms)"])
writer.writerows(data)
# ---- Safe Shutdown ----
keithley.shutdown()
print("Done. Data saved to resistance_data.csv")
Editor is loading...
Leave a Comment