From ab8167d12da6e8eec8d05c9f2d453d6ae3885fe1 Mon Sep 17 00:00:00 2001
From: unknown <asoalexandros@gmail.com>
Date: Mon, 3 Feb 2025 16:05:55 +0100
Subject: [PATCH] Values extraction from measurement data
---
hp4194/cv.py | 97 +++++++++++---
hp4194/values.ipynb | 307 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 384 insertions(+), 20 deletions(-)
create mode 100644 hp4194/values.ipynb
diff --git a/hp4194/cv.py b/hp4194/cv.py
index 1cddbc2..7c77db8 100644
--- a/hp4194/cv.py
+++ b/hp4194/cv.py
@@ -32,7 +32,7 @@ add_widgets_to_list(view,all_widgets)
add_widgets_to_list(sweep_parameter_dict,all_widgets)
add_widgets_to_list(messparameter_dict,all_widgets)
-
+fig, axs =
def on_measure_clicked(b):
with out:
clear_output()
@@ -65,6 +65,7 @@ def on_measure_clicked(b):
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)
+ device.write(sweep_parameter_dict["integration"].value) # Set integration number
# Now that we have set the frequency values ask user for calibration
answer = ask_for_calibration()
@@ -72,11 +73,8 @@ def on_measure_clicked(b):
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)
@@ -86,13 +84,26 @@ def on_measure_clicked(b):
device.write('autoscale_B') # Autoscale B
# create the numpy list with the biases
- # create the arrays with frequency, G and B
- frequency = []
- G = []
- B = []
+ # create the arrays with everything that needs to be saved into the array
+ f_values = []
+ G_values = []
+ B_values = []
+ log_f = []
+ omega = []
+ Z = []
+ phi = []
+ D = []
+ Cs =[]
+ Cp =[]
+ Cp_area =[]
+ Cs_area = []
+ ReZ = []
+ ImZ = []
+ G_f_omega = []
+
num_of_points =int(abs(messparameter_dict["stop"].value-messparameter_dict["start"].value)/abs(messparameter_dict["step"].value) + 1)
-
+ area = np.pi * radius**2
biases = np.linspace(messparameter_dict["start"].value,messparameter_dict["stop"].value,num_of_points,endpoint = True)
for bias in biases:
@@ -102,11 +113,35 @@ def on_measure_clicked(b):
# read the registers
- current_freq = device.read_register('reg_sweep')
- current_G = device.read_register('reg_A')
- current_B = device.read_register('reg_B')
+ freq = device.read_register('reg_sweep')
+ G = device.read_register('reg_A')
+ B = device.read_register('reg_B')
+
time.sleep(messparameter_dict["sleep"].value)
+
+ #do the calculations
+
+ f_values.extend(freq)
+ G_values.extend(G)
+ B_vlaues.extend(B)
+
+ for i in range(len(freq)):
+ log_f.append(np.log10(freq[i]))
+ omega.append(2*np.pi*freq[i])
+ log_omega.append(np.log10(omega))
+ polar = cmath.polar(1/complex(G[i],B[i]))
+ Z .append(polar[0])
+ phi.append(180/np.pi * polar[1]) #in deg
+ D.append(G[i]/B[i])
+ Cp.append(B[i]/omega)
+ Cs.append(Cp*(1+D**(2)))
+ Cp_area.append(Cp/area)
+ Cs_area.append(Cs/area)
+ Z_complex = cmath.rect(polar[0],polar[1])
+ ReZ.append(Z_complex.real)
+ ImZ.append(Z_complex.imag)
+ G_f_omega.append(G_p/area/omega)
# Do A test plot
fig,ax1 = plt.subplots()
@@ -136,25 +171,47 @@ def on_measure_clicked(b):
# read the registers
- current_freq = device.read_register('reg_sweep')
- current_G = device.read_register('reg_A')
- current_B = device.read_register('reg_B')
+ freq = device.read_register('reg_sweep')
+ G = device.read_register('reg_A')
+ B = device.read_register('reg_B')
time.sleep(messparameter_dict["sleep"].value)
-
+
+ f_values.extend(freq)
+ G_values.extend(G)
+ B_vlaues.extend(B)
+
+ #do the calculations
+ for i in range(len(freq)):
+ log_f.append(np.log10(freq[i]))
+ omega.append(2*np.pi*freq[i])
+ log_omega.append(np.log10(omega))
+ polar = cmath.polar(1/complex(G[i],B[i]))
+ Z.append(polar[0])
+ phi.append(180/np.pi * polar[1]) #in deg
+ D.append(G[i]/B[i])
+ Cp.append(B[i]/omega)
+ Cs.append(Cp*(1+D**(2)))
+ Cp_area.append(Cp/area)
+ Cs_area.append(Cs/area)
+ Z_complex = cmath.rect(polar[0],polar[1])
+ ReZ.append(Z_complex.real)
+ ImZ.append(Z_complex.imag)
+ G_f_omega.append(G_p/area/omega)
+
# 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.plot(freq,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.plot(freq,B, color=color)
ax2.tick_params(axis='y', labelcolor=color)
fig.suptitle(f"Results for Bias = {bias}V")
diff --git a/hp4194/values.ipynb b/hp4194/values.ipynb
new file mode 100644
index 0000000..c5ee0b9
--- /dev/null
+++ b/hp4194/values.ipynb
@@ -0,0 +1,307 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "9d2dbd8f-ac4a-4923-a059-6e377324f4d0",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import cmath\n",
+ "import numpy as np"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "6e2ff0c9-edda-4ea4-9776-857438f4243a",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# test values with the labview programm"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "59c934ec-e8f1-4a8a-883e-c7401923fa7f",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# test inputs\n",
+ "G_p = 1.27e-5\n",
+ "B_p = 0.0001507\n",
+ "U = -1.65\n",
+ "f = 1e6\n",
+ "area = 7.854E-5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "39a3c711-b8c8-4b64-a3c5-2f2f7867eb48",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "6.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "log_f = np.log10(f)\n",
+ "print(log_f)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "31bb2ff6-3844-4e93-8992-e71fe3b72b4f",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "6283185.307179586\n"
+ ]
+ }
+ ],
+ "source": [
+ "omega = 2*np.pi*f\n",
+ "print(omega)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "2a63cc3d-9eb8-4280-b0dc-3de3619b6139",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "6.798179868358115\n"
+ ]
+ }
+ ],
+ "source": [
+ "log_omega = np.log10(omega)\n",
+ "print(log_omega)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "3f1c119e-79ce-4a6c-9eae-7bded626e847",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(6612.26145303364, -1.4867215934478906)\n",
+ "<class 'tuple'>\n"
+ ]
+ }
+ ],
+ "source": [
+ "polar = cmath.polar(1/complex(G_p,B_p))\n",
+ "print(polar)\n",
+ "print(type(polar))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "id": "a28da13f-41c5-49df-9edc-c390801b6b08",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "6612.26145303364\n",
+ "-85.18287261552875\n"
+ ]
+ }
+ ],
+ "source": [
+ "Z = polar[0]\n",
+ "phi = 180/np.pi * polar[1] #in deg\n",
+ "\n",
+ "print(Z)\n",
+ "print(phi)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "id": "57eb43ca-de5a-49eb-b9fd-107c42f76dc9",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "0.08427339084273391\n"
+ ]
+ }
+ ],
+ "source": [
+ "D = G_p/B_p\n",
+ "print(D)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "id": "61ab4235-1027-42d6-825c-226c7d0b441f",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "2.398464992394863e-11\n"
+ ]
+ }
+ ],
+ "source": [
+ "C_p = B_p/omega\n",
+ "print(C_p)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "id": "79865b7e-23c7-4ec9-a0d3-c755a6ac39c7",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "2.415498901334008e-11\n"
+ ]
+ }
+ ],
+ "source": [
+ "C_s = C_p*(1+D**(2))\n",
+ "print(C_s)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "id": "1ed7e1d7-2f95-463f-abed-d8add9939408",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "3.0538133338360874e-07\n",
+ "3.0755015295823884e-07\n"
+ ]
+ }
+ ],
+ "source": [
+ "C_p_area = C_p/area\n",
+ "print(C_p_area)\n",
+ "\n",
+ "C_s_area = C_s/area\n",
+ "print(C_s_area)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "id": "b8bd3e45-b71c-4238-8703-6ae62d73d0b5",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(555.2694193455862-6588.905629557473j)\n",
+ "555.2694193455862\n",
+ "-6588.905629557473\n"
+ ]
+ }
+ ],
+ "source": [
+ "Z_complex = cmath.rect(polar[0],polar[1])\n",
+ "print(Z_complex)\n",
+ "\n",
+ "Rez = Z_complex.real\n",
+ "print(Rez)\n",
+ "\n",
+ "Imz = Z_complex.imag\n",
+ "print(Imz)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "id": "6d3b45a3-129b-4937-b516-bddc1a0de10e",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "2.573552046431208e-08\n"
+ ]
+ }
+ ],
+ "source": [
+ "G_f_omega = G_p/area/omega\n",
+ "\n",
+ "print(G_f_omega)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "id": "bc553d3e-f346-4f86-9fb9-8467ccf814f1",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# values pass all the tests"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "b449ceb5-5b6a-4904-8455-78f143abb050",
+ "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.12.0"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
--
GitLab