Skip to content

Commit 9848eac

Browse files
Removed the hardcoded path from K2400 IC
1 parent 9e7a6e8 commit 9848eac

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

Keithley_2400/Instrument_Control/IV_K2400_Loop_Instrument_Control_v10.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@
2424
from time import sleep
2525
from pymeasure.instruments.keithley import Keithley2400
2626
import pandas as pd
27+
import argparse
2728

2829

2930
def main():
3031
"""
3132
Main function to run the I-V sweep measurement.
3233
"""
34+
parser = argparse.ArgumentParser(description="Keithley 2400 I-V Sweep")
35+
parser.add_argument("--filename", required=True, help="Name of the file to save the data.")
36+
parser.add_argument("--path", help="Path to save the data file. Defaults to a 'data' folder.")
37+
parser.add_argument("--range", type=float, required=True, help="Highest value of Current (in micro A).")
38+
parser.add_argument("--step", type=float, required=True, help="The step size (in micro A).")
39+
args = parser.parse_args()
40+
3341
# object creation ----------------------------------
3442
keithley_2400 = Keithley2400("GPIB::4")
3543
keithley_2400.disable_buffer()
@@ -40,9 +48,9 @@ def main():
4048
Volt = []
4149

4250
# user input ----------------------------------
43-
I_range = float(input("Enter value of I: (in micro A, Highest value of Current from -I to I) "))
44-
I_step = float(input("Enter steps: (The step size, in micro A) "))
45-
filename = input("Enter filename:")
51+
I_range = args.range
52+
I_step = args.step
53+
filename = args.filename
4654

4755
print("Current (A) || Voltage(V) ")
4856

@@ -73,8 +81,15 @@ def IV_Measure(cur):
7381
print("\n--- Measurement Complete ---")
7482
print(df)
7583

76-
save_path = os.path.join(
77-
'C:/Users/Instrument-DSL/Desktop/LED_IV/', f"{filename}.txt")
84+
if args.path:
85+
save_dir = args.path
86+
else:
87+
save_dir = "data"
88+
89+
if not os.path.isdir(save_dir):
90+
os.makedirs(save_dir)
91+
92+
save_path = os.path.join(save_dir, f"{filename}.txt")
7893
df.to_csv(save_path, index=None, sep='\t', mode='w')
7994
print(f"Data saved to {save_path}")
8095

@@ -90,3 +105,6 @@ def IV_Measure(cur):
90105
plt.legend()
91106
plt.grid(True)
92107
plt.show()
108+
109+
if __name__ == "__main__":
110+
main()

0 commit comments

Comments
 (0)