From 40a2c579e2b2f42389334039451e1a18a912d86a Mon Sep 17 00:00:00 2001 From: unknown <asoalexandros@gmail.com> Date: Wed, 29 Jan 2025 17:08:11 +0100 Subject: [PATCH] CV programm flow test (calibration fails) --- hp4194/control.py | 2 +- hp4194/cv.py | 193 ++++++++++++++++++++------------------- hp4194/cv_interace.ipynb | 86 +++++++++++++++++ hp4194/help.py | 12 ++- hp4194/interface.py | 2 +- 5 files changed, 193 insertions(+), 102 deletions(-) create mode 100644 hp4194/cv_interace.ipynb diff --git a/hp4194/control.py b/hp4194/control.py index 33a6734..e863cbf 100644 --- a/hp4194/control.py +++ b/hp4194/control.py @@ -11,7 +11,7 @@ class hp4194(object): self.adress = address self.rm = pyvisa.ResourceManager() self.inst = self.rm.open_resource(address) - self.inst.control_ren(5) #local lockout + self.inst.control_ren(5) # local lockout self.inst.timeout = None self.library = pd.read_csv(library,sep = ";") diff --git a/hp4194/cv.py b/hp4194/cv.py index 7f346b5..1cddbc2 100644 --- a/hp4194/cv.py +++ b/hp4194/cv.py @@ -4,6 +4,7 @@ import matplotlib.pyplot as plt from help import * import time from IPython.display import clear_output +import numpy as np #connect to device @@ -21,12 +22,12 @@ out = widgets.Output() hbox1 = widgets.HBox([sample,control_panel]) display(hbox1) hbox2=widgets.HBox([messparameter,sweep_parameter]) -display(hbox2) -display(out) +display(hbox2,out) + #add widgets to a list for disabling them -all_widgets = [measure,calibrate,clear_graphs] +all_widgets = [measure,clear_graphs] add_widgets_to_list(view,all_widgets) add_widgets_to_list(sweep_parameter_dict,all_widgets) add_widgets_to_list(messparameter_dict,all_widgets) @@ -37,97 +38,64 @@ def on_measure_clicked(b): clear_output() change_state(all_widgets) if check_values(messparameter_dict,sweep_parameter_dict) == False: - information('Invalid Voltage Settings or Observation of non-existent data points!') + information_box('Invalid Voltage Settings or Observation of non-existent data points!') change_state(all_widgets) - device.write('reset') - - # perform an open calibration - device.inst.write("RQS255") - - device.write('imp_G_B') - device.write('bias_off') - - device.write('sweep_freq') - device.set_parameter('set_start',sweep_parameter_dict['start'].value) - device.set_parameter('set_stop',sweep_parameter_dict['stop'].value) - device.set_parameter('set_nop',sweep_parameter_dict['nop'].value) - - if sweep_parameter['type']=='Linear': - device.write('sweep_lin') - else:# log - device.write('sweep_log') - if sweep_parameter['direction']=='Up': - device.write('sweep_up') - else: - device.write('sweep_down') - - device.write('sweep_single') - device.write('imp_monitor_I') - device.set_parameter('set_osc',sweep_parameter_dict['osc'].value) - device.set_parameter('set_delay_time',sweep_parameter_dict['d_time'].value) - device.set_parameter('set_delay_apperture',sweep_parameter_dict['d_apperture'].value) - device.set_parameter('aver_num',sweep_parameter_dict['averaging'].value) - - # Now that we have set the frequency values ask user for calibration - answer = ask_for_calibration() - if answer == True : #perform an open calibration - device.write('open_cal_on') #data saved in registers OG and OB - device.write('start_open_cal') - device.wait() - - # open the file dialog - default_filename = f"{sample_dict['wafer'].value}_{sample_dict['sample'].value}_{sample_dict['field'].value}_CV.txt" - file = save_file(default_filename) - - #now perform the measurement - device.write('autoscale_A') # Autoscale A - device.write('autoscale_B') # Autoscale B - - # create the numpy list with the biases - # create the arrays with frequency, G and B - frequency = [] - G = [] - B = [] - - num_of_points = abs(messparameter_dict["stop"].value-messparameter_dict["start"].value)/abs(messparameter_dict["step"].value) + 1 - - biases = np.linspace(messparameter_dict["start"].value,messparameter_dict["stop"].value,num_of_points,endpoint = True) - - for bias in biases: - device.set_parameter('set_bias', bias) #set the bias - device.write('start_sweep') #start the measurement - device.wait() #wait for completition - - # read the registers - - current_freq = device.read_register('reg_sweep') - current_G = device.read_register('reg_A') - current_B = device.read_register('reg_B') - - time.sleep(messparameter_dict["sleep"].value) - - # Do A test plot - fig,ax1 = plt.subplots() - - color = 'b' - ax1.set_xlabel('Frequency (Hz)') - ax1.set_ylabel('G (S)', color=color) - ax1.plot(current_freq,current_G , color=color) - ax1.tick_params(axis='y', labelcolor=color) - - ax2 = ax1.twinx() - color = 'y' - ax2.set_ylabel('B (S)', color=color) # we already handled the x-label with ax1 - ax2.plot(current_freq,current_B, color=color) - ax2.tick_params(axis='y', labelcolor=color) - - fig.suptitle(f"Results for Bias = {bias}V") - fig.tight_layout() - display(fig) - - if messparameter_dict["hysteris"].value == True: - reversed_biases = reversed_array(biases) - for bias in reversed_biases: + return + + device.write('imp_G_B') + device.write('bias_off') + + device.write('sweep_freq') + device.set_parameter('set_start',sweep_parameter_dict['start'].value) + device.set_parameter('set_stop',sweep_parameter_dict['stop'].value) + device.set_parameter('set_nop',sweep_parameter_dict['nop'].value) + + if sweep_parameter_dict['type'].value=='Linear': + device.write('sweep_lin') + else:# log + device.write('sweep_log') + if sweep_parameter_dict['direction'].value=='Up': + device.write('sweep_up') + else: + device.write('sweep_down') + + device.write('sweep_single') + device.write('imp_monitor_I') + device.set_parameter('set_osc',sweep_parameter_dict['osc'].value) + device.set_parameter('set_delay_time',sweep_parameter_dict['d_time'].value) + device.set_parameter('set_delay_apperture',sweep_parameter_dict['d_apperture'].value) + device.set_parameter('aver_num',sweep_parameter_dict['averaging'].value) + + # Now that we have set the frequency values ask user for calibration + answer = ask_for_calibration() + if answer == True : #perform an open calibration + device.write('start_open_cal') + device.wait() + device.write('open_cal_on') #data saved in registers OG and OB + print(device.read_register('reg_open_offset_G')) + print(device.read_register('reg_open_offset_B')) + + print(device.read_register('reg_open_offset_G')) + print(device.read_register('reg_open_offset_B')) + # open the file dialog + default_filename = f"{sample_dict['wafer'].value}_{sample_dict['sample'].value}_{sample_dict['field'].value}_CV.txt" + file = save_file(default_filename) + + #now perform the measurement + device.write('autoscale_A') # Autoscale A + device.write('autoscale_B') # Autoscale B + + # create the numpy list with the biases + # create the arrays with frequency, G and B + frequency = [] + G = [] + B = [] + + num_of_points =int(abs(messparameter_dict["stop"].value-messparameter_dict["start"].value)/abs(messparameter_dict["step"].value) + 1) + + biases = np.linspace(messparameter_dict["start"].value,messparameter_dict["stop"].value,num_of_points,endpoint = True) + + for bias in biases: device.set_parameter('set_bias', bias) #set the bias device.write('start_sweep') #start the measurement device.wait() #wait for completition @@ -158,9 +126,44 @@ def on_measure_clicked(b): fig.suptitle(f"Results for Bias = {bias}V") fig.tight_layout() display(fig) - + if messparameter_dict["hysterisis"].value == True: + reversed_biases = reversed_array(biases) + for bias in reversed_biases: + device.set_parameter('set_bias', bias) #set the bias + device.write('start_sweep') #start the measurement + device.wait() #wait for completition + + # read the registers + + current_freq = device.read_register('reg_sweep') + current_G = device.read_register('reg_A') + current_B = device.read_register('reg_B') + + time.sleep(messparameter_dict["sleep"].value) + + # Do A test plot + fig,ax1 = plt.subplots() + + color = 'b' + ax1.set_xlabel('Frequency (Hz)') + ax1.set_ylabel('G (S)', color=color) + ax1.plot(current_freq,current_G , color=color) + ax1.tick_params(axis='y', labelcolor=color) + + ax2 = ax1.twinx() + color = 'y' + ax2.set_ylabel('B (S)', color=color) # we already handled the x-label with ax1 + ax2.plot(current_freq,current_B, color=color) + ax2.tick_params(axis='y', labelcolor=color) + + fig.suptitle(f"Results for Bias = {bias}V") + fig.tight_layout() + display(fig) + + device.write('bias_off') - change_state(all_widgets) + information_box("measurement finished") + change_state(all_widgets) measure.on_click(on_measure_clicked) \ No newline at end of file diff --git a/hp4194/cv_interace.ipynb b/hp4194/cv_interace.ipynb new file mode 100644 index 0000000..3f75927 --- /dev/null +++ b/hp4194/cv_interace.ipynb @@ -0,0 +1,86 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "912606ea-a3b6-43e8-94c5-8f1fe5281375", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "e951faa424004d51b9682ac089edf5b3", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "HBox(children=(Tab(children=(GridspecLayout(children=(Label(value='Wafer', layout=Layout(grid_area='widget001'…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "11d6bcc97620453b8706de861f6c2861", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "HBox(children=(Tab(children=(GridspecLayout(children=(Label(value='V_start (V)', layout=Layout(grid_area='widg…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1c180f310c57403aa5662003117eca89", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output()" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "%run cv.py" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "af882f36-6cbc-40bd-80f5-c8bedba0b73d", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/hp4194/help.py b/hp4194/help.py index f3aae65..d4026c5 100644 --- a/hp4194/help.py +++ b/hp4194/help.py @@ -2,6 +2,7 @@ import ipywidgets as widgets import tkinter as tk from tkinter import filedialog import tkinter.messagebox +import numpy as np def add_widgets_to_list(source_dictionary,target_list): @@ -55,7 +56,7 @@ def information_box(information): def check_values(voltage:dict,freq:dict): - if abs(voltage["step"].value) > abs(voltage["stop"].value-voltage["start"].value) or voltage["step"].value == 0: + if abs(voltage["step"].value) > abs(voltage["stop"].value-voltage["start"].value) or abs(voltage["step"].value)<0.01: return False #Invert Polarity if nesaccary @@ -74,7 +75,7 @@ def check_values(voltage:dict,freq:dict): if voltage["v_point"].value > voltage_points and voltage["hysterisis"].value == False: return False elif voltage["v_point"].value > 2*voltage_points and voltage["hysterisis"].value == True: - return False: + return False # prove that we check a valld frequency point if voltage["f_point"].value > freq['nop'].value: @@ -83,6 +84,7 @@ def check_values(voltage:dict,freq:dict): # create array for hysteris and remove the last element def reversed_array(arr): - arr = arr[np.arange(arr.size - 1)] - reversed_arr = arr[::-1] - return reversed_array \ No newline at end of file + arr = list(arr) + arr.pop() + arr.reverse() + return np.array(arr) \ No newline at end of file diff --git a/hp4194/interface.py b/hp4194/interface.py index 276ea30..14bb283 100644 --- a/hp4194/interface.py +++ b/hp4194/interface.py @@ -43,7 +43,7 @@ def messparameter(): messparameter[2,0] = widgets.Label('V_stop (V)',layout=Layout(height='auto', width = width)) messparameter[3,0] = widgets.BoundedFloatText(value = -3,min =-40 ,max = 40,step = 1,layout=Layout(height='auto', width = width)) #stop value messparameter[4,0] = widgets.Label('V_step (V)',layout=Layout(height='auto', width = width)) - messparameter[5,0] = widgets.BoundedFloatText(value = 0.05,min =0.01 ,max = 80,step = 0.01,layout=Layout(height='auto', width = width)) #step value + messparameter[5,0] = widgets.BoundedFloatText(value = 0.1,min = -80 ,max = 80,step = 0.01,layout=Layout(height='auto', width = width)) #step value messparameter[6,0] = widgets.Label('Wait in Voltage Point (s)',layout=Layout(height='auto', width = width)) messparameter[7,0] = widgets.BoundedFloatText(value = 0,min = 0 ,max = sys.float_info.max,step = 1,layout=Layout(height='auto', width = width)) #sleep value messparameter[8,0] = widgets.Label('Radius of The Test Stucture(um)',layout=Layout(height='auto', width = width)) -- GitLab