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

buttons for memristor

parent 8548d1d7
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:6d955a9f-629b-4bf5-be97-b4ae534824a0 tags:
``` python
import ipywidgets as widgets
```
%% Cell type:code id:b0ed6115-9df5-4ff7-b4dc-146c83fe50c5 tags:
``` python
reset=widgets.Button(description='RESET')
set=widgets.Button(description='SET')
sampling=widgets.Checkbox(description='sampling check')
full=widgets.Checkbox(description='full sweep')
```
%% Cell type:code id:ed90b452-1aa0-4b8d-892c-87f161d9c81f tags:
``` python
line1=widgets.HBox([set,sampling])
```
%% Cell type:code id:256f987e-04fd-4089-8e4f-c86ae9360c98 tags:
``` python
line2=widgets.HBox([reset,full])
```
%% Cell type:code id:720bf813-db95-46c6-a426-4b04d0e87677 tags:
``` python
all = widgets.VBox([line1,line2])
output = widgets.Output()
```
%% Cell type:code id:ac715ba2-fac6-421d-901d-de7ee250bc89 tags:
``` python
display(all,output)
```
%% Output
%% Cell type:code id:fd0ccb93-6b61-4e49-9952-f6bb6dd3c471 tags:
``` python
with output:
print(1)
sampling.value
sampling.disabled=True
```
%% Cell type:code id:ac583f6e-f8c8-424a-b79c-97661a4c782b tags:
%% Cell type:code id:a7fa339d-8d0f-4d4c-800a-5d8d52ff11d5 tags:
``` python
sampling.value
```
%% Output
True
%% Cell type:code id:f10795c4-76b1-40a4-a28d-b6b354d1afe3 tags:
``` python
```
......
......@@ -467,7 +467,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.12.0"
}
},
"nbformat": 4,
......
......@@ -5,8 +5,172 @@ import module
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import display, clear_output
import pandas as pd
from datetime import datetime
import configparser
from ipyfilechooser import FileChooser
def memristor():
#parameters set by the user
Vset=1
CC_vset=10**(-3)
Vreset=-1
CC_vreset=10**(-3)
step = 0.01
integration_time='MED'
name=input("enter the name of the DUT:")
counter=0
#connecting to the device
device = module.HP4155a('GPIBO::17::INSTR')
device.reset()
#setup the device
#smu1 and smu3 are disabled
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)
#define each different measurement as a function
#first sweep from start to stop and stop to start
def sweep(start,stop,step,comp,time):
nonlocal device
#delete all user functions
device.del_ufun()
device.measurement_mode('SWE')
#smu2 is constant and common
device.smu_mode_meas(2,'COMM')
device.smu_function_sweep(2,'CONS')
#smu4 is VAR1 and V
device.smu_mode_meas(4,'V')
device.smu_function_sweep(4,'VAR1')
device.integration_time(time)
#define double sweep
device.var1_mode('DOUB')
#start stop step and comp
device.start_value_sweep(start)
device.step_sweep(step)
device.stop_value_sweep(stop)
device.comp('VAR1',comp)
#display variables
device.display_variable('X','V4')
device.display_variable('Y1','I4')
#execute measurement
device.single_measurement()
while device.operation_completed==False:
pass
device.autoscaling()
#return values
V=device.return_data('V4')
I=device.return_data('I4')
#convert the list to np.array to return the absolute values for the logarithmic scale
V = np.array(V)
I = np.array(I)
#delete all user functions
device.del_ufun()
#return all values to the function
return V, I
#sampling follows in a bit...
#create buttons as it shown in the how_buttons_look
set=widgets.Button(description='SET')
reset=widgets.Button(description='RESET')
sampling=widgets.Checkbox(description='sampling check')
full=widgets.Checkbox(description='full sweep')
#align a button with a checkbox horizontaly
line1 = widgets.HBox([set,sampling])
line2 = widgets.Hbox([reset,full])
#pack them into a single vertical box
all = widgets.VBox([line1,line2])
output = widgets.Output()
#dispaly them all
display(all,output)
#handling events for the buttons:
def on_set_button_clicked(b):
nonlocal Vset,CC_vset,step,integration_time,name,device
with output:
clear_output()
#execute measurement
V1,I1=sweep(0,Vset,step,CC_vset,integration_time)
#plot results
plt.figure().clear()
fig, (ax1, ax2) = plt.subplots(2,sharex=True,figsize=(8,6)) #the plots share the same x axis
fig.suptitle('SET')
ax1.set_title('Linear I')
ax1.set(xlabel='Voltage(V)',ylabel='Current(A)')
ax2.set_title('Logarithmic I')
ax2.set(xlabel='Voltage(V)',ylabel='Current(A)')
ax2.set_yscale('log')
ax1.plot(V1,I1)
ax2.plot(V1,np.absolute(I1))
plt.show()
def on_reset_button_clicked(b):
nonlocal Vreset,CC_Vreset,step,integration_time,device
with output:
#execute measurement
V2,I2=sweep(0,Vreset,step,CC_vreset,integration_time)
#plot results
plt.figure().clear()
fig, (ax1, ax2) = plt.subplots(2,sharex=True,figsize=(8,6)) #the plots share the same x axis
fig.suptitle('RESET')
ax1.set_title('Linear I')
ax1.set(xlabel='Voltage(V)',ylabel='Current(A)')
ax2.set_title('Logarithmic I')
ax2.set(xlabel='Voltage(V)',ylabel='Current(A)')
ax2.set_yscale('log')
ax1.plot(V2,I2)
ax2.plot(V2,np.absolute(I2))
plt.show()
#link buttons with functions
set.on_click(on_set_button_clicked)
reset.on_click(on_reset_button_clicked)
\ No newline at end of file
......@@ -112,6 +112,10 @@ class HP4155a(object):
command=f":PAGE:MEAS:VAR1:STOP {value}"
self.inst.write(command)
def var1_mode(self,mode):
command = f":PAGE:MEAS:VAR1:MODE {mode}"
self.inst.write(command)
def cons_smu_value(self,smu_number,value):
command =f"PAGE:MEAS:CONS:SMU{smu_number} {value}"
self.inst.write(command)
......@@ -283,3 +287,8 @@ class HP4155a(object):
command=f":PAGE:CHAN:SMU{smu_number}:INAME '{iname}'"
self.inst.write(command)
#delete all user functions
def del_ufun(self):
command = f":PAGE:CHAN:UFUN:DEL:ALL"
self.inst.write(command)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment