From d947085c4c305a551f72e90d6972145cd34aea14 Mon Sep 17 00:00:00 2001 From: unknown <asoalexandros@gmail.com> Date: Wed, 27 Nov 2024 13:06:12 +0100 Subject: [PATCH] migration to the new cotrol class --- hp4155/memristor (Version 4.0)/help.py | 244 +++++++++++------- hp4155/memristor (Version 4.0)/memristor.py | 54 ++-- .../memristor_buttons.ipynb | 56 ++-- 3 files changed, 194 insertions(+), 160 deletions(-) diff --git a/hp4155/memristor (Version 4.0)/help.py b/hp4155/memristor (Version 4.0)/help.py index 4421447..5235e07 100644 --- a/hp4155/memristor (Version 4.0)/help.py +++ b/hp4155/memristor (Version 4.0)/help.py @@ -13,6 +13,7 @@ enabing and disabling widgets for jupyter(lists) import sys sys.path.insert(0, '..') #append parent directory +import hp4155a import module import matplotlib.pyplot as plt @@ -30,9 +31,7 @@ import os #these are the quick sampling checks -def regular_contact_check(): - device = module.HP4155a('GPIB0::17::INSTR') - +def regular_contact_check(device): resistances = {} smu = [1,2,3,4] @@ -42,29 +41,46 @@ def regular_contact_check(): We have the following pairs in order 1-4,1-3,1-2,2-4,2-3,3-4 """ - device.reset() device.measurement_mode('SAMP') - device.sampling_mode('LIN') - device.number_of_points(1) - device.integration_time('MED') - device.initial_interval(2e-3) - device.filter_status('OFF') - #remove total sampling time - device.auto_sampling_time('ON') + parameters ={ + 'mode' : 'LIN', + 'hold': 0, + 'interval':2e-3, + 'points': 1, + 'filter': 'OFF', + 'value':0.01, #voltage value + 'comp':0.1 #compliance value + } - #disable vmus and vsus - device.disable_vsu(1) - device.disable_vsu(2) - device.disable_vmu(1) - device.disable_vmu(2) - - device.smu_mode_meas(i,'V') #one smu is measuring - device.smu_mode_meas(j,'COMM') #one smu is ground + device.setup_sampling(parameters) + + device.auto_sampling_time('ON') + device.integration_time('MED') + + smu_v = device.smu_dict() + smu_v.update( + vname = f'V{i}', + iname = f'I{i}', + mode = 'V', + func = 'CONS' + ) + device.setup_smu(i,smu_v) + + smu_ground = device.smu_dict() + smu_ground.update( + vname =f'V{j}', + iname = f'I{j}', + mode = 'COMM', + func='CONS' + ) + device.setup_smu(j,smu_ground) + + #one smu is measuring + #one smu is ground #set voltage and compliance - device.constant_smu_sampling(i,0.01) - device.constant_smu_comp(i,'MAX') + device.setup_smu_sampling(i,parameters) #smus to remove smu_disable = smu.copy() @@ -72,137 +88,165 @@ def regular_contact_check(): smu_disable.remove(j) for number in smu_disable: - device.smu_disable_sweep(number) + device.smu_disable(number) + device.user_function(f'R{i}{j}','OHM',f'V{i}/I{i}') device.display_variable('X','@TIME') - device.display_variable('Y1',f'I{i}') + device.display_variable('Y1',f'R{i}{j}') device.single_measurement() while device.operation_completed() == False: time.sleep(2) device.autoscaling() - V = device.return_data(f'V{i}') - I = device.return_data(f'I{i}') - R = V[0]/I[0] + R = device.return_values(f'R{i}{j}')[0] #only the first value print(f"R{i}{j}:{'{:.2e}'.format(R)} Ohm") - resitances[f"{i}-{j}"] = R - #print(f"Contact check of smu{i} and smu{j} failed!") + resistances[f"{i}-{j}"] = R + + device.del_user_functions() - del device return resistances -def EBL(): +def EBL(device): # EBL are SMUs 1-4 and 2-3 - device = module.HP4155a('GPIB0::17::INSTR') resistances = {} + smu = [1,2,3,4] for i,j in zip(range(1,3),range(4,2,-1)): #loop simultaneously 1-4,2-3 pairs - device.reset() - device.measurement_mode('SAMP') - device.sampling_mode('LIN') - device.number_of_points(1) - device.integration_time('MED') - device.initial_interval(2e-3) - device.filter_status('OFF') - #remove total sampling time - device.auto_sampling_time('ON') + parameters ={ + 'mode' : 'LIN', + 'hold': 0, + 'interval':2e-3, + 'points': 1, + 'filter': 'OFF', + 'value':0.01, #voltage value + 'comp':0.1 #compliance value + } - #disable vmus and vsus - device.disable_vsu(1) - device.disable_vsu(2) - device.disable_vmu(1) - device.disable_vmu(2) - + device.setup_sampling(parameters) - - device.smu_mode_meas(i,'V') #one smu is measuring - device.smu_mode_meas(j,'COMM') #one smu is ground - + device.auto_sampling_time('ON') + device.integration_time('MED') + + smu_v = device.smu_dict() + smu_v.update( + vname = f'V{i}', + iname = f'I{i}', + mode = 'V', + func = 'CONS' + ) + device.setup_smu(i,smu_v) + + smu_ground = device.smu_dict() + smu_ground.update( + vname =f'V{j}', + iname = f'I{j}', + mode = 'COMM', + func='CONS' + ) + device.setup_smu(j,smu_ground) + + #one smu is measuring + #one smu is ground + #set voltage and compliance - device.constant_smu_sampling(i,0.01) - device.constant_smu_comp(i,'MAX') - + device.setup_smu_sampling(i,parameters) + #smus to remove smu_disable = smu.copy() smu_disable.remove(i) smu_disable.remove(j) - + for number in smu_disable: - device.smu_disable_sweep(number) - + device.smu_disable(number) + + device.user_function(f'R{i}{j}','OHM',f'V{i}/I{i}') device.display_variable('X','@TIME') - device.display_variable('Y1',f'I{i}') + device.display_variable('Y1',f'R{i}{j}') device.single_measurement() while device.operation_completed() == False: time.sleep(2) - + device.autoscaling() - V = device.return_data(f'V{i}') - I = device.return_data(f'I{i}') - R = V[0]/I[0] + R = device.return_values(f'R{i}{j}')[0] #only the first value print(f"R{i}{j}:{'{:.2e}'.format(R)} Ohm") - resitances[f"{i}-{j}"] = R - - del device + resistances[f"{i}-{j}"] = R + + device.del_user_functions() + return resistances + -def OL(): +def OL(device): # OL smu 3-4,1-2 - device = module.HP4155a('GPIB0::17::INSTR') resistances= {} + smu = [1,2,3,4] for i,j in zip(range(3,0,-2),range(4,1,-2)): #loop simultaneously 3-4 , 1-2 pairs - device.reset() - device.measurement_mode('SAMP') - device.sampling_mode('LIN') - device.number_of_points(1) - device.integration_time('MED') - device.initial_interval(2e-3) - device.filter_status('OFF') - #remove total sampling time - device.auto_sampling_time('ON') + parameters ={ + 'mode' : 'LIN', + 'hold': 0, + 'interval':2e-3, + 'points': 1, + 'filter': 'OFF', + 'value':0.01, #voltage value + 'comp':0.1 #compliance value + } - #disable vmus and vsus - device.disable_vsu(1) - device.disable_vsu(2) - device.disable_vmu(1) - device.disable_vmu(2) - + device.setup_sampling(parameters) - - device.smu_mode_meas(i,'V') #one smu is measuring - device.smu_mode_meas(j,'COMM') #one smu is ground - + device.auto_sampling_time('ON') + device.integration_time('MED') + + smu_v = device.smu_dict() + smu_v.update( + vname = f'V{i}', + iname = f'I{i}', + mode = 'V', + func = 'CONS' + ) + device.setup_smu(i,smu_v) + + smu_ground = device.smu_dict() + smu_ground.update( + vname =f'V{j}', + iname = f'I{j}', + mode = 'COMM', + func='CONS' + ) + device.setup_smu(j,smu_ground) + + #one smu is measuring + #one smu is ground + #set voltage and compliance - device.constant_smu_sampling(i,0.01) - device.constant_smu_comp(i,'MAX') - + device.setup_smu_sampling(i,parameters) + #smus to remove smu_disable = smu.copy() smu_disable.remove(i) smu_disable.remove(j) - + for number in smu_disable: - device.smu_disable_sweep(number) - + device.smu_disable(number) + + device.user_function(f'R{i}{j}','OHM',f'V{i}/I{i}') device.display_variable('X','@TIME') - device.display_variable('Y1',f'I{i}') + device.display_variable('Y1',f'R{i}{j}') device.single_measurement() while device.operation_completed() == False: time.sleep(2) - + device.autoscaling() - V = device.return_data(f'V{i}') - I = device.return_data(f'I{i}') - R = V[0]/I[0] + R = device.return_values(f'R{i}{j}')[0] #only the first value print(f"R{i}{j}:{'{:.2e}'.format(R)} Ohm") - resitances[f"{i}-{j}"] = R - - del device + resistances[f"{i}-{j}"] = R + + device.del_user_functions() + return resistances @@ -549,7 +593,7 @@ def save_contact_check(R,file): #save contact check to file """ with open(file,'a') as f: - f.write("\n\nContact Check Results:\n") + f.write("Contact Check Results:\n") df = pd.DataFrame(R.items(), columns=['SMU pair', 'Resistance (Ohm)']) f.write(df.to_string()) diff --git a/hp4155/memristor (Version 4.0)/memristor.py b/hp4155/memristor (Version 4.0)/memristor.py index 8a44695..657ec6c 100644 --- a/hp4155/memristor (Version 4.0)/memristor.py +++ b/hp4155/memristor (Version 4.0)/memristor.py @@ -37,11 +37,20 @@ DUT = widgets.Text( #choose a new folder button new_folder = widgets.Button(description='change folder') +image = widgets.Image( + value=open("schematic.png", "rb").read(), + format='png', + width=300, + height=100, +) +contact_check = widgets.Button(description = 'CONTACT CHECK') +qcc = widgets.Button(description = 'QUICK CONTACT CHECK',layout=widgets.Layout(width='80%'),style={"button_width": "auto"}) +qcc_select = widgets.RadioButtons(description = 'QCC type:',options = ['EBL','OL']) -horizontal = widgets.HBox([sample_series,new_folder]) -horizontal3= widgets.HBox([DUT,]) #here contact scehmatic -all_text_boxes = widgets.VBox([horizontal,field,horizontal3]) +vertical1 = widgets.VBox([sample_series,field,DUT,new_folder,contact_check,qcc,qcc_select]) +vertical2 = widgets.VBox([image]) +all_text_boxes = widgets.HBox([vertical1,vertical2]) @@ -63,10 +72,11 @@ integration_time=widgets.Dropdown( sampling=widgets.Checkbox(description='sampling check') -#align the widgets horizontaly -line0=widgets.HBox([step,integration_time,sampling]) - - +auto_qcc = widgets.Checkbox( + description = 'Auto QCC after Reset', + style = {'description_width': 'initial'}, + value = True +) # THE BUTTONS #create buttons as it shown in the how_buttons_look @@ -75,9 +85,7 @@ reset=widgets.Button(description='RESET') full=widgets.Button(description='FULL SWEEP') number = widgets.BoundedIntText(value=1,min=1,max=sys.maxsize,step=1,description='full sweeps:',disabled=False) #number of measuremts for the full sweep retention_button=widgets.Button(description='RETENTION') -contact_check = widgets.Button(description = 'CONTACT CHECK') -qcc = widgets.Button(description = 'QUICK CONTACT CHECK') -qcc_select = widgets.RadioButtons(description = 'QCC type:',options = ['EBL','OL']) + #parameter boxes @@ -140,13 +148,10 @@ duration=widgets.BoundedFloatText( description='Duration(s):', ) -auto_qcc = widgets.Checkbox( - description = 'Auto QCC after Reset:', - style = {'description_width': 'initial'}, - value = True -) + #align a button with a checkbox or integer bounded texts horizontaly +line0=widgets.HBox([step,integration_time,sampling,auto_qcc]) line1 = widgets.HBox([set,Vset,CC_vset]) line2 = widgets.HBox([reset,Vreset,CC_vreset]) line3 = widgets.HBox([full,number]) @@ -164,9 +169,6 @@ folder=choose_folder() #display all at the end display(all_text_boxes) -hbox = widgets.HBox([contact_check,qcc,qcc_select]) #HBox wirth contact checks -display(hbox) - cons_widgets,cons_dict = constant_pulse() sweep_widgets,sweep_dict = sweep_pulse() @@ -182,26 +184,24 @@ tab.titles = titles display(tab,output) -all_widgets = [ sweep_button,cons_button,sample_series,field,DUT,set,reset,full,new,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] +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] add_widgets_to_list(cons_dict,all_widgets) add_widgets_to_list(sweep_dict,all_widgets) -#display the buttons -""" the above is what happens when the programm starts all the rest have to be written into button trigger functions""" +device = hp4155a.HP4155a('GPIB0::17::INSTR') +device.reset() +device.disable_not_smu() def on_contact_check_clicked(b): global folder,temp_file with output: - global first,folder,file,temp_file clear_output(wait = True) change_state(all_widgets) filename=f"{sample_series.value}_{field.value}_{DUT.value}.txt" file = os.path.join(folder,filename) - - R = regular_contact_check() - + R = regular_contact_check(device) save_contact_check(R,temp_file) @@ -223,9 +223,9 @@ def on_qcc_clicked(b): if qcc_select.value == 'EBL': - R = EBL() + R = EBL(device) else: # OL - R = OL() + R = OL(device) save_contact_check(R,temp_file) diff --git a/hp4155/memristor (Version 4.0)/memristor_buttons.ipynb b/hp4155/memristor (Version 4.0)/memristor_buttons.ipynb index 0564861..401a656 100644 --- a/hp4155/memristor (Version 4.0)/memristor_buttons.ipynb +++ b/hp4155/memristor (Version 4.0)/memristor_buttons.ipynb @@ -9,49 +9,21 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "8e42e33b13b94bc28d51ac3879635a83", + "model_id": "45a61bab685e4422bbe94514a2439059", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "VBox(children=(HBox(children=(Text(value='', description='sample series:', placeholder='Enter text here:', sty…" + "HBox(children=(VBox(children=(Text(value='', description='sample series:', placeholder='Enter text here:', sty…" ] }, "metadata": {}, "output_type": "display_data" }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "b645be04ed3040d5bfa6ab024e5dd698", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Button(description='CONTACT CHECK', style=ButtonStyle())" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n" - ] - }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "382a0395fff84d78b2e3ef2c67f2de6a", + "model_id": "11da2c8be6de4612a31f3a065e50bc66", "version_major": 2, "version_minor": 0 }, @@ -65,7 +37,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "1f0a16c6eaf44dce8926c29cff203ec7", + "model_id": "0d1ba2ede27742c3aa2cd2b8ec3f50c8", "version_major": 2, "version_minor": 0 }, @@ -81,10 +53,28 @@ "%run memristor.py" ] }, + { + "cell_type": "code", + "execution_count": 2, + "id": "38e8523c-17f0-48b4-9501-dd2278ffe8d1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(0, '\"No error\"\\n')\n" + ] + } + ], + "source": [ + "print(device.error())" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "076a9132-edc2-4ae5-8a7f-c8a179473952", + "id": "ca8f0bc8-670c-4deb-bedb-8d5d92b978f2", "metadata": {}, "outputs": [], "source": [] -- GitLab