diff --git a/hp4155/ADU for double gate devices_version_3/lib/gatediode.py b/hp4155/ADU for double gate devices_version_3/lib/gatediode.py
new file mode 100644
index 0000000000000000000000000000000000000000..b22058e98024aa33aba78ea05d58a54b0c56af24
--- /dev/null
+++ b/hp4155/ADU for double gate devices_version_3/lib/gatediode.py	
@@ -0,0 +1,182 @@
+# This are the gatediode measurements
+
+import sys
+sys.path.insert(0, '..') #append parent directory
+
+import hp4155a
+from help import *
+from decimal import Decimal
+
+import os
+
+def VTG(ui,device):
+    device.del_user_functions() # delete all user functions 
+    device.clear_error_stack() # clear error stack
+    # setup the smus
+
+    norm = normalization_factor(ui.sample.width.value)
+
+    smu_source = device.smu_dict()
+    smu_source.update(vname ='VS',iname = 'IS',mode = 'COMM',func='CONS')
+
+    smu_top_gate = device.smu_dict()
+    smu_top_gate.update(vname = 'VTG',iname='ITG',mode = 'V',func='VAR1')
+
+    # setup VAR1
+    var1 = device.var1_dict()
+    var1.update(
+        mode = ui.Vg_gatediode.hyst.value,
+        start = ui.Vg_gatediode.start.value,
+        stop = ui.Vg_gatediode.stop.value,
+        step = ui.Vg_gatediode.step.value,
+        comp = ui.Vg_gatediode.comp.value,
+        pcomp = ui.Vg_gatediode.pcomp.value
+    )
+
+    try:
+        device.setup_smu(ui.sample.top_gate.value,smu_top_gate)
+        device.setup_smu(ui.sample.source.value,smu_source)
+    
+        # disable back gate smu
+        device.smu_disable(ui.sample.back_gate.value)
+    
+        # disable drain smu
+        device.smu_disable(ui.sample.drain.value)
+
+        device.setup_var1(var1)
+        device.integration_time(ui.integration_gatediode.value)
+        
+        variables_list = ['VTG','ITG']
+        device.variables_to_save(variables_list)
+
+         plotted_variables = graph_tool(ui.plot_gatediode,ui.sample.width.value,device)
+        
+        device.single_measurement()
+        while device.operation_completed()==False:
+            pass
+
+        device.error_occured()
+
+        if ui.sample.quick.value == False:
+            device.autoscaling()
+       
+    
+        values = dict([(variable,device.return_values(variable)) for variable in variables_list])
+        df = get_dataframe_from_results(values)
+    except Exception as e:
+        error_box(e)
+        return
+    
+    # Append the normalized current 
+    df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
+    default_filename = f"{ui.sample.sample.value}_{ui.sample.field.value}_{ui.sample.device.value}_TOP_GATE_D.txt"
+    file = create_file(default_filename)
+
+    with open(file,'w') as f:
+        date = str(datetime.today().replace(microsecond=0))
+        f.write(f"Gatediode Curve at {date}"+"\n")
+        write_sample_information(ui.sample,f)
+        f.write("Sweeping Gate:VTG"+"\n\n")
+        f.write('Parameters\n')
+        f.write(f"VTG from {ui.Vg_gatediode.start.value}V to {ui.Vg_gatediode.stop.value}V with step {ui.Vg_gatediode.step.value}V"+"\n")
+        
+        if ui.Vg_gatediode.pcomp.value==0:
+            f.write(f"Top Gate Current Compliance/A:{ui.Vg_gatediode.comp.value}"+"\n")
+        else:
+            f.write(f"Top Gate Power Compliance/A:{ui.Vg_gatediode.pcomp.value}"+"\n")
+
+        f.write(f"Integration Time:{ui.integration_gatediode.value}"+"\n")
+        f.write("\nResults\n")
+
+    df.to_csv(file,sep=" ",mode='a')
+
+    if ui.sample.quick.value == False:
+        df["label"] = df.apply(lambda row: "_nolegend_",axis = 1) # assign labels
+        create_plot(ui.plot_gatediode,df,file,"Top Gate Gatediode Measurement",None,ui.sample.save_fig.value)
+
+def VBG(ui,device):
+    device.del_user_functions() # delete all user functions 
+    device.clear_error_stack() # clear error stack
+    # setup the smus
+
+    norm = normalization_factor(ui.sample.width.value)
+
+    smu_source = device.smu_dict()
+    smu_source.update(vname ='VS',iname = 'IS',mode = 'COMM',func='CONS')
+
+    smu_back_gate = device.smu_dict()
+    smu_back_gate.update(vname = 'VBG',iname='IBG',mode = 'V',func='VAR1')
+
+    # setup VAR1
+    var1 = device.var1_dict()
+    var1.update(
+        mode = ui.Vg_gatediode.hyst.value,
+        start = ui.Vg_gatediode.start.value,
+        stop = ui.Vg_gatediode.stop.value,
+        step = ui.Vg_gatediode.step.value,
+        comp = ui.Vg_gatediode.comp.value,
+        pcomp = ui.Vg_gatediode.pcomp.value
+    )
+
+    try:
+        device.setup_smu(ui.sample.top_gate.value,smu_top_gate)
+        device.setup_smu(ui.sample.source.value,smu_source)
+    
+        # disable back gate smu
+        device.smu_disable(ui.sample.back_gate.value)
+    
+        # disable drain smu
+        device.smu_disable(ui.sample.drain.value)
+
+        device.setup_var1(var1)
+        device.integration_time(ui.integration_gatediode.value)
+        
+        variables_list = ['VBG','VTG']
+        device.variables_to_save(variables_list)
+
+         plotted_variables = graph_tool(ui.plot_gatediode,ui.sample.width.value,device)
+        
+        device.single_measurement()
+        while device.operation_completed()==False:
+            pass
+
+        device.error_occured()
+
+        if ui.sample.quick.value == False:
+            device.autoscaling()
+       
+    
+        values = dict([(variable,device.return_values(variable)) for variable in variables_list])
+        df = get_dataframe_from_results(values)
+    except Exception as e:
+        error_box(e)
+        return
+    
+    # Append the normalized current 
+    df["IBGmm/uA/um"]= (df["IBG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
+    default_filename = f"{ui.sample.sample.value}_{ui.sample.field.value}_{ui.sample.device.value}_BACK_GATE_D.txt"
+    file = create_file(default_filename)
+
+    with open(file,'w') as f:
+        date = str(datetime.today().replace(microsecond=0))
+        f.write(f"Gatediode Curve at {date}"+"\n")
+        write_sample_information(ui.sample,f)
+        f.write("Sweeping Gate:VBG"+"\n\n")
+        f.write('Parameters\n')
+        f.write(f"VTG from {ui.Vg_gatediode.start.value}V to {ui.Vg_gatediode.stop.value}V with step {ui.Vg_gatediode.step.value}V"+"\n")
+        
+        if ui.Vg_gatediode.pcomp.value==0:
+            f.write(f"Top Gate Current Compliance/A:{ui.Vg_gatediode.comp.value}"+"\n")
+        else:
+            f.write(f"Top Gate Power Compliance/A:{ui.Vg_gatediode.pcomp.value}"+"\n")
+
+        f.write(f"Integration Time:{ui.integration_gatediode.value}"+"\n")
+        f.write("\nResults\n")
+
+    df.to_csv(file,sep=" ",mode='a')
+
+    if ui.sample.quick.value == False:
+        df["label"] = df.apply(lambda row: "_nolegend_",axis = 1) # assign labels
+        create_plot(ui.plot_gatediode,df,file,"Top Gate Gatediode Measurement",None,ui.sample.save_fig.value)
+        
+    
\ No newline at end of file
diff --git a/hp4155/ADU for double gate devices_version_3/lib/measurements.py b/hp4155/ADU for double gate devices_version_3/lib/measurements.py
deleted file mode 100644
index 21b8c35af7f4bdd5b381a311ff882cf1fffd9f13..0000000000000000000000000000000000000000
--- a/hp4155/ADU for double gate devices_version_3/lib/measurements.py	
+++ /dev/null
@@ -1,753 +0,0 @@
-# New measurements file for ADU
-
-# The new measurements will have the smus configuration as a parameter and written from the interface
-
-import sys
-sys.path.insert(0, '..') #append parent directory
-
-import hp4155a
-from help import *
-from decimal import Decimal
-
-import os
-
-# Output with VTG
-def Output_VTG(device,params):
-    try:
-        device.setup_smu(params['MAP']['TG'],params["SMU_T"])
-        device.setup_smu(params['MAP']['D'],params["SMU_D"])
-        device.setup_smu(params['MAP']['BG'],params["SMU_B"])
-        device.setup_smu(params['MAP']['S'],params["SMU_S"])
-        
-        device.setup_var1(params["VAR1"])
-        device.setup_var2(params["VAR2"])
-    
-        device.integration_time(params["INTEGRATION"])
-    
-        variables_list = ['VDS','ID','VTG','ITG']
-        device.variables_to_save(variables_list)
-    
-        try:
-            plotted_variables = graph_tool(params,device)
-        except Exception as e:
-            error_box(e)
-            return
-    
-        device.single_measurement()
-        
-        while device.operation_completed()==False:
-            pass
-    
-        device.autoscaling()
-        device.error_occured()
-    
-        values = dict([(variable,device.return_values(variable)) for variable in variables_list])
-        df = get_dataframe_from_results(values)
-    except Exception as e:
-        error_box(e)
-        return
-
-    
-    # plot results
-    # calculate normalization factor
-    norm = normalization_factor(params['SAMPLE']["width"])
-    points = params["VAR2"]["points"]
-
-    # Append the normalized current 
-    df["IDmm/uA/um"]= (df["ID/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
-    df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
-
-    # Save the results
-    default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_TOP_GATE_A.txt"
-
-    root = tk.Tk()
-    root.withdraw()
-    root.lift() #show window above all other applications
-
-    root.attributes("-topmost", True)#window stays above all other applications
-
-    file = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files","*.txt")],title = "save results path",initialfile =default_filename)
-
-    #check if the file path is correct(.txt)
-    while file.endswith(".txt") == False:
-        #open again filedialog with error message box
-        tk.messagebox.showerror(message='invalid filename!')
-        file = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files","*.txt")],title = "save results path",initialfile =default_filename)
-
-    root.destroy()
-
-    with open(file,'w') as f:
-        date = str(datetime.today().replace(microsecond=0))
-        f.write(f"Output Curve at {date}"+"\n")
-        f.write(f"Series:{params['SAMPLE']['processing_number']}"+"\n")
-        f.write(f"Sample:{params['SAMPLE']['sample']}"+"\n")
-        f.write(f"Field:{params['SAMPLE']['field']}"+"\n")
-        f.write(f"Device:{params['SAMPLE']['device']}"+"\n")
-        f.write(f"Device Width/um:{params['SAMPLE']['width']}"+"\n")
-        f.write("Sweeping Gate:VTG"+"\n\n")
-
-        f.write('Parameters\n')
-        f.write(f"VTG from {params['VAR2']['start']}V to {params['VAR2']['stop']}V with step {params['VAR2']['step']}V"+"\n")
-        f.write(f"VDS from {params['VAR1']['start']}V to {params['VAR1']['stop']}V with step {params['VAR1']['step']}V"+"\n")
-        
-        #calculate the values
-        if params['VAR2']['pcomp']==0:
-            f.write(f"Top Gate Current Compliance/A:{params['VAR2']['comp']}"+"\n")
-        else:
-            f.write(f"Top Gate Power Compliance/A:{params['VAR2']['pcomp']}"+"\n")
-
-        if params['VAR1']['pcomp'] == 0:
-            f.write(f"Drain Current Compliance/A:{params['VAR1']['comp']}"+"\n")
-        else:
-             f.write(f"Drain Power Compliance/A:{params['VAR1']['pcomp']}"+"\n")
-
-        f.write(f"Integration Time:{params['INTEGRATION']}"+"\n")
-         
-        f.write("\nResults\n")
-
-    df.to_csv(file,sep=" ",mode='a')
-
-    plot_values = values_to_plot(params,device)
-
-    # Plot user specified results
-    fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
-
-    plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
-    scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
-    axes_labels = set_axes_labels(plot_list)
-
-    if scale_list[1]=='LOG':
-        ax1.set_yscale('log')
-
-    #now set the labels
-    ax1.set_xlabel(axes_labels[0])
-    ax1.set_ylabel(axes_labels[1])
-
-    x = np.split(plot_values['X'],points)
-    y1 = np.split(plot_values['Y1'],points)
-    labels =np.mean(np.array_split(df["VTG/V"],points),axis = 1) # VDS values for labels
-    
-    for i in range(points):
-        ax1.plot(x[i],y1[i],label = f"VTG:{round(labels[i],3)} (V)")
-    
-    # Adding title
-    fig.suptitle('Output Curve', fontweight ="bold")
-    fig.legend(loc='outside right upper')
-
-    display(fig)
-    #save plot if checked
-    if params["SAMPLE"]['save_fig'] == True:
-        filename= os.path.splitext(file)[0]
-        fig.savefig(filename+'_Y1.png')
-    
-    #add the second axis if applicable
-    if plot_list[2]!= "None":
-        fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
-        y2 = np.split(plot_values['Y2'],points)
-        
-        if scale_list[2]=='LOG':
-            ax2.set_yscale('log')
-
-        ax2.set_xlabel(axes_labels[0])
-         
-        ax2.set_ylabel(axes_labels[2])
-        for i in range(points):
-            ax2.plot(x[i],y2[i],label = f"VTG:{round(labels[i],3)} (V)")
-        
-        # Adding title
-        fig.suptitle('Output Curve', fontweight ="bold")
-        fig.legend(loc='outside right upper')
-    
-        display(fig)
-        #save plot if checked
-        if params["SAMPLE"]['save_fig'] == True:
-            filename= os.path.splitext(file)[0]
-            fig.savefig(filename+'Y2.png')
-    
-
-#Output VBG
-def Output_VBG(device,params):
-    try:
-        device.setup_smu(params["MAP"]['TG'],params["SMU_T"])
-        device.setup_smu(params["MAP"]['D'],params["SMU_D"])
-        device.setup_smu(params["MAP"]['BG'],params["SMU_B"])
-        device.setup_smu(params["MAP"]['S'],params["SMU_S"])
-    
-    
-        device.setup_var1(params["VAR1"])
-        device.setup_var2(params["VAR2"])
-    
-        device.integration_time(params["INTEGRATION"])
-    
-        variables_list = ['VDS','ID','VBG','IBG']
-        device.variables_to_save(variables_list)
-         
-        try:
-            plotted_variables = graph_tool(params,device)
-        except Exception as e:
-            error_box(e)
-            return
-    
-    
-        device.single_measurement()
-        
-        while device.operation_completed()==False:
-            pass
-        
-        device.autoscaling()
-        device.error_occured()
-        
-        values = dict([(variable,device.return_values(variable)) for variable in variables_list])
-        df = get_dataframe_from_results(values)
-    except Exception as e:
-        error_box(e)
-        return
-
-    # plot results
-
-    # calculate normalization factor
-    norm = normalization_factor(params["SAMPLE"]["width"])
-    points = params["VAR2"]["points"]
-
-    # Append the normalized current 
-    df["IDmm/uA/um"]= (df["ID/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
-    df["IBGmm/uA/um"]= (df["IBG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
-
-    # Save the results
-    default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_BACK_GATE_A.txt"
-
-    root = tk.Tk()
-    root.withdraw()
-    root.lift() #show window above all other applications
-
-    root.attributes("-topmost", True)#window stays above all other applications
-
-    file = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files","*.txt")],title = "save results path",initialfile =default_filename)
-
-    #check if the file path is correct(.txt)
-    while file.endswith(".txt") == False:
-        #open again filedialog with error message box
-        tk.messagebox.showerror(message='invalid filename!')
-        file = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files","*.txt")],title = "save results path",initialfile =default_filename)
-
-    root.destroy()
-
-    with open(file,'w') as f:
-        date = str(datetime.today().replace(microsecond=0))
-        f.write(f"Output Curve at {date}"+"\n")
-        f.write(f"Series:{params['SAMPLE']['processing_number']}"+"\n")
-        f.write(f"Sample:{params['SAMPLE']['sample']}"+"\n")
-        f.write(f"Field:{params['SAMPLE']['field']}"+"\n")
-        f.write(f"Device:{params['SAMPLE']['device']}"+"\n")
-        f.write(f"Device Width/um:{params['SAMPLE']['width']}"+"\n")
-        f.write("Sweeping Gate:VBG"+"\n\n")
-
-        f.write('Parameters\n')
-        f.write(f"VBG from {params['VAR2']['start']}V to {params['VAR2']['stop']}V with step {params['VAR2']['step']}V"+"\n")
-        f.write(f"VDS from {params['VAR1']['start']}V to {params['VAR1']['stop']}V with step {params['VAR1']['step']}V"+"\n")
-        
-        #calculate the values
-        if params['VAR2']['pcomp']==0:
-            f.write(f"Back Gate Current Compliance/A:{params['VAR2']['comp']}"+"\n")
-        else:
-            f.write(f"Back Gate Power Compliance/A:{params['VAR2']['pcomp']}"+"\n")
-
-        if params['VAR1']['pcomp'] == 0:
-            f.write(f"Drain Current Compliance/A:{params['VAR1']['comp']}"+"\n")
-        else:
-             f.write(f"Drain Power Compliance/A:{params['VAR1']['pcomp']}"+"\n")
-
-        f.write(f"Integration Time:{params['INTEGRATION']}"+"\n")
-         
-        f.write("\nResults\n")
-    df.to_csv(file,sep=" ",mode='a')
-
-    plot_values = values_to_plot(params,device)
-
-    # Plot user specified results
-    fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
-
-    plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
-    scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
-    axes_labels = set_axes_labels(plot_list)
-
-    if scale_list[1]=='LOG':
-        ax1.set_yscale('log')
-
-    #now set the labels
-    ax1.set_xlabel(axes_labels[0])
-    ax1.set_ylabel(axes_labels[1])
-
-    x = np.split(plot_values['X'],points)
-    y1 = np.split(plot_values['Y1'],points)
-    labels =np.mean(np.array_split(df["VBG/V"],points),axis = 1) # VDS values for labels
-    
-    for i in range(points):
-        ax1.plot(x[i],y1[i],label = f"VBG:{round(labels[i],3)} (V)")
-    
-    # Adding title
-    fig.suptitle('Output Curve', fontweight ="bold")
-    fig.legend(loc='outside right upper')
-
-    display(fig)
-    #save plot if checked
-    if params["SAMPLE"]['save_fig'] == True:
-        filename= os.path.splitext(file)[0]
-        fig.savefig(filename+'_Y1.png')
-    
-    #add the second axis if applicable
-    if plot_list[2]!= "None":
-        fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
-        y2 = np.split(plot_values['Y2'],points)
-        
-        if scale_list[2]=='LOG':
-            ax2.set_yscale('log')
-
-        ax2.set_xlabel(axes_labels[0])
-         
-        ax2.set_ylabel(axes_labels[2])
-        for i in range(points):
-            ax2.plot(x[i],y2[i],label = f"VBG:{round(labels[i],3)} (V)")
-        
-        # Adding title
-        fig.suptitle('Output Curve', fontweight ="bold")
-        fig.legend(loc='outside right upper')
-    
-        display(fig)
-        #save plot if checked
-        if params["SAMPLE"]['save_fig'] == True:
-            filename= os.path.splitext(file)[0]
-            fig.savefig(filename+'Y2.png')
-    
-# Output both
-def Output_BOTH(device,params):
-    try:
-        device.setup_smu(params["MAP"]['TG'],params["SMU_T"])
-        device.setup_smu(params["MAP"]['D'],params["SMU_D"])
-        device.setup_smu(params["MAP"]['BG'],params["SMU_B"])
-        device.setup_smu(params["MAP"]['S'],params["SMU_S"])
-    
-    
-        device.setup_var1(params["VAR1"])
-        device.setup_var2(params["VAR2"])
-        
-    
-        device.integration_time(params["INTEGRATION"])
-        try:
-            plotted_variables = graph_tool(params,device)
-        except Exception as e:
-            error_box(e)
-            return
-    
-        
-    
-        variables_list = ['VDS','ID','VBG','IBG','VTG','ITG']
-        device.variables_to_save(variables_list)
-    
-        for i , value in enumerate(params["VAR3"]['values']):
-            cons = device.cons_smu_dict()
-            cons.update(comp = params['VAR3']['comp'],value = value)
-            device.setup_cons_smu(params['MAP']['BG'],cons)
-    
-            if i == 0:
-                device.single_measurement()
-            else:
-                device.append_measurement()
-        
-            while device.operation_completed()==False:
-                pass
-            device.autoscaling()
-            device.error_occured()
-    
-        values = dict([(variable,device.return_values(variable)) for variable in variables_list])
-        df = get_dataframe_from_results(values)
-    except Exception as e:
-        error_box(e)
-        return
-
-    # plot results
-    points = params["VAR2"]['points']*params["VAR3"]["points"] # number of curves
-
-    # calculate normalization factor
-    norm = normalization_factor(params["SAMPLE"]["width"])
-
-    # Append the normalized current 
-    df["IDmm/uA/um"]= (df["ID/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
-    df["IBGmm/uA/um"]= (df["IBG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
-    df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
-
-      # Save the results
-    default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_BOTH_GATES_A.txt"
-
-    root = tk.Tk()
-    root.withdraw()
-    root.lift() #show window above all other applications
-
-    root.attributes("-topmost", True)#window stays above all other applications
-
-    file = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files","*.txt")],title = "save results path",initialfile =default_filename)
-
-    #check if the file path is correct(.txt)
-    while file.endswith(".txt") == False:
-        #open again filedialog with error message box
-        tk.messagebox.showerror(message='invalid filename!')
-        file = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files","*.txt")],title = "save results path",initialfile =default_filename)
-
-    root.destroy()
-
-    with open(file,'w') as f:
-        date = str(datetime.today().replace(microsecond=0))
-        f.write(f"Output Curve at {date}"+"\n")
-        f.write(f"Series:{params['SAMPLE']['processing_number']}"+"\n")
-        f.write(f"Sample:{params['SAMPLE']['sample']}"+"\n")
-        f.write(f"Field:{params['SAMPLE']['field']}"+"\n")
-        f.write(f"Device:{params['SAMPLE']['device']}"+"\n")
-        f.write(f"Device Width/um:{params['SAMPLE']['width']}"+"\n")
-        f.write("Sweeping Gates:VBG,VTG"+"\n\n")
-
-        f.write('Parameters\n')
-        f.write(f"VBG from {params['VAR3']['start']}V to {params['VAR3']['stop']}V with step {params['VAR3']['step']}V"+"\n")
-        f.write(f"VTG from {params['VAR2']['start']}V to {params['VAR2']['stop']}V with step {params['VAR2']['step']}V"+"\n")
-        f.write(f"VDS from {params['VAR1']['start']}V to {params['VAR1']['stop']}V with step {params['VAR1']['step']}V"+"\n")
-      
-        
-        #calculate the values
-        f.write(f"Back Gate Current Compliance/A:{params['VAR3']['comp']}"+"\n")
-        
-        if params['VAR2']['pcomp']==0:
-            f.write(f"Top Gate Current Compliance/A:{params['VAR2']['comp']}"+"\n")
-        else:
-            f.write(f"Top Gate Power Compliance/A:{params['VAR2']['pcomp']}"+"\n")
-
-
-        if params['VAR1']['pcomp'] == 0:
-            f.write(f"Drain Current Compliance/A:{params['VAR1']['comp']}"+"\n")
-        else:
-             f.write(f"Drain Power Compliance/A:{params['VAR1']['pcomp']}"+"\n")
-
-        f.write(f"Integration Time:{params['INTEGRATION']}"+"\n")
-         
-        f.write("\nResults\n")
-
-    df.to_csv(file,sep=" ",mode='a')
-
-    plot_values = values_to_plot(params,device)
-
-    # Plot user specified results
-    fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
-
-    plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
-    scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
-    axes_labels = set_axes_labels(plot_list)
-
-    if scale_list[1]=='LOG':
-        ax1.set_yscale('log')
-
-    #now set the labels
-    ax1.set_xlabel(axes_labels[0])
-    ax1.set_ylabel(axes_labels[1])
-
-    x = np.split(plot_values['X'],points)
-    y1 = np.split(plot_values['Y1'],points)
-    labels_VTG =np.mean(np.array_split(df["VTG/V"],points),axis = 1) # VTG values for labels
-    labels_VBG = np.mean(np.array_split(df["VBG/V"],points),axis = 1) # VBG values for labels
-    
-    for i in range(points):
-        ax1.plot(x[i],y1[i],label = f"VTG:{round(labels_VTG[i],3)} (V) , VBG:{round(labels_VBG[i],3)} (V)")
-    
-    # Adding title
-    fig.suptitle('Output Curve', fontweight ="bold")
-    fig.legend(loc='outside right upper')
-
-    display(fig)
-    #save plot if checked
-    if params["SAMPLE"]['save_fig'] == True:
-        filename= os.path.splitext(file)[0]
-        fig.savefig(filename+'_Y1.png')
-    
-    #add the second axis if applicable
-    if plot_list[2]!= "None":
-        fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
-        y2 = np.split(plot_values['Y2'],points)
-        
-        if scale_list[2]=='LOG':
-            ax2.set_yscale('log')
-
-        ax2.set_xlabel(axes_labels[0])
-         
-        ax2.set_ylabel(axes_labels[2])
-        for i in range(points):
-            ax2.plot(x[i],y2[i],label = f"VTG:{round(labels_VTG[i],3)} (V) , VBG:{round(labels_VBG[i],3)} (V)")
-        
-        # Adding title
-        fig.suptitle('Output Curve', fontweight ="bold")
-        fig.legend(loc='outside right upper')
-    
-        display(fig)
-        #save plot if checked
-        if params["SAMPLE"]['save_fig'] == True:
-            filename= os.path.splitext(file)[0]
-            fig.savefig(filename+'_Y2.png')
-  
-
-def Gatediode_VTG(device,params):
-    try:
-        device.setup_smu(params["MAP"]['TG'],params["SMU_T"])
-        device.smu_disable(params["MAP"]['BG'])
-        device.setup_smu(params["MAP"]['S'],params["SMU_S"])
-    
-        device.setup_var1(params["VAR1"])
-    
-        device.integration_time(params["INTEGRATION"])
-    
-        variables_list = ['VTG','ITG']
-        device.variables_to_save(variables_list)
-        try:
-            plotted_variables = graph_tool(params,device)
-        except Exception as e:
-            error_box(e)
-            return
-    
-    
-        device.single_measurement()
-        
-        while device.operation_completed()==False:
-            pass
-        device.autoscaling()
-        device.error_occured()
-        
-        values = dict([(variable,device.return_values(variable)) for variable in variables_list])
-        df = get_dataframe_from_results(values)
-    except Exception as e:
-        error_box(e)
-        return
-
-    # calculate normalization factor
-    norm = normalization_factor(params['SAMPLE']["width"])
-
-    # Append the normalized current 
-    df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
-
-     # Save the results
-    default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_TOP_GATE_D.txt"
-
-    root = tk.Tk()
-    root.withdraw()
-    root.lift() #show window above all other applications
-
-    root.attributes("-topmost", True)#window stays above all other applications
-
-    file = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files","*.txt")],title = "save results path",initialfile =default_filename)
-
-    #check if the file path is correct(.txt)
-    while file.endswith(".txt") == False:
-        #open again filedialog with error message box
-        tk.messagebox.showerror(message='invalid filename!')
-        file = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files","*.txt")],title = "save results path",initialfile =default_filename)
-
-    root.destroy()
-
-    with open(file,'w') as f:
-        date = str(datetime.today().replace(microsecond=0))
-        f.write(f"Gatediode Curve at {date}"+"\n")
-        f.write(f"Series:{params['SAMPLE']['processing_number']}"+"\n")
-        f.write(f"Sample:{params['SAMPLE']['sample']}"+"\n")
-        f.write(f"Field:{params['SAMPLE']['field']}"+"\n")
-        f.write(f"Device:{params['SAMPLE']['device']}"+"\n")
-        f.write(f"Device Width/um:{params['SAMPLE']['width']}"+"\n")
-        f.write("Sweeping Gate:VTG"+"\n\n")
-
-        f.write('Parameters\n')
-        f.write(f"VTG from {params['VAR1']['start']}V to {params['VAR1']['stop']}V with step {params['VAR1']['step']}V"+"\n")
-        
-        #calculate the values
-        if params['VAR1']['pcomp']==0:
-            f.write(f"Top Gate Current Compliance/A:{params['VAR1']['comp']}"+"\n")
-        else:
-            f.write(f"Top Gate Power Compliance/A:{params['VAR1']['pcomp'].value}"+"\n")
-
-        f.write(f"Integration Time:{params['INTEGRATION']}"+"\n")
-        
-        f.write("\nResults\n")
-
-    df.to_csv(file,sep=" ",mode='a')
-
-    plot_values = values_to_plot(params,device) 
-    # Plot user specified results
-    fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
-
-    plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
-    scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
-    axes_labels =set_axes_labels(plot_list)
-
-    if scale_list[1]=='LOG':
-        ax1.set_yscale('log')
-
-
-    #now set the labels
-    ax1.set_xlabel(axes_labels[0])
-    ax1.set_ylabel(axes_labels[1])
-
-    x = plot_values['X']
-    y1 = plot_values['Y1']
-    
-    ax1.plot(x,y1)
-    fig.suptitle('Gatediode Curve', fontweight ="bold")
-    display(fig)
-
-    if params["SAMPLE"]["save_fig"] == True:
-        filename= os.path.splitext(file)[0]
-        fig.savefig(filename+'_Y1.png')
-
-
-    #add the second axis if applicable
-    if plot_list[2]!= "None":
-        fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
-        y2 = plot_values['Y2']
-        
-        if scale_list[2]=='LOG':
-            ax2.set_yscale('log')
-        
-        ax2.set_xlabel(axes_labels[0])
-        ax2.set_ylabel(axes_labels[2])
-        ax2.plot(x,y2)
-
-        fig.suptitle('Gatediode Curve', fontweight ="bold")
-        display(fig)
-
-        if params["SAMPLE"]["save_fig"] == True:
-            filename= os.path.splitext(file)[0]
-            fig.savefig(filename+'_Y2.png')
-
-   
-def Gatediode_VBG(device,params):
-    try:
-        device.setup_smu(params["MAP"]['BG'],params["SMU_B"])
-        device.smu_disable(params["MAP"]['TG'])
-        device.setup_smu(params["MAP"]['S'],params["SMU_S"])
-    
-        device.setup_var1(params["VAR1"])
-    
-        device.integration_time(params["INTEGRATION"])
-    
-        variables_list = ['VBG','IBG']
-        device.variables_to_save(variables_list)
-         
-        try:
-            plotted_variables = graph_tool(params,device)
-        except Exception as e:
-            error_box(e)
-            return
-    
-    
-        device.single_measurement()
-        while device.operation_completed()==False:
-            pass
-    
-        device.autoscaling()
-        device.error_occured()
-    
-        values = dict([(variable,device.return_values(variable)) for variable in variables_list])
-        df = get_dataframe_from_results(values)
-    except Exception as e:
-        error_box(e)
-        return
-
-    # plot results
-
-    # calculate normalization factor
-    norm = normalization_factor(params["SAMPLE"]["width"])
-
-    # Append the normalized current 
-    df["IBGmm/uA/um"]= (df["IBG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
-
-    # Save the results
-    default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_BACK_GATE_D.txt"
-
-    root = tk.Tk()
-    root.withdraw()
-    root.lift() #show window above all other applications
-
-    root.attributes("-topmost", True)#window stays above all other applications
-
-    file = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files","*.txt")],title = "save results path",initialfile =default_filename)
-
-    #check if the file path is correct(.txt)
-    while file.endswith(".txt") == False:
-        #open again filedialog with error message box
-        tk.messagebox.showerror(message='invalid filename!')
-        file = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files","*.txt")],title = "save results path",initialfile =default_filename)
-
-    root.destroy()
-
-    with open(file,'w') as f:
-        date = str(datetime.today().replace(microsecond=0))
-        f.write(f"Gatediode Curve at {date}"+"\n")
-        f.write(f"Series:{params['SAMPLE']['processing_number']}"+"\n")
-        f.write(f"Sample:{params['SAMPLE']['sample']}"+"\n")
-        f.write(f"Field:{params['SAMPLE']['field']}"+"\n")
-        f.write(f"Device:{params['SAMPLE']['device']}"+"\n")
-        f.write(f"Device Width/um:{params['SAMPLE']['width']}"+"\n")
-        f.write("Sweeping Gate:VBG"+"\n\n")
-
-        f.write('Parameters\n')
-        f.write(f"VBG from {params['VAR1']['start']}V to {params['VAR1']['stop']}V with step {params['VAR1']['step']}V"+"\n")
-        
-        #calculate the values
-        if params['VAR1']['pcomp']==0:
-            f.write(f"Back Gate Current Compliance/A:{params['VAR1']['comp']}"+"\n")
-        else:
-            f.write(f"Back Gate Power Compliance/A:{params['VAR1']['pcomp']}"+"\n")
-
-        f.write(f"Integration Time:{params['INTEGRATION']}"+"\n")
-         
-        f.write("\nResults\n")
-
-    df.to_csv(file,sep=" ",mode='a')
-
-    plot_values = values_to_plot(params,device) 
-    # Plot user specified results
-    fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
-
-    plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
-    scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
-    axes_labels =set_axes_labels(plot_list)
-
-    if scale_list[1]=='LOG':
-        ax1.set_yscale('log')
-
-
-    #now set the labels
-    ax1.set_xlabel(axes_labels[0])
-    ax1.set_ylabel(axes_labels[1])
-
-    x = plot_values['X']
-    y1 = plot_values['Y1']
-    
-    ax1.plot(x,y1)
-    fig.suptitle('Gatediode Curve', fontweight ="bold")
-    display(fig)
-
-    if params["SAMPLE"]["save_fig"] == True:
-        filename= os.path.splitext(file)[0]
-        fig.savefig(filename+'_Y1.png')
-
-
-    #add the second axis if applicable
-    if plot_list[2]!= "None":
-        fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
-        y2 = plot_values['Y2']
-        
-        if scale_list[2]=='LOG':
-            ax2.set_yscale('log')
-        
-        ax2.set_xlabel(axes_labels[0])
-        ax2.set_ylabel(axes_labels[2])
-        ax2.plot(x,y2)
-
-        fig.suptitle('Gatediode Curve', fontweight ="bold")
-        display(fig)
-
-        if params["SAMPLE"]["save_fig"] == True:
-            filename= os.path.splitext(file)[0]
-            fig.savefig(filename+'_Y2.png')
diff --git a/hp4155/ADU for double gate devices_version_3/lib/output.py b/hp4155/ADU for double gate devices_version_3/lib/output.py
new file mode 100644
index 0000000000000000000000000000000000000000..7e25b0b0c22185b68c1d8309045522a4053b257f
--- /dev/null
+++ b/hp4155/ADU for double gate devices_version_3/lib/output.py	
@@ -0,0 +1,370 @@
+# This file contains the output measurements
+
+import sys
+sys.path.insert(0, '..') #append parent directory
+
+import hp4155a
+from help import *
+from decimal import Decimal
+
+import os
+
+def VTG(ui,device):
+    device.del_user_functions() # delete all user functions 
+    device.clear_error_stack() # clear error stack
+    # setup the smus
+
+    norm = normalization_factor(ui.sample.width.value)
+    points = number_of_points(ui.Vtg_output)
+
+    
+    smu_source = device.smu_dict()
+    smu_source.update(vname ='VS',iname = 'IS',mode = 'COMM',func='CONS')
+
+    smu_top_gate = device.smu_dict()
+    smu_top_gate.update(vname = 'VTG',iname='ITG',mode = 'V',func='VAR2')
+
+    smu_back_gate = device.smu_dict()
+    smu_back_gate.update(vname = 'VBG',iname='IBG',mode = 'COMM',func = 'CONS')
+
+    smu_drain = device.smu_dict()
+    smu_drain = device.update(vname='VDS',iname='ID',mode = 'V',func = 'VAR1')
+
+    # setup VAR1
+    var1 = device.var1_dict()
+    var1.update(
+        mode = ui.Vds_output.hyst.value,
+        start = ui.Vds_output.start.value,
+        stop = ui.Vds_output.stop.value,
+        step = ui.Vds_output.step.value,
+        comp = ui.Vds_output.comp.value,
+        pcomp = ui.Vds_output.pcomp.value
+    )
+
+    var2=device.var2_dict() #Vds_output is always used in tranfer curve with the same config
+    var2.update(
+        start=ui.Vtg_output.start.value,
+        step=ui.Vtg_output.step.value,
+        points=points,
+        comp=ui.Vtg_output.comp.value,
+        pcomp=ui.Vtg_output.pcomp.value,
+    )
+
+     try:
+        device.setup_smu(ui.sample.top_gate.value,smu_top_gate)
+        device.setup_smu(ui.sample.drain.value,smu_drain)
+        device.setup_smu(ui.sample.back_gate.value,smu_back_gate)
+        device.setup_smu(ui.sample.source.value,smu_source)
+    
+        device.setup_var1(var1)
+        device.setup_var2(var2)
+    
+        device.integration_time(ui.integration_output.value)
+        variables_list = ['VDS','ID','VTG','ITG']
+        device.variables_to_save(variables_list)
+
+        plotted_variables = graph_tool(plot_output,ui.sample.width.value,device)
+
+        device.single_measurement()
+        
+        while device.operation_completed()==False:
+            pass
+
+        device.error_occured()
+
+        if ui.sample.quick.value == False:
+            device.autoscaling()
+       
+    
+        values = dict([(variable,device.return_values(variable)) for variable in variables_list])
+        df = get_dataframe_from_results(values)
+    except Exception as e:
+        error_box(e)
+        return
+
+    # Append the normalized current 
+    df["IDmm/uA/um"]= (df["ID/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
+    df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
+
+    default_filename = f"{ui.sample.sample.value}_{ui.sample.field.value}_{ui.sample.device.value}_TOP_GATE_A.txt"
+    file = create_file(default_filename)
+
+    with open(file,'w') as f:
+        date = str(datetime.today().replace(microsecond=0))
+        f.write(f"Output Curve at {date}"+"\n")
+        write_sample_information(ui.sample,f)
+        f.write("Sweeping Gate:VTG"+"\n\n")
+        f.write('Parameters\n')
+        f.write(f"VTG from {ui.Vtg_output.start.value}V to {ui.Vtg_output.stop.value}V with step {ui.Vtg_output.step.value}V"+"\n")
+        f.write(f"VDS from {ui.Vds_output.start.value}V to {ui.Vds_output.stop.value}V with step {ui.Vds_output.step.value}V"+"\n")
+        
+        if ui.Vtg_output.pcomp.value==0:
+            f.write(f"Top Gate Current Compliance/A:{ui.Vtg_output.comp.value}"+"\n")
+        else:
+            f.write(f"Top Gate Power Compliance/A:{ui.Vtg_output.pcomp.value}"+"\n")
+
+        if ui.Vds_output.pcomp.value == 0:
+            f.write(f"Drain Current Compliance/A:{ui.Vds_output.comp.value}"+"\n")
+        else:
+             f.write(f"Drain Power Compliance/A:{ui.Vds_output.pcomp.value}"+"\n")
+        f.write(f"Integration Time:{ui.integration_output.value}"+"\n")
+        f.write("\nResults\n")
+
+    df.to_csv(file,sep=" ",mode='a')
+
+    if ui.sample.quick.value == False:
+        df["label"] = df.apply(lambda row:f"VTG = {row["VTG/V"]} (V)",axis = 1) # assign labels
+        create_plot(ui.plot_output,df,file,"Top Gate Output Measurement", "Swept VTG voltages:",ui.sample.save_fig.value)
+
+
+def VBG(ui,device):
+     device.del_user_functions() # delete all user functions 
+    device.clear_error_stack() # clear error stack
+    # setup the smus
+
+    norm = normalization_factor(ui.sample.width.value)
+    points = number_of_points(ui.Vbg_output)
+
+    
+    smu_source = device.smu_dict()
+    smu_source.update(vname ='VS',iname = 'IS',mode = 'COMM',func='CONS')
+
+    smu_top_gate = device.smu_dict()
+    smu_top_gate.update(vname = 'VTG',iname='ITG',mode = 'COMM',func='CONS')
+
+    smu_back_gate = device.smu_dict()
+    smu_back_gate.update(vname = 'VBG',iname='IBG',mode = 'V',func = 'VAR2')
+
+    smu_drain = device.smu_dict()
+    smu_drain = device.update(vname='VDS',iname='ID',mode = 'V',func = 'VAR1')
+
+    # setup VAR1
+    var1 = device.var1_dict()
+    var1.update(
+        mode = ui.Vds_output.hyst.value,
+        start = ui.Vds_output.start.value,
+        stop = ui.Vds_output.stop.value,
+        step = ui.Vds_output.step.value,
+        comp = ui.Vds_output.comp.value,
+        pcomp = ui.Vds_output.pcomp.value
+    )
+
+    var2=device.var2_dict() #Vds_output is always used in tranfer curve with the same config
+    var2.update(
+        start=ui.Vbg_output.start.value,
+        step=ui.Vbg_output.step.value,
+        points=points,
+        comp=ui.Vbg_output.comp.value,
+        pcomp=ui.Vbg_output.pcomp.value,
+    )
+
+     try:
+        device.setup_smu(ui.sample.top_gate.value,smu_top_gate)
+        device.setup_smu(ui.sample.drain.value,smu_drain)
+        device.setup_smu(ui.sample.back_gate.value,smu_back_gate)
+        device.setup_smu(ui.sample.source.value,smu_source)
+    
+        device.setup_var1(var1)
+        device.setup_var2(var2)
+    
+        device.integration_time(ui.integration_output.value)
+
+        variables_list = ['VDS','ID','VBG','IBG']
+        device.variables_to_save(variables_list)
+
+        plotted_variables = graph_tool(ui.plot_output,ui.sample.width.value,device)
+        
+        device.single_measurement()
+        
+        while device.operation_completed()==False:
+            pass
+
+        device.error_occured()
+
+        if ui.sample.quick.value == False:
+            device.autoscaling()
+       
+    
+        values = dict([(variable,device.return_values(variable)) for variable in variables_list])
+        df = get_dataframe_from_results(values)
+    except Exception as e:
+        error_box(e)
+        return
+
+    # Append the normalized current 
+    df["IDmm/uA/um"]= (df["ID/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
+    df["IBGmm/uA/um"]= (df["IBG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
+
+
+    # Save the results
+    default_filename = f"{ui.sample.sample.value}_{ui.sample.field.value}_{ui.sample.device.value}_BACK_GATE_A.txt"
+    file = create_file(default_filename)
+
+    with open(file,'w') as f:
+        date = str(datetime.today().replace(microsecond=0))
+        f.write(f"Output Curve at {date}"+"\n")
+        write_sample_information(ui.sample,f)
+        f.write("Sweeping Gate:VBG"+"\n\n")
+        f.write('Parameters\n')
+        f.write(f"VBG from {ui.Vbg_output.start.value}V to {ui.Vbg_output.stop.value}V with step {ui.Vbg_output.step.value}V"+"\n")
+        f.write(f"VDS from {ui.Vds_output.start.value}V to {ui.Vds_output.stop.value}V with step {ui.Vds_output.step.value}V"+"\n")
+        
+        if ui.Vbg_output.pcomp.value==0:
+            f.write(f"Back Gate Current Compliance/A:{ui.Vbg_output.comp.value}"+"\n")
+        else:
+            f.write(f"Back Gate Power Compliance/A:{ui.Vbg_output.pcomp.value}"+"\n")
+
+        if ui.Vds_output.pcomp.value == 0:
+            f.write(f"Drain Current Compliance/A:{ui.Vds_output.comp.value}"+"\n")
+        else:
+             f.write(f"Drain Power Compliance/A:{ui.Vds_output.pcomp.value}"+"\n")
+        f.write(f"Integration Time:{ui.integration_output.value}"+"\n")
+        f.write("\nResults\n")
+
+    df.to_csv(file,sep=" ",mode='a')
+
+    if ui.sample.quick.value == False:
+        df["label"] = df.apply(lambda row:f"VBG = {row["VBG/V"]} (V)",axis = 1) # assign labels
+        create_plot(ui,df,file,"Back Gate Output Measurement", "Swept VBG voltages:",ui.sample.save_fig.value)
+
+def SEQ(ui,device):
+    norm = normalization_factor(ui.sample.width.value)
+    points_VTG = number_of_points(ui.Vtg_output)
+    points_VBG = number_of_points(ui.Vbg_output)
+
+    try:
+        values_VBG = np.linspace(ui.Vbg_output.start.value, ui.Vbg_output.stop.value,num = points,endpoint = True)
+    except:
+        error_box("Invalid VBG values!")
+        return
+
+    smu_source = device.smu_dict()
+    smu_source.update(vname ='VS',iname = 'IS',mode = 'COMM',func='CONS')
+
+    smu_top_gate = device.smu_dict()
+    smu_top_gate.update(vname = 'VTG',iname='ITG',mode = 'V',func='VAR2')
+
+    smu_back_gate = device.smu_dict()
+    smu_back_gate.update(vname = 'VBG',iname='IBG',mode = 'V',func = 'CONS') 
+
+    smu_drain = device.smu_dict()
+    smu_drain = device.update(vname='VDS',iname='ID',mode = 'V',func = 'VAR1')
+
+    # setup VAR1
+    var1 = device.var1_dict()
+    var1.update(
+        mode = ui.Vds_output.hyst.value,
+        start = ui.Vds_output.start.value,
+        stop = ui.Vds_output.stop.value,
+        step = ui.Vds_output.step.value,
+        comp = ui.Vds_output.comp.value,
+        pcomp = ui.Vds_output.pcomp.value
+    )
+
+    var2=device.var2_dict() #Vds_output is always used in tranfer curve with the same config
+    var2.update(
+        start=ui.Vtg_output.start.value,
+        step=ui.Vtg_output.step.value,
+        points=points_VTG,
+        comp=ui.Vtg_output.comp.value,
+        pcomp=ui.Vtg_output.pcomp.value,
+    )
+    
+    try:
+        device.setup_smu(ui.sample.top_gate.value,smu_top_gate)
+        device.setup_smu(ui.sample.drain.value,smu_drain)
+        device.setup_smu(ui.sample.back_gate.value,smu_back_gate)
+        device.setup_smu(ui.sample.source.value,smu_source)
+    
+        device.setup_var1(var1) 
+        device.setup_var2(var2)
+
+        device.integration_time(ui.integration_output.value)
+        
+        variables_list =["VBG","IBG","VDS","ID","VTG","ITG"]
+        device.variables_to_save(variables_list)
+
+        plotted_variables = graph_tool(ui.plot_output,ui.sample.width.value,device)
+        for i,value in enumerate(VBG_values):
+            cons = device.cons_smu_dict()
+            cons.update(comp = ui.Vbg_output.comp.value, value = value)
+            device.setup_cons_smu(ui.sample.back_gate.value,cons)
+
+            if i == 0:
+                device.single_measurement()
+            else:
+                device.append_measurement()
+            
+            while device.operation_completed()==False:
+                pass
+            device.error_occured()
+
+        if ui.sample.quick.value == False:
+            device.autoscaling()
+        
+        values = dict([(variable,device.return_values(variable)) for variable in variables_list])
+        df = get_dataframe_from_results(values)
+
+    except Exception as e:
+        error_box(e)
+        return
+
+    # Append the normalized current 
+    df["IDmm/uA/um"]= (df["ID/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
+    df["IBGmm/uA/um"]= (df["IBG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
+    df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
+
+
+    # Save the results
+    default_filename = f"{ui.sample.sample.value}_{ui.sample.field.value}_{ui.sample.device.value}_BOTH_GATES_SEQ_A.txt"
+    file = create_file(default_filename)
+
+     with open(file,'w') as f:
+        date = str(datetime.today().replace(microsecond=0))
+        f.write(f"output Curve at {date}"+"\n")
+        write_sample_information(ui.sample,f)
+        f.write("Sweeping Gate:VTG,VBG sequentially"+"\n\n")
+        f.write('Parameters\n')
+        f.write(f"VBG from {ui.Vbg_output.start.value}V to {ui.Vbg_output.stop.value}V with step {ui.Vbg_output.step.value}V"+"\n")
+        f.write(f"VTG from {ui.Vtg_output.start.value]}V to {ui.Vtg_output.stop.value}V with step {ui.Vbg_output.step.value}V"+"\n")
+        f.write(f"VDS from {ui.Vds_output.start.value}V to {ui.Vds_output.stop.value}V with step {ui.Vds_output.step.value}V"+"\n")
+        
+        f.write(f"Back Gate Current Compliance/A:{ui.Vbg_output.comp.value}"+"\n")
+
+        if ui.Vtg_output.pcomp.value==0:
+            f.write(f"Top Gate Current Compliance/A:{ui.Vtg_output.comp.value}"+"\n")
+        else:
+            f.write(f"Top Gate Power Compliance/A:{ui.Vtg_output.pcomp.value}"+"\n")        
+
+        if ui.Vds_output.pcomp.value == 0:
+            f.write(f"Drain Current Compliance/A:{ui.Vds_output.comp.value}"+"\n")
+        else:
+             f.write(f"Drain Power Compliance/A:{ui.Vds_output.pcomp.value}"+"\n")
+        f.write(f"Integration Time:{ui.integration_output.value}"+"\n")
+        f.write("\nResults\n")
+
+    df.to_csv(file,sep=" ",mode='a')
+
+    if ui.sample.quick.value == False:
+        df["label"] = df.apply(lambda row:f"VTG = {row["VTG/V"]} (V), VBG = {row["VBG/V"]} (V)",axis = 1) # assign labels
+        create_plot(ui.plot_output,df,file,"Sequential Sweep of Both Gates Output Measurement", "Swept voltages:",ui.sample.save_fig.value)
+        
+        
+
+    
+    
+
+
+        
+    
+
+
+    
+
+    
+
+    
+        
+
+    
+    
\ No newline at end of file
diff --git a/hp4155/ADU for double gate devices_version_3/lib/transfer.py b/hp4155/ADU for double gate devices_version_3/lib/transfer.py
index 39daf59769d2e33d57b3522c1dba565d869fbab1..245290aee96690b57e81cff0c55e55ac419e19cc 100644
--- a/hp4155/ADU for double gate devices_version_3/lib/transfer.py	
+++ b/hp4155/ADU for double gate devices_version_3/lib/transfer.py	
@@ -114,7 +114,7 @@ def VTG(ui,device):
 
     if ui.sample.quick.value == False:
         df["label"] = df.apply(lambda row:f"VDS = {row["VDS/V"]} (V)",axis = 1) # assign labels
-        create_plot(ui,df,file,"Top Gate Transfer Measurement", "Swept VDS voltages:",ui.sample.save_fig.value)
+        create_plot(ui.plot_transfer,df,file,"Top Gate Transfer Measurement", "Swept VDS voltages:",ui.sample.save_fig.value)
 
 def VBG(ui,device):
     device.del_user_functions() # delete all user functions 
@@ -223,7 +223,7 @@ def VBG(ui,device):
 
     if ui.sample.quick.value == False:
         df["label"] = df.apply(lambda row:f"VDS = {row["VDS/V"]} (V)",axis = 1) # assign labels
-        create_plot(ui,df,file,"Back Gate Transfer Measurement", "Swept VDS voltages:",ui.sample.save_fig.value)
+        create_plot(ui.plot_transfer,df,file,"Back Gate Transfer Measurement", "Swept VDS voltages:",ui.sample.save_fig.value)
 
 
 # Simultaneously bóth gates
@@ -356,7 +356,7 @@ def SIM():
 
     if ui.sample.quick.value == False:
         df["label"] = df.apply(lambda row:f"VDS = {row["VDS/V"]} (V)",axis = 1) # assign labels
-        create_plot(ui,df,file,"Simultaneous Sweep of Both Gates Transfer Measurement", "Swept VDS voltages:",ui.sample.save_fig.value)
+        create_plot(ui.plot_transfer,df,file,"Simultaneous Sweep of Both Gates Transfer Measurement", "Swept VDS voltages:",ui.sample.save_fig.value)
 
 def SEQ(ui,device):
     
@@ -365,7 +365,7 @@ def SEQ(ui,device):
     points_VBG = number_of_points(ui.Vbg_transfer)
 
     try:
-        values_VBG = np.linspace(ui.Vbg_transfer.start.value)
+        values_VBG = np.linspace(ui.Vbg_transfer.start.value,ui.Vbg_transfer.stop.value,num = points, endpoint = True)
     except:
         error_box("Invalid VBG values!")
         return
@@ -383,7 +383,7 @@ def SEQ(ui,device):
     smu_drain = device.update(vname='VDS',iname='ID',mode = 'V',func = 'VAR2')
 
 
-        # setup VAR1
+    # setup VAR1
     var1 = device.var1_dict()
     var1.update(
         mode = ui.Vtg_transfer.hyst.value,
@@ -425,14 +425,14 @@ def SEQ(ui,device):
             cons.update(comp = ui.Vbg_transfer.comp.value, value = value)
             device.setup_cons_smu(ui.sample.back_gate.value,cons)
             
-             if i == 0:
-                    device.single_measurement()
-                else:
-                    device.append_measurement()
+            if i == 0:
+                device.single_measurement()
+            else:
+                device.append_measurement()
             
-                while device.operation_completed()==False:
-                    pass
-                device.error_occured()
+            while device.operation_completed()==False:
+                pass
+            device.error_occured()
         
         if ui.sample.quick.value == False:
             device.autoscaling()
@@ -487,52 +487,4 @@ def SEQ(ui,device):
         else:
             df["label"] = df.apply(lambda row:f"VDS = {row["VDS/V"]} (V), VTG = {row["VTG/V"]} (V)",axis = 1) # assign labels
 
-        create_plot(ui.plot_transfer,df,file,"Simultaneous Sweep of Both Gates Transfer Measurement", "Swept voltages:",ui.sample.save_fig.value)
-
-
-            
-
-    
-
-
-
-        
-                            
-    
-
-    
-
-    
-        
-    
-    
-    
-
-
-    
-        
-
-    
-
-
-
-
-    
-
-        
-        
-
-    
-                
-                
-        
-        
-    
-
-        
-        
-
-
-
-    
-
+        create_plot(ui.plot_transfer,df,file,"Sequential Sweep of Both Gates Transfer Measurement", "Swept voltages:",ui.sample.save_fig.value)
\ No newline at end of file