Skip to content
Snippets Groups Projects
Commit 635c3759 authored by Alexandros Asonitis's avatar Alexandros Asonitis
Browse files

bug fixes and more sampling checks in memristor

parent afa290ce
No related branches found
No related tags found
No related merge requests found
......@@ -205,10 +205,16 @@ def on_set_button_clicked(b):
change_state(buttons)
change_state(parameters)
#lock the device
device.inst.lock_excl()
clear_output()
#check values
valid = check_values(step.value,Vset.value,Vreset.value)
#during first button press
if first == True:
if first == True and valid == True:
change_state(information)#disable all widgets that are relevant about the information of the sample
filename=f"{sample_series.value}_{field.value}_{DUT.value}.txt"
file = os.path.join(folder,filename)
......@@ -216,10 +222,6 @@ def on_set_button_clicked(b):
write_header(temp_file,sample_series,field,DUT)
first = False
#check values
valid = check_values(step.value,Vset.value,Vreset.value)
if valid == True:
if sampling.value == True: #do sampling set before set process(100mV)
R_mean_before = sampling_check(0.1,device)
......@@ -245,9 +247,13 @@ def on_set_button_clicked(b):
#upload results
temp_file,file,folder=upload_results(temp_file,file,folder)
#show messagebox
information_box("Measurement finished!")
#unlock device
device.inst.unlock()
change_state(buttons)
change_state(parameters)
......@@ -257,10 +263,16 @@ def on_reset_button_clicked(b):
change_state(buttons)
change_state(parameters)
#lock device
device.inst.lock_excl()
clear_output()
#check values
valid = check_values(step.value,Vset.value,Vreset.value)
#during first button press
if first == True:
if first == True and valid == True:
#disable checkboxes, text fields etc.
change_state(information)
filename=f"{sample_series.value}_{field.value}_{DUT.value}.txt"
......@@ -269,11 +281,7 @@ def on_reset_button_clicked(b):
write_header(temp_file,sample_series,field,DUT)
first = False #set first to false irrelvant if it is in the if statement or not
#check values
valid = check_values(step.value,Vset.value,Vreset.value)
if valid == True:
if sampling.value == True: #do sampling set before reset process(10mV)
R_mean_before = sampling_check(0.01,device)
print(f"Average Resistance(Sampling Check):{R_mean_before:e} Ohm")
......@@ -285,7 +293,6 @@ def on_reset_button_clicked(b):
df = create_data_frame(V34,I34)
print(df)
if sampling.value == True: #do sampling set after reset process(100mV)
R_mean_after = sampling_check(0.1,device)
print(f"Average Resistance(Sampling Check):{R_mean_after:e} Ohm")
......@@ -298,9 +305,13 @@ def on_reset_button_clicked(b):
#upload results
temp_file,file,folder=upload_results(temp_file,file,folder)
#show messagebox
information_box("Measurement finished!")
#unlock device
device.inst.unlock()
change_state(buttons)
change_state(parameters)
......@@ -310,10 +321,16 @@ def on_full_button_clicked(b):
change_state(buttons)
change_state(parameters)
# lock device
device.inst.lock_excl()
clear_output()
#check values
valid = check_values(step.value,Vset.value,Vreset.value)
#during first button press
if first == True:
if first == True and valid == True:
#disable checkboxes, text fields etc.
change_state(information)
filename=f"{sample_series.value}_{field.value}_{DUT.value}.txt"
......@@ -322,8 +339,7 @@ def on_full_button_clicked(b):
write_header(temp_file,sample_series,field,DUT)
first = False #set first to false irrelvant if it is in the if statement or not
#check values
valid = check_values(step.value,Vset.value,Vreset.value)
if valid == True:
with open(temp_file,'a') as f:
f.write(f"{number.value} full sweeps with parameters:")
......@@ -359,19 +375,25 @@ def on_full_button_clicked(b):
#execute number of measurements
for i in range(number.value):#here it is easier to implement the sampling checks
if sampling.value == True: #before set(100mv)
R_mean_before = sampling_check(0.1,device)
resistances.append(R_mean_before)
R_mean_init = sampling_check(0.1,device)
resistances.append(R_mean_init)
V12,I12 = sweep(0,Vset.value,step.value,CC_vset.value,integration_time.value,device) #set
#after set/before set
if sampling.value == True: #before set(10mv)
R_mean_after = sampling_check(0.01,device)
resistances.append(R_mean_after)
R_mean_set = sampling_check(0.01,device)
resistances.append(R_mean_set)
V34,I34 = sweep(0,Vreset.value,step.value,CC_vreset.value,integration_time.value,device) #reset
#no reason to do check at the end because the next loop will do that
#no reason to do check at the end because the next loop will do that(not anymore) more sampling checks
#after reset
if sampling.value == True:#-0.1V
R_mean_reset = sampling_check(-0.1,device)
resistances.append(R_mean_reset)
#butterfly curve
V=np.concatenate((V12,V34))
......@@ -382,7 +404,7 @@ def on_full_button_clicked(b):
f.write(f"{i+1} Iteration")
f.write("\n")
if sampling.value == True:
f.write(f"R(Ohm) Before(set)/After(set)"+"\n"+f"{R_mean_before} {R_mean_after}"+"\n")
f.write(f"R(Ohm) INIT/SET/RESET"+"\n"+f"{R_mean_init} {R_mean_set} {R_mean_reset}"+"\n")
f.write(df.to_string())
f.write("\n\n")
......@@ -423,11 +445,15 @@ def on_full_button_clicked(b):
ax.set_yscale('log')
plt.scatter(indexes,resistances)
plt.show()
print(len(resistances))
print(indexes)
#print(len(resistances))
#print(indexes)
#upload results
temp_file,file,folder=upload_results(temp_file,file,folder)
#unlock the device
device.inst.unlock()
change_state(buttons)
change_state(parameters)
......@@ -443,8 +469,8 @@ def on_new_sample_button_clicked(b):
first = True
#change_state(information) not anymore creating changing state but enabling the widgets
enable_widgets(information)
sample_series.value=''
field.value=''
#sample_series.value=''
#field.value=''
DUT.value=''
#enable again
......@@ -469,6 +495,9 @@ def on_retention_button_clicked(b):
with output:
change_state(buttons)
change_state(parameters)
device.inst.lock_excl()
clear_output()
#during first button press
......@@ -493,6 +522,8 @@ def on_retention_button_clicked(b):
#show messagebox
information_box("Measurement finished!")
device.inst.unlock()
change_state(buttons)
change_state(parameters)
......
%% Cell type:code id:df99f5a2-80af-4892-8633-33177239e444 tags:
``` python
%run memristor.py
```
%% Output
%% Cell type:code id:a8266885-3aa9-4abf-9b02-575a783f3fab tags:
%% Cell type:code id:076a9132-edc2-4ae5-8a7f-c8a179473952 tags:
``` python
```
......
%% Cell type:code id:d310162d-c528-49ef-babb-47f603fee08b tags:
``` python
import sys
sys.path.insert(0, '..') #append parent directory
import matplotlib.pyplot as plt
import numpy as np
import module
import time
from random import uniform
import pandas as pd
from random import randint
#connect to the device
device = module.HP4155a('GPIB0::17::INSTR')
device.reset()
#set the measurement parameters
def pulse(start,stop,points,period,integration,device):
device.smu_disable_sweep(1)
device.smu_disable_sweep(3)
#disable vmus and vsus
device.disable_vsu(1)
device.disable_vsu(2)
device.disable_vmu(1)
device.disable_vmu(2)
device.user_function('R','OHM','V2/I2')
device.measurement_mode("SWE")
device.smu_function_sweep(2,"VAR1")
device.smu_mode_meas(4,"COMMON")
device.smu_function_sweep(4,"CONS")
device.smu_mode_meas(2,"VPULSE")
device.start_value_sweep(start)
device.stop_value_sweep(stop)
#define the number of steps given specific pulses
step = (stop-start)/(points-1)
device.step_sweep(step)
device.comp("VAR1","MAX")
device.display_variable("X","V2")
device.display_variable("Y1",'I2')
device.range_mode(4,"AUTO")
device.range_mode(2,"AUTO")
device.pulse_width(period/10)
device.pulse_period(period)
device.integration_time(integration)
t0 = time.time()
device.single_measurement()
while device.operation_completed()== False:
pass
t1 = time.time()
# get the execution time
elapsed_time = t1 - t0
device.autoscaling()
I_i=device.return_data("I2")
V_i=device.return_data("V2")
R_i = device.return_data("R")
expected_time = period*int(points)
times = (elapsed_time,expected_time)
values = (V_i,I_i,R_i)
return times,values
```
%% Output
---------------------------------------------------------------------------
VisaIOError Traceback (most recent call last)
Cell In[1], line 15
13 #connect to the device
14 device = module.HP4155a('GPIB0::17::INSTR')
---> 15 device.reset()
17 #set the measurement parameters
18 def pulse(start,stop,points,period,integration,device):
File ~\labcode\hp4155\memristor\..\module.py:18, in HP4155a.reset(self)
17 def reset(self):
---> 18 self.inst.write("*RST")
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\resources\messagebased.py:197, in MessageBasedResource.write(self, message, termination, encoding)
191 warnings.warn(
192 "write message already ends with " "termination characters",
193 stacklevel=2,
194 )
195 message += term
--> 197 count = self.write_raw(message.encode(enco))
199 return count
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\resources\messagebased.py:157, in MessageBasedResource.write_raw(self, message)
143 def write_raw(self, message: bytes) -> int:
144 """Write a byte message to the device.
145
146 Parameters
(...)
155
156 """
--> 157 return self.visalib.write(self.session, message)[0]
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\ctwrapper\functions.py:2796, in write(library, session, data)
2794 return_count = ViUInt32()
2795 # [ViSession, ViBuf, ViUInt32, ViPUInt32]
-> 2796 ret = library.viWrite(session, data, len(data), byref(return_count))
2797 return return_count.value, ret
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\ctwrapper\highlevel.py:226, in IVIVisaLibrary._return_handler(self, ret_value, func, arguments)
223 # Set session back to a safe value
224 session = None
--> 226 return self.handle_return_value(session, ret_value)
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\highlevel.py:251, in VisaLibraryBase.handle_return_value(self, session, status_code)
248 self._last_status_in_session[session] = rv
250 if rv < 0:
--> 251 raise errors.VisaIOError(rv)
253 if rv in self.issue_warning_on:
254 if session and rv not in self._ignore_warning_in_session[session]:
VisaIOError: VI_ERROR_RSRC_LOCKED (-1073807345): Specified type of lock cannot be obtained, or specified operation cannot be performed, because the resource is locked.
%% Cell type:code id:5173db43-2301-4946-9dbb-9296d61b979f tags:
``` python
index_start = int(input("Please Give The number of first iteration:"))
index_stop = int(input("Please Give the number of the last iteration"))
measurement = input("Give the name of the measurement:")
start = int(input("Give The Start Value:"))
stop = int(input("Give The Stop Value:"))
#set the number of iterations
for i in range(index_start-1,index_stop):
#for each iteration choose a random period and round it to 3 decimal points
period = uniform(0.005,1)
period = round(period,3)
#for each period choose 5 random pulse numbers from 2 to 100
pulses = [randint(2, 100) for p in range(5)]
#iterate over the pulses list
for j in range(len(pulses)):
#execute the measuremnt first for short and then medium integration time
for integration in ["SHOR","MED"]:
filename = r"\\FILESERVER\public\Datentransfer\Asonitis, Alexandros\memristor test\pulse_measurements\evaluation_" + f"{measurement}_{integration}_{pulses[j]}_{i+1}.txt"
times,values = pulse(start,stop,pulses[j],period,integration,device)
with open(filename,"w") as f:
f.write(f"{measurement}"+"\n")
f.write(f"period(s):{period}"+"\n")
f.write(f"execution time(s):{times[0]}"+"\n")
f.write(f"expected time(s):{times[1]}"+"\n")
f.write(f"number of pulses:{pulses[j]}"+"\n\n")
zipped = list(zip(values[0],values[1], values[2]))
df = pd.DataFrame(zipped, columns=['VPULSE(V)', 'IPULSE(A)', 'RPULSE(Ohm)'])
f.write("Results Pulse:\n")
f.write(df.to_string())
print("programm finished")
```
%% Output
Please Give The number of first iteration: 1
Please Give the number of the last iteration 10
Give the name of the measurement: DRAIN
Give The Start Value: 0
Give The Stop Value: 15
programm finished
%% Cell type:code id:6a4234c9-cf9f-42e2-99e8-f7ac9d1d5beb tags:
``` python
print(device.error())
```
%% Output
+0,"No error"
%% Cell type:code id:4aab235b-1533-4ae0-b4bb-930e5d3e0116 tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment