From b295a696c0adb5bf4d87ecc150cf8e197733bb53 Mon Sep 17 00:00:00 2001
From: unknown <asoalexandros@gmail.com>
Date: Tue, 22 Apr 2025 13:42:25 +0200
Subject: [PATCH] Voltmeter part 1

---
 hp4155/memristor (Version 4.1)/help.py        | 41 +++++++++++++++++--
 hp4155/memristor (Version 4.1)/memristor.py   | 22 +++++++---
 .../memristor_buttons.ipynb                   | 10 ++---
 3 files changed, 59 insertions(+), 14 deletions(-)

diff --git a/hp4155/memristor (Version 4.1)/help.py b/hp4155/memristor (Version 4.1)/help.py
index be1838e..31cf081 100644
--- a/hp4155/memristor (Version 4.1)/help.py	
+++ b/hp4155/memristor (Version 4.1)/help.py	
@@ -136,7 +136,7 @@ def OL(device):
     return df
 
 #double sweep from start to stop and then from start to stop
-def sweep(start,stop,step,comp,integration,device): #step cannot be negative
+def sweep(start,stop,step,comp,integration,voltmeter,device):
     device.del_user_functions()
     if start < stop and step < 0 :
         step = -step
@@ -168,13 +168,47 @@ def sweep(start,stop,step,comp,integration,device): #step cannot be negative
         pcomp = 0
     )
 
+    # Setup the voltmeter configurations
+    smu_voltmeter_1 = device.smu_dict()
+    smu_voltmeter_3 = device.smu_dict()
+    
+    smu_voltmeter_1.update(
+        iname = 'I1',
+        vname = 'V1',
+        mode = 'I',
+        func = 'CONS',
+        value = 0
+        comp = 'MAX',
+    )
+
+     smu_voltmeter_3.update(
+        iname = 'I3',
+        vname = 'V3',
+        mode = 'I',
+        func = 'CONS',
+        value = 0
+        comp = 'MAX',
+    )
+
     #disable smus 1 and 3
     device.measurement_mode('SWE')
-    device.smu_disable(1)
-    device.smu_disable(3)
+
+    if voltmeter == False:
+        device.smu_disable(1)
+        device.smu_disable(3)
+    else:
+        device.setup_smu(1,smu_voltmeter_1)
+        device.setup_smu(3,smu_voltmeter_3)
 
     device.setup_smu(2,smu_v)
     device.setup_smu(4,smu_ground)
+
+    # Do it as the tool would do it
+    if volmeter == True:
+        device.user_function("VMEAS","V","V3-V1")
+        device.setup_cons_smu(1,smu_voltmeter_1)
+        device.setup_cons_smu(3,smu_voltmeter_3)
+    
     device.setup_var1(parameters)
     device.integration_time(integration)
     
@@ -374,7 +408,6 @@ def plot_retention(x,y):
     ax.plot(x,y)
     display(fig)
     
-
 def create_data_frame(x,y):
     header = ['V(V)','ABSV(V)',"I(A)",'ABSI(A)',"R(Ohm)"]
     data = {header[0]:x,header[1]:np.absolute(x),header[2]:y,header[3]:np.absolute(y),header[4]:np.divide(x,y)}
diff --git a/hp4155/memristor (Version 4.1)/memristor.py b/hp4155/memristor (Version 4.1)/memristor.py
index ddb5750..2cce96b 100644
--- a/hp4155/memristor (Version 4.1)/memristor.py	
+++ b/hp4155/memristor (Version 4.1)/memristor.py	
@@ -77,6 +77,12 @@ auto_qcc = widgets.Checkbox(
     style = {'description_width': 'initial'},
     value = True
 )
+# Voltmeter for set reset endurance
+voltmeter = widgets.Checkbox(
+    description = "Voltmeter",
+    style = {'description_width': 'initial'},
+    value = False
+)
 
 # THE BUTTONS 
 #create buttons as it shown in the how_buttons_look 
@@ -164,7 +170,7 @@ threshold = widgets.FloatText(
 )
 
 #align a button with a checkbox or integer bounded texts horizontaly
-line0 = widgets.HBox([step,integration_time,sampling,auto_qcc])
+line0 = widgets.HBox([step,integration_time,sampling,voltmeter,auto_qcc])
 line1 = widgets.HBox([set,Vset,CC_vset])
 line2 = widgets.HBox([reset,Vreset,CC_vreset])
 line3 = widgets.HBox([full,number,auto_stop,threshold])
@@ -196,7 +202,7 @@ display(tab)
 display(widgets.HBox([import_ini_button,export_ini_button]))
 display(output)
 
-all_widgets=[sweep_button,cons_button,sample_series,field,DUT,set,reset,full,new_folder,retention_button,contact_check,qcc,qcc_select,Vset,CC_vset,Vreset,CC_vreset,step,integration_time,number,sampling,Vretention,period,duration,auto_qcc,auto_stop,threshold,export_ini_button,import_ini_button]
+all_widgets=[sweep_button,cons_button,sample_series,field,DUT,set,reset,full,new_folder,retention_button,contact_check,qcc,qcc_select,Vset,CC_vset,Vreset,CC_vreset,step,integration_time,number,sampling,Vretention,period,duration,auto_qcc,auto_stop,threshold,export_ini_button,import_ini_button,voltmeter]
 add_widgets_to_list(cons_dict,all_widgets)
 add_widgets_to_list(sweep_dict,all_widgets)
 
@@ -298,9 +304,11 @@ def on_set_button_clicked(b):
                  
                
             #execute measurement,plot results and save them
-            V12,I12 = sweep(0,Vset.value,step.value,CC_vset.value,integration_time.value,device)
+            V12,I12 = sweep(0,Vset.value,step.value,CC_vset.value,integration_time.value,voltmeter.value,device)
             plot_sweep(V12,I12,'SET')
             df = create_data_frame(V12,I12)
+            if voltmeter.value == True:
+                df["V3-V1 (V)"] = np.array(device.return_data("VMEAS"))
             display(df)
             
 
@@ -346,9 +354,11 @@ def on_reset_button_clicked(b):
                 R_mean_before = sampling_check(0.01,device)
             
             #execute measurement,plot results and save them
-            V34,I34 = sweep(0,Vreset.value,step.value,CC_vreset.value,integration_time.value,device)
+            V34,I34 = sweep(0,Vreset.value,step.value,CC_vreset.value,integration_time.value,voltmeter.value,device)
             plot_sweep(V34,I34,'RESET')
             df = create_data_frame(V34,I34)
+            if voltmeter.value == True:
+                df["V3-V1 (V)"] = np.array(device.return_data("VMEAS"))
             display(df)
             
             if sampling.value == True: #do sampling set after reset process(100mV)
@@ -428,7 +438,9 @@ def on_full_button_clicked(b):
                         R_mean_init = sampling_check(-0.01,device)
                         resistances.append(R_mean_init)
                         
-                    V12,I12 = sweep(0,Vset.value,step.value,CC_vset.value,integration_time.value,device) #set
+                    V12,I12 = sweep(0,Vset.value,step.value,CC_vset.value,integration_time.value,voltmeter.value,device) #set
+                    if voltmeter.value == True:
+                        V12_meas = np.array(device.return_data("VMEAS"))
                     plot_sweep(V12,I12,f"SET Iteration {i+1}")
                     
                     #after set/before reset
diff --git a/hp4155/memristor (Version 4.1)/memristor_buttons.ipynb b/hp4155/memristor (Version 4.1)/memristor_buttons.ipynb
index 3f0b2d2..5811320 100644
--- a/hp4155/memristor (Version 4.1)/memristor_buttons.ipynb	
+++ b/hp4155/memristor (Version 4.1)/memristor_buttons.ipynb	
@@ -9,7 +9,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "ee37bb9143ea4700b52b65472396a736",
+       "model_id": "38e9df2d71aa4c47946afdab7283fcb5",
        "version_major": 2,
        "version_minor": 0
       },
@@ -23,7 +23,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "69dc37eef3324042bde9312312e3c7ae",
+       "model_id": "891d087e72f44bc68d9e6f0b66ae895c",
        "version_major": 2,
        "version_minor": 0
       },
@@ -37,7 +37,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "07e0dcf7487e4865a0dca762f11622f5",
+       "model_id": "50b7551dd46f459499e748aaf5a7ec0c",
        "version_major": 2,
        "version_minor": 0
       },
@@ -51,7 +51,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "6a06dee55f204e44963596e9fe610547",
+       "model_id": "ab08cb608ea848b9b05a0a9d08bd011a",
        "version_major": 2,
        "version_minor": 0
       },
@@ -70,7 +70,7 @@
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "cf97050b-5c05-4e11-a706-60a4d48c3d0d",
+   "id": "a917fee4-b51f-4eb3-8ab9-dabee429d75f",
    "metadata": {},
    "outputs": [],
    "source": []
-- 
GitLab