Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
labcode
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CST
labcode
Commits
e03980f7
Commit
e03980f7
authored
1 year ago
by
Alexandros Asonitis
Browse files
Options
Downloads
Patches
Plain Diff
removed filechooser(replaced with buttons and tkinter)
parent
a80c3dd5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
hp4155/memristor/help.py
+40
-3
40 additions, 3 deletions
hp4155/memristor/help.py
hp4155/memristor/memristor.py
+130
-89
130 additions, 89 deletions
hp4155/memristor/memristor.py
hp4155/memristor/memristor_buttons.ipynb
+11
-26
11 additions, 26 deletions
hp4155/memristor/memristor_buttons.ipynb
with
181 additions
and
118 deletions
hp4155/memristor/help.py
+
40
−
3
View file @
e03980f7
...
...
@@ -11,10 +11,14 @@ enabing and disabling widgets for jupyter(lists)
"""
import
sys
sys
.
path
.
append
(
r
"
C:\Users\user\labcode\hp4155
"
)
sys
.
path
.
insert
(
0
,
'
..
'
)
#append parent directory
import
module
#
import module
import
matplotlib.pyplot
as
plt
import
tkinter
as
tk
from
tkinter
import
filedialog
import
numpy
as
np
from
IPython.display
import
display
,
clear_output
import
pandas
as
pd
...
...
@@ -194,3 +198,36 @@ def write_to_file(file,title,df):
f
.
write
(
"
\n
"
)
f
.
write
(
df
.
to_string
())
f
.
write
(
"
\n\n
"
)
#### new functions ##############
def
change_state
(
widgets_list
):
for
widget
in
widgets_list
:
widget
.
disabled
=
not
widget
.
disabled
#works
def
initialize_tkinter
(
sample_series
,
field
,
DUT
):
#open dialog and hide the main window
root
=
tk
.
Tk
()
root
.
withdraw
()
file_path
=
filedialog
.
asksaveasfilename
(
defaultextension
=
"
.txt
"
,
filetypes
=
[(
"
Text files
"
,
"
*.txt
"
)],
title
=
"
save results path
"
,
initialfile
=
f
'
{
DUT
.
value
}
_Memristor.txt
'
)
#check if the file path is correct(.txt)
while
file_path
.
endswith
(
"
.txt
"
)
==
False
:
#open again filedialog with error message box
tk
.
messagebox
.
showerror
(
message
=
'
invalid filename!
'
)
file_path
=
filedialog
.
asksaveasfilename
(
defaultextension
=
"
.txt
"
,
filetypes
=
[(
"
Text files
"
,
"
*.txt
"
)],
title
=
"
save results path
"
,
initialfile
=
f
'
{
DUT
.
value
}
_Memristor.txt
'
)
#the first time open the file in write mode!(replaces the old file)
#write sample series
with
open
(
file_path
,
'
w
'
)
as
f
:
title
=
f
"
Memristor Measurement
"
+
"
\n\n
"
+
f
"
Sample series:
{
sample_series
.
value
}
"
+
"
\n
"
+
f
"
field:
{
field
.
value
}
"
+
"
\n
"
+
f
"
DUT:
{
DUT
.
value
}
"
+
"
\n\n
"
f
.
write
(
title
)
root
.
destroy
()
#return the file path
return
file_path
\ No newline at end of file
This diff is collapsed.
Click to expand it.
hp4155/memristor/memristor.py
+
130
−
89
View file @
e03980f7
...
...
@@ -3,36 +3,10 @@ from help import *
import
ipywidgets
as
widgets
from
keyboard
import
add_hotkey
,
remove_hotkey
def
memristor
():
#parameters set by the user
Vset
=
1
CC_vset
=
10
**
(
-
3
)
Vreset
=-
1
CC_vreset
=
10
**
(
-
3
)
step
=
0.02
integration_time
=
'
MED
'
#additional variables
first
=
True
#first measurement
file_path
=
os
.
getcwd
()
file
=
None
#default ini file
ini_file_path
=
os
.
getcwd
()
ini_file_name
=
r
"
default.ini
"
ini_file
=
os
.
path
.
join
(
ini_file_path
,
ini_file_name
)
#filechooser
fc
=
FileChooser
(
select_desc
=
'
load .ini
'
)
fc
.
default_path
=
r
"
\\FILESERVER\public
"
fc
.
filter_pattern
=
'
*.ini
'
display
(
fc
)
#pathchooser
pc
=
FileChooser
(
select_desc
=
"
save path
"
)
pc
.
default_path
=
r
"
\\FILESERVER\public
"
pc
.
show_only_dirs
=
True
display
(
pc
)
print
()
file_path
=
None
# the three naming fields
...
...
@@ -42,6 +16,7 @@ def memristor():
description
=
'
sample series:
'
,
style
=
{
'
description_width
'
:
'
initial
'
}
)
field
=
widgets
.
Text
(
value
=
''
,
placeholder
=
'
Enter text here:
'
,
...
...
@@ -60,41 +35,109 @@ def memristor():
display
(
all_text_boxes
)
print
()
#first series of parameters
step
=
widgets
.
BoundedFloatText
(
value
=
0.01
,
min
=
0
,
max
=
200
,
step
=
0.01
,
description
=
'
Step(V):
'
,
)
integration_time
=
widgets
.
Dropdown
(
options
=
[
'
SHORt
'
,
'
MEDium
'
,
'
LONG
'
],
value
=
'
MEDium
'
,
description
=
'
Integration:
'
,
#style = {'description_width': 'initial'},
)
sampling
=
widgets
.
Checkbox
(
description
=
'
sampling check
'
)
#align the widgets horizontaly
line0
=
widgets
.
HBox
([
step
,
integration_time
,
sampling
])
display
(
line0
)
print
()
# THE BUTTONS
#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
.
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
#parameter boxes
Vset
=
widgets
.
BoundedFloatText
(
value
=
1
,
min
=
0
,
max
=
200
,
step
=
0.1
,
description
=
'
Voltage(V):
'
,
)
#parameter buttons
CC_vset
=
widgets
.
BoundedFloatText
(
value
=
1e-3
,
min
=-
1
,
max
=
1
,
step
=
0.1
,
description
=
'
Comp(A):
'
,
)
#parameter buttons
Vreset
=
widgets
.
BoundedFloatText
(
value
=-
1
,
min
=-
200
,
max
=
0
,
step
=
0.1
,
description
=
'
Voltage(V):
'
,
)
#parameter buttons
CC_vreset
=
widgets
.
BoundedFloatText
(
value
=
1e-3
,
min
=-
1
,
max
=
1
,
step
=
0.1
,
description
=
'
Comp(A):
'
,
)
#align a button with a checkbox or integer bounded texts horizontaly
line1
=
widgets
.
HBox
([
set
,
sampling
])
line1
=
widgets
.
HBox
([
set
,
Vset
,
CC_vset
])
line2
=
widgets
.
HBox
([
reset
,
Vreset
,
CC_vreset
])
line3
=
widgets
.
HBox
([
full
,
number
])
#pack them into a single vertical box
all
=
widgets
.
VBox
([
line1
,
reset
,
line3
])
all
=
widgets
.
VBox
([
line1
,
line2
,
line3
])
output
=
widgets
.
Output
()
#dispaly them all
print
()
display
(
all
,
output
)
#help lists for changing state of the buttons
information
=
[
sample_series
,
field
,
DUT
,
sampling
]
buttons
=
[
set
,
reset
,
full
]
parameters
=
[
Vset
,
CC_vset
,
Vreset
,
CC_vreset
,
step
,
integration_time
,
number
]
#connect to the device
device
=
module
.
HP4155a
(
'
GPIB0::17::INSTR
'
)
device
.
reset
()
#
device = module.HP4155a('GPIB0::17::INSTR')
#
device.reset()
#disable all irrelevant units for the measurement
#smu1 and smu3 are disabled
device
.
smu_disable_sweep
(
1
)
device
.
smu_disable_sweep
(
3
)
#
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
)
#device.disable_vsu(1)
#device.disable_vsu(2)
#device.disable_vmu(1)
#device.disable_vmu(2)
"""
the above is what happens when the programm starts all the rest have to be written into button trigger functions
"""
"""
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,file
...
...
@@ -324,9 +367,7 @@ def memristor():
set.on_click(on_set_button_clicked)
reset.on_click(on_reset_button_clicked)
full.on_click(on_full_button_clicked)
"""
...
...
This diff is collapsed.
Click to expand it.
hp4155/memristor/memristor_buttons.ipynb
+
11
−
26
View file @
e03980f7
...
...
@@ -9,26 +9,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
ef458f5667f049839ef3e6ed61b53907
",
"model_id": "
34775156e4f248eea7b51bb428df11bc
",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FileChooser(path='\\\\FILESERVER\\public', filename='', title='', show_hidden=False, select_desc='load .ini', cha…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4f68e61ccdb6496f9f43fa1c1b3be18f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FileChooser(path='\\\\FILESERVER\\public', filename='', title='', show_hidden=False, select_desc='save path', cha…"
"VBox(children=(Text(value='', description='sample series:', placeholder='Enter text here:', style=TextStyle(de…"
]
},
"metadata": {},
...
...
@@ -44,12 +30,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
75f43558269d4f56990a6f1daee52143
",
"model_id": "
e45df3bc7ab7442580a3532765fbfbf4
",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"
V
Box(children=(Text(value=
''
, description='
sample series:', placeholder='Enter text here:', style=TextStyle(de
…"
"
H
Box(children=(
BoundedFloat
Text(value=
0.01
, description='
Step(V):', max=200.0, step=0.01), Dropdown(descriptio
…"
]
},
"metadata": {},
...
...
@@ -59,18 +45,19 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
300fe370bc954ffc82ba91f28f9aac1b
",
"model_id": "
2d4b3e4a24c0497fb0862af18e37c422
",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HBox(children=(Button(description='SET', style=ButtonStyle()),
Checkbox
(value=
False
, desc
riptio
…"
"VBox(children=(HBox(children=(Button(description='SET', style=ButtonStyle()),
BoundedFloatText
(value=
1.0
, desc…"
]
},
"metadata": {},
...
...
@@ -79,7 +66,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
4f819112a0be45c590679662308bb582
",
"model_id": "
ba53d0042220449f829471e4fb23b9ec
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -92,15 +79,13 @@
}
],
"source": [
"from memristor import *\n",
"\n",
"memristor()"
"%run memristor.py"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "
541c465a-2858-4998-8411-8c06ab4b466c
",
"id": "
2fc85780-0e32-4b77-9de5-684c87f55a6b
",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -122,7 +107,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.1
1.4
"
"version": "3.1
2.0
"
}
},
"nbformat": 4,
...
...
%% Cell type:code id:33f299ef-2302-4e0a-b45f-291460d944c6 tags:
```
python
from
memristor
import
*
memristor
()
%
run
memristor
.
py
```
%% Output
%% Cell type:code id:
541c465a-2858-4998-8411-8c06ab4b466c
tags:
%% Cell type:code id:
2fc85780-0e32-4b77-9de5-684c87f55a6b
tags:
```
python
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment