Skip to content

Commit 76ff950

Browse files
cleanups
1 parent 07624dd commit 76ff950

13 files changed

Lines changed: 1266 additions & 187 deletions

Keithley_2400/Backends/IV_K2400_Loop_Backend_v10.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def IV_Measure(cur):
8686
sleep(1)
8787
current_values.append(cur * 1e-6) # Use the actual sourced value
8888
Volt.append(v_meas)
89-
print(f"{cur * 1e-6:.3e} A {v_meas:.4f} V")
89+
print(f"{cur * 1e-6:.3e} A {v_meas} V")
9090
i += 1
9191

9292
print("In loop 1")

Keithley_2400/RT_K2400_L350_T_Control_GUI_v3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def create_widgets(self):
303303
font_title_main = ('Segoe UI', self.FONT_BASE[1] + 4, 'bold')
304304
ttk.Label(
305305
header,
306-
text=f"K2400 & L350: R-T Sweep (T-Control)",
306+
text="K2400 & L350: R-T Sweep (T-Control)",
307307
style='Header.TLabel',
308308
font=font_title_main,
309309
foreground=self.CLR_ACCENT_GOLD).pack(

Keithley_2400/RT_K2400_L350_T_Sensing_GUI_v4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class RT_GUI_Passive:
185185

186186
def __init__(self, root):
187187
self.root = root
188-
self.root.title(f"K2400 & L350: R-T (T-Sensing)")
188+
self.root.title("K2400 & L350: R-T (T-Sensing)")
189189
self.root.geometry("1600x950")
190190
self.root.minsize(1400, 800)
191191
self.root.configure(bg=self.CLR_BG_DARK)

Keithley_2400_Keithley_2182/IV_K2400_K2182_GUI_v3.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def create_widgets(self):
291291

292292
ttk.Label(
293293
header,
294-
text=f"I-V Sweep (K2400 + K2182)",
294+
text="I-V Sweep (K2400 + K2182)",
295295
style='Header.TLabel',
296296
font=font_title_main,
297297
foreground=self.CLR_ACCENT_GOLD).pack(
@@ -565,8 +565,9 @@ def _measurement_worker(self):
565565
"""Worker thread function to perform the measurement."""
566566
try:
567567
current_setpoint = self.current_points[self.current_step_index]
568-
self.root.after(0, lambda: self.log(
569-
f"--- Setting current to {current_setpoint:.3e} A ({self.current_step_index + 1}/{len(self.current_points)}) ---"))
568+
log_msg = (f"--- Setting current to {current_setpoint:.3e} A "
569+
f"({self.current_step_index + 1}/{len(self.current_points)}) ---")
570+
self.root.after(0, lambda: self.log(log_msg))
570571
self.root.after(0, lambda: self.ax_main.set_title(
571572
f"Measuring at {current_setpoint:.3e} A..."))
572573
self.root.after(0, lambda: self.canvas.draw_idle())

Keithley_2400_Keithley_2182/RT_K2400_2182_L350_T_Sensing_GUI_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def create_widgets(self):
300300
header.pack(side='top', fill='x')
301301
ttk.Label(
302302
header,
303-
text=f"K2400/2182 & L350: R-T (T-Sensing)",
303+
text="K2400/2182 & L350: R-T (T-Sensing)",
304304
style='Header.TLabel',
305305
font=font_title_main,
306306
foreground=self.CLR_ACCENT_GOLD).pack(

Keithley_6517B/High_Resistance/Backends/IV_K6517B_Simple_Backend_v10.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def plot_results(data):
154154
print(f"Data saved successfully to '{filename}'")
155155

156156
except VisaIOError:
157-
print(f"\n[VISA Connection Error]")
157+
print("\n[VISA Connection Error]")
158158
print(f"Could not connect to the instrument at '{VISA_ADDRESS}'.")
159159
print("Please check the address, cable connections, and if the instrument is on.")
160160
except ValueError:

Keithley_6517B/High_Resistance/IV_K6517B_GUI_v11.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def initialize_instruments(self, parameters):
176176
except VisaIOError as e:
177177
print(f" [VISA Connection Error] Could not connect. Details: {e}")
178178
raise ConnectionError(
179-
f"Could not connect to Keithley 6517B.\nCheck address and connections.") from e
179+
"Could not connect to Keithley 6517B.\nCheck address and connections.") from e
180180
except Exception as e:
181181
print(f" [Unexpected Error] during initialization. Details: {e}")
182182
raise e
@@ -445,11 +445,12 @@ def create_info_frame(self, parent):
445445
justify='center')
446446

447447
institute_font = ('Segoe UI', self.FONT_SIZE_BASE + 1, 'bold')
448-
ttk.Label(
448+
info_label = ttk.Label(
449449
frame,
450450
text="UGC-DAE Consortium for Scientific Research",
451451
font=institute_font,
452-
background=self.CLR_BG_DARK).grid(
452+
background=self.CLR_BG_DARK)
453+
info_label.grid(
453454
row=0,
454455
column=1,
455456
padx=10,
Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,54 @@
11
# -------------------------------------------------------------------------------
22
# Name: Keithley 6517B Poling
3-
# Purpose:
4-
#
3+
# Purpose: Apply a poling voltage to a sample.
54
# Author: Prathamesh K Deshmukh
6-
#
75
# Created: 03-03-2024
8-
9-
# updates: V1.3
6+
# Updated: 22-11-2025 (Refactored for robustness)
107
# -------------------------------------------------------------------------------
118

129
import time
1310
from pymeasure.instruments.keithley import Keithley6517B
1411

1512

16-
try:
17-
keithley = Keithley6517B("GPIB0::27::INSTR")
18-
time.sleep(0.5)
19-
# keithley.apply_voltage() # Sets up to source current
20-
# keithley.source_voltage_range = 20 # Sets the source voltage
21-
# range to 200 V
22-
# keithley.source_voltage = 20 # Sets the source voltage to 20 V
23-
time.sleep(0.5)
24-
# keithley.enable_source() # Enables the source output
25-
time.sleep(0.5)
26-
keithley.source_voltage = 100
27-
# keithley.measure_resistance() # Sets up to measure resistance
28-
# keithley.ramp_to_voltage(10) # Ramps the voltage to 50 V
29-
# print(keithley.resistance) # Prints the resistance in Ohms
30-
time.sleep(20)
31-
print(f'Current is {(keithley.current)}')
32-
33-
# and disables outpu
34-
except Exception as e:
35-
print(f"error with Keithley6517B : {e}")
36-
37-
except KeyboardInterrupt:
38-
# keithley.source_voltage = 0 # Ramps the voltage to 50 V
39-
keithley.shutdown() # Ramps the voltage to 0 V
40-
print("\n Poling stopped...")
41-
42-
time.sleep(0.5)
43-
keithley.clear()
44-
time.sleep(0.5)
45-
keithley.reset()
46-
47-
keithley.shutdown() # Ramps the current to 0 mA and disables output
48-
49-
50-
except Exception as e:
51-
print(f"error with keithley : {e}")
52-
keithley.shutdown()
13+
def main():
14+
"""
15+
Connects to a Keithley 6517B, applies a fixed voltage for a duration,
16+
and then safely shuts down.
17+
"""
18+
keithley = None
19+
try:
20+
# Initialize and configure the instrument
21+
keithley = Keithley6517B("GPIB0::27::INSTR")
22+
time.sleep(0.5)
23+
24+
# Apply a poling voltage
25+
keithley.source_voltage = 100
26+
keithley.enable_source()
27+
print("Source enabled. Applying 100V for poling.")
28+
time.sleep(1)
29+
30+
# Wait for the poling duration, periodically checking current
31+
print("Waiting for poling to complete (20s)... Press Ctrl+C to stop early.")
32+
for i in range(20):
33+
time.sleep(1)
34+
# You can uncomment the next line to monitor current during poling
35+
# print(f" -> Time: {i+1}s, Current: {keithley.current:.3e} A", end='\r')
36+
37+
print(f"\nPoling complete. Final current: {keithley.current:.3e} A")
38+
39+
except KeyboardInterrupt:
40+
print("\nPoling stopped by user (Ctrl+C).")
41+
except Exception as e:
42+
print(f"An error occurred with the Keithley 6517B: {e}")
43+
finally:
44+
# Guaranteed shutdown logic
45+
if keithley:
46+
print("Ramping down voltage and shutting down source...")
47+
keithley.shutdown()
48+
print("Source is off.")
49+
# Optional: Reset the instrument to default state
50+
keithley.reset()
51+
52+
53+
if __name__ == "__main__":
54+
main()

0 commit comments

Comments
 (0)