From 58383becddfcb0143cf2f358445ba9158e2bf9ee Mon Sep 17 00:00:00 2001
From: JupyterHub User <1myhisij@jupyter.rwth-aachen.de>
Date: Thu, 31 Aug 2023 10:25:49 +0000
Subject: [PATCH] implementened single step CTLM with no plots/ csv file

---
 .../measurements-checkpoint.py                | 189 ++++++++++++++++++
 hp4155/measurements.py                        |  58 +++++-
 hp4155/module.py                              |   7 +
 3 files changed, 253 insertions(+), 1 deletion(-)

diff --git a/hp4155/.ipynb_checkpoints/measurements-checkpoint.py b/hp4155/.ipynb_checkpoints/measurements-checkpoint.py
index e69de29..f5fc3bb 100644
--- a/hp4155/.ipynb_checkpoints/measurements-checkpoint.py
+++ b/hp4155/.ipynb_checkpoints/measurements-checkpoint.py
@@ -0,0 +1,189 @@
+# this is a python file that minimizes the amount of code seen to the user
+
+import module
+import matplotlib.pyplot as plt
+import pandas as pd
+from datetime import datetime
+
+
+def I_V_Measurement(start,stop,step):
+    
+    device = module.HP4155a('GPIB0::17::INSTR')
+    device.inst.write(":PAGE:MEAS")
+    device.inst.write(":PAGE:CHAN:MODE SWEEP") #go to sweep page and prepare sweep measurement
+    device.reset()
+    
+    #setup sweep
+    device.inst.write(":PAGE:CHAN:MODE SWEEP") #go to sweep page and prepare sweep measurement
+
+    #smu2 and smu4 are disabled
+    device.smu_disable_sweep(2)
+    device.smu_disable_sweep(4)
+
+    #smu1 is constant and common
+    device.smu_mode_meas(1,'COMM')
+    device.smu_function_sweep(1,'CONS')
+
+    #smu3 is VAR1 and V
+    device.smu_mode_meas(3,'V')
+    device.smu_function_sweep(3,'VAR1')
+
+    #define start-step-stop
+    device.start_value_sweep(start)
+    device.step_sweep(step)
+    device.stop_value_sweep(stop)
+    
+    #start measurement
+    device.single_measurement()
+    while device.operation_completed() == False:
+        pass
+    
+    voltage_values = device.return_data('V3')
+    current_values = device.return_data('I3')
+    
+    # show plot
+    plt.plot(voltage_values,current_values)
+    plt.show()
+    
+    #export data to csv file
+    #add title to the results
+    
+    header = ['Voltage(V)', 'Current(A)']
+
+    data = {header[0]:voltage_values,header[1]:current_values}
+    df = pd.DataFrame(data)
+    date = str(datetime.today().replace(microsecond=0))
+    
+    print(df)
+    
+    #exporting the data frame in an excel file
+    file_name = 'results_'+date+'.csv'
+    df.to_csv(file_name)
+    
+    del device
+
+def stress_sampling():
+    
+    #connect to device
+    device = module.HP4155a('GPIB0::17::INSTR')
+    device.reset()
+    
+    device.stress_page()
+    
+    #define smus to numbers in mode and values for stress 
+
+    #mode
+    device.smu_mode(1,'COMM')
+    device.smu_mode(2,'V')
+    device.smu_mode(3,'V')
+    device.smu_mode(4,'COMM')
+    device.sync(4,0)
+
+    #values
+    device.smu_value(2,10)
+    device.smu_value(3,-3)
+    #time
+    zeit=device.stress_time(30)
+    
+    device.start_stress()
+    while device.operation_completed() == False:
+        pass
+    
+    #start with sampling measurement
+    device.measurement_mode('SAMP')
+
+    #set the mode of smus for sampling
+    device.smu_mode_meas(1,'COMM')
+    device.smu_mode_meas(2,'V')
+    device.smu_mode_meas(3,'V')
+    device.smu_mode_meas(4,'COMM')
+
+
+    #set the values of smu for sampling
+    device.constant_smu_sampling(2,10)
+    device.constant_smu_sampling(3,2)
+    
+    
+    #time log10
+    device.sampling_mode('L10')
+
+    #minimum initial interval
+    #device.initial_interval('MIN')
+
+    device.number_of_points(21)
+    device.integration_time('SHOR')
+    
+    device.single_measurement()
+    while device.operation_completed() == False:
+        pass
+
+    time_values = device.return_data('@TIME')
+    I3_values = device.return_data('I3')
+    I2_values = device.return_data('I2')
+    
+    fig = plt.figure()
+    plt.plot(time_values,I2_values)
+    plt.show()
+    
+    fig = plt.figure()
+    plt.plot(time_values,I3_values)
+    plt.show()
+    
+    del device
+    
+# These are some help functions for the setup of the CTLM measurement
+    
+def single_ctlm(time,start=-50*10**(-3),stop=50*10**(-3),step=10**(-3),comp=10V):
+        
+    device.reset()
+    device.inst.write(":PAGE:MEAS")
+    device.inst.write(":PAGE:CHAN:MODE SWEEP") #go to sweep page and prepare sweep measurement
+    
+    #setup smus
+    
+    #smu1 is constant and common
+    device.smu_mode_meas(1,'COMM')
+    device.smu_function_sweep(1,'CONS')
+    
+    #smu2 is constant and I
+    device.smu_mode_meas(2,'I')
+    device.smu_function_sweep(2,'CONS')
+    
+    #smu3 is var1 and I
+    device.smu_mode_meas(3,'I')
+    device.smu_function_sweep(3,'VAR1')
+    
+    #smu4 is constant and I
+    device.smu_mode_meas(4,'I')
+    device.smu_function_sweep(4,'CONS')
+    
+    #select compliance of smu3
+    device.comp('VAR1',comp)
+    
+    #compliance of smu2 and smu4 is 10V
+    device.const_comp(2,10)
+    device.const_comp(4,10)
+    
+    # smu1 is common and compliance is automatically set to maximum
+    
+    #integration time
+    device.integration_time(time)
+    
+    #define start-step-stop
+    device.start_value_sweep(start)
+    device.step_sweep(step)
+    device.stop_value_sweep(stop)
+    
+    #start measurement
+    device.single_measurement()
+    while device.operation_completed() == False:
+        pass
+    
+    voltage_values = device.return_data('V3')
+    current_values = device.return_data('I3')
+    
+    resistance_values=[]
+    
+    for i in range(len(voltage_values)):
+        resistance_values.append(voltage_values[i]/current_values[i])
+        
\ No newline at end of file
diff --git a/hp4155/measurements.py b/hp4155/measurements.py
index 0722472..f5fc3bb 100644
--- a/hp4155/measurements.py
+++ b/hp4155/measurements.py
@@ -129,5 +129,61 @@ def stress_sampling():
     plt.plot(time_values,I3_values)
     plt.show()
     
+    del device
+    
+# These are some help functions for the setup of the CTLM measurement
+    
+def single_ctlm(time,start=-50*10**(-3),stop=50*10**(-3),step=10**(-3),comp=10V):
+        
+    device.reset()
+    device.inst.write(":PAGE:MEAS")
+    device.inst.write(":PAGE:CHAN:MODE SWEEP") #go to sweep page and prepare sweep measurement
+    
+    #setup smus
+    
+    #smu1 is constant and common
+    device.smu_mode_meas(1,'COMM')
+    device.smu_function_sweep(1,'CONS')
+    
+    #smu2 is constant and I
+    device.smu_mode_meas(2,'I')
+    device.smu_function_sweep(2,'CONS')
+    
+    #smu3 is var1 and I
+    device.smu_mode_meas(3,'I')
+    device.smu_function_sweep(3,'VAR1')
+    
+    #smu4 is constant and I
+    device.smu_mode_meas(4,'I')
+    device.smu_function_sweep(4,'CONS')
+    
+    #select compliance of smu3
+    device.comp('VAR1',comp)
+    
+    #compliance of smu2 and smu4 is 10V
+    device.const_comp(2,10)
+    device.const_comp(4,10)
+    
+    # smu1 is common and compliance is automatically set to maximum
+    
+    #integration time
+    device.integration_time(time)
+    
+    #define start-step-stop
+    device.start_value_sweep(start)
+    device.step_sweep(step)
+    device.stop_value_sweep(stop)
+    
+    #start measurement
+    device.single_measurement()
+    while device.operation_completed() == False:
+        pass
+    
+    voltage_values = device.return_data('V3')
+    current_values = device.return_data('I3')
+    
+    resistance_values=[]
     
-    
\ No newline at end of file
+    for i in range(len(voltage_values)):
+        resistance_values.append(voltage_values[i]/current_values[i])
+        
\ No newline at end of file
diff --git a/hp4155/module.py b/hp4155/module.py
index 9cf2719..de2918e 100644
--- a/hp4155/module.py
+++ b/hp4155/module.py
@@ -139,6 +139,7 @@ class HP4155a(object):
         command = f":PAGE:MEAS:SAMP:POIN {number}"
         self.inst.write(command)
 
+    #integration time is SHOR,MED,LONG   
     def integration_time(self,time):
         command=f":PAGE:MEAS:MSET:ITIM {time}"
         self.inst.write(command)
@@ -183,5 +184,11 @@ class HP4155a(object):
     def comp(self,variable,value):
         command = f":PAGE:MEAS:{variable}:COMP {value}"
         self.inst.write(command)
+    
+    # constant voltage compiance of an smu(only use if the smu is constant and the mode is not COMMON)
+    
+    def const_comp(self,smu_number,value):
+        command = f":PAGE:MEAS:CONS:SMU{smu_number}:COMP {value}"
+        self.inst.write(command)
         
         
\ No newline at end of file
-- 
GitLab