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

fixed errors after testing in the clean room!

parent 7fbc2181
Branches
No related tags found
No related merge requests found
......@@ -150,20 +150,10 @@ def decode_ini(process,ini_file):
return voltage,comp,integration_time,step
#disable widgets list
def disable_widgets(widgets_list):
for widget in widgets_list:
widgets.disabled=True
#enable widgets list
def enable_widgets(widgets_list):
for widget in widgets_list:
widgets.disabled = False
#write results to file
def write_to_file(file,title,df):
with open(file,'a') as f:
f.write(title)
f.write("\n")
f.write(df.to_string)
f.write("\n")
\ No newline at end of file
f.write(df.to_string())
f.write("\n\n")
\ No newline at end of file
### this is the new memrstor measurement (set and reset as many times as the user wants and full sweeps with a button)
from help import *
import ipywidgets as widgets
def memristor():
#parameters set by the user
......@@ -77,10 +78,6 @@ def memristor():
#dispaly them all
display(all,output)
#handling events for the buttons:
widgets_list=[sampling,DUT,sample_series,field]
buttons_list =[set,reset,full,number]
#connect to the device
device = module.HP4155a('GPIB0::17::INSTR')
device.reset()
......@@ -99,14 +96,22 @@ def memristor():
""" the above is what happens when the programm starts all the rest have to be written into button trigger functions"""
def on_set_button_clicked(b):
nonlocal Vset,CC_vset,step,integration_time,device,first,DUT,sample_series,field,file_path,ini_file,widgets_list,buttons_list,file
nonlocal Vset,CC_vset,step,integration_time,device,first,DUT,sample_series,field,file_path,ini_file,file
with output:
#disable buttons
set.disabled = True
reset.disabled=True
full.disabled =True
number.disabled =True
clear_output()
#during first button press
if first == True:
#disable checkboxes, text fields etc.
disable_widgets(widgets_list)
sample_series.disabled = True
field.disabled = True
DUT.disabled = True
sampling.disabled = True
#get ini file,and path from filechooser and open a new file
if fc.selected!=None:
......@@ -118,12 +123,10 @@ def memristor():
file = initialize_file(sample_series,field,DUT,file_path)
first = False
try:
#decode ini file
Vset,CC_vset,integration_time,step=decode_ini('SET',ini_file)
#disable buttons
disable_widgets(buttons_list)
#execute measurement,plot results and save them
V12,I12 = sweep(0,Vset,step,CC_vset,integration_time,device)
plot_sweep(V12,I12,'SET')
......@@ -132,17 +135,38 @@ def memristor():
write_to_file(file,title,df)
#enable buttons
enable_widgets(buttons_list)
set.disabled = False
reset.disabled=False
full.disabled =False
number.disabled=False
except Exception as e:
print(e)
print('please ensure that all parameters are correct')
set.disabled = False
reset.disabled=False
full.disabled =False
number.disabled=False
def on_reset_button_clicked(b):
nonlocal Vreset,CC_vreset,step,integration_time,device,first,DUT,sample_series,field,file_path,ini_file,widgets_list,buttons_list,file
nonlocal Vreset,CC_vreset,step,integration_time,device,first,DUT,sample_series,field,file_path,ini_file,file
with output:
set.disabled = True
reset.disabled=True
full.disabled =True
number.disabled=True
clear_output()
#during first button press
if first == True:
#disable checkboxes, text fields etc.
disable_widgets(widgets_list)
sample_series.disabled = True
field.disabled = True
DUT.disabled = True
sampling.disabled = True
#get ini file,and path from filechooser and open a new file
if fc.selected!=None:
......@@ -154,12 +178,10 @@ def memristor():
file = initialize_file(sample_series,field,DUT,file_path)
first = False #set first to false irrelvant if it is in the if statement or not
try:
#decode ini file
Vreset,CC_vreset,integration_time,step=decode_ini('RESET',ini_file)
#disable buttons
disable_widgets(buttons_list)
#execute measurement,plot results and save them
V34,I34 = sweep(0,Vreset,step,CC_vreset,integration_time,device)
plot_sweep(V34,I34,'RESET')
......@@ -168,18 +190,37 @@ def memristor():
write_to_file(file,title,df)
#enable buttons
enable_widgets(buttons_list)
set.disabled = False
reset.disabled=False
full.disabled =False
number.disabled=False
except Exception as e:
print(e)
print('please ensure that all parameters are correct')
set.disabled = False
reset.disabled=False
full.disabled =False
number.disabled=False
def on_full_button_clicked(b):
nonlocal Vset,CC_vset,step,integration_time,device,first,DUT,sample_series,field,file_path,ini_file,widgets_list,buttons_list,file,Vreset,CC_vreset,number
nonlocal Vset,CC_vset,step,integration_time,device,first,DUT,sample_series,field,file_path,ini_file,file,Vreset,CC_vreset,number
with output:
#disable buttons
set.disabled = True
reset.disabled=True
full.disabled =True
number.disabled=True
clear_output()
#during first button press
if first == True:
#disable checkboxes, text fields etc.
disable_widgets(widgets_list)
sample_series.disabled = True
field.disabled = True
DUT.disabled = True
sampling.disabled = True
#get ini file,and path from filechooser and open a new file
if fc.selected!=None:
......@@ -191,12 +232,11 @@ def memristor():
file = initialize_file(sample_series,field,DUT,file_path)
first = False
try:
#decode ini
Vreset,CC_vreset,integration_time,step=decode_ini('RESET',ini_file)
Vset,CC_vset,integration_time,step=decode_ini('SET',ini_file)
#disable buttons
disable_widgets(buttons_list)
with open(file,'a') as f:
f.write(f"{number.value} full sweeps with parameters:")
......@@ -233,21 +273,36 @@ def memristor():
df = create_data_frame(V,I)
f.write(f"{i+1} Iteration")
f.write("\n")
f.write(df.to_string)
f.write("\n")
f.write(df.to_string())
f.write("\n\n")
#plot results
ax1.plot(V,I,label=f"{i+1} Iteration")
ax2.plot(V,np.absolute(I),label=f"{i+1} Iteration")
ax1.legend(loc='best')
ax2.legend(loc='best')
ax1.plot(V,I)
ax2.plot(V,np.absolute(I))
fig.tight_layout()
#update plot
clear_output(wait = True)
print(df)
display(fig)
set.disabled = False
reset.disabled=False
full.disabled =False
number.disabled=False
except Exception as e:
print(e)
print('please ensure that all parameters are correct')
set.disabled = False
reset.disabled=False
full.disabled =False
number.disabled=False
#link buttons with functions
set.on_click(on_set_button_clicked)
reset.on_click(on_reset_button_clicked)
full.on_click(on_full_button_clicked)
......
%% Cell type:code id:33f299ef-2302-4e0a-b45f-291460d944c6 tags:
``` python
from memristor import *
memristor()
```
%% Output
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[1], line 3
1 from memristor import *
----> 3 memristor()
File ~\Desktop\labcode\hp4155\memristor\memristor.py:84, in memristor()
81 buttons_list =[set,reset,full,number]
83 #connect to the device
---> 84 device = module.HP4155a('GPIB0::17::INSTR')
85 device.reset()
87 #disable all irrelevant units for the measurement
88 #smu1 and smu3 are disabled
NameError: name 'module' is not defined
%% Cell type:code id:541c465a-2858-4998-8411-8c06ab4b466c tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment